summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/emscripten/system/lib/libc/musl/src/math/fabs.c
blob: 566a461ffdd37aaf67eec74b8eb90ec7df55bdd8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <math.h>
#include <stdint.h>

double fabs(double x)
{
// XXX EMSCRIPTEN: use the wasm instruction via clang builtin
// See https://github.com/emscripten-core/emscripten/issues/9236
#ifdef __wasm__
	return __builtin_fabs(x);
#else
	union {double f; uint64_t i;} u = {x};
	u.i &= -1ULL/2;
	return u.f;
#endif
}