summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/emscripten/system/lib/libc/musl/src/math/copysign.c
blob: 1fc78c9f23ad122fd64d19a07251958b5ee49a23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "libm.h"

double copysign(double x, double y) {
// XXX EMSCRIPTEN: use the wasm instruction via clang builtin
// See https://github.com/emscripten-core/emscripten/issues/9236
#ifdef __wasm__
	return __builtin_copysign(x, y);
#else
	union {double f; uint64_t i;} ux={x}, uy={y};
	ux.i &= -1ULL/2;
	ux.i |= uy.i & 1ULL<<63;
	return ux.f;
#endif
}