summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/sources/complex-builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-bottom-half/sources/complex-builtins.c')
-rw-r--r--libc-bottom-half/sources/complex-builtins.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libc-bottom-half/sources/complex-builtins.c b/libc-bottom-half/sources/complex-builtins.c
new file mode 100644
index 0000000..971d57e
--- /dev/null
+++ b/libc-bottom-half/sources/complex-builtins.c
@@ -0,0 +1,29 @@
+// Each of the following complex functions can be implemented with a single
+// wasm instruction, so use that implementation rather than the portable
+// one in libm.
+
+#include <complex.h>
+
+float (crealf)(float _Complex x) {
+ return __builtin_crealf(x);
+}
+
+double (creal)(double _Complex x) {
+ return __builtin_creal(x);
+}
+
+long double (creall)(long double _Complex x) {
+ return __builtin_creall(x);
+}
+
+float (cimagf)(float _Complex x) {
+ return __builtin_cimagf(x);
+}
+
+double (cimag)(double _Complex x) {
+ return __builtin_cimag(x);
+}
+
+long double (cimagl)(long double _Complex x) {
+ return __builtin_cimagl(x);
+}