Skip to content

Commit a69db39

Browse files
committed
Merge pull request #2905 from juj/musl_mathfuncs
Musl mathfuncs
2 parents 0c3be23 + b7f8cd2 commit a69db39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+5866
-203
lines changed

emscripten-version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.28.0
1+
1.28.1
22

src/library.js

-202
Original file line numberDiff line numberDiff line change
@@ -4518,202 +4518,11 @@ LibraryManager.library = {
45184518
llvm_log_f64: 'Math_log',
45194519
llvm_exp_f32: 'Math_exp',
45204520
llvm_exp_f64: 'Math_exp',
4521-
cbrt: function(x) {
4522-
return Math.pow(x, 1/3);
4523-
},
4524-
cbrtf: 'cbrt',
4525-
cbrtl: 'cbrt',
4526-
4527-
modf: function(x, intpart) {
4528-
{{{ makeSetValue('intpart', 0, '(x < 0) ? Math.ceil(x) : Math.floor(x)', 'double') }}};
4529-
return x - {{{ makeGetValue('intpart', 0, 'double') }}};
4530-
},
4531-
modff: function(x, intpart) {
4532-
{{{ makeSetValue('intpart', 0, '(x < 0) ? Math.ceil(x) : Math.floor(x)', 'float') }}};
4533-
return x - {{{ makeGetValue('intpart', 0, 'float') }}};
4534-
},
4535-
finite: function(x) {
4536-
return isFinite(x);
4537-
},
4538-
__finite: 'finite',
4539-
isinf: function(x) {
4540-
return !isNaN(x) && !isFinite(x);
4541-
},
4542-
__isinf: 'isinf',
4543-
isnan: function(x) {
4544-
return isNaN(x);
4545-
},
4546-
__isnan: 'isnan',
45474521

45484522
_reallyNegative: function(x) {
45494523
return x < 0 || (x === 0 && (1/x) === -Infinity);
45504524
},
45514525

4552-
copysign__deps: ['_reallyNegative'],
4553-
copysign: function(a, b) {
4554-
return __reallyNegative(a) === __reallyNegative(b) ? a : -a;
4555-
},
4556-
copysignf: 'copysign',
4557-
copysignl: 'copysign',
4558-
__signbit__deps: ['copysign'],
4559-
__signbit: function(x) {
4560-
// We implement using copysign so that we get support
4561-
// for negative zero (once copysign supports that).
4562-
return _copysign(1.0, x) < 0;
4563-
},
4564-
__signbitd: '__signbit',
4565-
__signbitf: '__signbit',
4566-
__signbitl: '__signbit',
4567-
hypot: function(a, b) {
4568-
return Math.sqrt(a*a + b*b);
4569-
},
4570-
hypotf: 'hypot',
4571-
hypotl: 'hypot',
4572-
sinh: function(x) {
4573-
var p = Math.pow(Math.E, x);
4574-
return (p - (1 / p)) / 2;
4575-
},
4576-
sinhf: 'sinh',
4577-
sinhl: 'sinh',
4578-
cosh: function(x) {
4579-
var p = Math.pow(Math.E, x);
4580-
return (p + (1 / p)) / 2;
4581-
},
4582-
coshf: 'cosh',
4583-
coshl: 'cosh',
4584-
tanh__deps: ['sinh', 'cosh'],
4585-
tanh: function(x) {
4586-
return _sinh(x) / _cosh(x);
4587-
},
4588-
tanhf: 'tanh',
4589-
tanhl: 'tanh',
4590-
asinh: function(x) {
4591-
return Math.log(x + Math.sqrt(x * x + 1));
4592-
},
4593-
asinhf: 'asinh',
4594-
asinhl: 'asinh',
4595-
acosh: function(x) {
4596-
return Math.log(x * 1 + Math.sqrt(x * x - 1));
4597-
},
4598-
acoshf: 'acosh',
4599-
acoshl: 'acosh',
4600-
atanh: function(x) {
4601-
return Math.log((1 + x) / (1 - x)) / 2;
4602-
},
4603-
atanhf: 'atanh',
4604-
atanhl: 'atanh',
4605-
exp2: function(x) {
4606-
return Math.pow(2, x);
4607-
},
4608-
exp2f: 'exp2',
4609-
exp2l: 'exp2',
4610-
expm1: function(x) {
4611-
return Math.exp(x) - 1;
4612-
},
4613-
expm1f: 'expm1',
4614-
expm1l: 'expm1',
4615-
round: function(x) {
4616-
return (x < 0) ? -Math.round(-x) : Math.round(x);
4617-
},
4618-
roundf: 'round',
4619-
roundl: 'round',
4620-
lround: 'round',
4621-
lroundf: 'round',
4622-
lroundl: 'round',
4623-
llround: 'round',
4624-
llroundf: 'round',
4625-
llroundl: 'round',
4626-
rint: function(x) {
4627-
if (Math.abs(x % 1) !== 0.5) return Math.round(x);
4628-
return x + x % 2 + ((x < 0) ? 1 : -1);
4629-
},
4630-
rintf: 'rint',
4631-
rintl: 'rint',
4632-
lrint: 'rint',
4633-
lrintf: 'rint',
4634-
lrintl: 'rint',
4635-
#if USE_TYPED_ARRAYS == 2
4636-
llrint: function(x) {
4637-
x = (x < 0) ? -Math.round(-x) : Math.round(x);
4638-
{{{ makeStructuralReturn(splitI64('x')) }}};
4639-
},
4640-
#else
4641-
llrint: 'rint',
4642-
#endif
4643-
llrintf: 'llrint',
4644-
llrintl: 'llrint',
4645-
nearbyint: 'rint',
4646-
nearbyintf: 'rint',
4647-
nearbyintl: 'rint',
4648-
trunc: function(x) {
4649-
return (x < 0) ? Math.ceil(x) : Math.floor(x);
4650-
},
4651-
truncf: 'trunc',
4652-
truncl: 'trunc',
4653-
fdim: function(x, y) {
4654-
return (x > y) ? x - y : 0;
4655-
},
4656-
fdimf: 'fdim',
4657-
fdiml: 'fdim',
4658-
fmax: function(x, y) {
4659-
return isNaN(x) ? y : isNaN(y) ? x : Math.max(x, y);
4660-
},
4661-
fmaxf: 'fmax',
4662-
fmaxl: 'fmax',
4663-
fmin: function(x, y) {
4664-
return isNaN(x) ? y : isNaN(y) ? x : Math.min(x, y);
4665-
},
4666-
fminf: 'fmin',
4667-
fminl: 'fmin',
4668-
fma: function(x, y, z) {
4669-
return x * y + z;
4670-
},
4671-
fmaf: 'fma',
4672-
fmal: 'fma',
4673-
fmod: function(x, y) {
4674-
return x % y;
4675-
},
4676-
fmodf: 'fmod',
4677-
fmodl: 'fmod',
4678-
remainder: 'fmod',
4679-
remainderf: 'fmod',
4680-
remainderl: 'fmod',
4681-
log10: function(x) {
4682-
return Math.log(x) / Math.LN10;
4683-
},
4684-
log10f: 'log10',
4685-
log10l: 'log10',
4686-
log1p: function(x) {
4687-
return Math.log(1 + x);
4688-
},
4689-
log1pf: 'log1p',
4690-
log1pl: 'log1p',
4691-
log2: function(x) {
4692-
return Math.log(x) / Math.LN2;
4693-
},
4694-
log2f: 'log2',
4695-
log2l: 'log2',
4696-
nan: function(x) {
4697-
return NaN;
4698-
},
4699-
nanf: 'nan',
4700-
nanl: 'nan',
4701-
4702-
sincos: function(x, sine, cosine) {
4703-
var sineVal = Math.sin(x),
4704-
cosineVal = Math.cos(x);
4705-
{{{ makeSetValue('sine', '0', 'sineVal', 'double') }}};
4706-
{{{ makeSetValue('cosine', '0', 'cosineVal', 'double') }}};
4707-
},
4708-
sincosl: 'sincos',
4709-
4710-
sincosf: function(x, sine, cosine) {
4711-
var sineVal = Math.sin(x),
4712-
cosineVal = Math.cos(x);
4713-
{{{ makeSetValue('sine', '0', 'sineVal', 'float') }}};
4714-
{{{ makeSetValue('cosine', '0', 'cosineVal', 'float') }}};
4715-
},
4716-
47174526
div: function(divt, numer, denom) {
47184527
var quot = (numer / denom) | 0;
47194528
var rem = numer - quot * denom;
@@ -4722,17 +4531,6 @@ LibraryManager.library = {
47224531
return divt;
47234532
},
47244533

4725-
__fpclassify: function(x) {
4726-
if (isNaN(x)) return {{{ cDefine('FP_NAN') }}};
4727-
if (!isFinite(x)) return {{{ cDefine('FP_INFINITE') }}};
4728-
if (x == 0) return {{{ cDefine('FP_ZERO') }}};
4729-
// FP_SUBNORMAL..?
4730-
return {{{ cDefine('FP_NORMAL') }}};
4731-
},
4732-
__fpclassifyd: '__fpclassify', // Needed by tests/python/python.le32.bc
4733-
__fpclassifyf: '__fpclassify',
4734-
__fpclassifyl: '__fpclassify',
4735-
47364534
// ==========================================================================
47374535
// sys/utsname.h
47384536
// ==========================================================================

system/lib/libc.symbols

+108
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,83 @@
11
T __floatscan
2+
T __fpclassify
3+
T __fpclassifyf
4+
T __fpclassifyl
25
T __intscan
36
T __overflow
47
T __shgetc
58
T __shlim
9+
T __signbit
10+
T __signbitf
11+
T __signbitl
612
W __strtod_l
713
W __strtof_l
814
W __strtold_l
915
T __toread
1016
T __towrite
1117
T __uflow
18+
T acosh
19+
T acoshf
20+
T acoshl
21+
T asinh
22+
T asinhf
23+
T asinhl
24+
T atanh
25+
T atanhf
26+
T atanhl
1227
T atof
1328
T atoi
1429
T atol
1530
W bulk_free
1631
W calloc
32+
T cbrt
33+
T cbrtf
34+
T cbrtl
35+
T copysign
36+
T copysignf
37+
T copysignl
38+
T cosh
39+
T coshf
40+
T coshl
1741
T drand48
1842
T erand48
43+
T exp2
44+
T exp2f
45+
T exp2l
46+
T expm1
47+
T expm1f
48+
T expm1l
49+
T feclearexcept
50+
T feraiseexcept
51+
T fetestexcept
52+
T fegetround
53+
T __fesetround
54+
T fegetenv
55+
T fesetenv
56+
T fdim
57+
T fdimf
58+
T fdiml
1959
T ffs
60+
T finite
61+
T finitef
62+
T fma
63+
T fmaf
64+
T fmal
65+
T fmax
66+
T fmaxf
67+
T fmaxl
68+
T fmin
69+
T fminf
70+
T fminl
71+
T fmod
72+
T fmodf
73+
T fmodl
2074
W free
2175
T frexp
2276
T frexpf
2377
T frexpl
78+
T hypot
79+
T hypotf
80+
T hypotl
2481
W independent_calloc
2582
W independent_comalloc
2683
T initstate
@@ -31,8 +88,29 @@
3188
T lcg31
3289
T lcg64
3390
T lcong48
91+
T llrint
92+
T llrintf
93+
T llrintl
94+
T llround
95+
T llroundf
96+
T llroundl
3497
T loadstate
98+
T log10
99+
T log10f
100+
T log10l
101+
T log1p
102+
T log1pf
103+
T log1pl
104+
T log2
105+
T log2f
106+
T log2l
35107
T lrand48
108+
T lrint
109+
T lrintf
110+
T lrintl
111+
T lround
112+
T lroundf
113+
T lroundl
36114
W mallinfo
37115
W malloc
38116
W malloc_footprint
@@ -44,8 +122,17 @@
44122
W malloc_usable_size
45123
W mallopt
46124
W memalign
125+
T modf
126+
T modff
127+
T modfl
47128
T MUSL_vfprintf
48129
T mrand48
130+
T nan
131+
T nanf
132+
T nanl
133+
T nearbyint
134+
T nearbyintf
135+
T nearbyintl
49136
T nrand48
50137
W posix_memalign
51138
W pvalloc
@@ -54,9 +141,30 @@
54141
T random
55142
W realloc
56143
W realloc_in_place
144+
T remainder
145+
T remainderf
146+
T remainderl
147+
T rint
148+
T rintf
149+
T rintl
150+
T round
151+
T roundf
152+
T roundl
57153
T scalbn
58154
T scalbnl
155+
T sincos
156+
T sincosf
157+
T sincosl
158+
T sinh
159+
T sinhf
160+
T sinhl
59161
T srand
162+
T tanh
163+
T tanhf
164+
T tanhl
165+
T trunc
166+
T truncf
167+
T truncl
60168
T memchr
61169
T memcmp
62170
T memcpy

0 commit comments

Comments
 (0)