]> git.proxmox.com Git - wasi-libc.git/blob - basics/sources/math-builtins.c
Avoid using cast expressions in WASI API constants. (#148)
[wasi-libc.git] / basics / sources / math-builtins.c
1 // Each of the following math functions can be implemented with a single
2 // wasm instruction, so use that implementation rather than the portable
3 // one in libm.
4
5 #include <math.h>
6
7 float fabsf(float x) {
8 return __builtin_fabsf(x);
9 }
10
11 double fabs(double x) {
12 return __builtin_fabs(x);
13 }
14
15 float sqrtf(float x) {
16 return __builtin_sqrtf(x);
17 }
18
19 double sqrt(double x) {
20 return __builtin_sqrt(x);
21 }
22
23 float copysignf(float x, float y) {
24 return __builtin_copysignf(x, y);
25 }
26
27 double copysign(double x, double y) {
28 return __builtin_copysign(x, y);
29 }
30
31 float ceilf(float x) {
32 return __builtin_ceilf(x);
33 }
34
35 double ceil(double x) {
36 return __builtin_ceil(x);
37 }
38
39 float floorf(float x) {
40 return __builtin_floorf(x);
41 }
42
43 double floor(double x) {
44 return __builtin_floor(x);
45 }
46
47 float truncf(float x) {
48 return __builtin_truncf(x);
49 }
50
51 double trunc(double x) {
52 return __builtin_trunc(x);
53 }
54
55 float nearbyintf(float x) {
56 return __builtin_nearbyintf(x);
57 }
58
59 double nearbyint(double x) {
60 return __builtin_nearbyint(x);
61 }
62
63 float rintf(float x) {
64 return __builtin_rintf(x);
65 }
66
67 double rint(double x) {
68 return __builtin_rint(x);
69 }