aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/ansi
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:52 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 18:24:51 -0500
commitf5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch)
tree93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/options/ansi
parentbd5969fc876a10b18613302db7087ef3c40f18e1 (diff)
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/ansi')
-rw-r--r--lib/mlibc/options/ansi/generic/assert-stubs.cpp13
-rw-r--r--lib/mlibc/options/ansi/generic/complex-stubs.c9
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cabs.c53
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cabsf.c19
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cacos.c99
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cacosf.c46
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cacosh.c93
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cacoshf.c48
-rw-r--r--lib/mlibc/options/ansi/generic/complex/carg.c59
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cargf.c19
-rw-r--r--lib/mlibc/options/ansi/generic/complex/casin.c165
-rw-r--r--lib/mlibc/options/ansi/generic/complex/casinf.c122
-rw-r--r--lib/mlibc/options/ansi/generic/complex/casinh.c97
-rw-r--r--lib/mlibc/options/ansi/generic/complex/casinhf.c44
-rw-r--r--lib/mlibc/options/ansi/generic/complex/catan.c130
-rw-r--r--lib/mlibc/options/ansi/generic/complex/catanf.c79
-rw-r--r--lib/mlibc/options/ansi/generic/complex/catanh.c90
-rw-r--r--lib/mlibc/options/ansi/generic/complex/catanhf.c44
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ccos.c81
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ccosf.c48
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ccosh.c81
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ccoshf.c48
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cephes_subr.c126
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cephes_subr.h9
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cephes_subrf.c125
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cephes_subrf.h9
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cexp.c82
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cexpf.c49
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cimag.c54
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cimagf.c21
-rw-r--r--lib/mlibc/options/ansi/generic/complex/clog.c91
-rw-r--r--lib/mlibc/options/ansi/generic/complex/clogf.c49
-rw-r--r--lib/mlibc/options/ansi/generic/complex/conj.c56
-rw-r--r--lib/mlibc/options/ansi/generic/complex/conjf.c23
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cpow.c101
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cpowf.c59
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cproj.c105
-rw-r--r--lib/mlibc/options/ansi/generic/complex/cprojf.c67
-rw-r--r--lib/mlibc/options/ansi/generic/complex/creal.c54
-rw-r--r--lib/mlibc/options/ansi/generic/complex/crealf.c21
-rw-r--r--lib/mlibc/options/ansi/generic/complex/csin.c81
-rw-r--r--lib/mlibc/options/ansi/generic/complex/csinf.c48
-rw-r--r--lib/mlibc/options/ansi/generic/complex/csinh.c80
-rw-r--r--lib/mlibc/options/ansi/generic/complex/csinhf.c48
-rw-r--r--lib/mlibc/options/ansi/generic/complex/csqrt.c137
-rw-r--r--lib/mlibc/options/ansi/generic/complex/csqrtf.c102
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ctan.c91
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ctanf.c58
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ctanh.c83
-rw-r--r--lib/mlibc/options/ansi/generic/complex/ctanhf.c50
-rw-r--r--lib/mlibc/options/ansi/generic/complex/fdlibm.h17
-rw-r--r--lib/mlibc/options/ansi/generic/ctype-stubs.cpp326
-rw-r--r--lib/mlibc/options/ansi/generic/environment.cpp164
-rw-r--r--lib/mlibc/options/ansi/generic/errno-stubs.cpp12
-rw-r--r--lib/mlibc/options/ansi/generic/fenv-stubs.cpp43
-rw-r--r--lib/mlibc/options/ansi/generic/file-io.cpp745
-rw-r--r--lib/mlibc/options/ansi/generic/inttypes-stubs.cpp100
-rw-r--r--lib/mlibc/options/ansi/generic/locale-stubs.cpp195
-rw-r--r--lib/mlibc/options/ansi/generic/math-stubs.ignored-cpp1831
-rw-r--r--lib/mlibc/options/ansi/generic/signal-stubs.cpp44
-rw-r--r--lib/mlibc/options/ansi/generic/stdio-stubs.cpp1270
-rw-r--r--lib/mlibc/options/ansi/generic/stdlib-stubs.cpp511
-rw-r--r--lib/mlibc/options/ansi/generic/string-stubs.cpp542
-rw-r--r--lib/mlibc/options/ansi/generic/threads.cpp97
-rw-r--r--lib/mlibc/options/ansi/generic/time-stubs.cpp729
-rw-r--r--lib/mlibc/options/ansi/generic/uchar.cpp23
-rw-r--r--lib/mlibc/options/ansi/generic/wchar-stubs.cpp783
-rw-r--r--lib/mlibc/options/ansi/generic/wctype.cpp9
-rw-r--r--lib/mlibc/options/ansi/include/alloca.h8
-rw-r--r--lib/mlibc/options/ansi/include/assert.h46
-rw-r--r--lib/mlibc/options/ansi/include/bits/ansi/fenv.h54
-rw-r--r--lib/mlibc/options/ansi/include/bits/ansi/time_t.h8
-rw-r--r--lib/mlibc/options/ansi/include/bits/ansi/timespec.h13
-rw-r--r--lib/mlibc/options/ansi/include/complex.h134
-rw-r--r--lib/mlibc/options/ansi/include/ctype.h46
-rw-r--r--lib/mlibc/options/ansi/include/errno.h31
-rw-r--r--lib/mlibc/options/ansi/include/fenv.h44
-rw-r--r--lib/mlibc/options/ansi/include/inttypes.h146
-rw-r--r--lib/mlibc/options/ansi/include/limits.h117
-rw-r--r--lib/mlibc/options/ansi/include/locale.h81
-rw-r--r--lib/mlibc/options/ansi/include/math.h383
-rw-r--r--lib/mlibc/options/ansi/include/mlibc/ansi-sysdeps.hpp71
-rw-r--r--lib/mlibc/options/ansi/include/mlibc/environment.hpp10
-rw-r--r--lib/mlibc/options/ansi/include/mlibc/file-io.hpp111
-rw-r--r--lib/mlibc/options/ansi/include/setjmp.h48
-rw-r--r--lib/mlibc/options/ansi/include/signal.h48
-rw-r--r--lib/mlibc/options/ansi/include/stdc-predef.h6
-rw-r--r--lib/mlibc/options/ansi/include/stdio.h229
-rw-r--r--lib/mlibc/options/ansi/include/stdlib.h128
-rw-r--r--lib/mlibc/options/ansi/include/string.h107
-rw-r--r--lib/mlibc/options/ansi/include/threads.h61
-rw-r--r--lib/mlibc/options/ansi/include/time.h154
-rw-r--r--lib/mlibc/options/ansi/include/uchar.h29
-rw-r--r--lib/mlibc/options/ansi/include/wchar.h128
-rw-r--r--lib/mlibc/options/ansi/include/wctype.h52
-rw-r--r--lib/mlibc/options/ansi/meson.build326
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__cos.c71
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__cosdf.c35
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__cosl.c96
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__expo2.c16
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__expo2f.c16
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__fpclassify.c11
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__fpclassifyf.c11
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__fpclassifyl.c34
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__invtrigl.c63
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__invtrigl.h11
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__polevll.c93
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__rem_pio2.c177
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__rem_pio2_large.c442
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__rem_pio2f.c75
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__rem_pio2l.c141
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__signbit.c13
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__signbitf.c11
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__signbitl.c14
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__sin.c64
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__sindf.c36
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__sinl.c78
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__tan.c110
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__tandf.c54
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/__tanl.c143
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/acos.c101
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/acosf.c71
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/acosh.c24
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/acoshf.c26
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/acoshl.c29
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/acosl.c67
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/asin.c107
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/asinf.c61
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/asinh.c28
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/asinhf.c28
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/asinhl.c41
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/asinl.c71
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atan.c116
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atan2.c107
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atan2f.c83
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atan2l.c85
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atanf.c94
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atanh.c29
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atanhf.c28
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atanhl.c35
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/atanl.c184
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/cbrt.c103
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/cbrtf.c66
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/cbrtl.c124
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ceil.c31
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ceilf.c27
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ceill.c34
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/copysign.c8
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/copysignf.c10
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/copysignl.c16
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/cos.c77
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/cosf.c78
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/cosh.c40
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/coshf.c33
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/coshl.c47
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/cosl.c39
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/erf.c273
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/erff.c183
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/erfl.c353
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/exp.c134
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/exp10.c26
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/exp10f.c24
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/exp10l.c34
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/exp2.c375
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/exp2f.c126
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/exp2l.c619
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/expf.c83
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/expl.c128
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/expm1.c201
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/expm1f.c111
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/expm1l.c123
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fabs.c9
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fabsf.c9
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fabsl.c15
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fdim.c10
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fdimf.c10
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fdiml.c18
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/finite.c7
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/finitef.c7
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/floor.c31
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/floorf.c27
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/floorl.c34
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fma.c194
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmaf.c93
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmal.c293
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmax.c13
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmaxf.c13
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmaxl.c21
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmin.c13
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fminf.c13
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fminl.c21
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmod.c68
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmodf.c65
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/fmodl.c105
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/frexp.c23
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/frexpf.c23
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/frexpl.c29
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/hypot.c67
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/hypotf.c35
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/hypotl.c66
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ilogb.c26
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ilogbf.c26
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ilogbl.c55
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/j0.c375
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/j0f.c314
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/j1.c362
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/j1f.c310
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/jn.c280
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/jnf.c202
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ldexp.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ldexpf.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/ldexpl.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lgamma.c9
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lgamma_r.c285
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lgammaf.c9
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lgammaf_r.c220
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lgammal.c361
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/libm.h186
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/llrint.c8
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/llrintf.c8
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/llrintl.c36
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/llround.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/llroundf.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/llroundl.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log.c118
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log10.c101
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log10f.c77
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log10l.c191
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log1p.c122
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log1pf.c77
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log1pl.c177
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log2.c122
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log2f.c74
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/log2l.c182
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/logb.c17
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/logbf.c10
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/logbl.c16
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/logf.c69
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/logl.c175
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lrint.c46
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lrintf.c8
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lrintl.c36
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lround.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lroundf.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/lroundl.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/modf.c34
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/modff.c34
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/modfl.c53
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nan.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nanf.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nanl.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nearbyint.c20
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nearbyintf.c18
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nearbyintl.c26
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nextafter.c31
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nextafterf.c30
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nextafterl.c75
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nexttoward.c42
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nexttowardf.c35
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/nexttowardl.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/pow.c328
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/powf.c259
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/powl.c522
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/remainder.c11
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/remainderf.c11
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/remainderl.c15
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/remquo.c82
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/remquof.c82
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/remquol.c124
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/rint.c28
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/rintf.c30
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/rintl.c29
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/round.c35
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/roundf.c36
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/roundl.c37
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalb.c35
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalbf.c32
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalbln.c12
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalblnf.c12
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalblnl.c20
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalbn.c33
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalbnf.c31
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/scalbnl.c36
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/signgam.c5
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/significand.c7
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/significandf.c7
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sin.c78
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sincos.c69
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sincosf.c117
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sincosl.c60
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sinf.c76
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sinh.c39
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sinhf.c31
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sinhl.c43
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sinl.c41
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sqrt.c185
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sqrtf.c84
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/sqrtl.c7
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tan.c70
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tanf.c64
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tanh.c45
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tanhf.c39
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tanhl.c48
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tanl.c29
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tgamma.c222
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tgammaf.c6
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/tgammal.c281
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/trunc.c19
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/truncf.c19
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/truncl.c34
-rw-r--r--lib/mlibc/options/ansi/musl-generic-math/weak_alias.h7
311 files changed, 0 insertions, 30252 deletions
diff --git a/lib/mlibc/options/ansi/generic/assert-stubs.cpp b/lib/mlibc/options/ansi/generic/assert-stubs.cpp
deleted file mode 100644
index 6ebb6ed..0000000
--- a/lib/mlibc/options/ansi/generic/assert-stubs.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <bits/ensure.h>
-
-[[gnu::noreturn]] void __assert_fail(const char *assertion, const char *file, unsigned int line,
- const char *function) {
- fprintf(stderr, "In function %s, file %s:%d: Assertion '%s' failed!\n",
- function, file, line, assertion);
- abort();
-}
diff --git a/lib/mlibc/options/ansi/generic/complex-stubs.c b/lib/mlibc/options/ansi/generic/complex-stubs.c
deleted file mode 100644
index 069626b..0000000
--- a/lib/mlibc/options/ansi/generic/complex-stubs.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <complex.h>
-
-long double cimagl(long double complex z) {
- return __imag__(z);
-}
-
-long double creall(long double complex z) {
- return __real__(z);
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cabs.c b/lib/mlibc/options/ansi/generic/complex/cabs.c
deleted file mode 100644
index 2750fab..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cabs.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* $NetBSD: cabs.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<cabs>>, <<cabsf>>---complex absolute-value
-
-INDEX
- cabs
-INDEX
- cabsf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double cabs(double complex <[z]>);
- float cabsf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute compute the complex absolute value
- (also called norm, modulus, or magnitude) of <[z]>.
-
- <<cabsf>> is identical to <<cabs>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The cabs functions return the complex absolute value.
-
-PORTABILITY
- <<cabs>> and <<cabsf>> are ISO C99
-
-QUICKREF
- <<cabs>> and <<cabsf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-
-double
-cabs(double complex z)
-{
-
- return hypot( creal(z), cimag(z) );
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cabsf.c b/lib/mlibc/options/ansi/generic/complex/cabsf.c
deleted file mode 100644
index 635e23e..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cabsf.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* $NetBSD: cabsf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float
-cabsf(float complex z)
-{
-
- return hypotf( crealf(z), cimagf(z) );
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cacos.c b/lib/mlibc/options/ansi/generic/complex/cacos.c
deleted file mode 100644
index 86e1198..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cacos.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* $NetBSD: cacos.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<cacos>>, <<cacosf>>---complex arc cosine
-
-INDEX
- cacos
-INDEX
- cacosf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex cacos(double complex <[z]>);
- float complex cacosf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex arc cosine of <[z]>,
- with branch cuts outside the interval [-1, +1] along the real axis.
-
- <<cacosf>> is identical to <<cacos>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- These functions return the complex arc cosine value, in the range
- of a strip mathematically unbounded along the imaginary axis
- and in the interval [0, pi] along the real axis.
- @end ifnottex
- @tex
- These functions return the complex arc cosine value, in the range
- of a strip mathematically unbounded along the imaginary axis
- and in the interval [<<0>>, $\pi$] along the real axis.
- @end tex
-
-PORTABILITY
- <<cacos>> and <<cacosf>> are ISO C99
-
-QUICKREF
- <<cacos>> and <<cacosf>> are ISO C99
-
-*/
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-cacos(double complex z)
-{
- double complex w;
-
- /* FIXME: The original NetBSD code results in an ICE when trying to
- build this function on ARM/Thumb using gcc 4.5.1. For now we use
- a hopefully temporary workaround. */
-#if 0
- w = casin(z);
- w = (M_PI_2 - creal(w)) - cimag(w) * I;
-#else
- double complex tmp0, tmp1;
-
- tmp0 = casin(z);
- tmp1 = M_PI_2 - creal(tmp0);
- w = tmp1 - (cimag(tmp0) * I);
-#endif
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cacosf.c b/lib/mlibc/options/ansi/generic/complex/cacosf.c
deleted file mode 100644
index 3874dd5..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cacosf.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* $NetBSD: cacosf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-cacosf(float complex z)
-{
- float complex w;
-
- w = casinf(z);
- w = ((float)M_PI_2 - crealf(w)) - cimagf(w) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cacosh.c b/lib/mlibc/options/ansi/generic/complex/cacosh.c
deleted file mode 100644
index 3d42c40..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cacosh.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* $NetBSD: cacosh.c,v 1.2 2009/08/03 19:41:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<cacosh>>, <<cacoshf>>---complex arc hyperbolic cosine
-
-INDEX
- cacosh
-INDEX
- cacoshf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex cacosh(double complex <[z]>);
- float complex cacoshf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex arc hyperbolic cosine of <[z]>,
- with a branch cut at values less than 1 along the real axis.
-
- <<cacoshf>> is identical to <<cacosh>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- These functions return the complex arc hyperbolic cosine value,
- in the range of a half-strip of non-negative values along the
- real axis and in the interval [-i * pi, +i * pi] along the
- imaginary axis.
- @end ifnottex
- @tex
- These functions return the complex arc hyperbolic cosine value,
- in the range of a half-strip of non-negative values along the
- real axis and in the interval [$-i\pi$, $+i\pi$] along the
- imaginary axis.
- @end tex
-
-PORTABILITY
- <<cacosh>> and <<cacoshf>> are ISO C99
-
-QUICKREF
- <<cacosh>> and <<cacoshf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-
-double complex
-cacosh(double complex z)
-{
- double complex w;
-
-#if 0 /* does not give the principal value */
- w = I * cacos(z);
-#else
- w = clog(z + csqrt(z + 1) * csqrt(z - 1));
-#endif
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cacoshf.c b/lib/mlibc/options/ansi/generic/complex/cacoshf.c
deleted file mode 100644
index 41a557a..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cacoshf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $NetBSD: cacoshf.c,v 1.2 2009/08/03 19:41:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-
-float complex
-cacoshf(float complex z)
-{
- float complex w;
-
-#if 0 /* does not give the principal value */
- w = I * cacosf(z);
-#else
- w = clogf(z + csqrtf(z + 1) * csqrtf(z - 1));
-#endif
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/carg.c b/lib/mlibc/options/ansi/generic/complex/carg.c
deleted file mode 100644
index 0447420..0000000
--- a/lib/mlibc/options/ansi/generic/complex/carg.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $NetBSD: carg.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<carg>>, <<cargf>>---argument (phase angle)
-
-INDEX
- carg
-INDEX
- cargf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double carg(double complex <[z]>);
- float cargf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the argument (also called phase angle)
- of <[z]>, with a branch cut along the negative real axis.
-
- <<cargf>> is identical to <<carg>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- The carg functions return the value of the argument in the
- interval [-pi, +pi]
- @end ifnottex
- @tex
- The carg functions return the value of the argument in the
- interval [$-\pi$, $+\pi$]
- @end tex
-
-PORTABILITY
- <<carg>> and <<cargf>> are ISO C99
-
-QUICKREF
- <<carg>> and <<cargf>> are ISO C99
-
-*/
-
-#include <complex.h>
-#include <math.h>
-
-double
-carg(double complex z)
-{
-
- return atan2( cimag(z) , creal(z) );
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cargf.c b/lib/mlibc/options/ansi/generic/complex/cargf.c
deleted file mode 100644
index 1683d21..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cargf.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* $NetBSD: cargf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float
-cargf(float complex z)
-{
-
- return atan2f( cimagf(z), crealf(z) );
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/casin.c b/lib/mlibc/options/ansi/generic/complex/casin.c
deleted file mode 100644
index 5019fd8..0000000
--- a/lib/mlibc/options/ansi/generic/complex/casin.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/* $NetBSD: casin.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<casin>>, <<casinf>>---complex arc sine
-
-INDEX
- casin
-INDEX
- casinf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex casin(double complex <[z]>);
- float complex casinf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex arc sine of <[z]>,
- with branch cuts outside the interval [-1, +1] along the real axis.
-
- <<casinf>> is identical to <<casin>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- These functions return the complex arc sine value, in the range
- of a strip mathematically unbounded along the imaginary axis
- and in the interval [-pi/2, +pi/2] along the real axis.
- @end ifnottex
- @tex
- These functions return the complex arc sine value, in the range
- of a strip mathematically unbounded along the imaginary axis
- and in the interval [$-\pi/2$, $+\pi/2$] along the real axis.
- @end tex
-
-PORTABILITY
- <<casin>> and <<casinf>> are ISO C99
-
-QUICKREF
- <<casin>> and <<casinf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-
-#ifdef __weak_alias
-__weak_alias(casin, _casin)
-#endif
-
-double complex
-casin(double complex z)
-{
- double complex w;
- double complex ca, ct, zz, z2;
- double x, y;
-
- x = creal(z);
- y = cimag(z);
-
-#if 0 /* MD: test is incorrect, casin(>1) is defined */
- if (y == 0.0) {
- if (fabs(x) > 1.0) {
- w = M_PI_2 + 0.0 * I;
-#if 0
- mtherr ("casin", DOMAIN);
-#endif
- } else {
- w = asin(x) + 0.0 * I;
- }
- return w;
- }
-#endif
-
-/* Power series expansion */
-/*
-b = cabs(z);
-if( b < 0.125 )
-{
-z2.r = (x - y) * (x + y);
-z2.i = 2.0 * x * y;
-
-cn = 1.0;
-n = 1.0;
-ca.r = x;
-ca.i = y;
-sum.r = x;
-sum.i = y;
-do
- {
- ct.r = z2.r * ca.r - z2.i * ca.i;
- ct.i = z2.r * ca.i + z2.i * ca.r;
- ca.r = ct.r;
- ca.i = ct.i;
-
- cn *= n;
- n += 1.0;
- cn /= n;
- n += 1.0;
- b = cn/n;
-
- ct.r *= b;
- ct.i *= b;
- sum.r += ct.r;
- sum.i += ct.i;
- b = fabs(ct.r) + fabs(ct.i);
- }
-while( b > MACHEP );
-w->r = sum.r;
-w->i = sum.i;
-return;
-}
-*/
-
-
- ca = x + y * I;
- ct = ca * I;
- /* sqrt( 1 - z*z) */
- /* cmul( &ca, &ca, &zz ) */
- /*x * x - y * y */
- zz = (x - y) * (x + y) + (2.0 * x * y) * I;
-
- zz = 1.0 - creal(zz) - cimag(zz) * I;
- z2 = csqrt(zz);
-
- zz = ct + z2;
- zz = clog(zz);
- /* multiply by 1/i = -i */
- w = zz * (-1.0 * I);
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/casinf.c b/lib/mlibc/options/ansi/generic/complex/casinf.c
deleted file mode 100644
index 9a9f759..0000000
--- a/lib/mlibc/options/ansi/generic/complex/casinf.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* $NetBSD: casinf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-#ifdef __weak_alias
-__weak_alias(casinf, _casinf)
-#endif
-
-float complex
-casinf(float complex z)
-{
- float complex w;
- float complex ca, ct, zz, z2;
- float x, y;
-
- x = crealf(z);
- y = cimagf(z);
-
-#if 0 /* MD: test is incorrect, casin(>1) is defined */
- if (y == 0.0f) {
- if (fabsf(x) > 1.0) {
- w = M_PI_2 + 0.0f * I;
-#if 0
- mtherr ("casin", DOMAIN);
-#endif
- } else {
- w = asinf(x) + 0.0f * I;
- }
- return w;
- }
-#endif
-
-/* Power series expansion */
-/*
-b = cabsf(z);
-if( b < 0.125 )
-{
-z2.r = (x - y) * (x + y);
-z2.i = 2.0 * x * y;
-
-cn = 1.0;
-n = 1.0;
-ca.r = x;
-ca.i = y;
-sum.r = x;
-sum.i = y;
-do
- {
- ct.r = z2.r * ca.r - z2.i * ca.i;
- ct.i = z2.r * ca.i + z2.i * ca.r;
- ca.r = ct.r;
- ca.i = ct.i;
-
- cn *= n;
- n += 1.0;
- cn /= n;
- n += 1.0;
- b = cn/n;
-
- ct.r *= b;
- ct.i *= b;
- sum.r += ct.r;
- sum.i += ct.i;
- b = fabsf(ct.r) + fabsf(ct.i);
- }
-while( b > MACHEP );
-w->r = sum.r;
-w->i = sum.i;
-return;
-}
-*/
-
-
- ca = x + y * I;
- ct = ca * I;
- /* sqrt( 1 - z*z) */
- /* cmul( &ca, &ca, &zz ) */
- /*x * x - y * y */
- zz = (x - y) * (x + y) + (2.0f * x * y) * I;
-
- zz = 1.0f - crealf(zz) - cimagf(zz) * I;
- z2 = csqrtf(zz);
-
- zz = ct + z2;
- zz = clogf(zz);
- /* multiply by 1/i = -i */
- w = zz * (-1.0f * I);
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/casinh.c b/lib/mlibc/options/ansi/generic/complex/casinh.c
deleted file mode 100644
index 16238a6..0000000
--- a/lib/mlibc/options/ansi/generic/complex/casinh.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* $NetBSD: casinh.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<casinh>>, <<casinhf>>---complex arc hyperbolic sine
-
-INDEX
- casinh
-INDEX
- casinhf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex casinh(double complex <[z]>);
- float complex casinhf(float complex <[z]>);
-
-
-DESCRIPTION
- @ifnottex
- These functions compute the complex arc hyperbolic sine of <[z]>,
- with branch cuts outside the interval [-i, +i] along the
- imaginary axis.
- @end ifnottex
- @tex
- These functions compute the complex arc hyperbolic sine of <[z]>,
- with branch cuts outside the interval [$-i$, $+i$] along the
- imaginary axis.
- @end tex
-
- <<casinhf>> is identical to <<casinh>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- These functions return the complex arc hyperbolic sine value,
- in the range of a strip mathematically unbounded along the
- real axis and in the interval [-i*p/2, +i*p/2] along the
- imaginary axis.
- @end ifnottex
- @tex
- These functions return the complex arc hyperbolic sine value,
- in the range of a strip mathematically unbounded along the
- real axis and in the interval [$-i\pi/2$, $+i\pi/2$] along the
- imaginary axis.
- @end tex
-
-PORTABILITY
- <<casinh>> and <<casinhf>> are ISO C99
-
-QUICKREF
- <<casinh>> and <<casinhf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-
-double complex
-casinh(double complex z)
-{
- double complex w;
-
- w = -1.0 * I * casin(z * I);
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/casinhf.c b/lib/mlibc/options/ansi/generic/complex/casinhf.c
deleted file mode 100644
index 0db55a0..0000000
--- a/lib/mlibc/options/ansi/generic/complex/casinhf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $NetBSD: casinhf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-
-float complex
-casinhf(float complex z)
-{
- float complex w;
-
- w = -1.0f * I * casinf(z * I);
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/catan.c b/lib/mlibc/options/ansi/generic/complex/catan.c
deleted file mode 100644
index 0cf4739..0000000
--- a/lib/mlibc/options/ansi/generic/complex/catan.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* $NetBSD: catan.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<catan>>, <<catanf>>---complex arc tangent
-
-INDEX
- catan
-INDEX
- catanf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex catan(double complex <[z]>);
- float complex catanf(float complex <[z]>);
-
-
-DESCRIPTION
- @ifnottex
- These functions compute the complex arc tangent of <[z]>,
- with branch cuts outside the interval [-i, +i] along the
- imaginary axis.
- @end ifnottex
- @tex
- These functions compute the complex arc tangent of <[z]>,
- with branch cuts outside the interval [$-i$, $+i$] along the
- imaginary axis.
- @end tex
-
- <<catanf>> is identical to <<catan>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- These functions return the complex arc tangent value, in the range
- of a strip mathematically unbounded along the imaginary axis
- and in the interval [-pi/2, +pi/2] along the real axis.
- @end ifnottex
- @tex
- These functions return the complex arc tangent, in the range
- of a strip mathematically unbounded along the imaginary axis
- and in the interval [$-\pi/2$, $+\pi/2$] along the real axis.
- @end tex
-
-PORTABILITY
- <<catan>> and <<catanf>> are ISO C99
-
-QUICKREF
- <<catan>> and <<catanf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subr.h"
-
-#ifdef __weak_alias
-__weak_alias(catan, _catan)
-#endif
-
-double complex
-catan(double complex z)
-{
- double complex w;
- double a, t, x, x2, y;
-
- x = creal(z);
- y = cimag(z);
-
- if ((x == 0.0) && (y > 1.0))
- goto ovrf;
-
- x2 = x * x;
- a = 1.0 - x2 - (y * y);
- if (a == 0.0)
- goto ovrf;
-
- t = 0.5 * atan2(2.0 * x, a);
- w = __mlibc_redupi(t);
-
- t = y - 1.0;
- a = x2 + (t * t);
- if (a == 0.0)
- goto ovrf;
-
- t = y + 1.0;
- a = (x2 + (t * t))/a;
- w = w + (0.25 * log(a)) * I;
- return w;
-
-ovrf:
-#if 0
- mtherr ("catan", OVERFLOW);
-#endif
- w = HUGE_VAL + HUGE_VAL * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/catanf.c b/lib/mlibc/options/ansi/generic/complex/catanf.c
deleted file mode 100644
index 33c47df..0000000
--- a/lib/mlibc/options/ansi/generic/complex/catanf.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* $NetBSD: catanf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subrf.h"
-
-#ifdef __weak_alias
-__weak_alias(catanf, _catanf)
-#endif
-
-float complex
-catanf(float complex z)
-{
- float complex w;
- float a, t, x, x2, y;
-
- x = crealf(z);
- y = cimagf(z);
-
- if ((x == 0.0f) && (y > 1.0f))
- goto ovrf;
-
- x2 = x * x;
- a = 1.0f - x2 - (y * y);
- if (a == 0.0f)
- goto ovrf;
-
- t = 0.5f * atan2f(2.0f * x, a);
- w = __mlibc_redupif(t);
-
- t = y - 1.0f;
- a = x2 + (t * t);
- if (a == 0.0f)
- goto ovrf;
-
- t = y + 1.0f;
- a = (x2 + (t * t))/a;
- w = w + (0.25f * logf(a)) * I;
- return w;
-
-ovrf:
-#if 0
- mtherr ("catan", OVERFLOW);
-#endif
- w = HUGE_VALF + HUGE_VALF * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/catanh.c b/lib/mlibc/options/ansi/generic/complex/catanh.c
deleted file mode 100644
index 2b9ef9e..0000000
--- a/lib/mlibc/options/ansi/generic/complex/catanh.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $NetBSD: catanh.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<catanh>>, <<catanhf>>---complex arc hyperbolic tangent
-
-INDEX
- catanh
-INDEX
- catanhf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex catanh(double complex <[z]>);
- float complex catanhf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex arc hyperbolic tan of <[z]>,
- with branch cuts outside the interval [-1, +1] along the
- real axis.
-
- <<catanhf>> is identical to <<catanh>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- These functions return the complex arc hyperbolic tangent value,
- in the range of a strip mathematically unbounded along the
- real axis and in the interval [-i*p/2, +i*p/2] along the
- imaginary axis.
- @end ifnottex
- @tex
- These functions return the complex arc hyperbolic tangent value,
- in the range of a strip mathematically unbounded along the
- real axis and in the interval [$-i\pi/2$, $+i\pi/2$] along the
- imaginary axis.
- @end tex
-
-PORTABILITY
- <<catanh>> and <<catanhf>> are ISO C99
-
-QUICKREF
- <<catanh>> and <<catanhf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-
-double complex
-catanh(double complex z)
-{
- double complex w;
-
- w = -1.0 * I * catan(z * I);
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/catanhf.c b/lib/mlibc/options/ansi/generic/complex/catanhf.c
deleted file mode 100644
index fe6127a..0000000
--- a/lib/mlibc/options/ansi/generic/complex/catanhf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $NetBSD: catanhf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-
-float complex
-catanhf(float complex z)
-{
- float complex w;
-
- w = -1.0f * I * catanf(z * I);
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ccos.c b/lib/mlibc/options/ansi/generic/complex/ccos.c
deleted file mode 100644
index ebb52bf..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ccos.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* $NetBSD: ccos.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<ccos>>, <<ccosf>>---complex cosine
-
-INDEX
- ccos
-INDEX
- ccosf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex ccos(double complex <[z]>);
- float complex ccosf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex cosine of <[z]>.
-
- <<ccosf>> is identical to <<ccos>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- These functions return the complex cosine value.
-
-PORTABILITY
- <<ccos>> and <<ccosf>> are ISO C99
-
-QUICKREF
- <<ccos>> and <<ccosf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subr.h"
-
-double complex
-ccos(double complex z)
-{
- double complex w;
- double ch, sh;
-
- __mlibc_cchsh(cimag(z), &ch, &sh);
- w = cos(creal(z)) * ch - (sin(creal(z)) * sh) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ccosf.c b/lib/mlibc/options/ansi/generic/complex/ccosf.c
deleted file mode 100644
index db7fab3..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ccosf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $NetBSD: ccosf.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subrf.h"
-
-float complex
-ccosf(float complex z)
-{
- float complex w;
- float ch, sh;
-
- __mlibc_cchshf(cimagf(z), &ch, &sh);
- w = cosf(crealf(z)) * ch - (sinf(crealf(z)) * sh) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ccosh.c b/lib/mlibc/options/ansi/generic/complex/ccosh.c
deleted file mode 100644
index 223a5ed..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ccosh.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* $NetBSD: ccosh.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<ccosh>>, <<ccoshf>>---complex hyperbolic cosine
-
-INDEX
- ccosh
-INDEX
- ccoshf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex ccosh(double complex <[z]>);
- float complex ccoshf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex hyperbolic cosine of <[z]>.
-
- <<ccoshf>> is identical to <<ccosh>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- These functions return the complex hyperbolic cosine value.
-
-PORTABILITY
- <<ccosh>> and <<ccoshf>> are ISO C99
-
-QUICKREF
- <<ccosh>> and <<ccoshf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-ccosh(double complex z)
-{
- double complex w;
- double x, y;
-
- x = creal(z);
- y = cimag(z);
- w = cosh(x) * cos(y) + (sinh(x) * sin(y)) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ccoshf.c b/lib/mlibc/options/ansi/generic/complex/ccoshf.c
deleted file mode 100644
index af11353..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ccoshf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $NetBSD: ccoshf.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-ccoshf(float complex z)
-{
- float complex w;
- float x, y;
-
- x = crealf(z);
- y = cimagf(z);
- w = coshf(x) * cosf(y) + (sinhf(x) * sinf(y)) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cephes_subr.c b/lib/mlibc/options/ansi/generic/complex/cephes_subr.c
deleted file mode 100644
index fe08b42..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cephes_subr.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* $NetBSD: cephes_subr.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subr.h"
-
-/* calculate cosh and sinh */
-
-void
-__mlibc_cchsh(double x, double *c, double *s)
-{
- double e, ei;
-
- if (fabs(x) <= 0.5) {
- *c = cosh(x);
- *s = sinh(x);
- } else {
- e = exp(x);
- ei = 0.5 / e;
- e = 0.5 * e;
- *s = e - ei;
- *c = e + ei;
- }
-}
-
-/* Program to subtract nearest integer multiple of PI */
-
-/* extended precision value of PI: */
-static const double DP1 = 3.14159265160560607910E0;
-static const double DP2 = 1.98418714791870343106E-9;
-static const double DP3 = 1.14423774522196636802E-17;
-#define MACHEP 1.1e-16
-
-double
-__mlibc_redupi(double x)
-{
- double t;
- long i;
-
- t = x / M_PI;
- if (t >= 0.0)
- t += 0.5;
- else
- t -= 0.5;
-
- i = t; /* the multiple */
- t = i;
- t = ((x - t * DP1) - t * DP2) - t * DP3;
- return t;
-}
-
-/* Taylor series expansion for cosh(2y) - cos(2x) */
-
-double
-__mlibc_ctans(double complex z)
-{
- double f, x, x2, y, y2, rn, t;
- double d;
-
- x = fabs(2.0 * creal(z));
- y = fabs(2.0 * cimag(z));
-
- x = __mlibc_redupi(x);
-
- x = x * x;
- y = y * y;
- x2 = 1.0;
- y2 = 1.0;
- f = 1.0;
- rn = 0.0;
- d = 0.0;
- do {
- rn += 1.0;
- f *= rn;
- rn += 1.0;
- f *= rn;
- x2 *= x;
- y2 *= y;
- t = y2 + x2;
- t /= f;
- d += t;
-
- rn += 1.0;
- f *= rn;
- rn += 1.0;
- f *= rn;
- x2 *= x;
- y2 *= y;
- t = y2 - x2;
- t /= f;
- d += t;
- } while (fabs(t/d) > MACHEP);
- return d;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cephes_subr.h b/lib/mlibc/options/ansi/generic/complex/cephes_subr.h
deleted file mode 100644
index 719075e..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cephes_subr.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* $NetBSD: cephes_subr.h,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
-
-#ifndef __MLIBC_ABI_ONLY
-
-void __mlibc_cchsh(double, double *, double *);
-double __mlibc_redupi(double);
-double __mlibc_ctans(double complex);
-
-#endif /* !__MLIBC_ABI_ONLY */
diff --git a/lib/mlibc/options/ansi/generic/complex/cephes_subrf.c b/lib/mlibc/options/ansi/generic/complex/cephes_subrf.c
deleted file mode 100644
index 1ce18e5..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cephes_subrf.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* $NetBSD: cephes_subrf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subrf.h"
-
-/* calculate cosh and sinh */
-
-void
-__mlibc_cchshf(float x, float *c, float *s)
-{
- float e, ei;
-
- if (fabsf(x) <= 0.5f) {
- *c = coshf(x);
- *s = sinhf(x);
- } else {
- e = expf(x);
- ei = 0.5f / e;
- e = 0.5f * e;
- *s = e - ei;
- *c = e + ei;
- }
-}
-
-/* Program to subtract nearest integer multiple of PI */
-
-/* extended precision value of PI: */
-static const double DP1 = 3.140625;
-static const double DP2 = 9.67502593994140625E-4;
-static const double DP3 = 1.509957990978376432E-7;
-#define MACHEPF 3.0e-8
-
-float
-__mlibc_redupif(float x)
-{
- float t;
- long i;
-
- t = x / (float)M_PI;
- if (t >= 0.0f)
- t += 0.5f;
- else
- t -= 0.5f;
-
- i = t; /* the multiple */
- t = i;
- t = ((x - t * DP1) - t * DP2) - t * DP3;
- return t;
-}
-
-/* Taylor series expansion for cosh(2y) - cos(2x) */
-
-float
-__mlibc_ctansf(float complex z)
-{
- float f, x, x2, y, y2, rn, t, d;
-
- x = fabsf(2.0f * crealf(z));
- y = fabsf(2.0f * cimagf(z));
-
- x = __mlibc_redupif(x);
-
- x = x * x;
- y = y * y;
- x2 = 1.0f;
- y2 = 1.0f;
- f = 1.0f;
- rn = 0.0f;
- d = 0.0f;
- do {
- rn += 1.0f;
- f *= rn;
- rn += 1.0f;
- f *= rn;
- x2 *= x;
- y2 *= y;
- t = y2 + x2;
- t /= f;
- d += t;
-
- rn += 1.0f;
- f *= rn;
- rn += 1.0f;
- f *= rn;
- x2 *= x;
- y2 *= y;
- t = y2 - x2;
- t /= f;
- d += t;
- } while (fabsf(t/d) > MACHEPF);
- return d;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cephes_subrf.h b/lib/mlibc/options/ansi/generic/complex/cephes_subrf.h
deleted file mode 100644
index 84cdd82..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cephes_subrf.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* $NetBSD: cephes_subrf.h,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
-
-#ifndef __MLIBC_ABI_ONLY
-
-void __mlibc_cchshf(float, float *, float *);
-float __mlibc_redupif(float);
-float __mlibc_ctansf(float complex);
-
-#endif /* !__MLIBC_ABI_ONLY */
diff --git a/lib/mlibc/options/ansi/generic/complex/cexp.c b/lib/mlibc/options/ansi/generic/complex/cexp.c
deleted file mode 100644
index b9a3fd0..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cexp.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* $NetBSD: cexp.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<cexp>>, <<cexpf>>---complex base-e exponential
-
-INDEX
- cexp
-INDEX
- cexpf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex cexp(double complex <[z]>);
- float complex cexpf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex base-<[e]> exponential of <[z]>.
-
- <<cexpf>> is identical to <<cexp>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The cexp functions return the complex base-<[e]> exponential value.
-
-PORTABILITY
- <<cexp>> and <<cexpf>> are ISO C99
-
-QUICKREF
- <<cexp>> and <<cexpf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-cexp(double complex z)
-{
- double complex w;
- double r, x, y;
-
- x = creal(z);
- y = cimag(z);
- r = exp(x);
- w = r * cos(y) + r * sin(y) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cexpf.c b/lib/mlibc/options/ansi/generic/complex/cexpf.c
deleted file mode 100644
index 07fab1f..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cexpf.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* $NetBSD: cexpf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-cexpf(float complex z)
-{
- float complex w;
- float r, x, y;
-
- x = crealf(z);
- y = cimagf(z);
- r = expf(x);
- w = r * cosf(y) + r * sinf(y) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cimag.c b/lib/mlibc/options/ansi/generic/complex/cimag.c
deleted file mode 100644
index 24619f0..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cimag.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $NetBSD: cimag.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<cimag>>, <<cimagf>>---imaginary part
-
-INDEX
- cimag
-INDEX
- cimagf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double cimag(double complex <[z]>);
- float cimagf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the imaginary part of <[z]>.
-
- <<cimagf>> is identical to <<cimag>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The cimag functions return the imaginary part value (as a real).
-
-PORTABILITY
- <<cimag>> and <<cimagf>> are ISO C99
-
-QUICKREF
- <<cimag>> and <<cimagf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-
-#include "fdlibm.h"
-
-double
-cimag(double complex z)
-{
- double_complex w = { .z = z };
-
- return (IMAG_PART(w));
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cimagf.c b/lib/mlibc/options/ansi/generic/complex/cimagf.c
deleted file mode 100644
index 28ed81c..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cimagf.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* $NetBSD: cimagf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-
-#include "fdlibm.h"
-
-float
-cimagf(float complex z)
-{
- float_complex w = { .z = z };
-
- return (IMAG_PART(w));
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/clog.c b/lib/mlibc/options/ansi/generic/complex/clog.c
deleted file mode 100644
index f7ad3d2..0000000
--- a/lib/mlibc/options/ansi/generic/complex/clog.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* $NetBSD: clog.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<clog>>, <<clogf>>---complex base-e logarithm
-
-INDEX
- clog
-INDEX
- clogf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex clog(double complex <[z]>);
- float complex clogf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex natural (base-<[e]>) logarithm
- of <[z]>, with a branch cut along the negative real axis.
-
- <<clogf>> is identical to <<clog>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- @ifnottex
- The clog functions return the complex natural logarithm value, in
- the range of a strip mathematically unbounded along the real axis
- and in the interval [-i*pi , +i*pi] along the imaginary axis.
- @end ifnottex
- @tex
- The clog functions return the complex natural logarithm value, in
- the range of a strip mathematically unbounded along the real axis
- and in the interval [$-i\pi$, $+i\pi$] along the imaginary axis.
- @end tex
-
-PORTABILITY
- <<clog>> and <<clogf>> are ISO C99
-
-QUICKREF
- <<clog>> and <<clogf>> are ISO C99
-
-*/
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-clog(double complex z)
-{
- double complex w;
- double p, rr;
-
- rr = cabs(z);
- p = log(rr);
- rr = atan2(cimag(z), creal(z));
- w = p + rr * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/clogf.c b/lib/mlibc/options/ansi/generic/complex/clogf.c
deleted file mode 100644
index 078cea5..0000000
--- a/lib/mlibc/options/ansi/generic/complex/clogf.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* $NetBSD: clogf.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-clogf(float complex z)
-{
- float complex w;
- float p, rr;
-
- rr = cabsf(z);
- p = logf(rr);
- rr = atan2f(cimagf(z), crealf(z));
- w = p + rr * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/conj.c b/lib/mlibc/options/ansi/generic/complex/conj.c
deleted file mode 100644
index a761b5a..0000000
--- a/lib/mlibc/options/ansi/generic/complex/conj.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* $NetBSD: conj.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<conj>>, <<conjf>>---complex conjugate
-
-INDEX
- conj
-INDEX
- conjf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex conj(double complex <[z]>);
- float complex conjf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex conjugate of <[z]>,
- by reversing the sign of its imaginary part.
-
- <<conjf>> is identical to <<conj>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The conj functions return the complex conjugate value.
-
-PORTABILITY
- <<conj>> and <<conjf>> are ISO C99
-
-QUICKREF
- <<conj>> and <<conjf>> are ISO C99
-
-*/
-
-#include <complex.h>
-
-#include "fdlibm.h"
-
-double complex
-conj(double complex z)
-{
- double_complex w = { .z = z };
-
- IMAG_PART(w) = -IMAG_PART(w);
-
- return (w.z);
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/conjf.c b/lib/mlibc/options/ansi/generic/complex/conjf.c
deleted file mode 100644
index 0ca71ef..0000000
--- a/lib/mlibc/options/ansi/generic/complex/conjf.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* $NetBSD: conjf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-
-#include "fdlibm.h"
-
-float complex
-conjf(float complex z)
-{
- float_complex w = { .z = z };
-
- IMAG_PART(w) = -IMAG_PART(w);
-
- return (w.z);
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cpow.c b/lib/mlibc/options/ansi/generic/complex/cpow.c
deleted file mode 100644
index b60f7be..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cpow.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* $NetBSD: cpow.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<cpow>>, <<cpowf>>---complex power
-
-INDEX
- cpow
-INDEX
- cpowf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex cpow(double complex <[x]>, double complex <[y]>);
- float complex cpowf(float complex <[x]>, float complex <[y]>);
-
-
-DESCRIPTION
- @ifnottex
- The cpow functions compute the complex power function x^y
- power, with a branch cut for the first parameter along the
- negative real axis.
- @end ifnottex
- @tex
- The cpow functions compute the complex power function $x^y$
- power, with a branch cut for the first parameter along the
- negative real axis.
- @end tex
-
- <<cpowf>> is identical to <<cpow>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The cpow functions return the complex power function value.
-
-PORTABILITY
- <<cpow>> and <<cpowf>> are ISO C99
-
-QUICKREF
- <<cpow>> and <<cpowf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-cpow(double complex a, double complex z)
-{
- double complex w;
- double x, y, r, theta, absa, arga;
-
- x = creal(z);
- y = cimag(z);
- absa = cabs(a);
- if (absa == 0.0) {
- return (0.0 + 0.0 * I);
- }
- arga = carg(a);
- r = pow(absa, x);
- theta = x * arga;
- if (y != 0.0) {
- r = r * exp(-y * arga);
- theta = theta + y * log(absa);
- }
- w = r * cos(theta) + (r * sin(theta)) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cpowf.c b/lib/mlibc/options/ansi/generic/complex/cpowf.c
deleted file mode 100644
index 1e736af..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cpowf.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $NetBSD: cpowf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-cpowf(float complex a, float complex z)
-{
- float complex w;
- float x, y, r, theta, absa, arga;
-
- x = crealf(z);
- y = cimagf(z);
- absa = cabsf(a);
- if (absa == 0.0f) {
- return (0.0f + 0.0f * I);
- }
- arga = cargf(a);
- r = powf(absa, x);
- theta = x * arga;
- if (y != 0.0f) {
- r = r * expf(-y * arga);
- theta = theta + y * logf(absa);
- }
- w = r * cosf(theta) + (r * sinf(theta)) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cproj.c b/lib/mlibc/options/ansi/generic/complex/cproj.c
deleted file mode 100644
index 0ed50f2..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cproj.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* $NetBSD: cproj.c,v 1.3 2010/09/20 17:51:38 christos Exp $ */
-
-/*-
- * Copyright (c) 2010 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<cproj>>, <<cprojf>>--- Riemann sphere projection
-
-INDEX
- cproj
-INDEX
- cprojf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex cproj(double complex <[z]>);
- float complex cprojf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute a projection of <[z]> onto the Riemann
- sphere: <[z]> projects to <[z]> except that all complex infinities
- (even those with one infinite part and one NaN part) project
- to positive infinity on the real axis. If <[z]> has an infinite part,
- then <<cproj>>(<[z]>) is equivalent to
-
- INFINITY + I * copysign(0.0, cimag(z))
-
- <<cprojf>> is identical to <<cproj>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The cproj functions return the value of the projection onto
- the Riemann sphere.
-
-PORTABILITY
- <<cproj>> and <<cprojf>> are ISO C99
-
-QUICKREF
- <<cproj>> and <<cprojf>> are ISO C99
-
-*/
-
-/*__RCSID("$NetBSD: cproj.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */
-
-#include <complex.h>
-#include <math.h>
-
-#include "fdlibm.h"
-
-/*
- * cproj(double complex z)
- *
- * These functions return the value of the projection (not stereographic!)
- * onto the Riemann sphere.
- *
- * z projects to z, except that all complex infinities (even those with one
- * infinite part and one NaN part) project to positive infinity on the real axis.
- * If z has an infinite part, then cproj(z) shall be equivalent to:
- *
- * INFINITY + I * copysign(0.0, cimag(z))
- */
-double complex
-cproj(double complex z)
-{
- double_complex w = { .z = z };
-
- if (isinf(creal(z)) || isinf(cimag(z))) {
-#ifdef __INFINITY
- REAL_PART(w) = __INFINITY;
-#else
- REAL_PART(w) = INFINITY;
-#endif
- IMAG_PART(w) = copysign(0.0, cimag(z));
- }
-
- return (w.z);
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/cprojf.c b/lib/mlibc/options/ansi/generic/complex/cprojf.c
deleted file mode 100644
index 76c3d8a..0000000
--- a/lib/mlibc/options/ansi/generic/complex/cprojf.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* $NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $ */
-
-/*-
- * Copyright (c) 2010 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*__RCSID("$NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */
-
-#include <complex.h>
-#include <math.h>
-
-#include "fdlibm.h"
-
-/*
- * cprojf(float complex z)
- *
- * These functions return the value of the projection (not stereographic!)
- * onto the Riemann sphere.
- *
- * z projects to z, except that all complex infinities (even those with one
- * infinite part and one NaN part) project to positive infinity on the real axis.
- * If z has an infinite part, then cproj(z) shall be equivalent to:
- *
- * INFINITY + I * copysign(0.0, cimag(z))
- */
-
-float complex
-cprojf(float complex z)
-{
- float_complex w = { .z = z };
-
- if (isinf(crealf(z)) || isinf(cimagf(z))) {
-#ifdef __INFINITY
- REAL_PART(w) = __INFINITY;
-#else
- REAL_PART(w) = INFINITY;
-#endif
- IMAG_PART(w) = copysignf(0.0, cimagf(z));
- }
-
- return (w.z);
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/creal.c b/lib/mlibc/options/ansi/generic/complex/creal.c
deleted file mode 100644
index 07bf96f..0000000
--- a/lib/mlibc/options/ansi/generic/complex/creal.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $NetBSD: creal.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<creal>>, <<crealf>>---real part
-
-INDEX
- creal
-INDEX
- crealf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double creal(double complex <[z]>);
- float crealf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the real part of <[z]>.
-
- <<crealf>> is identical to <<creal>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The creal functions return the real part value.
-
-PORTABILITY
- <<creal>> and <<crealf>> are ISO C99
-
-QUICKREF
- <<creal>> and <<crealf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-
-#include "fdlibm.h"
-
-double
-creal(double complex z)
-{
- double_complex w = { .z = z };
-
- return (REAL_PART(w));
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/crealf.c b/lib/mlibc/options/ansi/generic/complex/crealf.c
deleted file mode 100644
index 245986d..0000000
--- a/lib/mlibc/options/ansi/generic/complex/crealf.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* $NetBSD: crealf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
-
-/*
- * Written by Matthias Drochner <drochner@NetBSD.org>.
- * Public domain.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-
-#include "fdlibm.h"
-
-float
-crealf(float complex z)
-{
- float_complex w = { .z = z };
-
- return (REAL_PART(w));
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/csin.c b/lib/mlibc/options/ansi/generic/complex/csin.c
deleted file mode 100644
index b32d057..0000000
--- a/lib/mlibc/options/ansi/generic/complex/csin.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* $NetBSD: csin.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<csin>>, <<csinf>>---complex sine
-
-INDEX
- csin
-INDEX
- csinf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex csin(double complex <[z]>);
- float complex csinf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex sine of <[z]>.
-
- <<csinf>> is identical to <<csin>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- These functions return the complex sine value.
-
-PORTABILITY
- <<csin>> and <<csinf>> are ISO C99
-
-QUICKREF
- <<csin>> and <<csinf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subr.h"
-
-double complex
-csin(double complex z)
-{
- double complex w;
- double ch, sh;
-
- __mlibc_cchsh(cimag(z), &ch, &sh);
- w = sin(creal(z)) * ch + (cos(creal(z)) * sh) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/csinf.c b/lib/mlibc/options/ansi/generic/complex/csinf.c
deleted file mode 100644
index 0d81d41..0000000
--- a/lib/mlibc/options/ansi/generic/complex/csinf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $NetBSD: csinf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subrf.h"
-
-float complex
-csinf(float complex z)
-{
- float complex w;
- float ch, sh;
-
- __mlibc_cchshf(cimagf(z), &ch, &sh);
- w = sinf(crealf(z)) * ch + (cosf(crealf(z)) * sh) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/csinh.c b/lib/mlibc/options/ansi/generic/complex/csinh.c
deleted file mode 100644
index f117162..0000000
--- a/lib/mlibc/options/ansi/generic/complex/csinh.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* $NetBSD: csinh.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<csinh>>, <<csinhf>>---complex hyperbolic sine
-
-INDEX
- csinh
-INDEX
- csinhf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex csinh(double complex <[z]>);
- float complex csinhf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex hyperbolic sine of <[z]>.
-
- <<ccoshf>> is identical to <<ccosh>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- These functions return the complex hyperbolic sine value.
-
-PORTABILITY
- <<csinh>> and <<csinhf>> are ISO C99
-
-QUICKREF
- <<csinh>> and <<csinhf>> are ISO C99
-
-*/
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-csinh(double complex z)
-{
- double complex w;
- double x, y;
-
- x = creal(z);
- y = cimag(z);
- w = sinh(x) * cos(y) + (cosh(x) * sin(y)) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/csinhf.c b/lib/mlibc/options/ansi/generic/complex/csinhf.c
deleted file mode 100644
index 3cd6ba7..0000000
--- a/lib/mlibc/options/ansi/generic/complex/csinhf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $NetBSD: csinhf.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-csinhf(float complex z)
-{
- float complex w;
- float x, y;
-
- x = crealf(z);
- y = cimagf(z);
- w = sinhf(x) * cosf(y) + (coshf(x) * sinf(y)) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/csqrt.c b/lib/mlibc/options/ansi/generic/complex/csqrt.c
deleted file mode 100644
index b144b7c..0000000
--- a/lib/mlibc/options/ansi/generic/complex/csqrt.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* $NetBSD: csqrt.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<csqrt>>, <<csqrtf>>---complex square root
-
-INDEX
- csqrt
-INDEX
- csqrtf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex csqrt(double complex <[z]>);
- float complex csqrtf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex square root of <[z]>, with
- a branch cut along the negative real axis.
-
- <<csqrtf>> is identical to <<csqrt>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- The csqrt functions return the complex square root value, in
- the range of the right halfplane (including the imaginary axis).
-
-PORTABILITY
- <<csqrt>> and <<csqrtf>> are ISO C99
-
-QUICKREF
- <<csqrt>> and <<csqrtf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-csqrt(double complex z)
-{
- double complex w;
- double x, y, r, t, scale;
-
- x = creal (z);
- y = cimag (z);
-
- if (y == 0.0) {
- if (x == 0.0) {
- w = 0.0 + y * I;
- } else {
- r = fabs(x);
- r = sqrt(r);
- if (x < 0.0) {
- w = 0.0 + r * I;
- } else {
- w = r + y * I;
- }
- }
- return w;
- }
- if (x == 0.0) {
- r = fabs(y);
- r = sqrt(0.5 * r);
- if (y > 0)
- w = r + r * I;
- else
- w = r - r * I;
- return w;
- }
- /* Rescale to avoid internal overflow or underflow. */
- if ((fabs(x) > 4.0) || (fabs(y) > 4.0)) {
- x *= 0.25;
- y *= 0.25;
- scale = 2.0;
- } else {
-#if 1
- x *= 1.8014398509481984e16; /* 2^54 */
- y *= 1.8014398509481984e16;
- scale = 7.450580596923828125e-9; /* 2^-27 */
-#else
- x *= 4.0;
- y *= 4.0;
- scale = 0.5;
-#endif
- }
- w = x + y * I;
- r = cabs(w);
- if (x > 0) {
- t = sqrt(0.5 * r + 0.5 * x);
- r = scale * fabs((0.5 * y) / t );
- t *= scale;
- } else {
- r = sqrt(0.5 * r - 0.5 * x);
- t = scale * fabs((0.5 * y) / r);
- r *= scale;
- }
- if (y < 0)
- w = t - r * I;
- else
- w = t + r * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/csqrtf.c b/lib/mlibc/options/ansi/generic/complex/csqrtf.c
deleted file mode 100644
index 13451fa..0000000
--- a/lib/mlibc/options/ansi/generic/complex/csqrtf.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* $NetBSD: csqrtf.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-csqrtf(float complex z)
-{
- float complex w;
- float x, y, r, t, scale;
-
- x = crealf (z);
- y = cimagf (z);
-
- if (y == 0.0f) {
- if (x < 0.0f) {
- w = 0.0f + sqrtf(-x) * I;
- return w;
- } else if (x == 0.0f) {
- return (0.0f + y * I);
- } else {
- w = sqrtf(x) + y * I;
- return w;
- }
- }
-
- if (x == 0.0f) {
- r = fabsf(y);
- r = sqrtf(0.5f * r);
- if (y > 0)
- w = r + r * I;
- else
- w = r - r * I;
- return w;
- }
-
- /* Rescale to avoid internal overflow or underflow. */
- if ((fabsf(x) > 4.0f) || (fabsf(y) > 4.0f)) {
- x *= 0.25f;
- y *= 0.25f;
- scale = 2.0f;
- } else {
-#if 1
- x *= 6.7108864e7f; /* 2^26 */
- y *= 6.7108864e7f;
- scale = 1.220703125e-4f; /* 2^-13 */
-#else
- x *= 4.0f;
- y *= 4.0f;
- scale = 0.5f;
-#endif
- }
- w = x + y * I;
- r = cabsf(w);
- if( x > 0 ) {
- t = sqrtf(0.5f * r + 0.5f * x);
- r = scale * fabsf((0.5f * y) / t);
- t *= scale;
- } else {
- r = sqrtf(0.5f * r - 0.5f * x);
- t = scale * fabsf((0.5f * y) / r);
- r *= scale;
- }
-
- if (y < 0)
- w = t - r * I;
- else
- w = t + r * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ctan.c b/lib/mlibc/options/ansi/generic/complex/ctan.c
deleted file mode 100644
index 600989d..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ctan.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* $NetBSD: ctan.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<ctan>>, <<ctanf>>---complex tangent
-
-INDEX
- ctan
-INDEX
- ctanf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex ctan(double complex <[z]>);
- float complex ctanf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex tangent of <[z]>.
-
- <<ctanf>> is identical to <<ctan>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- These functions return the complex tangent value.
-
-PORTABILITY
- <<ctan>> and <<ctanf>> are ISO C99
-
-QUICKREF
- <<ctan>> and <<ctanf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subr.h"
-
-double complex
-ctan(double complex z)
-{
- double complex w;
- double d;
-
- d = cos(2.0 * creal(z)) + cosh(2.0 * cimag(z));
-
- if (fabs(d) < 0.25)
- d = __mlibc_ctans(z);
-
- if (d == 0.0) {
- /* mtherr ("ctan", OVERFLOW); */
- w = HUGE_VAL + HUGE_VAL * I;
- return w;
- }
-
- w = sin(2.0 * creal(z)) / d + (sinh(2.0 * cimag(z)) / d) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ctanf.c b/lib/mlibc/options/ansi/generic/complex/ctanf.c
deleted file mode 100644
index 52360e0..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ctanf.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $NetBSD: ctanf.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-#include "cephes_subrf.h"
-
-float complex
-ctanf(float complex z)
-{
- float complex w;
- float d;
-
- d = cosf(2.0f * crealf(z)) + coshf(2.0f * cimagf(z));
-
- if (fabsf(d) < 0.25f)
- d = __mlibc_ctansf(z);
-
- if (d == 0.0f) {
- /* mtherr ("ctan", OVERFLOW); */
- w = HUGE_VALF + HUGE_VALF * I;
- return w;
- }
-
- w = sinf(2.0f * crealf(z)) / d + (sinhf(2.0f * cimagf(z)) / d) * I;
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ctanh.c b/lib/mlibc/options/ansi/generic/complex/ctanh.c
deleted file mode 100644
index db27e5b..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ctanh.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* $NetBSD: ctanh.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-/*
-FUNCTION
- <<ctanh>>, <<ctanf>>---complex hyperbolic tangent
-
-INDEX
- ctanh
-INDEX
- ctanhf
-
-ANSI_SYNOPSIS
- #include <complex.h>
- double complex ctanh(double complex <[z]>);
- float complex ctanhf(float complex <[z]>);
-
-
-DESCRIPTION
- These functions compute the complex hyperbolic tangent of <[z]>.
-
- <<ctanhf>> is identical to <<ctanh>>, except that it performs
- its calculations on <<floats complex>>.
-
-RETURNS
- These functions return the complex hyperbolic tangent value.
-
-PORTABILITY
- <<ctanh>> and <<ctanhf>> are ISO C99
-
-QUICKREF
- <<ctanh>> and <<ctanhf>> are ISO C99
-
-*/
-
-
-#include <complex.h>
-#include <math.h>
-
-double complex
-ctanh(double complex z)
-{
- double complex w;
- double x, y, d;
-
- x = creal(z);
- y = cimag(z);
- d = cosh(2.0 * x) + cos(2.0 * y);
- w = sinh(2.0 * x) / d + (sin(2.0 * y) / d) * I;
-
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/ctanhf.c b/lib/mlibc/options/ansi/generic/complex/ctanhf.c
deleted file mode 100644
index 6aaf20f..0000000
--- a/lib/mlibc/options/ansi/generic/complex/ctanhf.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: ctanhf.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */
-
-/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software written by Stephen L. Moshier.
- * It is redistributed by the NetBSD Foundation by permission of the author.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * imported and modified include for newlib 2010/10/03
- * Marco Atzeri <marco_atzeri@yahoo.it>
- */
-
-#include <complex.h>
-#include <math.h>
-
-float complex
-ctanhf(float complex z)
-{
- float complex w;
- float x, y, d;
-
- x = crealf(z);
- y = cimagf(z);
- d = coshf(2.0f * x) + cosf(2.0f * y);
- w = sinhf(2.0f * x) / d + (sinf(2.0f * y) / d) * I;
-
- return w;
-}
diff --git a/lib/mlibc/options/ansi/generic/complex/fdlibm.h b/lib/mlibc/options/ansi/generic/complex/fdlibm.h
deleted file mode 100644
index 75cdd2a..0000000
--- a/lib/mlibc/options/ansi/generic/complex/fdlibm.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __MLIBC_FDLIBM_H
-#define __MLIBC_FDLIBM_H
-
-#define REAL_PART(z) ((z).parts[0])
-#define IMAG_PART(z) ((z).parts[1])
-
-typedef union {
- float complex z;
- float parts[2];
-} float_complex;
-
-typedef union {
- double complex z;
- double parts[2];
-} double_complex;
-
-#endif
diff --git a/lib/mlibc/options/ansi/generic/ctype-stubs.cpp b/lib/mlibc/options/ansi/generic/ctype-stubs.cpp
deleted file mode 100644
index 3ce76e9..0000000
--- a/lib/mlibc/options/ansi/generic/ctype-stubs.cpp
+++ /dev/null
@@ -1,326 +0,0 @@
-
-#include <ctype.h>
-#include <wctype.h>
-
-#include <bits/ensure.h>
-#include <mlibc/charset.hpp>
-
-// --------------------------------------------------------------------------------------
-// char ctype functions.
-// --------------------------------------------------------------------------------------
-
-int isalpha(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_alpha(cp);
-}
-
-int isdigit(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_digit(cp);
-}
-
-int isxdigit(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_xdigit(cp);
-}
-
-int isalnum(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_alnum(cp);
-}
-
-int ispunct(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_punct(cp);
-}
-
-int isgraph(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_graph(cp);
-}
-
-int isblank(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_blank(cp);
-}
-
-int isspace(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_space(cp);
-}
-
-int isprint(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_print(cp);
-}
-
-int islower(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_lower(cp);
-}
-
-int isupper(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_upper(cp);
-}
-
-int iscntrl(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::generic_is_control(cp);
-}
-
-int isascii(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return cp <= 0x7F;
-}
-
-// --------------------------------------------------------------------------------------
-// wchar_t ctype functions.
-// --------------------------------------------------------------------------------------
-
-int iswalpha(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_alpha(cp);
-}
-
-int iswdigit(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_digit(cp);
-}
-
-int iswxdigit(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_xdigit(cp);
-}
-
-int iswalnum(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_alnum(cp);
-}
-
-int iswpunct(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_punct(cp);
-}
-
-int iswgraph(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_graph(cp);
-}
-
-int iswblank(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_blank(cp);
-}
-
-int iswspace(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_space(cp);
-}
-
-int iswprint(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_print(cp);
-}
-
-int iswlower(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_lower(cp);
-}
-
-int iswupper(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::current_charset()->is_upper(cp);
-}
-
-int iswcntrl(wint_t nc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return 0;
- return mlibc::generic_is_control(cp);
-}
-
-// --------------------------------------------------------------------------------------
-// iswctype functions.
-// --------------------------------------------------------------------------------------
-
-namespace {
- enum {
- ct_null,
- ct_alnum,
- ct_alpha,
- ct_blank,
- ct_cntrl,
- ct_digit,
- ct_graph,
- ct_lower,
- ct_print,
- ct_punct,
- ct_space,
- ct_upper,
- ct_xdigit,
- ct_count
- };
-}
-
-wctype_t wctype(const char *cs) {
- frg::string_view s{cs};
- if(s == "alnum") return ct_alnum;
- if(s == "alpha") return ct_alpha;
- if(s == "blank") return ct_blank;
- if(s == "cntrl") return ct_cntrl;
- if(s == "digit") return ct_digit;
- if(s == "graph") return ct_graph;
- if(s == "lower") return ct_lower;
- if(s == "print") return ct_print;
- if(s == "punct") return ct_punct;
- if(s == "space") return ct_space;
- if(s == "upper") return ct_upper;
- if(s == "xdigit") return ct_xdigit;
- mlibc::infoLogger() << "mlibc: wctype(\"" << cs << "\") is not supported" << frg::endlog;
- return ct_null;
-}
-
-int iswctype(wint_t wc, wctype_t type) {
- switch (type) {
- case ct_alnum:
- return iswalnum(wc);
- case ct_alpha:
- return iswalpha(wc);
- case ct_blank:
- return iswblank(wc);
- case ct_cntrl:
- return iswcntrl(wc);
- case ct_digit:
- return iswdigit(wc);
- case ct_graph:
- return iswgraph(wc);
- case ct_lower:
- return iswlower(wc);
- case ct_print:
- return iswprint(wc);
- case ct_punct:
- return iswpunct(wc);
- case ct_space:
- return iswspace(wc);
- case ct_upper:
- return iswupper(wc);
- case ct_xdigit:
- return iswxdigit(wc);
- }
- return 0;
-}
-
-// --------------------------------------------------------------------------------------
-// char conversion functions.
-// --------------------------------------------------------------------------------------
-
-int tolower(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return nc;
- return mlibc::current_charset()->to_lower(cp);
-}
-
-int toupper(int nc) {
- auto cc = mlibc::current_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(nc, cp); e != mlibc::charcode_error::null)
- return nc;
- return mlibc::current_charset()->to_upper(cp);
-}
-
-// --------------------------------------------------------------------------------------
-// wchar_t conversion functions.
-// --------------------------------------------------------------------------------------
-
-wint_t towlower(wint_t wc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(wc, cp); e != mlibc::charcode_error::null)
- return wc;
- return mlibc::current_charset()->to_lower(cp);
-}
-
-wint_t towupper(wint_t wc) {
- auto cc = mlibc::platform_wide_charcode();
- mlibc::codepoint cp;
- if(auto e = cc->promote(wc, cp); e != mlibc::charcode_error::null)
- return wc;
- return mlibc::current_charset()->to_upper(cp);
-}
-
diff --git a/lib/mlibc/options/ansi/generic/environment.cpp b/lib/mlibc/options/ansi/generic/environment.cpp
deleted file mode 100644
index 5625592..0000000
--- a/lib/mlibc/options/ansi/generic/environment.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <bits/ensure.h>
-#include <mlibc/allocator.hpp>
-#include <mlibc/debug.hpp>
-
-#include <frg/string.hpp>
-#include <frg/vector.hpp>
-
-namespace {
- char *empty_environment[] = { nullptr };
-}
-
-char **environ = empty_environment;
-
-namespace {
-
-size_t find_environ_index(frg::string_view name) {
- for(size_t i = 0; environ[i]; i++) {
- frg::string_view view{environ[i]};
- size_t s = view.find_first('=');
- if(s == size_t(-1)) {
- mlibc::infoLogger() << "mlibc: environment string \""
- << frg::escape_fmt{view.data(), view.size()}
- << "\" does not contain an equals sign (=)" << frg::endlog;
- continue;
- }
- if(view.sub_string(0, s) == name)
- return i;
- }
-
- return -1;
-}
-
-// Environment vector that is mutated by putenv() and setenv().
-// Cannot be global as it is accessed during library initialization.
-frg::vector<char *, MemoryAllocator> &get_vector() {
- static frg::vector<char *, MemoryAllocator> vector{getAllocator()};
- return vector;
-}
-
-void update_vector() {
- auto &vector = get_vector();
- if(environ == vector.data())
- return;
-
- // If the environ variable was changed, we copy the environment.
- // Note that we must only copy the pointers but not the strings themselves!
- vector.clear();
- for(size_t i = 0; environ[i]; i++)
- vector.push(environ[i]);
- vector.push(nullptr);
-
- environ = vector.data();
-}
-
-void assign_variable(frg::string_view name, const char *string, bool overwrite) {
- auto &vector = get_vector();
- __ensure(environ == vector.data());
-
- auto k = find_environ_index(name);
- if(k != size_t(-1)) {
- if(overwrite)
- vector[k] = const_cast<char *>(string);
- }else{
- // Last pointer of environ must always be a null delimiter.
- __ensure(!vector.back());
- vector.back() = const_cast<char *>(string);
- vector.push(nullptr);
- }
-
- // push() might have re-allocated the vector.
- environ = vector.data();
-}
-
-void unassign_variable(frg::string_view name) {
- auto &vector = get_vector();
- __ensure(environ == vector.data());
-
- auto k = find_environ_index(name);
- if(k == size_t(-1))
- return;
-
- // Last pointer of environ must always be a null delimiter.
- __ensure(vector.size() >= 2 && !vector.back());
- std::swap(vector[k], vector[vector.size() - 2]);
- vector.pop();
- vector.back() = nullptr;
-
- // pop() might have re-allocated the vector.
- environ = vector.data();
-}
-
-} // anonymous namespace
-
-char *getenv(const char *name) {
- auto k = find_environ_index(name);
- if(k == size_t(-1))
- return nullptr;
-
- frg::string_view view{environ[k]};
- size_t s = view.find_first('=');
- __ensure(s != size_t(-1));
- return const_cast<char *>(view.data() + s + 1);
-}
-
-namespace mlibc {
-
-int putenv(char *string) {
- frg::string_view view{string};
- size_t s = view.find_first('=');
- if(s == size_t(-1))
- __ensure(!"Environment strings need to contain an equals sign");
-
- update_vector();
- assign_variable(view.sub_string(0, s), string, true);
- return 0;
-}
-
-} // namespace mlibc
-
-#if __MLIBC_POSIX_OPTION
-
-int putenv(char *string) {
- return mlibc::putenv(string);
-}
-
-int setenv(const char *name, const char *value, int overwrite) {
- frg::string_view view{name};
- size_t s = view.find_first('=');
- if(s != size_t(-1)) {
- mlibc::infoLogger() << "mlibc: environment variable \""
- << frg::escape_fmt{view.data(), view.size()} << "\" contains an equals sign"
- << frg::endlog;
- errno = EINVAL;
- return -1;
- }
-
- // We never free strings here. TODO: Reuse them?
- char *string;
- __ensure(asprintf(&string, "%s=%s", name, value) > 0);
- __ensure(string);
-
- update_vector();
- assign_variable(name, string, overwrite);
- return 0;
-}
-
-int unsetenv(const char *name) {
- update_vector();
- unassign_variable(name);
- return 0;
-}
-
-int clearenv(void) {
- auto vector = get_vector();
- vector.clear();
- update_vector();
- return 0;
-}
-
-#endif /* __MLIBC_POSIX_OPTION */
diff --git a/lib/mlibc/options/ansi/generic/errno-stubs.cpp b/lib/mlibc/options/ansi/generic/errno-stubs.cpp
deleted file mode 100644
index 8229a9a..0000000
--- a/lib/mlibc/options/ansi/generic/errno-stubs.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <errno.h>
-
-int __thread __mlibc_errno;
-
-char *program_invocation_name = nullptr;
-char *program_invocation_short_name = nullptr;
-extern char *__progname __attribute__((__weak__, __alias__("program_invocation_short_name")));
-extern char *__progname_full __attribute__((__weak__, __alias__("program_invocation_name")));
-
-int *__errno_location() {
- return &__mlibc_errno;
-}
diff --git a/lib/mlibc/options/ansi/generic/fenv-stubs.cpp b/lib/mlibc/options/ansi/generic/fenv-stubs.cpp
deleted file mode 100644
index 7153844..0000000
--- a/lib/mlibc/options/ansi/generic/fenv-stubs.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-#include <bits/ensure.h>
-#include <fenv.h>
-
-// The functions that are not in this file but are defined in the header
-// are implemented like musl does in assembly.
-extern "C" __attribute__((__visibility__("hidden"))) int __fesetround(int);
-
-int fegetexceptflag(fexcept_t *, int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int feholdexcept(fenv_t *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int fesetexceptflag(const fexcept_t *, int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int fesetround(int r) {
- if (r != FE_TONEAREST
-#ifdef FE_DOWNWARD
- && r != FE_DOWNWARD
-#endif
-#ifdef FE_UPWARD
- && r != FE_UPWARD
-#endif
-#ifdef FE_TOWARDZERO
- && r != FE_TOWARDZERO
-#endif
- )
- return -1;
- return __fesetround(r);
-}
-
-int feupdateenv(const fenv_t *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
diff --git a/lib/mlibc/options/ansi/generic/file-io.cpp b/lib/mlibc/options/ansi/generic/file-io.cpp
deleted file mode 100644
index e59b109..0000000
--- a/lib/mlibc/options/ansi/generic/file-io.cpp
+++ /dev/null
@@ -1,745 +0,0 @@
-
-#include <errno.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#if __MLIBC_GLIBC_OPTION
-#include <stdio_ext.h>
-#endif
-
-#include <bits/ensure.h>
-
-#include <mlibc/debug.hpp>
-
-#include <abi-bits/fcntl.h>
-#include <frg/allocation.hpp>
-#include <frg/mutex.hpp>
-#include <mlibc/allocator.hpp>
-#include <mlibc/file-io.hpp>
-#include <mlibc/ansi-sysdeps.hpp>
-#include <mlibc/lock.hpp>
-
-namespace mlibc {
-
-// --------------------------------------------------------------------------------------
-// abstract_file implementation.
-// --------------------------------------------------------------------------------------
-
-namespace {
- using file_list = frg::intrusive_list<
- abstract_file,
- frg::locate_member<
- abstract_file,
- frg::default_list_hook<abstract_file>,
- &abstract_file::_list_hook
- >
- >;
-
- // Useful when debugging the FILE implementation.
- constexpr bool globallyDisableBuffering = false;
-
- // The maximum number of characters we permit the user to ungetc.
- constexpr size_t ungetBufferSize = 8;
-
- // List of files that will be flushed before exit().
- file_list &global_file_list() {
- static frg::eternal<file_list> list;
- return list.get();
- };
-}
-
-// For pipe-like streams (seek returns ESPIPE), we need to make sure
-// that the buffer only ever contains all-dirty or all-clean data.
-// Regarding _type and _bufmode:
-// As we might construct FILE objects for FDs that are not actually
-// open (e.g. for std{in,out,err}), we defer the type determination and cache the result.
-
-abstract_file::abstract_file(void (*do_dispose)(abstract_file *))
-: _type{stream_type::unknown}, _bufmode{buffer_mode::unknown}, _do_dispose{do_dispose} {
- // TODO: For __fwriting to work correctly, set the __io_mode to 1 if the write is write-only.
- __buffer_ptr = nullptr;
- __unget_ptr = nullptr;
- __buffer_size = 4096;
- __offset = 0;
- __io_offset = 0;
- __valid_limit = 0;
- __dirty_begin = 0;
- __dirty_end = 0;
- __io_mode = 0;
- __status_bits = 0;
-
- global_file_list().push_back(this);
-}
-
-abstract_file::~abstract_file() {
- if(__dirty_begin != __dirty_end)
- mlibc::infoLogger() << "mlibc warning: File is not flushed before destruction"
- << frg::endlog;
-
- if(__buffer_ptr)
- getAllocator().free(__buffer_ptr - ungetBufferSize);
-
- auto it = global_file_list().iterator_to(this);
- global_file_list().erase(it);
-}
-
-void abstract_file::dispose() {
- if(!_do_dispose)
- return;
- _do_dispose(this);
-}
-
-// Note that read() and write() are asymmetric:
-// While read() can trigger a write-back, write() can never trigger a read-ahead().
-// This peculiarity is reflected in their code.
-
-int abstract_file::read(char *buffer, size_t max_size, size_t *actual_size) {
- __ensure(max_size);
-
- if(_init_bufmode())
- return -1;
-
- size_t unget_length = 0;
- if (__unget_ptr != __buffer_ptr) {
- unget_length = frg::min(max_size, (size_t)(__buffer_ptr - __unget_ptr));
- memcpy(buffer, __unget_ptr, unget_length);
-
- __unget_ptr += unget_length;
- buffer += unget_length;
- max_size -= unget_length;
-
- if (max_size == 0) {
- *actual_size = unget_length;
- return 0;
- }
- }
-
- if(globallyDisableBuffering || _bufmode == buffer_mode::no_buffer) {
- size_t io_size;
- if(int e = io_read(buffer, max_size, &io_size); e) {
- __status_bits |= __MLIBC_ERROR_BIT;
- return e;
- }
- if(!io_size)
- __status_bits |= __MLIBC_EOF_BIT;
- *actual_size = io_size + unget_length;
- return 0;
- }
-
- // Ensure correct buffer type for pipe-like streams.
- // TODO: In order to support pipe-like streams we need to write-back the buffer.
- if(__io_mode && __valid_limit)
- mlibc::panicLogger() << "mlibc: Cannot read-write to same pipe-like stream"
- << frg::endlog;
- __io_mode = 0;
-
- // Clear the buffer, then buffer new data.
- if(__offset == __valid_limit) {
- // TODO: We only have to write-back/reset if __valid_limit reaches the buffer end.
- if(int e = _write_back(); e)
- return e;
- if(int e = _reset(); e)
- return e;
-
- // Perform a read-ahead.
- _ensure_allocation();
- size_t io_size;
- if(int e = io_read(__buffer_ptr, __buffer_size, &io_size); e) {
- __status_bits |= __MLIBC_ERROR_BIT;
- return e;
- }
- if(!io_size) {
- __status_bits |= __MLIBC_EOF_BIT;
- *actual_size = 0;
- return 0;
- }
-
- __io_offset = io_size;
- __valid_limit = io_size;
- }
-
- // Return data from the buffer.
- __ensure(__offset < __valid_limit);
-
- auto chunk = frg::min(size_t(__valid_limit - __offset), max_size);
- memcpy(buffer, __buffer_ptr + __offset, chunk);
- __offset += chunk;
-
- *actual_size = chunk + unget_length;
- return 0;
-}
-
-int abstract_file::write(const char *buffer, size_t max_size, size_t *actual_size) {
- __ensure(max_size);
-
- if(_init_bufmode())
- return -1;
- if(globallyDisableBuffering || _bufmode == buffer_mode::no_buffer) {
- // As we do not buffer, nothing can be dirty.
- __ensure(__dirty_begin == __dirty_end);
- size_t io_size;
- if(int e = io_write(buffer, max_size, &io_size); e) {
- __status_bits |= __MLIBC_ERROR_BIT;
- return e;
- }
- *actual_size = io_size;
- return 0;
- }
-
- // Flush the buffer if necessary.
- if(__offset == __buffer_size) {
- if(int e = _write_back(); e)
- return e;
- if(int e = _reset(); e)
- return e;
- }
-
- // Ensure correct buffer type for pipe-like streams.
- // TODO: We could full support pipe-like files
- // by ungetc()ing all data before a write happens,
- // however, for now we just report an error.
- if(!__io_mode && __valid_limit) // TODO: Only check this for pipe-like streams.
- mlibc::panicLogger() << "mlibc: Cannot read-write to same pipe-like stream"
- << frg::endlog;
- __io_mode = 1;
-
- __ensure(__offset < __buffer_size);
- auto chunk = frg::min(__buffer_size - __offset, max_size);
-
- // Line-buffered streams perform I/O on full lines.
- bool flush_line = false;
- if(_bufmode == buffer_mode::line_buffer) {
- auto nl = reinterpret_cast<char *>(memchr(buffer, '\n', chunk));
- if(nl) {
- chunk = nl + 1 - buffer;
- flush_line = true;
- }
- }
- __ensure(chunk);
-
- // Buffer data (without necessarily performing I/O).
- _ensure_allocation();
- memcpy(__buffer_ptr + __offset, buffer, chunk);
-
- if(__dirty_begin != __dirty_end) {
- __dirty_begin = frg::min(__dirty_begin, __offset);
- __dirty_end = frg::max(__dirty_end, __offset + chunk);
- }else{
- __dirty_begin = __offset;
- __dirty_end = __offset + chunk;
- }
- __valid_limit = frg::max(__offset + chunk, __valid_limit);
- __offset += chunk;
-
- // Flush line-buffered streams.
- if(flush_line) {
- if(_write_back())
- return -1;
- }
-
- *actual_size = chunk;
- return 0;
-}
-
-int abstract_file::unget(char c) {
- if (!__unget_ptr) {
- // This can happen if the file is unbuffered, but we still need
- // a space to store ungetc'd data.
- __ensure(!__buffer_ptr);
- _ensure_allocation();
- __ensure(__unget_ptr);
- }
-
- if ((size_t)(__buffer_ptr - __unget_ptr) + 1 > ungetBufferSize)
- return EOF;
- else {
- *(--__unget_ptr) = c;
- return c;
- }
-}
-
-int abstract_file::update_bufmode(buffer_mode mode) {
- // setvbuf() has undefined behavior if I/O has been performed.
- __ensure(__dirty_begin == __dirty_end
- && "update_bufmode() must only be called before performing I/O");
- _bufmode = mode;
- return 0;
-}
-
-void abstract_file::purge() {
- __offset = 0;
- __io_offset = 0;
- __valid_limit = 0;
- __dirty_end = __dirty_begin;
- __unget_ptr = __buffer_ptr;
-}
-
-int abstract_file::flush() {
- if (__dirty_end != __dirty_begin) {
- if (int e = _write_back(); e)
- return e;
- }
-
- if (int e = _save_pos(); e)
- return e;
- purge();
- return 0;
-}
-
-int abstract_file::tell(off_t *current_offset) {
- off_t seek_offset;
- if(int e = io_seek(0, SEEK_CUR, &seek_offset); e)
- return e;
-
- *current_offset = seek_offset + (off_t(__offset) - off_t(__io_offset));
- return 0;
-}
-
-int abstract_file::seek(off_t offset, int whence) {
- if(int e = _write_back(); e)
- return e;
-
- off_t new_offset;
- if(whence == SEEK_CUR) {
- auto seek_offset = offset + (off_t(__offset) - off_t(__io_offset));
- if(int e = io_seek(seek_offset, whence, &new_offset); e) {
- __status_bits |= __MLIBC_ERROR_BIT;
- return e;
- }
- }else{
- __ensure(whence == SEEK_SET || whence == SEEK_END);
- if(int e = io_seek(offset, whence, &new_offset); e) {
- __status_bits |= __MLIBC_ERROR_BIT;
- return e;
- }
- }
-
- // We just forget the current buffer.
- // TODO: If the seek is "small", we can just modify our internal offset.
- purge();
-
- return 0;
-}
-
-int abstract_file::_init_type() {
- if(_type != stream_type::unknown)
- return 0;
-
- if(int e = determine_type(&_type); e)
- return e;
- __ensure(_type != stream_type::unknown);
- return 0;
-}
-
-int abstract_file::_init_bufmode() {
- if(_bufmode != buffer_mode::unknown)
- return 0;
-
- if(determine_bufmode(&_bufmode))
- return -1;
- __ensure(_bufmode != buffer_mode::unknown);
- return 0;
-}
-
-int abstract_file::_write_back() {
- if(int e = _init_type(); e)
- return e;
-
- if(__dirty_begin == __dirty_end)
- return 0;
-
- // For non-pipe streams, first do a seek to reset the
- // I/O position to zero, then do a write().
- if(_type == stream_type::file_like) {
- if(__io_offset != __dirty_begin) {
- __ensure(__dirty_begin - __io_offset > 0);
- off_t new_offset;
- if(int e = io_seek(off_t(__dirty_begin) - off_t(__io_offset), SEEK_CUR, &new_offset); e)
- return e;
- __io_offset = __dirty_begin;
- }
- }else{
- __ensure(_type == stream_type::pipe_like);
- __ensure(__io_offset == __dirty_begin);
- }
-
- // Now, we are in the correct position to write-back everything.
- while(__io_offset < __dirty_end) {
- size_t io_size;
- if(int e = io_write(__buffer_ptr + __io_offset, __dirty_end - __io_offset, &io_size); e) {
- __status_bits |= __MLIBC_ERROR_BIT;
- return e;
- }
- __ensure(io_size > 0 && "io_write() is expected to always write at least one byte");
- __io_offset += io_size;
- __dirty_begin += io_size;
- }
-
- return 0;
-}
-
-int abstract_file::_save_pos() {
- if (int e = _init_type(); e)
- return e;
- if (int e = _init_bufmode(); e)
- return e;
-
- if (_type == stream_type::file_like && _bufmode != buffer_mode::no_buffer) {
- off_t new_offset;
- auto seek_offset = (off_t(__offset) - off_t(__io_offset));
- if (int e = io_seek(seek_offset, SEEK_CUR, &new_offset); e) {
- __status_bits |= __MLIBC_ERROR_BIT;
- mlibc::infoLogger() << "hit io_seek() error " << e << frg::endlog;
- return e;
- }
- return 0;
- }
- return 0; // nothing to do for the rest
-}
-
-int abstract_file::_reset() {
- if(int e = _init_type(); e)
- return e;
-
- // For pipe-like files, we must not forget already read data.
- // TODO: Report this error to the user.
- if(_type == stream_type::pipe_like)
- __ensure(__offset == __valid_limit);
-
- __ensure(__dirty_begin == __dirty_end);
- __offset = 0;
- __io_offset = 0;
- __valid_limit = 0;
-
- return 0;
-}
-
-// This may still be called when buffering is disabled, for ungetc.
-void abstract_file::_ensure_allocation() {
- if(__buffer_ptr)
- return;
-
- auto ptr = getAllocator().allocate(__buffer_size + ungetBufferSize);
- __buffer_ptr = reinterpret_cast<char *>(ptr) + ungetBufferSize;
- __unget_ptr = __buffer_ptr;
-}
-
-// --------------------------------------------------------------------------------------
-// fd_file implementation.
-// --------------------------------------------------------------------------------------
-
-fd_file::fd_file(int fd, void (*do_dispose)(abstract_file *), bool force_unbuffered)
-: abstract_file{do_dispose}, _fd{fd}, _force_unbuffered{force_unbuffered} { }
-
-int fd_file::fd() {
- return _fd;
-}
-
-int fd_file::close() {
- if(__dirty_begin != __dirty_end)
- mlibc::infoLogger() << "mlibc warning: File is not flushed before closing"
- << frg::endlog;
- if(int e = mlibc::sys_close(_fd); e)
- return e;
- return 0;
-}
-
-int fd_file::reopen(const char *path, const char *mode) {
- int mode_flags = parse_modestring(mode);
-
- int fd;
- if(int e = sys_open(path, mode_flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, &fd); e) {
- return e;
- }
-
- flush();
- close();
- getAllocator().deallocate(__buffer_ptr, __buffer_size + ungetBufferSize);
-
- __buffer_ptr = nullptr;
- __unget_ptr = nullptr;
- __buffer_size = 4096;
- _reset();
- _fd = fd;
-
- if(mode_flags & O_APPEND) {
- seek(0, SEEK_END);
- }
-
- return 0;
-}
-
-int fd_file::determine_type(stream_type *type) {
- off_t offset;
- int e = mlibc::sys_seek(_fd, 0, SEEK_CUR, &offset);
- if(!e) {
- *type = stream_type::file_like;
- return 0;
- }else if(e == ESPIPE) {
- *type = stream_type::pipe_like;
- return 0;
- }else{
- return e;
- }
-}
-
-int fd_file::determine_bufmode(buffer_mode *mode) {
- // When isatty() is not implemented, we fall back to the safest default (no buffering).
- if(!mlibc::sys_isatty) {
- MLIBC_MISSING_SYSDEP();
- *mode = buffer_mode::no_buffer;
- return 0;
- }
- if(_force_unbuffered) {
- *mode = buffer_mode::no_buffer;
- return 0;
- }
-
- if(int e = mlibc::sys_isatty(_fd); !e) {
- *mode = buffer_mode::line_buffer;
- return 0;
- }else if(e == ENOTTY) {
- *mode = buffer_mode::full_buffer;
- return 0;
- }else{
- mlibc::infoLogger() << "mlibc: sys_isatty() failed while determining whether"
- " stream is interactive" << frg::endlog;
- return -1;
- }
-}
-
-int fd_file::io_read(char *buffer, size_t max_size, size_t *actual_size) {
- ssize_t s;
- if(int e = mlibc::sys_read(_fd, buffer, max_size, &s); e)
- return e;
- *actual_size = s;
- return 0;
-}
-
-int fd_file::io_write(const char *buffer, size_t max_size, size_t *actual_size) {
- ssize_t s;
- if(int e = mlibc::sys_write(_fd, buffer, max_size, &s); e)
- return e;
- *actual_size = s;
- return 0;
-}
-
-int fd_file::io_seek(off_t offset, int whence, off_t *new_offset) {
- if(int e = mlibc::sys_seek(_fd, offset, whence, new_offset); e)
- return e;
- return 0;
-}
-
-int fd_file::parse_modestring(const char *mode) {
- // Consume the first char; this must be 'r', 'w' or 'a'.
- int flags = 0;
- bool has_plus = strchr(mode, '+');
- if(*mode == 'r') {
- if(has_plus) {
- flags = O_RDWR;
- }else{
- flags = O_RDONLY;
- }
- }else if(*mode == 'w') {
- if(has_plus) {
- flags = O_RDWR;
- }else{
- flags = O_WRONLY;
- }
- flags |= O_CREAT | O_TRUNC;
- }else if(*mode == 'a') {
- if(has_plus) {
- flags = O_APPEND | O_RDWR;
- }else{
- flags = O_APPEND | O_WRONLY;
- }
- flags |= O_CREAT;
- }else{
- mlibc::infoLogger() << "Illegal fopen() mode '" << *mode << "'" << frg::endlog;
- }
- mode += 1;
-
- // Consume additional flags.
- while(*mode) {
- if(*mode == '+') {
- mode++; // This is already handled above.
- }else if(*mode == 'b') {
- mode++; // mlibc assumes that there is no distinction between text and binary.
- }else if(*mode == 'e') {
- flags |= O_CLOEXEC;
- mode++;
- }else{
- mlibc::infoLogger() << "Illegal fopen() flag '" << mode << "'" << frg::endlog;
- mode++;
- }
- }
-
- return flags;
-}
-
-} // namespace mlibc
-
-namespace {
- mlibc::fd_file stdin_file{0};
- mlibc::fd_file stdout_file{1};
- mlibc::fd_file stderr_file{2, nullptr, true};
-
- struct stdio_guard {
- stdio_guard() { }
-
- ~stdio_guard() {
- // Only flush the files but do not close them.
- for(auto it : mlibc::global_file_list()) {
- if(int e = it->flush(); e)
- mlibc::infoLogger() << "mlibc warning: Failed to flush file before exit()"
- << frg::endlog;
- }
- }
- } global_stdio_guard;
-}
-
-FILE *stderr = &stderr_file;
-FILE *stdin = &stdin_file;
-FILE *stdout = &stdout_file;
-
-int fileno_unlocked(FILE *file_base) {
- auto file = static_cast<mlibc::fd_file *>(file_base);
- return file->fd();
-}
-
-int fileno(FILE *file_base) {
- auto file = static_cast<mlibc::fd_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- return fileno_unlocked(file_base);
-}
-
-FILE *fopen(const char *path, const char *mode) {
- int flags = mlibc::fd_file::parse_modestring(mode);
-
- int fd;
- if(int e = mlibc::sys_open(path, flags, 0666, &fd); e) {
- errno = e;
- return nullptr;
- }
-
- return frg::construct<mlibc::fd_file>(getAllocator(), fd,
- mlibc::file_dispose_cb<mlibc::fd_file>);
-}
-
-int fclose(FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- int e = 0;
- if(file->flush())
- e = EOF;
- if(file->close())
- e = EOF;
- file->dispose();
- return e;
-}
-
-int fseek(FILE *file_base, long offset, int whence) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- if(int e = file->seek(offset, whence); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-long ftell(FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- off_t current_offset;
- if(int e = file->tell(&current_offset); e) {
- errno = e;
- return -1;
- }
- return current_offset;
-}
-
-int fflush_unlocked(FILE *file_base) {
- if(file_base == NULL) {
- // Only flush the files but do not close them.
- for(auto it : mlibc::global_file_list()) {
- if(int e = it->flush(); e)
- mlibc::infoLogger() << "mlibc warning: Failed to flush file"
- << frg::endlog;
- }
- return 0;
- }
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- if(file->flush())
- return EOF;
- return 0;
-}
-int fflush(FILE *file_base) {
- if(file_base == NULL) {
- // Only flush the files but do not close them.
- for(auto it : mlibc::global_file_list()) {
- frg::unique_lock lock(it->_lock);
- if(int e = it->flush(); e)
- mlibc::infoLogger() << "mlibc warning: Failed to flush file"
- << frg::endlog;
- }
- return 0;
- }
-
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- if (file->flush())
- return EOF;
- return 0;
-}
-
-int setvbuf(FILE *file_base, char *, int mode, size_t) {
- // TODO: We could also honor the buffer, but for now use just set the mode.
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- if(mode == _IONBF) {
- if(int e = file->update_bufmode(mlibc::buffer_mode::no_buffer); e) {
- errno = e;
- return -1;
- }
- }else if(mode == _IOLBF) {
- if(int e = file->update_bufmode(mlibc::buffer_mode::line_buffer); e) {
- errno = e;
- return -1;
- }
- }else if(mode == _IOFBF) {
- if(int e = file->update_bufmode(mlibc::buffer_mode::full_buffer); e) {
- errno = e;
- return -1;
- }
- }else{
- errno = EINVAL;
- return -1;
- }
-
- return 0;
-}
-
-void rewind(FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- file->seek(0, SEEK_SET);
- file_base->__status_bits &= ~(__MLIBC_EOF_BIT | __MLIBC_ERROR_BIT);
-}
-
-int ungetc(int c, FILE *file_base) {
- if (c == EOF)
- return EOF;
-
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- return file->unget(c);
-}
-
-#if __MLIBC_GLIBC_OPTION
-void __fpurge(FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- file->purge();
-}
-#endif
-
diff --git a/lib/mlibc/options/ansi/generic/inttypes-stubs.cpp b/lib/mlibc/options/ansi/generic/inttypes-stubs.cpp
deleted file mode 100644
index ae0f9e7..0000000
--- a/lib/mlibc/options/ansi/generic/inttypes-stubs.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-
-#include <ctype.h>
-#include <inttypes.h>
-#include <string.h>
-
-#include <bits/ensure.h>
-#include <mlibc/debug.hpp>
-
-static const char *__mlibc_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
-
-intmax_t imaxabs(intmax_t num) {
- return num < 0 ? -num : num;
-}
-imaxdiv_t imaxdiv(intmax_t number, intmax_t denom) {
- imaxdiv_t r;
- r.quot = number / denom;
- r.rem = number % denom;
- return r;
-}
-
-template <class T> T strtoxmax(const char *it, char **out, int base) {
- T v = 0;
- bool negate = false;
- const unsigned char *s = (const unsigned char *)it;
- int c;
-
- if(std::is_signed<T>::value) {
- if(*s == '+') {
- s++;
- }else if(*s == '-') {
- negate = true;
- s++;
- }
- }
-
- do {
- c = *s++;
- } while (isspace(c));
- if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
-
- if(base == 8) {
- if(*it != 0)
- goto parse_digits;
- it++;
- }else if(base == 16) {
- if(*it != 0)
- goto parse_digits;
- it++;
- if(*it != 'x' && *it != 'X')
- goto parse_digits;
- it++;
- }
-
-parse_digits:
- while(*it) {
- if(isspace(*it)) {
- it++;
- continue;
- }
-
- __ensure(base <= 10); // TODO: For base > 10 we need to implement tolower().
- //auto c = strchr(__mlibc_digits, tolower(*it));
- auto c = strchr(__mlibc_digits, *it);
- if(!c || (c - __mlibc_digits) >= base)
- break;
- v = v * base + (c - __mlibc_digits);
- it++;
- }
-
- if(std::is_signed<T>::value) {
- if(negate)
- v = -v;
- }
-
- if(out)
- *out = const_cast<char *>(it);
- return v;
-}
-
-intmax_t strtoimax(const char *it, char **out, int base) {
- // TODO: This function has to check for overflow!
- return strtoxmax<intmax_t>(it, out, base);
-}
-uintmax_t strtoumax(const char *it, char **out, int base) {
- return strtoxmax<uintmax_t>(it, out, base);
-}
-intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
diff --git a/lib/mlibc/options/ansi/generic/locale-stubs.cpp b/lib/mlibc/options/ansi/generic/locale-stubs.cpp
deleted file mode 100644
index 38f5859..0000000
--- a/lib/mlibc/options/ansi/generic/locale-stubs.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-
-#include <limits.h>
-#include <locale.h>
-#include <string.h>
-
-#include <bits/ensure.h>
-
-#include <mlibc/debug.hpp>
-#include <frg/optional.hpp>
-
-namespace {
- // Values of the C locale are defined by the C standard.
- constexpr lconv c_lconv = {
- const_cast<char *>("."), // decimal_point
- const_cast<char *>(""), // thousands_sep
- const_cast<char *>(""), // grouping
- const_cast<char *>(""), // mon_decimal_point
- const_cast<char *>(""), // mon_thousands_sep
- const_cast<char *>(""), // mon_grouping
- const_cast<char *>(""), // positive_sign
- const_cast<char *>(""), // negative_sign
- const_cast<char *>(""), // currency_symbol
- CHAR_MAX, // frac_digits
- CHAR_MAX, // p_cs_precedes
- CHAR_MAX, // n_cs_precedes
- CHAR_MAX, // p_sep_by_space
- CHAR_MAX, // n_sep_by_space
- CHAR_MAX, // p_sign_posn
- CHAR_MAX, // n_sign_posn
- const_cast<char *>(""), // int_curr_symbol
- CHAR_MAX, // int_frac_digits
- CHAR_MAX, // int_p_cs_precedes
- CHAR_MAX, // int_n_cs_precedes
- CHAR_MAX, // int_p_sep_by_space
- CHAR_MAX, // int_n_sep_by_space
- CHAR_MAX, // int_p_sign_posn
- CHAR_MAX // int_n_sign_posn
- };
-}
-
-namespace mlibc {
- struct locale_description {
- // Identifier of this locale. used in setlocale().
- const char *name;
- lconv lc;
- };
-
- constinit const locale_description c_locale{
- .name = "C",
- .lc = c_lconv
- };
-
- constinit const locale_description posix_locale{
- .name = "POSIX",
- .lc = c_lconv
- };
-
- const locale_description *query_locale_description(const char *name) {
- if(!strcmp(name, "C"))
- return &c_locale;
- if(!strcmp(name, "POSIX"))
- return &posix_locale;
- return nullptr;
- }
-
- const locale_description *collate_facet;
- const locale_description *ctype_facet;
- const locale_description *monetary_facet;
- const locale_description *numeric_facet;
- const locale_description *time_facet;
- const locale_description *messages_facet;
-}
-
-void __mlibc_initLocale() {
- mlibc::collate_facet = &mlibc::c_locale;
- mlibc::ctype_facet = &mlibc::c_locale;
- mlibc::monetary_facet = &mlibc::c_locale;
- mlibc::numeric_facet = &mlibc::c_locale;
- mlibc::time_facet = &mlibc::c_locale;
- mlibc::messages_facet = &mlibc::c_locale;
-}
-
-char *setlocale(int category, const char *name) {
- if(category == LC_ALL) {
- // ´TODO: Implement correct return value when categories differ.
- auto current_desc = mlibc::collate_facet;
- __ensure(current_desc == mlibc::ctype_facet);
- __ensure(current_desc == mlibc::monetary_facet);
- __ensure(current_desc == mlibc::numeric_facet);
- __ensure(current_desc == mlibc::time_facet);
- __ensure(current_desc == mlibc::messages_facet);
-
- if(name) {
- // Our default C locale is the C locale.
- if(!strlen(name))
- name = "C";
-
- auto new_desc = mlibc::query_locale_description(name);
- if(!new_desc) {
- mlibc::infoLogger() << "mlibc: Locale " << name
- << " is not supported" << frg::endlog;
- return nullptr;
- }
-
- mlibc::collate_facet = new_desc;
- mlibc::ctype_facet = new_desc;
- mlibc::monetary_facet = new_desc;
- mlibc::numeric_facet = new_desc;
- mlibc::time_facet = new_desc;
- mlibc::messages_facet = new_desc;
- }
- return const_cast<char *>(current_desc->name);
- }else{
- const mlibc::locale_description **facet_ptr;
- switch(category) {
- case LC_COLLATE:
- facet_ptr = &mlibc::collate_facet;
- break;
- case LC_CTYPE:
- facet_ptr = &mlibc::ctype_facet;
- break;
- case LC_MONETARY:
- facet_ptr = &mlibc::monetary_facet;
- break;
- case LC_NUMERIC:
- facet_ptr = &mlibc::numeric_facet;
- break;
- case LC_TIME:
- facet_ptr = &mlibc::time_facet;
- break;
- case LC_MESSAGES:
- facet_ptr = &mlibc::messages_facet;
- break;
- default:
- mlibc::infoLogger() << "mlibc: Unexpected value " << category
- << " for category in setlocale()" << frg::endlog;
- return nullptr;
- }
-
- auto current_desc = *facet_ptr;
- if(name) {
- // Our default C locale is the C locale.
- if(!strlen(name))
- name = "C";
-
- auto new_desc = mlibc::query_locale_description(name);
- if(!new_desc) {
- mlibc::infoLogger() << "mlibc: Locale " << name
- << " is not supported" << frg::endlog;
- return nullptr;
- }
-
- *facet_ptr = new_desc;
- }
- return const_cast<char *>(current_desc->name);
- }
-}
-
-namespace {
- lconv effective_lc;
-}
-
-struct lconv *localeconv(void) {
- // Numeric locale.
- const auto &numeric_lc = mlibc::numeric_facet->lc;
- effective_lc.decimal_point = numeric_lc.decimal_point;
- effective_lc.thousands_sep = numeric_lc.thousands_sep;
- effective_lc.grouping = numeric_lc.grouping;
-
- // Monetary locale.
- const auto &monetary_lc = mlibc::monetary_facet->lc;
- effective_lc.mon_decimal_point = monetary_lc.mon_decimal_point;
- effective_lc.mon_thousands_sep = monetary_lc.mon_thousands_sep;
- effective_lc.mon_grouping = monetary_lc.mon_grouping;
- effective_lc.positive_sign = monetary_lc.positive_sign;
- effective_lc.negative_sign = monetary_lc.negative_sign;
- effective_lc.currency_symbol = monetary_lc.currency_symbol;
- effective_lc.frac_digits = monetary_lc.frac_digits;
- effective_lc.p_cs_precedes = monetary_lc.p_cs_precedes;
- effective_lc.n_cs_precedes = monetary_lc.n_cs_precedes;
- effective_lc.p_sep_by_space = monetary_lc.p_sep_by_space;
- effective_lc.n_sep_by_space = monetary_lc.n_sep_by_space;
- effective_lc.p_sign_posn = monetary_lc.p_sign_posn;
- effective_lc.n_sign_posn = monetary_lc.n_sign_posn;
- effective_lc.int_curr_symbol = monetary_lc.int_curr_symbol;
- effective_lc.int_frac_digits = monetary_lc.int_frac_digits;
- effective_lc.int_p_cs_precedes = monetary_lc.int_p_cs_precedes;
- effective_lc.int_n_cs_precedes = monetary_lc.int_n_cs_precedes;
- effective_lc.int_p_sep_by_space = monetary_lc.int_p_sep_by_space;
- effective_lc.int_n_sep_by_space = monetary_lc.int_n_sep_by_space;
- effective_lc.int_p_sign_posn = monetary_lc.int_p_sign_posn;
- effective_lc.int_n_sign_posn = monetary_lc.int_n_sign_posn;
-
- return &effective_lc;
-}
diff --git a/lib/mlibc/options/ansi/generic/math-stubs.ignored-cpp b/lib/mlibc/options/ansi/generic/math-stubs.ignored-cpp
deleted file mode 100644
index 9be985f..0000000
--- a/lib/mlibc/options/ansi/generic/math-stubs.ignored-cpp
+++ /dev/null
@@ -1,1831 +0,0 @@
-
-#include <math.h>
-#include <immintrin.h>
-
-#include <bits/ensure.h>
-
-#include <stdint.h>
-
-#include <mlibc/debug.hpp>
-
-// Taken from musl. See musl for the license/copyright!
-#define FORCE_EVAL(x) do { \
- if (sizeof(x) == sizeof(float)) { \
- volatile float __x; \
- __x = (x); \
- } else if (sizeof(x) == sizeof(double)) { \
- volatile double __x; \
- __x = (x); \
- } else { \
- volatile long double __x; \
- __x = (x); \
- } \
-} while(0)
-
-namespace ieee754 {
-
-struct SoftDouble {
- typedef uint64_t Bits;
- typedef uint64_t Mantissa;
- typedef int16_t Exp;
-
- static constexpr int kMantissaBits = 52;
- static constexpr int kExpBits = 11;
- static constexpr int kBias = 1023;
-
- // this exponent represents zeros (when mantissa = 0) and subnormals (when mantissa != 0)
- static constexpr Exp kSubExp = -kBias;
- // this exponent represents infinities (when mantissa = 0) and NaNs (when mantissa != 0)
- static constexpr Exp kInfExp = ((Exp(1) << kExpBits) - 1) - kBias;
-
- static constexpr Bits kMantissaMask = (Bits(1) << kMantissaBits) - 1;
- static constexpr Bits kExpMask = ((Bits(1) << kExpBits) - 1) << kMantissaBits;
- static constexpr Bits kSignMask = Bits(1) << (kMantissaBits + kExpBits);
-
- SoftDouble(bool negative, Mantissa mantissa, Exp exp)
- : negative(negative), mantissa(mantissa), exp(exp) {
-// mlibc::infoLogger.log() << "(" << (int)negative << ", " << (void *)mantissa
-// << ", " << exp << ")" << frg::end_log;
- __ensure(mantissa < (Mantissa(1) << kMantissaBits));
- __ensure((exp + kBias) >= 0);
- __ensure((exp + kBias) < (Exp(1) << kExpBits));
- }
-
- const bool negative;
- const Mantissa mantissa;
- const Exp exp;
-};
-
-template<typename F>
-using Bits = typename F::Bits;
-
-template<typename F>
-using Mantissa = typename F::Mantissa;
-
-template<typename F>
-using Exp = typename F::Exp;
-
-template<typename F>
-bool isZero(F x) {
- return x.exp == F::kSubExp && x.mantissa == 0;
-}
-
-template<typename F>
-bool isFinite(F x) {
- return x.exp != F::kInfExp;
-}
-
-// --------------------------------------------------------
-// Soft float operations
-// --------------------------------------------------------
-
-template<typename F>
-F constZero(bool negative) {
- return F(negative, 0, F::kSubExp);
-}
-
-template<typename F>
-F constOne(bool negative) {
- return F(negative, 0, 0);
-}
-
-template<typename F>
-F floor(F x) {
- if(!isFinite(x) || isZero(x)) // TODO: need exception for the not-finite case?
- return x;
-
- if(x.exp > F::kMantissaBits)
- return x; // x is already integral
-
- if(x.exp < 0) {
- // TODO: raise inexact
- // return -1 or +0
- return x.negative ? constOne<F>(true) : constZero<F>(false);
- }
-
- Mantissa<F> mask = F::kMantissaMask >> x.exp;
- if(!(x.mantissa & mask))
- return x; // x is already integral
-
- // TODO: raise inexact
- Mantissa<F> integral_position = (Mantissa<F>(1) << F::kMantissaBits) >> x.exp;
- if(x.negative)
- return F(true, (x.mantissa + integral_position) & (~mask), x.exp);
- return F(false, x.mantissa & (~mask), x.exp);
-}
-
-template<typename F>
-F ceil(F x) {
- if(!isFinite(x) || isZero(x)) // TODO: need exception for the not-finite case?
- return x;
-
- if(x.exp > F::kMantissaBits)
- return x; // x is already integral
-
- if(x.exp < 0) {
- // TODO: raise inexact
- // return -0 or +1
- return x.negative ? constZero<F>(true) : constOne<F>(false);
- }
-
- Mantissa<F> mask = F::kMantissaMask >> x.exp;
- if(!(x.mantissa & mask))
- return x; // x is already integral
-
- // TODO: raise inexact
- Mantissa<F> integral_position = (Mantissa<F>(1) << F::kMantissaBits) >> x.exp;
- if(x.negative)
- return F(true, x.mantissa & (~mask), x.exp);
- return F(false, (x.mantissa + integral_position) & (~mask), x.exp);
-}
-
-// --------------------------------------------------------
-// Soft float <-> bit string conversion functions
-// --------------------------------------------------------
-
-template<typename F>
-uint64_t compileBits(F soft) {
- auto bits = Bits<F>(soft.mantissa) | ((Bits<F>(soft.exp) + F::kBias) << soft.kMantissaBits);
- return soft.negative ? (F::kSignMask | bits) : bits;
-}
-
-SoftDouble extractBits(uint64_t bits) {
- return SoftDouble(bits & SoftDouble::kSignMask, bits & SoftDouble::kMantissaMask,
- ((bits & SoftDouble::kExpMask) >> SoftDouble::kMantissaBits) - SoftDouble::kBias);
-}
-
-// --------------------------------------------------------
-// Soft float -> native float conversion functions
-// --------------------------------------------------------
-
-union DoubleBits {
- double fp;
- uint64_t bits;
-};
-
-double compileNative(SoftDouble soft) {
- DoubleBits word;
- word.bits = compileBits(soft);
- return word.fp;
-}
-
-SoftDouble extractNative(double native) {
- DoubleBits word;
- word.fp = native;
- return extractBits(word.bits);
-}
-
-} // namespace ieee754
-
-int __mlibc_fpclassify(double x) {
- return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x);
-}
-int __mlibc_fpclassifyf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-int __mlibc_fpclassifyl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double acos(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float acosf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double acosl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double asin(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float asinf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double asinl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double atan(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float atanf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double atanl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double atan2(double x, double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float atan2f(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double atan2l(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-// Taken from musl. See musl for the license/copyright!
-float __sindf(double x) {
- /* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
- static const double S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
- S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */
- S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
- S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */
-
- double r, s, w, z;
-
- /* Try to optimize for parallel evaluation as in __tandf.c. */
- z = x*x;
- w = z*z;
- r = S3 + z*S4;
- s = z*x;
- return (x + s*(S1 + z*S2)) + s*w*r;
-}
-
-// Taken from musl. See musl for the license/copyright!
-float __cosdf(double x) {
- /* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
- static const double C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
- C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
- C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
- C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
-
- double r, w, z;
-
- /* Try to optimize for parallel evaluation as in __tandf.c. */
- z = x*x;
- w = z*z;
- r = C2+z*C3;
- return ((1.0+z*C0) + w*C1) + (w*z)*r;
-}
-
-float __tandf(double x, int odd) {
- /* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
- static const double T[] = {
- 0x15554d3418c99f.0p-54, /* 0.333331395030791399758 */
- 0x1112fd38999f72.0p-55, /* 0.133392002712976742718 */
- 0x1b54c91d865afe.0p-57, /* 0.0533812378445670393523 */
- 0x191df3908c33ce.0p-58, /* 0.0245283181166547278873 */
- 0x185dadfcecf44e.0p-61, /* 0.00297435743359967304927 */
- 0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */
- };
-
- double z,r,w,s,t,u;
-
- z = x*x;
- /*
- * Split up the polynomial into small independent terms to give
- * opportunities for parallel evaluation. The chosen splitting is
- * micro-optimized for Athlons (XP, X64). It costs 2 multiplications
- * relative to Horner's method on sequential machines.
- *
- * We add the small terms from lowest degree up for efficiency on
- * non-sequential machines (the lowest degree terms tend to be ready
- * earlier). Apart from this, we don't care about order of
- * operations, and don't need to to care since we have precision to
- * spare. However, the chosen splitting is good for accuracy too,
- * and would give results as accurate as Horner's method if the
- * small terms were added from highest degree down.
- */
- r = T[4] + z*T[5];
- t = T[2] + z*T[3];
- w = z*z;
- s = z*x;
- u = T[0] + z*T[1];
- r = (x + s*u) + (s*w)*(t + w*r);
- return odd ? -1.0/r : r;
-}
-
-#define DBL_EPSILON 2.22044604925031308085e-16
-#define EPS DBL_EPSILON
-
-/* Get a 32 bit int from a float. */
-#define GET_FLOAT_WORD(w,d) \
-do { \
- union {float f; uint32_t i;} __u; \
- __u.f = (d); \
- (w) = __u.i; \
-} while (0)
-
-/* Get the more significant 32 bit int from a double. */
-#define GET_HIGH_WORD(hi,d) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.f = (d); \
- (hi) = __u.i >> 32; \
-} while (0)
-
-/* Get the less significant 32 bit int from a double. */
-#define GET_LOW_WORD(lo,d) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.f = (d); \
- (lo) = (uint32_t)__u.i; \
-} while (0)
-
-// Taken from musl. See musl for the license/copyright!
-int __rem_pio2_large(double *x, double *y, int e0, int nx, int prec)
-{
- static const int init_jk[] = {3,4,4,6}; /* initial value for jk */
-
- /*
- * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
- *
- * integer array, contains the (24*i)-th to (24*i+23)-th
- * bit of 2/pi after binary point. The corresponding
- * floating value is
- *
- * ipio2[i] * 2^(-24(i+1)).
- *
- * NB: This table must have at least (e0-3)/24 + jk terms.
- * For quad precision (e0 <= 16360, jk = 6), this is 686.
- */
- static const int32_t ipio2[] = {
- 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
- 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
- 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
- 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
- 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8,
- 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF,
- 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5,
- 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
- 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3,
- 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880,
- 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
-
- #if LDBL_MAX_EXP > 1024
- 0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6,
- 0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2,
- 0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35,
- 0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30,
- 0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C,
- 0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4,
- 0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770,
- 0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7,
- 0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19,
- 0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522,
- 0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16,
- 0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6,
- 0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E,
- 0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48,
- 0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3,
- 0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF,
- 0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55,
- 0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612,
- 0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929,
- 0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC,
- 0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B,
- 0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C,
- 0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4,
- 0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB,
- 0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC,
- 0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C,
- 0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F,
- 0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5,
- 0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437,
- 0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B,
- 0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA,
- 0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD,
- 0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3,
- 0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3,
- 0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717,
- 0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F,
- 0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61,
- 0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB,
- 0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51,
- 0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0,
- 0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C,
- 0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6,
- 0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC,
- 0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED,
- 0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328,
- 0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D,
- 0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0,
- 0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B,
- 0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4,
- 0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3,
- 0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F,
- 0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD,
- 0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B,
- 0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4,
- 0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761,
- 0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31,
- 0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30,
- 0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262,
- 0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E,
- 0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1,
- 0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C,
- 0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4,
- 0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08,
- 0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196,
- 0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9,
- 0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4,
- 0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC,
- 0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C,
- 0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0,
- 0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C,
- 0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0,
- 0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC,
- 0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22,
- 0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893,
- 0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7,
- 0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5,
- 0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F,
- 0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4,
- 0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF,
- 0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B,
- 0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2,
- 0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138,
- 0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E,
- 0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569,
- 0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34,
- 0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9,
- 0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D,
- 0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F,
- 0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855,
- 0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569,
- 0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B,
- 0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE,
- 0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41,
- 0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49,
- 0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F,
- 0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110,
- 0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8,
- 0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365,
- 0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A,
- 0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270,
- 0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5,
- 0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616,
- 0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B,
- 0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0,
- #endif
- };
-
- static const double PIo2[] = {
- 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
- 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
- 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
- 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
- 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
- 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
- 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
- 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
- };
-
- int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
- double z,fw,f[20],fq[20],q[20];
-
- /* initialize jk*/
- jk = init_jk[prec];
- jp = jk;
-
- /* determine jx,jv,q0, note that 3>q0 */
- jx = nx-1;
- jv = (e0-3)/24; if(jv<0) jv=0;
- q0 = e0-24*(jv+1);
-
- /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
- j = jv-jx; m = jx+jk;
- for (i=0; i<=m; i++,j++)
- f[i] = j<0 ? 0.0 : (double)ipio2[j];
-
- /* compute q[0],q[1],...q[jk] */
- for (i=0; i<=jk; i++) {
- for (j=0,fw=0.0; j<=jx; j++)
- fw += x[j]*f[jx+i-j];
- q[i] = fw;
- }
-
- jz = jk;
-recompute:
- /* distill q[] into iq[] reversingly */
- for (i=0,j=jz,z=q[jz]; j>0; i++,j--) {
- fw = (double)(int32_t)(0x1p-24*z);
- iq[i] = (int32_t)(z - 0x1p24*fw);
- z = q[j-1]+fw;
- }
-
- /* compute n */
- z = scalbn(z,q0); /* actual value of z */
- z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */
- n = (int32_t)z;
- z -= (double)n;
- ih = 0;
- if (q0 > 0) { /* need iq[jz-1] to determine n */
- i = iq[jz-1]>>(24-q0); n += i;
- iq[jz-1] -= i<<(24-q0);
- ih = iq[jz-1]>>(23-q0);
- }
- else if (q0 == 0) ih = iq[jz-1]>>23;
- else if (z >= 0.5) ih = 2;
-
- if (ih > 0) { /* q > 0.5 */
- n += 1; carry = 0;
- for (i=0; i<jz; i++) { /* compute 1-q */
- j = iq[i];
- if (carry == 0) {
- if (j != 0) {
- carry = 1;
- iq[i] = 0x1000000 - j;
- }
- } else
- iq[i] = 0xffffff - j;
- }
- if (q0 > 0) { /* rare case: chance is 1 in 12 */
- switch(q0) {
- case 1:
- iq[jz-1] &= 0x7fffff; break;
- case 2:
- iq[jz-1] &= 0x3fffff; break;
- }
- }
- if (ih == 2) {
- z = 1.0 - z;
- if (carry != 0)
- z -= scalbn(1.0,q0);
- }
- }
-
- /* check if recomputation is needed */
- if (z == 0.0) {
- j = 0;
- for (i=jz-1; i>=jk; i--) j |= iq[i];
- if (j == 0) { /* need recomputation */
- for (k=1; iq[jk-k]==0; k++); /* k = no. of terms needed */
-
- for (i=jz+1; i<=jz+k; i++) { /* add q[jz+1] to q[jz+k] */
- f[jx+i] = (double)ipio2[jv+i];
- for (j=0,fw=0.0; j<=jx; j++)
- fw += x[j]*f[jx+i-j];
- q[i] = fw;
- }
- jz += k;
- goto recompute;
- }
- }
-
- /* chop off zero terms */
- if (z == 0.0) {
- jz -= 1;
- q0 -= 24;
- while (iq[jz] == 0) {
- jz--;
- q0 -= 24;
- }
- } else { /* break z into 24-bit if necessary */
- z = scalbn(z,-q0);
- if (z >= 0x1p24) {
- fw = (double)(int32_t)(0x1p-24*z);
- iq[jz] = (int32_t)(z - 0x1p24*fw);
- jz += 1;
- q0 += 24;
- iq[jz] = (int32_t)fw;
- } else
- iq[jz] = (int32_t)z;
- }
-
- /* convert integer "bit" chunk to floating-point value */
- fw = scalbn(1.0,q0);
- for (i=jz; i>=0; i--) {
- q[i] = fw*(double)iq[i];
- fw *= 0x1p-24;
- }
-
- /* compute PIo2[0,...,jp]*q[jz,...,0] */
- for(i=jz; i>=0; i--) {
- for (fw=0.0,k=0; k<=jp && k<=jz-i; k++)
- fw += PIo2[k]*q[i+k];
- fq[jz-i] = fw;
- }
-
- /* compress fq[] into y[] */
- switch(prec) {
- case 0:
- fw = 0.0;
- for (i=jz; i>=0; i--)
- fw += fq[i];
- y[0] = ih==0 ? fw : -fw;
- break;
- case 1:
- case 2:
- fw = 0.0;
- for (i=jz; i>=0; i--)
- fw += fq[i];
- // TODO: drop excess precision here once double_t is used
- fw = (double)fw;
- y[0] = ih==0 ? fw : -fw;
- fw = fq[0]-fw;
- for (i=1; i<=jz; i++)
- fw += fq[i];
- y[1] = ih==0 ? fw : -fw;
- break;
- case 3: /* painful */
- for (i=jz; i>0; i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (i=jz; i>1; i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (fw=0.0,i=jz; i>=2; i--)
- fw += fq[i];
- if (ih==0) {
- y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
- } else {
- y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
- }
- }
- return n&7;
-}
-
-int __rem_pio2f(float x, double *y) {
- /*
- * invpio2: 53 bits of 2/pi
- * pio2_1: first 25 bits of pi/2
- * pio2_1t: pi/2 - pio2_1
- */
- static const double toint = 1.5/EPS,
- invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
- pio2_1 = 1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
- pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
-
- union {float f; uint32_t i;} u = {x};
- double tx[1],ty[1];
- double fn;
- uint32_t ix;
- int n, sign, e0;
-
- ix = u.i & 0x7fffffff;
- /* 25+53 bit pi is good enough for medium size */
- if (ix < 0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */
- /* Use a specialized rint() to get fn. Assume round-to-nearest. */
- fn = (double)x*invpio2 + toint - toint;
- n = (int32_t)fn;
- *y = x - fn*pio2_1 - fn*pio2_1t;
- return n;
- }
- if(ix>=0x7f800000) { /* x is inf or NaN */
- *y = x-x;
- return 0;
- }
- /* scale x into [2^23, 2^24-1] */
- sign = u.i>>31;
- e0 = (ix>>23) - (0x7f+23); /* e0 = ilogb(|x|)-23, positive */
- u.i = ix - (e0<<23);
- tx[0] = u.f;
- n = __rem_pio2_large(tx,ty,e0,1,0);
- if (sign) {
- *y = -ty[0];
- return -n;
- }
- *y = ty[0];
- return n;
-}
-
-double cos(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-// Taken from musl. See musl for the license/copyright!
-float cosf(float x) {
- /* Small multiples of pi/2 rounded to double precision. */
- static const double c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
- c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
- c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
- c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
- double y;
- uint32_t ix;
- unsigned n, sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
-
- if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- /* raise inexact if x != 0 */
- FORCE_EVAL(x + 0x1p120f);
- return 1.0f;
- }
- return __cosdf(x);
- }
- if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */
- return -__cosdf(sign ? x+c2pio2 : x-c2pio2);
- else {
- if (sign)
- return __sindf(x + c1pio2);
- else
- return __sindf(c1pio2 - x);
- }
- }
- if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */
- return __cosdf(sign ? x+c4pio2 : x-c4pio2);
- else {
- if (sign)
- return __sindf(-x - c3pio2);
- else
- return __sindf(x - c3pio2);
- }
- }
-
- /* cos(Inf or NaN) is NaN */
- if (ix >= 0x7f800000)
- return x-x;
-
- /* general argument reduction needed */
- n = __rem_pio2f(x,&y);
- switch (n&3) {
- case 0: return __cosdf(y);
- case 1: return __sindf(-y);
- case 2: return -__cosdf(y);
- default:
- return __sindf(y);
- }
-}
-long double cosl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double sin(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-// Taken from musl. See musl for the license/copyright!
-float sinf(float x) {
- /* Small multiples of pi/2 rounded to double precision. */
- static const double s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
- s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
- s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
- s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
- double y;
- uint32_t ix;
- int n, sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
-
- if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f);
- return x;
- }
- return __sindf(x);
- }
- if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
- if (sign)
- return -__cosdf(x + s1pio2);
- else
- return __cosdf(x - s1pio2);
- }
- return __sindf(sign ? -(x + s2pio2) : -(x - s2pio2));
- }
- if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
- if (sign)
- return __cosdf(x + s3pio2);
- else
- return -__cosdf(x - s3pio2);
- }
- return __sindf(sign ? x + s4pio2 : x - s4pio2);
- }
-
- /* sin(Inf or NaN) is NaN */
- if (ix >= 0x7f800000)
- return x - x;
-
- /* general argument reduction needed */
- n = __rem_pio2f(x, &y);
- switch (n&3) {
- case 0: return __sindf(y);
- case 1: return __cosdf(y);
- case 2: return __sindf(-y);
- default:
- return -__cosdf(y);
- }
-}
-long double sinl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double tan(double x) {
- mlibc::infoLogger() << "mlibc: tan() is not precise" << frg::endlog;
- return tanf(x);
-}
-// Taken from musl. See musl for the license/copyright!
-float tanf(float x) {
- /* Small multiples of pi/2 rounded to double precision. */
- static const double t1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
- t2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
- t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
- t4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
- double y;
- uint32_t ix;
- unsigned n, sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
-
- if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f);
- return x;
- }
- return __tandf(x, 0);
- }
- if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if (ix <= 0x4016cbe3) /* |x| ~<= 3pi/4 */
- return __tandf((sign ? x+t1pio2 : x-t1pio2), 1);
- else
- return __tandf((sign ? x+t2pio2 : x-t2pio2), 0);
- }
- if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if (ix <= 0x40afeddf) /* |x| ~<= 7*pi/4 */
- return __tandf((sign ? x+t3pio2 : x-t3pio2), 1);
- else
- return __tandf((sign ? x+t4pio2 : x-t4pio2), 0);
- }
-
- /* tan(Inf or NaN) is NaN */
- if (ix >= 0x7f800000)
- return x - x;
-
- /* argument reduction */
- n = __rem_pio2f(x, &y);
- return __tandf(y, n&1);
-}
-long double tanl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double acosh(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float acoshf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double acoshl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double asinh(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float asinhf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double asinhl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double atanh(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float atanhf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double atanhl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double cosh(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float coshf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double coshl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double sinh(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float sinhf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double sinhl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double tanh(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float tanhf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double tanhl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double exp(double x) {
- static const double half[2] = {0.5,-0.5},
- ln2hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
- ln2lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */
- invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
- P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
- P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
- P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
- P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
- P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
-
- double hi, lo, c, xx, y;
- int k, sign;
- uint32_t hx;
-
- GET_HIGH_WORD(hx, x);
- sign = hx>>31;
- hx &= 0x7fffffff; /* high word of |x| */
-
- /* special cases */
- if (hx >= 0x4086232b) { /* if |x| >= 708.39... */
- if (isnan(x))
- return x;
- if (x > 709.782712893383973096) {
- /* overflow if x!=inf */
- x *= 0x1p1023;
- return x;
- }
- if (x < -708.39641853226410622) {
- /* underflow if x!=-inf */
- FORCE_EVAL((float)(-0x1p-149/x));
- if (x < -745.13321910194110842)
- return 0;
- }
- }
-
- /* argument reduction */
- if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
- if (hx >= 0x3ff0a2b2) /* if |x| >= 1.5 ln2 */
- k = (int)(invln2*x + half[sign]);
- else
- k = 1 - sign - sign;
- hi = x - k*ln2hi; /* k*ln2hi is exact here */
- lo = k*ln2lo;
- x = hi - lo;
- } else if (hx > 0x3e300000) { /* if |x| > 2**-28 */
- k = 0;
- hi = x;
- lo = 0;
- } else {
- /* inexact if x!=0 */
- FORCE_EVAL(0x1p1023 + x);
- return 1 + x;
- }
-
- /* x is now in primary range */
- xx = x*x;
- c = x - xx*(P1+xx*(P2+xx*(P3+xx*(P4+xx*P5))));
- y = 1 + (x*c/(2-c) - lo + hi);
- if (k == 0)
- return y;
- return scalbn(y, k);
-}
-float expf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double expl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double exp2(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-// Taken from musl. See musl for the license/copyright!
-float exp2f(float x) {
- constexpr int TBLSIZE = 16;
-
- constexpr float redux = 0x1.8p23f / TBLSIZE;
- constexpr float P1 = 0x1.62e430p-1f;
- constexpr float P2 = 0x1.ebfbe0p-3f;
- constexpr float P3 = 0x1.c6b348p-5f;
- constexpr float P4 = 0x1.3b2c9cp-7f;
-
- constexpr double exp2ft[TBLSIZE] = {
- 0x1.6a09e667f3bcdp-1,
- 0x1.7a11473eb0187p-1,
- 0x1.8ace5422aa0dbp-1,
- 0x1.9c49182a3f090p-1,
- 0x1.ae89f995ad3adp-1,
- 0x1.c199bdd85529cp-1,
- 0x1.d5818dcfba487p-1,
- 0x1.ea4afa2a490dap-1,
- 0x1.0000000000000p+0,
- 0x1.0b5586cf9890fp+0,
- 0x1.172b83c7d517bp+0,
- 0x1.2387a6e756238p+0,
- 0x1.306fe0a31b715p+0,
- 0x1.3dea64c123422p+0,
- 0x1.4bfdad5362a27p+0,
- 0x1.5ab07dd485429p+0,
- };
-
- double t, r, z;
- union {float f; uint32_t i;} u = {x};
- union {double f; uint64_t i;} uk;
- uint32_t ix, i0, k;
-
- /* Filter out exceptional cases. */
- ix = u.i & 0x7fffffff;
- if (ix > 0x42fc0000) { /* |x| > 126 */
- if (ix > 0x7f800000) /* NaN */
- return x;
- if (u.i >= 0x43000000 && u.i < 0x80000000) { /* x >= 128 */
- x *= 0x1p127f;
- return x;
- }
- if (u.i >= 0x80000000) { /* x < -126 */
- if (u.i >= 0xc3160000 || (u.i & 0x0000ffff))
- FORCE_EVAL(-0x1p-149f/x);
- if (u.i >= 0xc3160000) /* x <= -150 */
- return 0;
- }
- } else if (ix <= 0x33000000) { /* |x| <= 0x1p-25 */
- return 1.0f + x;
- }
-
- /* Reduce x, computing z, i0, and k. */
- u.f = x + redux;
- i0 = u.i;
- i0 += TBLSIZE / 2;
- k = i0 / TBLSIZE;
- uk.i = (uint64_t)(0x3ff + k)<<52;
- i0 &= TBLSIZE - 1;
- u.f -= redux;
- z = x - u.f;
- /* Compute r = exp2(y) = exp2ft[i0] * p(z). */
- r = exp2ft[i0];
- t = r * z;
- r = r + t * (P1 + z * P2) + t * (z * z) * (P3 + z * P4);
-
- /* Scale by 2**k */
- return r * uk.f;
-}
-long double exp2l(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double expm1(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float expm1f(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double expm1l(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double frexp(double x, int *power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float frexpf(float x, int *power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double frexpl(long double x, int *power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double ilogb(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float ilogbf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double ilogbl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double ldexp(double x, int power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float ldexpf(float x, int power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double ldexpl(long double x, int power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double log(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float logf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double logl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double log10(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float log10f(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double log10l(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double log1p(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float log1pf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double log1pl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-// Taken from musl. See musl for the license/copyright!
-double log2(double x) {
- static const double
- ivln2hi = 1.44269504072144627571e+00, /* 0x3ff71547, 0x65200000 */
- ivln2lo = 1.67517131648865118353e-10, /* 0x3de705fc, 0x2eefa200 */
- Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
- Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
- Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
- Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
- Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
- Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
- Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
- union {double f; uint64_t i;} u = {x};
- double hfsq,f,s,z,R,w,t1,t2,y,hi,lo,val_hi,val_lo;
- uint32_t hx;
- int k;
-
- hx = u.i>>32;
- k = 0;
- if (hx < 0x00100000 || hx>>31) {
- if (u.i<<1 == 0)
- return -1/(x*x); /* log(+-0)=-inf */
- if (hx>>31)
- return (x-x)/0.0; /* log(-#) = NaN */
- /* subnormal number, scale x up */
- k -= 54;
- x *= 0x1p54;
- u.f = x;
- hx = u.i>>32;
- } else if (hx >= 0x7ff00000) {
- return x;
- } else if (hx == 0x3ff00000 && u.i<<32 == 0)
- return 0;
-
- /* reduce x into [sqrt(2)/2, sqrt(2)] */
- hx += 0x3ff00000 - 0x3fe6a09e;
- k += (int)(hx>>20) - 0x3ff;
- hx = (hx&0x000fffff) + 0x3fe6a09e;
- u.i = (uint64_t)hx<<32 | (u.i&0xffffffff);
- x = u.f;
-
- f = x - 1.0;
- hfsq = 0.5*f*f;
- s = f/(2.0+f);
- z = s*s;
- w = z*z;
- t1 = w*(Lg2+w*(Lg4+w*Lg6));
- t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- R = t2 + t1;
-
- /*
- * f-hfsq must (for args near 1) be evaluated in extra precision
- * to avoid a large cancellation when x is near sqrt(2) or 1/sqrt(2).
- * This is fairly efficient since f-hfsq only depends on f, so can
- * be evaluated in parallel with R. Not combining hfsq with R also
- * keeps R small (though not as small as a true `lo' term would be),
- * so that extra precision is not needed for terms involving R.
- *
- * Compiler bugs involving extra precision used to break Dekker's
- * theorem for spitting f-hfsq as hi+lo, unless double_t was used
- * or the multi-precision calculations were avoided when double_t
- * has extra precision. These problems are now automatically
- * avoided as a side effect of the optimization of combining the
- * Dekker splitting step with the clear-low-bits step.
- *
- * y must (for args near sqrt(2) and 1/sqrt(2)) be added in extra
- * precision to avoid a very large cancellation when x is very near
- * these values. Unlike the above cancellations, this problem is
- * specific to base 2. It is strange that adding +-1 is so much
- * harder than adding +-ln2 or +-log10_2.
- *
- * This uses Dekker's theorem to normalize y+val_hi, so the
- * compiler bugs are back in some configurations, sigh. And I
- * don't want to used double_t to avoid them, since that gives a
- * pessimization and the support for avoiding the pessimization
- * is not yet available.
- *
- * The multi-precision calculations for the multiplications are
- * routine.
- */
-
- /* hi+lo = f - hfsq + s*(hfsq+R) ~ log(1+f) */
- hi = f - hfsq;
- u.f = hi;
- u.i &= (uint64_t)-1<<32;
- hi = u.f;
- lo = f - hi - hfsq + s*(hfsq+R);
-
- val_hi = hi*ivln2hi;
- val_lo = (lo+hi)*ivln2lo + lo*ivln2hi;
-
- /* spadd(val_hi, val_lo, y), except for not using double_t: */
- y = k;
- w = y + val_hi;
- val_lo += (y - w) + val_hi;
- val_hi = w;
-
- return val_lo + val_hi;
-}
-float log2f(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double log2l(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double logb(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float logbf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double logbl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double modf(double x, double *integral) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float modff(float x, float *integral) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double modfl(long double x, long double *integral) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double scalbn(double x, int n) {
- union {double f; uint64_t i;} u;
- double y = x;
-
- if (n > 1023) {
- y *= 0x1p1023;
- n -= 1023;
- if (n > 1023) {
- y *= 0x1p1023;
- n -= 1023;
- if (n > 1023)
- n = 1023;
- }
- } else if (n < -1022) {
- /* make sure final n < -53 to avoid double
- rounding in the subnormal range */
- y *= 0x1p-1022 * 0x1p53;
- n += 1022 - 53;
- if (n < -1022) {
- y *= 0x1p-1022 * 0x1p53;
- n += 1022 - 53;
- if (n < -1022)
- n = -1022;
- }
- }
- u.i = (uint64_t)(0x3ff+n)<<52;
- x = y * u.f;
- return x;
-}
-float scalbnf(float x, int power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double scalbnl(long double x, int power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double scalbln(double x, long power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float scalblnf(float x, long power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double scalblnl(long double x, long power) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double cbrt(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float cbrtf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double cbrtl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double fabs(double x) {
- return signbit(x) ? -x : x;
-}
-float fabsf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double fabsl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double hypot(double x, double y) {
- __ensure(isfinite(x));
- __ensure(isfinite(y));
- // TODO: fix exception handling
- double u = fabs(x);
- double v = fabs(y);
- if(u > v)
- return u * sqrt(1 + (v / u) * (v / u));
- return v * sqrt(1 + (u / v) * (u / v));
-}
-float hypotf(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double hypotl(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double pow(double x, double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float powf(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double powl(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double sqrt(double x) {
- auto sse_x = _mm_set_sd(x);
- return _mm_cvtsd_f64(_mm_sqrt_sd(sse_x, sse_x));
-}
-float sqrtf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double sqrtl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double erf(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float erff(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double erfl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double erfc(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float erfcf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double erfcl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double lgamma(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float lgammaf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double lgammal(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double tgamma(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float tgammaf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double tgammal(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double ceil(double x) {
- auto soft_x = ieee754::extractNative(x);
- auto result = ieee754::ceil(soft_x);
- return ieee754::compileNative(result);
-}
-float ceilf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double ceill(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double floor(double x) {
- auto soft_x = ieee754::extractNative(x);
- auto result = ieee754::floor(soft_x);
- return ieee754::compileNative(result);
-}
-float floorf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double floorl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double nearbyint(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float nearbyintf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double nearbyintl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double rint(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float rintf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double rintl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-long lrint(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long lrintf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long lrintl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-long long llrint(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long long llrintf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long long llrintl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double round(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float roundf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double roundl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-long lround(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long lroundf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long lroundl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-long long llround(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long long llroundf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long long llroundl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double trunc(double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float truncf(float x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double truncl(long double x) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double fmod(double x, double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float fmodf(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double fmodl(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double remainder(double x, double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float remainderf(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double remainderl(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double remquo(double x, double y, int *quotient) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float remquof(float x, float y, int *quotient) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double remquol(long double x, long double y, int *quotient) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double copysign(double x, double sign) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float copysignf(float x, float sign) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double copysignl(long double x, long double sign) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double nan(const char *tag) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float nanf(const char *tag) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double nanl(const char *tag) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double nextafter(double x, double dir) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float nextafterf(float x, float dir) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double nextafterl(long double x, long double dir) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double nexttoward(double x, long double dir) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float nexttowardf(float x, long double dir) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double nexttowardl(long double x, long double dir) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double fdim(double x, double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-float fdimf(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double fdiml(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double fmax(double x, double y) {
- __ensure(isfinite(x) && isfinite(y));
- return x < y ? y : x;
-}
-float fmaxf(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double fmaxl(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-double fmin(double x, double y) {
- __ensure(isfinite(x) && isfinite(y));
- return x < y ? x : y;
-}
-float fminf(float x, float y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-long double fminl(long double x, long double y) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-//gnu extension
-
-void sincos(double x, double *sx, double *cx) {
- mlibc::infoLogger() << "mlibc: sincos() is not precise" << frg::endlog;
- float sxf;
- float cxf;
- sincosf(x, &sxf, &cxf);
- *sx = sxf;
- *cx = cxf;
-}
-
-void sincosf(float x, float *sx, float *cx) {
- // This is a lazy implementation.
- __ensure(sx);
- __ensure(cx);
- *sx = sinf(x);
- *cx = cosf(x);
-}
-void sincosl(long double, long double *, long double *) {
- __ensure(!"sincosl() not implemented");
- __builtin_unreachable();
-}
-
-double exp10(double) {
- __ensure(!"exp10() not implemented");
- __builtin_unreachable();
-}
-float exp10f(float) {
- __ensure(!"exp10f() not implemented");
- __builtin_unreachable();
-}
-long double exp10l(long double) {
- __ensure(!"exp10l() not implemented");
- __builtin_unreachable();
-}
-
-double pow10(double) {
- __ensure(!"pow10() not implemented");
- __builtin_unreachable();
-}
-float pow10f(float) {
- __ensure(!"pow10f() not implemented");
- __builtin_unreachable();
-}
-long double pow10l(long double) {
- __ensure(!"pow10l() not implemented");
- __builtin_unreachable();
-}
-
diff --git a/lib/mlibc/options/ansi/generic/signal-stubs.cpp b/lib/mlibc/options/ansi/generic/signal-stubs.cpp
deleted file mode 100644
index 6da9dc1..0000000
--- a/lib/mlibc/options/ansi/generic/signal-stubs.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-#include <bits/ensure.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <mlibc/debug.hpp>
-#include <mlibc/ansi-sysdeps.hpp>
-
-__sighandler signal(int sn, __sighandler handler) {
- struct sigaction sa;
- sa.sa_handler = handler;
- sa.sa_flags = 0;
- sa.sa_mask = 0;
- struct sigaction old;
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_sigaction, SIG_ERR);
- if(int e = mlibc::sys_sigaction(sn, &sa, &old)){
- errno = e;
- return SIG_ERR;
- }
- return old.sa_handler;
-}
-
-int raise(int sig) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getpid && mlibc::sys_kill, -1);
- pid_t pid = mlibc::sys_getpid();
-
- if (int e = mlibc::sys_kill(pid, sig)) {
- errno = e;
- return -1;
- }
-
- return 0;
-}
-
-// This is a POSIX extension, but we have it in here for sigsetjmp
-int sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict retrieve) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_sigprocmask, -1);
- if(int e = mlibc::sys_sigprocmask(how, set, retrieve); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
diff --git a/lib/mlibc/options/ansi/generic/stdio-stubs.cpp b/lib/mlibc/options/ansi/generic/stdio-stubs.cpp
deleted file mode 100644
index 479a655..0000000
--- a/lib/mlibc/options/ansi/generic/stdio-stubs.cpp
+++ /dev/null
@@ -1,1270 +0,0 @@
-#include <ctype.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <ctype.h>
-#include <limits.h>
-
-#include <abi-bits/fcntl.h>
-
-#include <bits/ensure.h>
-
-#include <mlibc/lock.hpp>
-#include <mlibc/allocator.hpp>
-#include <mlibc/debug.hpp>
-#include <mlibc/file-io.hpp>
-#include <mlibc/ansi-sysdeps.hpp>
-#include <frg/mutex.hpp>
-#include <frg/expected.hpp>
-#include <frg/printf.hpp>
-
-template<typename F>
-struct PrintfAgent {
- PrintfAgent(F *formatter, frg::va_struct *vsp)
- : _formatter{formatter}, _vsp{vsp} { }
-
- frg::expected<frg::format_error> operator() (char c) {
- _formatter->append(c);
- return {};
- }
- frg::expected<frg::format_error> operator() (const char *c, size_t n) {
- _formatter->append(c, n);
- return {};
- }
-
- frg::expected<frg::format_error> operator() (char t, frg::format_options opts,
- frg::printf_size_mod szmod) {
- switch(t) {
- case 'c':
- if (szmod == frg::printf_size_mod::long_size) {
- char c_buf[sizeof(wchar_t)];
- auto c = static_cast<wchar_t>(va_arg(_vsp->args, wint_t));
- mbstate_t shift_state = {};
- if (wcrtomb(c_buf, c, &shift_state) == size_t(-1))
- return frg::format_error::agent_error;
- _formatter->append(c_buf);
- break;
- }
- frg::do_printf_chars(*_formatter, t, opts, szmod, _vsp);
- break;
- case 'p': case 's':
- frg::do_printf_chars(*_formatter, t, opts, szmod, _vsp);
- break;
- case 'd': case 'i': case 'o': case 'x': case 'X': case 'u':
- frg::do_printf_ints(*_formatter, t, opts, szmod, _vsp);
- break;
- case 'f': case 'F': case 'g': case 'G': case 'e': case 'E':
- frg::do_printf_floats(*_formatter, t, opts, szmod, _vsp);
- break;
- case 'm':
- __ensure(!opts.fill_zeros);
- __ensure(!opts.left_justify);
- __ensure(!opts.alt_conversion);
- __ensure(opts.minimum_width == 0);
- __ensure(szmod == frg::printf_size_mod::default_size);
- __ensure(!opts.precision);
- _formatter->append(strerror(errno));
- break;
- case 'n': {
- __ensure(szmod == frg::printf_size_mod::default_size);
- auto p = va_arg(_vsp->args, int *);
- *p = _formatter->count;
- break;
- }
- default:
- mlibc::infoLogger() << "\e[31mmlibc: Unknown printf terminator '"
- << t << "'\e[39m" << frg::endlog;
- __ensure(!"Illegal printf terminator");
- }
-
- return {};
- }
-
-private:
- F *_formatter;
- frg::va_struct *_vsp;
-};
-
-struct StreamPrinter {
- StreamPrinter(FILE *stream)
- : stream(stream), count(0) { }
-
- void append(char c) {
- fwrite_unlocked(&c, 1, 1, stream);
- count++;
- }
-
- void append(const char *str) {
- fwrite_unlocked(str, strlen(str), 1, stream);
- count += strlen(str);
- }
-
- void append(const char *str, size_t n) {
- fwrite_unlocked(str, n, 1, stream);
- count += n;
- }
-
- FILE *stream;
- size_t count;
-};
-
-struct BufferPrinter {
- BufferPrinter(char *buffer)
- : buffer(buffer), count(0) { }
-
- void append(char c) {
- buffer[count] = c;
- count++;
- }
-
- void append(const char *str) {
- // TODO: use strcat
- for(size_t i = 0; str[i]; i++) {
- buffer[count] = str[i];
- count++;
- }
- }
-
- void append(const char *str, size_t n) {
- // TODO: use strcat
- for(size_t i = 0; i < n; i++) {
- buffer[count] = str[i];
- count++;
- }
- }
-
- char *buffer;
- size_t count;
-};
-
-struct LimitedPrinter {
- LimitedPrinter(char *buffer, size_t limit)
- : buffer(buffer), limit(limit), count(0) { }
-
- void append(char c) {
- if(count < limit)
- buffer[count] = c;
- count++;
- }
-
- void append(const char *str) {
- // TODO: use strcat
- for(size_t i = 0; str[i]; i++)
- append(str[i]);
- }
-
- void append(const char *str, size_t n) {
- // TODO: use strcat
- for(size_t i = 0; i < n; i++)
- append(str[i]);
- }
-
- char *buffer;
- size_t limit;
- size_t count;
-};
-
-struct ResizePrinter {
- ResizePrinter()
- : buffer(nullptr), limit(0), count(0) { }
-
- void expand() {
- if(count == limit) {
- auto new_limit = frg::max(2 * limit, size_t(16));
- auto new_buffer = reinterpret_cast<char *>(malloc(new_limit));
- __ensure(new_buffer);
- memcpy(new_buffer, buffer, count);
- free(buffer);
- buffer = new_buffer;
- limit = new_limit;
- }
- __ensure(count < limit);
- }
-
- void append(char c) {
- expand();
- buffer[count] = c;
- count++;
- }
-
- void append(const char *str) {
- for(size_t i = 0; str[i]; i++)
- append(str[i]);
- }
-
- void append(const char *str, size_t n) {
- for(size_t i = 0; i < n; i++)
- append(str[i]);
- }
-
- char *buffer;
- size_t limit;
- size_t count;
-};
-
-int remove(const char *filename) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_rmdir, -1);
- if(int e = mlibc::sys_rmdir(filename); e) {
- if (e == ENOTDIR) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_unlinkat, -1);
- if(e = mlibc::sys_unlinkat(AT_FDCWD, filename, 0); e) {
- errno = e;
- return -1;
- }
-
- return 0;
- }
- return -1;
- }
-
- return 0;
-}
-
-int rename(const char *path, const char *new_path) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_rename, -1);
- if(int e = mlibc::sys_rename(path, new_path); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-int renameat(int olddirfd, const char *old_path, int newdirfd, const char *new_path) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_renameat, -1);
- if(int e = mlibc::sys_renameat(olddirfd, old_path, newdirfd, new_path); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-FILE *tmpfile(void) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-char *tmpnam(char *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-// fflush() is provided by the POSIX sublibrary
-// fopen() is provided by the POSIX sublibrary
-FILE *freopen(const char *__restrict path, const char *__restrict mode, FILE *__restrict f) {
- auto file = static_cast<mlibc::abstract_file *>(f);
- frg::unique_lock lock(file->_lock);
-
- if(file->reopen(path, mode) == -1) {
- errno = EINVAL;
- return nullptr;
- }
-
- return f;
-}
-
-void setbuf(FILE *__restrict stream, char *__restrict buffer) {
- setvbuf(stream, buffer, buffer ? _IOFBF : _IONBF, BUFSIZ);
-}
-// setvbuf() is provided by the POSIX sublibrary
-
-void setlinebuf(FILE *stream) {
- setvbuf(stream, NULL, _IOLBF, 0);
-}
-
-void setbuffer(FILE *f, char *buf, size_t size) {
- setvbuf(f, buf, buf ? _IOFBF : _IONBF, size);
-}
-
-int fprintf(FILE *__restrict stream, const char *__restrict format, ...) {
- va_list args;
- va_start(args, format);
- int result = vfprintf(stream, format, args);
- va_end(args);
- return result;
-}
-
-int fscanf(FILE *__restrict stream, const char *__restrict format, ...) {
- va_list args;
- va_start(args, format);
- int result = vfscanf(stream, format, args);
- va_end(args);
- return result;
-}
-
-int printf(const char *__restrict format, ...) {
- va_list args;
- va_start(args, format);
- int result = vfprintf(stdout, format, args);
- va_end(args);
- return result;
-}
-
-namespace {
- enum {
- SCANF_TYPE_CHAR,
- SCANF_TYPE_SHORT,
- SCANF_TYPE_INTMAX,
- SCANF_TYPE_L,
- SCANF_TYPE_LL,
- SCANF_TYPE_PTRDIFF,
- SCANF_TYPE_SIZE_T,
- SCANF_TYPE_INT
- };
-}
-
-static void store_int(void *dest, unsigned int size, unsigned long long i) {
- switch (size) {
- case SCANF_TYPE_CHAR:
- *(char *)dest = i;
- break;
- case SCANF_TYPE_SHORT:
- *(short *)dest = i;
- break;
- case SCANF_TYPE_INTMAX:
- *(intmax_t *)dest = i;
- break;
- case SCANF_TYPE_L:
- *(long *)dest = i;
- break;
- case SCANF_TYPE_LL:
- *(long long *)dest = i;
- break;
- case SCANF_TYPE_PTRDIFF:
- *(ptrdiff_t *)dest = i;
- break;
- case SCANF_TYPE_SIZE_T:
- *(size_t *)dest = i;
- break;
- /* fallthrough */
- case SCANF_TYPE_INT:
- default:
- *(int *)dest = i;
- break;
- }
-}
-
-template<typename H>
-static int do_scanf(H &handler, const char *fmt, __builtin_va_list args) {
- int match_count = 0;
- for (; *fmt; fmt++) {
-
- if (isspace(*fmt)) {
- while (isspace(fmt[1])) fmt++;
- while (isspace(handler.look_ahead()))
- handler.consume();
- continue;
- }
-
- if (*fmt != '%' || fmt[1] == '%') {
- if (*fmt == '%')
- fmt++;
- char c = handler.consume();
- if (c != *fmt)
- break;
- continue;
- }
-
- void *dest = NULL;
- /* %n$ format */
- if (isdigit(*fmt) && fmt[1] == '$') {
- /* TODO: dest = get_arg_at_pos(args, *fmt -'0'); */
- fmt += 3;
- } else {
- if (fmt[1] != '*') {
- dest = va_arg(args, void*);
- }
- fmt++;
- }
-
- int width = 0;
- if (*fmt == '*') {
- fmt++;
- } else if (*fmt == '\'') {
- /* TODO: numeric seperators locale stuff */
- mlibc::infoLogger() << "do_scanf: \' not implemented!" << frg::endlog;
- fmt++;
- continue;
- } else if (*fmt == 'm') {
- /* TODO: allocate buffer for them */
- mlibc::infoLogger() << "do_scanf: m not implemented!" << frg::endlog;
- fmt++;
- continue;
- } else if (*fmt >= '0' && *fmt <= '9') {
- /* read in width specifier */
- width = 0;
- while (*fmt >= '0' && *fmt <= '9') {
- width = width * 10 + (*fmt - '0');
- fmt++;
- continue;
- }
- }
-
- /* type modifiers */
- unsigned int type = SCANF_TYPE_INT;
- unsigned int base = 10;
- switch (*fmt) {
- case 'h': {
- if (fmt[1] == 'h') {
- type = SCANF_TYPE_CHAR;
- fmt += 2;
- break;
- }
- type = SCANF_TYPE_SHORT;
- fmt++;
- break;
- }
- case 'j': {
- type = SCANF_TYPE_INTMAX;
- fmt++;
- break;
- }
- case 'l': {
- if (fmt[1] == 'l') {
- type = SCANF_TYPE_LL;
- fmt += 2;
- break;
- }
- type = SCANF_TYPE_L;
- fmt++;
- break;
- }
- case 'L': {
- type = SCANF_TYPE_LL;
- fmt++;
- break;
- }
- case 'q': {
- type = SCANF_TYPE_LL;
- fmt++;
- break;
- }
- case 't': {
- type = SCANF_TYPE_PTRDIFF;
- fmt++;
- break;
- }
- case 'z': {
- type = SCANF_TYPE_SIZE_T;
- fmt++;
- break;
- }
- }
-
- // Leading whitespace is skipped for most conversions except these.
- if (*fmt != 'c' && *fmt != '[' && *fmt != 'n') {
- while (isspace(handler.look_ahead()))
- handler.consume();
- }
-
- switch (*fmt) {
- case 'd':
- case 'u':
- base = 10;
- [[fallthrough]];
- case 'i': {
- bool is_negative = false;
- unsigned long long res = 0;
-
- if((*fmt == 'i' || *fmt == 'd') && handler.look_ahead() == '-') {
- handler.consume();
- is_negative = true;
- }
-
- if(*fmt == 'i' && handler.look_ahead() == '0') {
- handler.consume();
- if(handler.look_ahead() == 'x') {
- handler.consume();
- base = 16;
- } else {
- base = 8;
- }
- }
-
- char c = handler.look_ahead();
- switch (base) {
- case 10:
- if(!isdigit(c))
- return match_count;
- while (c >= '0' && c <= '9') {
- handler.consume();
- res = res * 10 + (c - '0');
- c = handler.look_ahead();
- }
- break;
- case 16:
- if (c == '0') {
- handler.consume();
- c = handler.look_ahead();
- if (c == 'x') {
- handler.consume();
- c = handler.look_ahead();
- }
- }
- while (true) {
- if (c >= '0' && c <= '9') {
- handler.consume();
- res = res * 16 + (c - '0');
- } else if (c >= 'a' && c <= 'f') {
- handler.consume();
- res = res * 16 + (c - 'a' + 10);
- } else if (c >= 'A' && c <= 'F') {
- handler.consume();
- res = res * 16 + (c - 'A' + 10);
- } else {
- break;
- }
- c = handler.look_ahead();
- }
- break;
- case 8:
- while (c >= '0' && c <= '7') {
- handler.consume();
- res = res * 8 + (c - '0');
- c = handler.look_ahead();
- }
- break;
- }
- if (dest) {
- if(is_negative)
- store_int(dest, type, -res);
- else
- store_int(dest, type, res);
- }
- break;
- }
- case 'o': {
- unsigned long long res = 0;
- char c = handler.look_ahead();
- while (c >= '0' && c <= '7') {
- handler.consume();
- res = res * 8 + (c - '0');
- c = handler.look_ahead();
- }
- if (dest)
- store_int(dest, type, res);
- break;
- }
- case 'x':
- case 'X': {
- unsigned long long res = 0;
- char c = handler.look_ahead();
- if (c == '0') {
- handler.consume();
- c = handler.look_ahead();
- if (c == 'x') {
- handler.consume();
- c = handler.look_ahead();
- }
- }
- while (true) {
- if (c >= '0' && c <= '9') {
- handler.consume();
- res = res * 16 + (c - '0');
- } else if (c >= 'a' && c <= 'f') {
- handler.consume();
- res = res * 16 + (c - 'a' + 10);
- } else if (c >= 'A' && c <= 'F') {
- handler.consume();
- res = res * 16 + (c - 'A' + 10);
- } else {
- break;
- }
- c = handler.look_ahead();
- }
- if (dest)
- store_int(dest, type, res);
- break;
- }
- case 's': {
- char *typed_dest = (char *)dest;
- char c = handler.look_ahead();
- int count = 0;
- while (c && !isspace(c)) {
- handler.consume();
- if (typed_dest)
- typed_dest[count] = c;
- c = handler.look_ahead();
- count++;
- if (width && count >= width)
- break;
- }
- if (typed_dest)
- typed_dest[count] = '\0';
- break;
- }
- case 'c': {
- char *typed_dest = (char *)dest;
- char c = handler.look_ahead();
- int count = 0;
- if (!width)
- width = 1;
- while (c && count < width) {
- handler.consume();
- if (typed_dest)
- typed_dest[count] = c;
- c = handler.look_ahead();
- count++;
- }
- break;
- }
- case '[': {
- fmt++;
- int invert = 0;
- if (*fmt == '^') {
- invert = 1;
- fmt++;
- }
-
- char scanset[257];
- memset(&scanset[0], invert, sizeof(char) * 257);
- scanset[0] = '\0';
-
- if (*fmt == '-') {
- fmt++;
- scanset[1+'-'] = 1 - invert;
- } else if (*fmt == ']') {
- fmt++;
- scanset[1+']'] = 1 - invert;
- }
-
- for (; *fmt != ']'; fmt++) {
- if (!*fmt) return EOF;
- if (*fmt == '-' && *fmt != ']') {
- fmt++;
- for (char c = *(fmt - 2); c < *fmt; c++)
- scanset[1 + c] = 1 - invert;
- }
- scanset[1 + *fmt] = 1 - invert;
- }
-
- char *typed_dest = (char *)dest;
- int count = 0;
- char c = handler.look_ahead();
- while (c && (!width || count < width)) {
- handler.consume();
- if (!scanset[1 + c])
- break;
- if (typed_dest)
- typed_dest[count] = c;
- c = handler.look_ahead();
- count++;
- }
- if (typed_dest)
- typed_dest[count] = '\0';
- break;
- }
- case 'p': {
- unsigned long long res = 0;
- char c = handler.look_ahead();
- if (c == '0') {
- handler.consume();
- c = handler.look_ahead();
- if (c == 'x') {
- handler.consume();
- c = handler.look_ahead();
- }
- }
- while (true) {
- if (c >= '0' && c <= '9') {
- handler.consume();
- res = res * 16 + (c - '0');
- } else if (c >= 'a' && c <= 'f') {
- handler.consume();
- res = res * 16 + (c - 'a');
- } else if (c >= 'A' && c <= 'F') {
- handler.consume();
- res = res * 16 + (c - 'A');
- } else {
- break;
- }
- c = handler.look_ahead();
- }
- void **typed_dest = (void **)dest;
- *typed_dest = (void *)(uintptr_t)res;
- break;
- }
- case 'n': {
- int *typed_dest = (int *)dest;
- if (typed_dest)
- *typed_dest = handler.num_consumed;
- continue;
- }
- }
- if (dest) match_count++;
- }
- return match_count;
-}
-
-int scanf(const char *__restrict format, ...) {
- va_list args;
- va_start(args, format);
- int result = vfscanf(stdin, format, args);
- va_end(args);
- return result;
-}
-
-int snprintf(char *__restrict buffer, size_t max_size, const char *__restrict format, ...) {
- va_list args;
- va_start(args, format);
- int result = vsnprintf(buffer, max_size, format, args);
- va_end(args);
- return result;
-}
-
-int sprintf(char *__restrict buffer, const char *__restrict format, ...) {
- va_list args;
- va_start(args, format);
- int result = vsprintf(buffer, format, args);
- va_end(args);
- return result;
-}
-
-int sscanf(const char *__restrict buffer, const char *__restrict format, ...) {
- va_list args;
- va_start(args, format);
-
- int result = vsscanf(buffer, format, args);
-
- va_end(args);
- return result;
-}
-
-int vfprintf(FILE *__restrict stream, const char *__restrict format, __builtin_va_list args) {
- frg::va_struct vs;
- frg::arg arg_list[NL_ARGMAX + 1];
- vs.arg_list = arg_list;
- va_copy(vs.args, args);
- auto file = static_cast<mlibc::abstract_file *>(stream);
- frg::unique_lock lock(file->_lock);
- StreamPrinter p{stream};
-// mlibc::infoLogger() << "printf(" << format << ")" << frg::endlog;
- auto res = frg::printf_format(PrintfAgent{&p, &vs}, format, &vs);
- if (!res)
- return -static_cast<int>(res.error());
-
- return p.count;
-}
-
-int vfscanf(FILE *__restrict stream, const char *__restrict format, __builtin_va_list args) {
- auto file = static_cast<mlibc::abstract_file *>(stream);
- frg::unique_lock lock(file->_lock);
-
- struct {
- char look_ahead() {
- char c;
- size_t actual_size;
- file->read(&c, 1, &actual_size);
- if (actual_size)
- file->unget(c);
- return actual_size ? c : 0;
- }
-
- char consume() {
- char c;
- size_t actual_size;
- file->read(&c, 1, &actual_size);
- if (actual_size)
- num_consumed++;
- return actual_size ? c : 0;
- }
-
- mlibc::abstract_file *file;
- int num_consumed;
- } handler = {file, 0};
-
- return do_scanf(handler, format, args);
-}
-
-int vprintf(const char *__restrict format, __builtin_va_list args){
- return vfprintf(stdout, format, args);
-}
-
-int vscanf(const char *__restrict, __builtin_va_list) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int vsnprintf(char *__restrict buffer, size_t max_size,
- const char *__restrict format, __builtin_va_list args) {
- frg::va_struct vs;
- frg::arg arg_list[NL_ARGMAX + 1];
- vs.arg_list = arg_list;
- va_copy(vs.args, args);
- LimitedPrinter p{buffer, max_size ? max_size - 1 : 0};
-// mlibc::infoLogger() << "printf(" << format << ")" << frg::endlog;
- auto res = frg::printf_format(PrintfAgent{&p, &vs}, format, &vs);
- if (!res)
- return -static_cast<int>(res.error());
- if (max_size)
- p.buffer[frg::min(max_size - 1, p.count)] = 0;
- return p.count;
-}
-
-int vsprintf(char *__restrict buffer, const char *__restrict format, __builtin_va_list args) {
- frg::va_struct vs;
- frg::arg arg_list[NL_ARGMAX + 1];
- vs.arg_list = arg_list;
- va_copy(vs.args, args);
- BufferPrinter p(buffer);
-// mlibc::infoLogger() << "printf(" << format << ")" << frg::endlog;
- auto res = frg::printf_format(PrintfAgent{&p, &vs}, format, &vs);
- if (!res)
- return -static_cast<int>(res.error());
- p.buffer[p.count] = 0;
- return p.count;
-}
-
-int vsscanf(const char *__restrict buffer, const char *__restrict format, __builtin_va_list args) {
- struct {
- char look_ahead() {
- return *buffer;
- }
-
- char consume() {
- num_consumed++;
- return *buffer++;
- }
-
- const char *buffer;
- int num_consumed;
- } handler = {buffer, 0};
-
- int result = do_scanf(handler, format, args);
-
- return result;
-}
-
-int fwprintf(FILE *__restrict, const wchar_t *__restrict, ...) MLIBC_STUB_BODY
-int fwscanf(FILE *__restrict, const wchar_t *__restrict, ...) MLIBC_STUB_BODY
-int vfwprintf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY
-int vfwscanf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY
-
-int swprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, ...) MLIBC_STUB_BODY
-int swscanf(wchar_t *__restrict, size_t, const wchar_t *__restrict, ...) MLIBC_STUB_BODY
-int vswprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY
-int vswscanf(wchar_t *__restrict, size_t, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY
-
-int wprintf(const wchar_t *__restrict, ...) MLIBC_STUB_BODY
-int wscanf(const wchar_t *__restrict, ...) MLIBC_STUB_BODY
-int vwprintf(const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY
-int vwscanf(const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY
-
-int fgetc(FILE *stream) {
- char c;
- auto bytes_read = fread(&c, 1, 1, stream);
- if(bytes_read != 1)
- return EOF;
- return c;
-}
-
-char *fgets(char *__restrict buffer, size_t max_size, FILE *__restrict stream) {
- auto file = static_cast<mlibc::abstract_file *>(stream);
- frg::unique_lock lock(file->_lock);
- return fgets_unlocked(buffer, max_size, stream);
-}
-
-int fputc_unlocked(int c, FILE *stream) {
- char d = c;
- if(fwrite_unlocked(&d, 1, 1, stream) != 1)
- return EOF;
- return 1;
-}
-
-int fputc(int c, FILE *stream) {
- auto file = static_cast<mlibc::abstract_file *>(stream);
- frg::unique_lock lock(file->_lock);
- return fputc_unlocked(c, stream);
-}
-
-int fputs_unlocked(const char *__restrict string, FILE *__restrict stream) {
- if(fwrite_unlocked(string, strlen(string), 1, stream) != 1)
- return EOF;
- return 1;
-}
-
-int fputs(const char *__restrict string, FILE *__restrict stream) {
- auto file = static_cast<mlibc::abstract_file *>(stream);
- frg::unique_lock lock(file->_lock);
- return fputs_unlocked(string, stream);
-}
-
-int getc_unlocked(FILE *stream) {
- return fgetc_unlocked(stream);
-}
-
-int getc(FILE *stream) {
- return fgetc(stream);
-}
-
-int getchar_unlocked(void) {
- return fgetc_unlocked(stdin);
-}
-
-int getchar(void) {
- return fgetc(stdin);
-}
-
-char *gets(char *s){
- return fgets(s, SIZE_MAX, stdin);
-}
-
-int putc_unlocked(int c, FILE *stream) {
- char d = c;
- if(fwrite_unlocked(&d, 1, 1, stream) != 1)
- return EOF;
- return c;
-}
-
-int putc(int c, FILE *stream) {
- auto file = static_cast<mlibc::abstract_file *>(stream);
- frg::unique_lock lock(file->_lock);
- return putc_unlocked(c, stream);
-}
-
-int putchar_unlocked(int c) {
- return putc_unlocked(c, stdout);
-}
-
-int putchar(int c) {
- auto file = static_cast<mlibc::abstract_file *>(stdout);
- frg::unique_lock lock(file->_lock);
- return putchar_unlocked(c);
-}
-
-int puts(const char *string) {
- auto file = static_cast<mlibc::abstract_file *>(stdout);
- frg::unique_lock lock(file->_lock);
-
- size_t progress = 0;
- size_t len = strlen(string);
- while(progress < len) {
- size_t chunk;
- if(file->write(string + progress,
- len - progress, &chunk)) {
- return EOF;
- }else if(!chunk) {
- return EOF;
- }
-
- progress += chunk;
- }
-
- size_t unused;
- if (!file->write("\n", 1, &unused)) {
- return EOF;
- }
-
- return 1;
-}
-
-wint_t fgetwc(FILE *) MLIBC_STUB_BODY
-wchar_t *fgetws(wchar_t *__restrict, int, FILE *__restrict) MLIBC_STUB_BODY
-wint_t fputwc(wchar_t, FILE *) MLIBC_STUB_BODY
-int fputws(const wchar_t *__restrict, FILE *__restrict) MLIBC_STUB_BODY
-int fwide(FILE *, int) MLIBC_STUB_BODY
-wint_t getwc(FILE *) MLIBC_STUB_BODY
-wint_t getwchar(void) MLIBC_STUB_BODY
-wint_t putwc(wchar_t, FILE *) MLIBC_STUB_BODY
-wint_t putwchar(wchar_t) MLIBC_STUB_BODY
-wint_t ungetwc(wint_t, FILE *) MLIBC_STUB_BODY
-
-size_t fread(void *buffer, size_t size, size_t count, FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- return fread_unlocked(buffer, size, count, file_base);
-}
-
-size_t fwrite(const void *buffer, size_t size , size_t count, FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- frg::unique_lock lock(file->_lock);
- return fwrite_unlocked(buffer, size, count, file_base);
-}
-
-int fgetpos(FILE *__restrict, fpos_t *__restrict) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-// fseek() is provided by the POSIX sublibrary
-int fsetpos(FILE *, const fpos_t *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-// ftell() is provided by the POSIX sublibrary
-
-void clearerr(FILE *file_base) {
- file_base->__status_bits = 0;
-}
-
-int feof(FILE *file_base) {
- return file_base->__status_bits & __MLIBC_EOF_BIT;
-}
-
-int ferror(FILE *file_base) {
- return file_base->__status_bits & __MLIBC_ERROR_BIT;
-}
-
-void perror(const char *string) {
- int error = errno;
- if (string && *string) {
- fprintf(stderr, "%s: ", string);
- }
- fprintf(stderr, "%s\n", strerror(error));
-}
-
-// POSIX extensions.
-
-ssize_t getline(char **line, size_t *n, FILE *stream) {
- return getdelim(line, n, '\n', stream);
-}
-
-ssize_t getdelim(char **line, size_t *n, int delim, FILE *stream) {
- // Otherwise, we cannot store the buffer / size.
- if(!line || !n) {
- errno = EINVAL;
- return -1;
- }
-
- char *buffer = *line;
- /* set the starting capacity to 512 if buffer = NULL */
- size_t capacity = (!buffer) ? 512 : *n;
- size_t nwritten = 0;
-
- auto file = static_cast<mlibc::abstract_file *>(stream);
- frg::unique_lock lock(file->_lock);
-
- // Avoid allocating if we've already hit the end
- auto c = fgetc_unlocked(stream);
- if (c == EOF || ferror(stream)) {
- return -1;
- } else {
- file->unget(c);
- }
-
- while (true) {
- // Fill the buffer
- while (buffer && capacity > 0 && nwritten < capacity - 1) {
- auto c = fgetc_unlocked(stream);
- if (ferror(stream)) {
- return -1;
- } else if (c == EOF) {
- buffer[nwritten] = 0;
- return nwritten;
- }
-
- buffer[nwritten++] = c;
-
- if (c == delim) {
- buffer[nwritten] = 0;
- return nwritten;
- }
- }
-
- // Double the size of the buffer (but make sure it's at least 1024)
- capacity = (capacity >= 1024) ? capacity * 2 : 1024;
- buffer = reinterpret_cast<char *>(getAllocator().reallocate(*line, capacity));
- if (!buffer) {
- errno = ENOMEM;
- return -1;
- }
-
- *line = buffer;
- *n = capacity;
- }
-}
-
-// GLIBC extensions.
-
-int asprintf(char **out, const char *format, ...) {
- va_list args;
- va_start(args, format);
- int result = vasprintf(out, format, args);
- va_end(args);
- return result;
-}
-
-int vasprintf(char **out, const char *format, __builtin_va_list args) {
- frg::va_struct vs;
- frg::arg arg_list[NL_ARGMAX + 1];
- vs.arg_list = arg_list;
- va_copy(vs.args, args);
- ResizePrinter p;
-// mlibc::infoLogger() << "printf(" << format << ")" << frg::endlog;
- auto res = frg::printf_format(PrintfAgent{&p, &vs}, format, &vs);
- if (!res)
- return -static_cast<int>(res.error());
- p.expand();
- p.buffer[p.count] = 0;
- *out = p.buffer;
- return p.count;
-}
-
-// Linux unlocked I/O extensions.
-
-void flockfile(FILE *file_base) {
- static_cast<mlibc::abstract_file *>(file_base)->_lock.lock();
-}
-
-void funlockfile(FILE *file_base) {
- static_cast<mlibc::abstract_file *>(file_base)->_lock.unlock();
-}
-
-int ftrylockfile(FILE *file_base) {
- static_cast<mlibc::abstract_file *>(file_base)->_lock.try_lock();
- return 0;
-}
-
-void clearerr_unlocked(FILE *file_base) {
- file_base->__status_bits = 0;
-}
-
-int feof_unlocked(FILE *file_base) {
- return file_base->__status_bits & __MLIBC_EOF_BIT;
-}
-
-int ferror_unlocked(FILE *file_base) {
- return file_base->__status_bits & __MLIBC_ERROR_BIT;
-}
-
-int fgetc_unlocked(FILE *stream) {
- unsigned char d;
- if(fread_unlocked(&d, 1, 1, stream) != 1)
- return EOF;
- return (int)d;
-}
-
-size_t fread_unlocked(void *buffer, size_t size, size_t count, FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- if(!size || !count)
- return 0;
-
- // Distinguish two cases here: If the object size is one, we perform byte-wise reads.
- // Otherwise, we try to read each object individually.
- if(size == 1) {
- size_t progress = 0;
- while(progress < count) {
- size_t chunk;
- if(int e = file->read((char *)buffer + progress,
- count - progress, &chunk)) {
- errno = e;
- return 0;
- }else if(!chunk) {
- // TODO: Handle eof.
- break;
- }
-
- progress += chunk;
- }
-
- return progress;
- }else{
- for(size_t i = 0; i < count; i++) {
- size_t progress = 0;
- while(progress < size) {
- size_t chunk;
- if(int e = file->read((char *)buffer + i * size + progress,
- size - progress, &chunk)) {
- errno = e;
- return 0;
- }else if(!chunk) {
- // TODO: Handle eof.
- break;
- }
-
- progress += chunk;
- }
-
- if(progress < size)
- return i;
- }
-
- return count;
- }
-}
-
-size_t fwrite_unlocked(const void *buffer, size_t size, size_t count, FILE *file_base) {
- auto file = static_cast<mlibc::abstract_file *>(file_base);
- if(!size || !count)
- return 0;
-
- // Distinguish two cases here: If the object size is one, we perform byte-wise writes.
- // Otherwise, we try to write each object individually.
- if(size == 1) {
- size_t progress = 0;
- while(progress < count) {
- size_t chunk;
- if(file->write((const char *)buffer + progress,
- count - progress, &chunk)) {
- // TODO: Handle I/O errors.
- mlibc::infoLogger() << "mlibc: fwrite() I/O errors are not handled"
- << frg::endlog;
- break;
- }else if(!chunk) {
- // TODO: Handle eof.
- break;
- }
-
- progress += chunk;
- }
-
- return progress;
- }else{
- for(size_t i = 0; i < count; i++) {
- size_t progress = 0;
- while(progress < size) {
- size_t chunk;
- if(file->write((const char *)buffer + i * size + progress,
- size - progress, &chunk)) {
- // TODO: Handle I/O errors.
- mlibc::infoLogger() << "mlibc: fwrite() I/O errors are not handled"
- << frg::endlog;
- break;
- }else if(!chunk) {
- // TODO: Handle eof.
- break;
- }
-
- progress += chunk;
- }
-
- if(progress < size)
- return i;
- }
-
- return count;
- }
-}
-
-char *fgets_unlocked(char *__restrict buffer, int max_size, FILE *stream) {
- __ensure(max_size > 0);
- for(int i = 0; ; i++) {
- if(i == max_size - 1) {
- buffer[i] = 0;
- return buffer;
- }
-
- auto c = fgetc_unlocked(stream);
-
- // If fgetc() fails, there is either an EOF or an I/O error.
- if(c == EOF) {
- if(i) {
- buffer[i] = 0;
- return buffer;
- } else {
- // In this case, the buffer is not changed.
- return nullptr;
- }
- } else {
- buffer[i] = c;
- }
-
- if(c == '\n') {
- buffer[i + 1] = 0;
- return buffer;
- }
- }
-}
diff --git a/lib/mlibc/options/ansi/generic/stdlib-stubs.cpp b/lib/mlibc/options/ansi/generic/stdlib-stubs.cpp
deleted file mode 100644
index 86b8a9a..0000000
--- a/lib/mlibc/options/ansi/generic/stdlib-stubs.cpp
+++ /dev/null
@@ -1,511 +0,0 @@
-
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <wchar.h>
-#include <setjmp.h>
-#include <limits.h>
-
-#include <frg/random.hpp>
-#include <mlibc/debug.hpp>
-#include <bits/ensure.h>
-#include <bits/sigset_t.h>
-
-#include <mlibc/allocator.hpp>
-#include <mlibc/charcode.hpp>
-#include <mlibc/ansi-sysdeps.hpp>
-#include <mlibc/strtofp.hpp>
-#include <mlibc/strtol.hpp>
-#include <mlibc/global-config.hpp>
-
-#if __MLIBC_POSIX_OPTION
-#include <pthread.h>
-#endif // __MLIBC_POSIX_OPTION
-
-extern "C" int __cxa_atexit(void (*function)(void *), void *argument, void *dso_tag);
-void __mlibc_do_finalize();
-
-namespace {
- // According to the first paragraph of [C11 7.22.7],
- // mblen(), mbtowc() and wctomb() have an internal state.
- // The string functions mbstowcs() and wcstombs() do *not* have this state.
- thread_local __mlibc_mbstate mblen_state = __MLIBC_MBSTATE_INITIALIZER;
- thread_local __mlibc_mbstate mbtowc_state = __MLIBC_MBSTATE_INITIALIZER;
-}
-
-double atof(const char *string) {
- return strtod(string, NULL);
-}
-int atoi(const char *string) {
- return strtol(string, nullptr, 10);
-}
-long atol(const char *string) {
- return strtol(string, nullptr, 10);
-}
-long long atoll(const char *string) {
- return strtoll(string, nullptr, 10);
-}
-
-// POSIX extensions but are here for simplicities sake. Forward declaration is here
-// to avoid exporting sigprocmask when posix is disabled.
-int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
-extern "C" {
- __attribute__((__returns_twice__)) int __sigsetjmp(sigjmp_buf buffer, int savesigs) {
- buffer[0].savesigs = savesigs;
- if (savesigs)
- sigprocmask(0, NULL, &buffer[0].sigset);
- return 0;
- }
-}
-
-__attribute__((__noreturn__)) void siglongjmp(sigjmp_buf buffer, int value) {
- if (buffer[0].savesigs)
- sigprocmask(SIG_SETMASK, &buffer[0].sigset, NULL);
- jmp_buf b;
- b[0].reg_state = buffer[0].reg_state;
- longjmp(b, value);
-}
-
-double strtod(const char *__restrict string, char **__restrict end) {
- return mlibc::strtofp<double>(string, end);
-}
-float strtof(const char *__restrict string, char **__restrict end) {
- return mlibc::strtofp<float>(string, end);
-}
-long double strtold(const char *__restrict string, char **__restrict end) {
- return mlibc::strtofp<long double>(string, end);
-}
-
-long strtol(const char *__restrict string, char **__restrict end, int base) {
- return mlibc::stringToInteger<long, char>(string, end, base);
-}
-long long strtoll(const char *__restrict string, char **__restrict end, int base) {
- return mlibc::stringToInteger<long long, char>(string, end, base);
-}
-unsigned long strtoul(const char *__restrict string, char **__restrict end, int base) {
- return mlibc::stringToInteger<unsigned long, char>(string, end, base);
-}
-unsigned long long strtoull(const char *__restrict string, char **__restrict end, int base) {
- return mlibc::stringToInteger<unsigned long long, char>(string, end, base);
-}
-
-frg::mt19937 __mlibc_rand_engine;
-
-int rand() {
- // rand() is specified to return a positive number so we discard the MSB.
- return static_cast<int>(__mlibc_rand_engine() & 0x7FFFFFFF);
-}
-
-static unsigned temper(unsigned x) {
- x ^= x >> 11;
- x ^= x << 7 & 0x9D2C5680;
- x ^= x << 15 & 0xEFC60000;
- x ^= x >> 18;
- return x;
-}
-
-int rand_r(unsigned *seed) {
- return temper(*seed = *seed * 1103515245 + 12345) / 2;
-}
-
-void srand(unsigned int s) {
- __mlibc_rand_engine.seed(s);
-}
-
-void *aligned_alloc(size_t alignment, size_t size) {
- void *ptr;
-
- // alignment must be a power of two, and size % alignment must be 0
- if (alignment & (alignment - 1) || size & (alignment - 1)) {
- errno = EINVAL;
- return nullptr;
- }
-
- // posix_memalign requires that the alignment is a multiple of sizeof(void *)
- if (alignment < sizeof(void *))
- alignment = sizeof(void *);
-
- int ret = posix_memalign(&ptr, alignment, size);
- if (ret) {
- errno = ret;
- return nullptr;
- }
- return ptr;
-
-}
-void *calloc(size_t count, size_t size) {
- // we want to ensure that count*size > SIZE_MAX doesn't happen
- // to prevent overflowing, we divide both sides of the inequality by size and check with that
- if(size && count > (SIZE_MAX / size)) {
- errno = EINVAL;
- return NULL;
- }
-
- // TODO: this could be done more efficient if the OS gives us already zero'd pages
- void *ptr = malloc(count * size);
- if(!ptr)
- return nullptr;
- memset(ptr, 0, count * size);
- return ptr;
-}
-// free() is provided by the platform
-// malloc() is provided by the platform
-// realloc() is provided by the platform
-
-void abort(void) {
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set, SIGABRT);
- if (mlibc::sys_sigprocmask) {
- mlibc::sys_sigprocmask(SIG_UNBLOCK, &set, nullptr);
- }
-
- raise(SIGABRT);
-
- sigfillset(&set);
- sigdelset(&set, SIGABRT);
- if (mlibc::sys_sigprocmask) {
- mlibc::sys_sigprocmask(SIG_SETMASK, &set, nullptr);
- }
-
- struct sigaction sa;
- sa.sa_handler = SIG_DFL;
- sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
-
- if (mlibc::sys_sigaction(SIGABRT, &sa, nullptr))
- mlibc::panicLogger() << "mlibc: sigaction failed in abort" << frg::endlog;
-
- if (raise(SIGABRT))
- mlibc::panicLogger() << "mlibc: raise failed in abort" << frg::endlog;
-
- __builtin_trap();
-}
-
-int atexit(void (*func)(void)) {
- // TODO: the function pointer types are not compatible;
- // the conversion here is undefined behavior. its fine to do
- // this on the x86_64 abi though.
- __cxa_atexit((void (*) (void *))func, nullptr, nullptr);
- return 0;
-}
-int at_quick_exit(void (*func)(void)) {
- (void)func;
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-void exit(int status) {
- __mlibc_do_finalize();
- mlibc::sys_exit(status);
-}
-
-void _Exit(int status) {
- mlibc::sys_exit(status);
-}
-
-// getenv() is provided by POSIX
-void quick_exit(int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-extern char **environ;
-
-int system(const char *command) {
- int status = -1;
- pid_t child;
-
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fork && mlibc::sys_waitpid &&
- mlibc::sys_execve && mlibc::sys_sigprocmask && mlibc::sys_sigaction, -1);
-
-#if __MLIBC_POSIX_OPTION
- pthread_testcancel();
-#endif // __MLIBC_POSIX_OPTION
-
- if (!command) {
- return 1;
- }
-
- struct sigaction new_sa, old_int, old_quit;
- sigset_t new_mask, old_mask;
-
- new_sa.sa_handler = SIG_IGN;
- new_sa.sa_flags = 0;
- sigemptyset(&new_sa.sa_mask);
- mlibc::sys_sigaction(SIGINT, &new_sa, &old_int);
- mlibc::sys_sigaction(SIGQUIT, &new_sa, &old_quit);
-
- sigemptyset(&new_mask);
- sigaddset(&new_mask, SIGCHLD);
- mlibc::sys_sigprocmask(SIG_BLOCK, &new_mask, &old_mask);
-
- if (int e = mlibc::sys_fork(&child)) {
- errno = e;
- } else if (!child) {
- mlibc::sys_sigaction(SIGINT, &old_int, nullptr);
- mlibc::sys_sigaction(SIGQUIT, &old_quit, nullptr);
- mlibc::sys_sigprocmask(SIG_SETMASK, &old_mask, nullptr);
-
- const char *args[] = {
- "sh", "-c", command, nullptr
- };
-
- mlibc::sys_execve("/bin/sh", const_cast<char **>(args), environ);
- _Exit(127);
- } else {
- int err;
- pid_t unused;
-
- while ((err = mlibc::sys_waitpid(child, &status, 0, NULL, &unused)) < 0) {
- if (err == EINTR)
- continue;
-
- errno = err;
- status = -1;
- }
- }
-
- mlibc::sys_sigaction(SIGINT, &old_int, nullptr);
- mlibc::sys_sigaction(SIGQUIT, &old_quit, nullptr);
- mlibc::sys_sigprocmask(SIG_SETMASK, &old_mask, nullptr);
-
- return status;
-}
-
-char *mktemp(char *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-void *bsearch(const void *key, const void *base, size_t count, size_t size,
- int (*compare)(const void *, const void *)) {
- // Invariant: Element is in the interval [i, j).
- size_t i = 0;
- size_t j = count;
-
- while(i < j) {
- size_t k = (j - i) / 2;
- auto element = reinterpret_cast<const char *>(base) + (i + k) * size;
- auto res = compare(key, element);
- if(res < 0) {
- j = i + k;
- }else if(res > 0) {
- i = i + k + 1;
- }else{
- return const_cast<char *>(element);
- }
- }
- __ensure(i == j);
-
- return nullptr;
-}
-
-static int qsort_callback(const void *a, const void *b, void *arg) {
- auto compare = reinterpret_cast<int (*)(const void *, const void *)>(arg);
-
- return compare(a, b);
-}
-
-void qsort(void *base, size_t count, size_t size,
- int (*compare)(const void *, const void *)) {
- return qsort_r(base, count, size, qsort_callback, (void *) compare);
-}
-
-void qsort_r(void *base, size_t count, size_t size,
- int (*compare)(const void *, const void *, void *),
- void *arg) {
- // TODO: implement a faster sort
- for(size_t i = 0; i < count; i++) {
- void *u = (void *)((uintptr_t)base + i * size);
- for(size_t j = i + 1; j < count; j++) {
- void *v = (void *)((uintptr_t)base + j * size);
- if(compare(u, v, arg) <= 0)
- continue;
-
- // swap u and v
- char *u_bytes = (char *)u;
- char *v_bytes = (char *)v;
- for(size_t k = 0; k < size; k++) {
- char temp = u_bytes[k];
- u_bytes[k] = v_bytes[k];
- v_bytes[k] = temp;
- }
- }
- }
-}
-
-int abs(int num) {
- return num < 0 ? -num : num;
-}
-
-long labs(long num) {
- return num < 0 ? -num : num;
-}
-
-long long llabs(long long num) {
- return num < 0 ? -num : num;
-}
-
-div_t div(int number, int denom) {
- div_t r;
- r.quot = number / denom;
- r.rem = number % denom;
- return r;
-}
-
-ldiv_t ldiv(long number, long denom) {
- ldiv_t r;
- r.quot = number / denom;
- r.rem = number % denom;
- return r;
-}
-
-lldiv_t lldiv(long long number, long long denom) {
- lldiv_t r;
- r.quot = number / denom;
- r.rem = number % denom;
- return r;
-}
-
-int mblen(const char *mbs, size_t mb_limit) {
- auto cc = mlibc::current_charcode();
- wchar_t wc;
- mlibc::code_seq<const char> nseq{mbs, mbs + mb_limit};
- mlibc::code_seq<wchar_t> wseq{&wc, &wc + 1};
-
- if(!mbs) {
- mblen_state = __MLIBC_MBSTATE_INITIALIZER;
- return cc->has_shift_states;
- }
-
- if(auto e = cc->decode_wtranscode(nseq, wseq, mblen_state); e != mlibc::charcode_error::null)
- __ensure(!"decode_wtranscode() errors are not handled");
- return nseq.it - mbs;
-}
-
-int mbtowc(wchar_t *__restrict wc, const char *__restrict mb, size_t max_size) {
- auto cc = mlibc::current_charcode();
- __ensure(max_size);
-
- // If wc is NULL, decode into a single local character which we discard
- // to obtain the length.
- wchar_t tmp_wc;
- if (!wc)
- wc = &tmp_wc;
-
- if (mb) {
- if (*mb) {
- mlibc::code_seq<wchar_t> wseq{wc, wc + 1};
- mlibc::code_seq<const char> nseq{mb, mb + max_size};
- auto e = cc->decode_wtranscode(nseq, wseq, mbtowc_state);
- switch(e) {
- // We keep the state, so we can simply return here.
- case mlibc::charcode_error::input_underflow:
- case mlibc::charcode_error::null: {
- return nseq.it - mb;
- }
- case mlibc::charcode_error::illegal_input: {
- errno = -EILSEQ;
- return -1;
- }
- case mlibc::charcode_error::dirty: {
- mlibc::panicLogger() << "decode_wtranscode() charcode_error::dirty errors are not handled" << frg::endlog;
- break;
- }
- case mlibc::charcode_error::output_overflow: {
- mlibc::panicLogger() << "decode_wtranscode() charcode_error::output_overflow errors are not handled" << frg::endlog;
- break;
- }
- }
- __builtin_unreachable();
- } else {
- *wc = L'\0';
- return 0; // When mbs is a null byte, return 0
- }
- } else {
- mblen_state = __MLIBC_MBSTATE_INITIALIZER;
- return cc->has_shift_states;
- }
-}
-
-int wctomb(char *, wchar_t) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-size_t mbstowcs(wchar_t *wcs, const char *mbs, size_t wc_limit) {
- auto cc = mlibc::current_charcode();
- __mlibc_mbstate st = __MLIBC_MBSTATE_INITIALIZER;
- mlibc::code_seq<const char> nseq{mbs, nullptr};
- mlibc::code_seq<wchar_t> wseq{wcs, wcs + wc_limit};
-
- if(!wcs) {
- size_t size;
- if(auto e = cc->decode_wtranscode_length(nseq, &size, st); e != mlibc::charcode_error::null)
- __ensure(!"decode_wtranscode() errors are not handled");
- return size;
- }
-
- if(auto e = cc->decode_wtranscode(nseq, wseq, st); e != mlibc::charcode_error::null) {
- __ensure(!"decode_wtranscode() errors are not handled");
- __builtin_unreachable();
- }else{
- size_t n = wseq.it - wcs;
- if(n < wc_limit) // Null-terminate resulting wide string.
- wcs[n] = 0;
- return n;
- }
-}
-
-size_t wcstombs(char *mb_string, const wchar_t *wc_string, size_t max_size) {
- return wcsrtombs(mb_string, &wc_string, max_size, 0);
-}
-
-void free(void *ptr) {
- // TODO: Print PID only if POSIX option is enabled.
- if (mlibc::globalConfig().debugMalloc) {
- mlibc::infoLogger() << "mlibc (PID ?): free() on "
- << ptr << frg::endlog;
- if((uintptr_t)ptr & 1)
- mlibc::infoLogger() << __builtin_return_address(0) << frg::endlog;
- }
- getAllocator().free(ptr);
-}
-
-void *malloc(size_t size) {
- auto nptr = getAllocator().allocate(size);
- // TODO: Print PID only if POSIX option is enabled.
- if (mlibc::globalConfig().debugMalloc)
- mlibc::infoLogger() << "mlibc (PID ?): malloc() returns "
- << nptr << frg::endlog;
- return nptr;
-}
-
-void *realloc(void *ptr, size_t size) {
- auto nptr = getAllocator().reallocate(ptr, size);
- // TODO: Print PID only if POSIX option is enabled.
- if (mlibc::globalConfig().debugMalloc)
- mlibc::infoLogger() << "mlibc (PID ?): realloc() on "
- << ptr << " returns " << nptr << frg::endlog;
- return nptr;
-}
-
-int posix_memalign(void **out, size_t align, size_t size) {
- if(align < sizeof(void *))
- return EINVAL;
- if(align & (align - 1)) // Make sure that align is a power of two.
- return EINVAL;
- auto p = getAllocator().allocate(frg::max(align, size));
- if(!p)
- return ENOMEM;
- // Hope that the alignment was respected. This works on the current allocator.
- // TODO: Make the allocator alignment-aware.
- __ensure(!(reinterpret_cast<uintptr_t>(p) & (align - 1)));
- *out = p;
- return 0;
-}
diff --git a/lib/mlibc/options/ansi/generic/string-stubs.cpp b/lib/mlibc/options/ansi/generic/string-stubs.cpp
deleted file mode 100644
index 8defd0e..0000000
--- a/lib/mlibc/options/ansi/generic/string-stubs.cpp
+++ /dev/null
@@ -1,542 +0,0 @@
-#include <string.h>
-#include <errno.h>
-#include <wchar.h>
-#include <ctype.h>
-
-#include <bits/ensure.h>
-#include <mlibc/strtol.hpp>
-
-// memset() is defined in options/internals.
-// memcpy() is defined in options/internals.
-// memmove() is defined in options/internals.
-// strlen() is defined in options/internals.
-
-char *strcpy(char *__restrict dest, const char *src) {
- char *dest_bytes = (char *)dest;
- char *src_bytes = (char *)src;
- while(*src_bytes)
- *(dest_bytes++) = *(src_bytes++);
- *dest_bytes = 0;
- return dest;
-}
-char *strncpy(char *__restrict dest, const char *src, size_t max_size) {
- auto dest_bytes = static_cast<char *>(dest);
- auto src_bytes = static_cast<const char *>(src);
- size_t i = 0;
- while(*src_bytes && i < max_size) {
- *(dest_bytes++) = *(src_bytes++);
- i++;
- }
- while(i < max_size) {
- *(dest_bytes++) = 0;
- i++;
- }
- return dest;
-}
-
-char *strcat(char *__restrict dest, const char *__restrict src) {
- strcpy(dest + strlen(dest), src);
- return dest;
-}
-char *strncat(char *__restrict dest, const char *__restrict src, size_t max_size) {
- auto dest_bytes = static_cast<char *>(dest);
- auto src_bytes = static_cast<const char *>(src);
- dest_bytes += strlen(dest);
- size_t i = 0;
- while(*src_bytes && i < max_size) {
- *(dest_bytes++) = *(src_bytes++);
- i++;
- }
- *dest_bytes = 0;
- return dest;
-}
-
-int memcmp(const void *a, const void *b, size_t size) {
- for(size_t i = 0; i < size; i++) {
- auto a_byte = static_cast<const unsigned char *>(a)[i];
- auto b_byte = static_cast<const unsigned char *>(b)[i];
- if(a_byte < b_byte)
- return -1;
- if(a_byte > b_byte)
- return 1;
- }
- return 0;
-}
-int strcmp(const char *a, const char *b) {
- size_t i = 0;
- while(true) {
- unsigned char a_byte = a[i];
- unsigned char b_byte = b[i];
- if(!a_byte && !b_byte)
- return 0;
- // If only one char is null, one of the following cases applies.
- if(a_byte < b_byte)
- return -1;
- if(a_byte > b_byte)
- return 1;
- i++;
- }
-}
-
-int strcoll(const char *a, const char *b) {
- // TODO: strcoll should take "LC_COLLATE" into account.
- return strcmp(a, b);
-}
-
-int strncmp(const char *a, const char *b, size_t max_size) {
- size_t i = 0;
- while(true) {
- if(!(i < max_size))
- return 0;
- unsigned char a_byte = a[i];
- unsigned char b_byte = b[i];
- if(!a_byte && !b_byte)
- return 0;
- // If only one char is null, one of the following cases applies.
- if(a_byte < b_byte)
- return -1;
- if(a_byte > b_byte)
- return 1;
- i++;
- }
-}
-
-size_t strxfrm(char *__restrict dest, const char *__restrict src, size_t n) {
- // NOTE: This might not work for non ANSI charsets.
- size_t l = strlen(src);
-
- // man page: If the value returned is n or more, the contents of dest are indeterminate.
- if(n > l)
- strncpy(dest, src, n);
-
- return l;
-}
-
-void *memchr(const void *s, int c, size_t size) {
- auto s_bytes = static_cast<const unsigned char *>(s);
- for(size_t i = 0; i < size; i++)
- if(s_bytes[i] == static_cast<unsigned char>(c))
- return const_cast<unsigned char *>(s_bytes + i);
- return nullptr;
-}
-char *strchr(const char *s, int c) {
- size_t i = 0;
- while(s[i]) {
- if(s[i] == c)
- return const_cast<char *>(&s[i]);
- i++;
- }
- if(c == 0)
- return const_cast<char *>(&s[i]);
- return nullptr;
-}
-size_t strcspn(const char *s, const char *chrs) {
- size_t n = 0;
- while(true) {
- if(!s[n] || strchr(chrs, s[n]))
- return n;
- n++;
- }
-}
-char *strpbrk(const char *s, const char *chrs) {
- size_t n = 0;
- while(s[n]) {
- if(strchr(chrs, s[n]))
- return const_cast<char *>(s + n);
- n++;
- }
- return nullptr;
-}
-char *strrchr(const char *s, int c) {
- // The null-terminator is considered to be part of the string.
- size_t length = strlen(s);
- for(size_t i = 0; i <= length; i++) {
- if(s[length - i] == c)
- return const_cast<char *>(s + (length - i));
- }
- return nullptr;
-}
-size_t strspn(const char *s, const char *chrs) {
- size_t n = 0;
- while(true) {
- if(!s[n] || !strchr(chrs, s[n]))
- return n;
- n++;
- }
-}
-char *strstr(const char *s, const char *pattern) {
- for(size_t i = 0; s[i]; i++) {
- bool found = true;
- for(size_t j = 0; pattern[j]; j++) {
- if(!pattern[j] || s[i + j] == pattern[j])
- continue;
-
- found = false;
- break;
- }
-
- if(found)
- return const_cast<char *>(&s[i]);
- }
-
- return nullptr;
-}
-char *strtok_r(char *__restrict s, const char *__restrict del, char **__restrict m) {
- __ensure(m);
-
- // We use *m = null to memorize that the entire string was consumed.
- char *tok;
- if(s) {
- tok = s;
- }else if(*m) {
- tok = *m;
- }else {
- return nullptr;
- }
-
- // Skip initial delimiters.
- // After this loop: *tok is non-null iff we return a token.
- while(*tok && strchr(del, *tok))
- tok++;
-
- // Replace the following delimiter by a null-terminator.
- // After this loop: *p is null iff we reached the end of the string.
- auto p = tok;
- while(*p && !strchr(del, *p))
- p++;
-
- if(*p) {
- *p = 0;
- *m = p + 1;
- }else{
- *m = nullptr;
- }
- if(p == tok)
- return nullptr;
- return tok;
-}
-char *strtok(char *__restrict s, const char *__restrict delimiter) {
- static char *saved;
- return strtok_r(s, delimiter, &saved);
-}
-
-// This is a GNU extension.
-char *strchrnul(const char *s, int c) {
- size_t i = 0;
- while(s[i]) {
- if(s[i] == c)
- return const_cast<char *>(s + i);
- i++;
- }
- return const_cast<char *>(s + i);
-}
-
-double wcstod(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY
-float wcstof(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY
-long double wcstold(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY
-
-long wcstol(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base) {
- return mlibc::stringToInteger<long, wchar_t>(nptr, endptr, base);
-}
-unsigned long wcstoul(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base) {
- return mlibc::stringToInteger<unsigned long, wchar_t>(nptr, endptr, base);
-}
-long long wcstoll(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base) {
- return mlibc::stringToInteger<long long, wchar_t>(nptr, endptr, base);
-}
-unsigned long long wcstoull(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base) {
- return mlibc::stringToInteger<unsigned long long, wchar_t>(nptr, endptr, base);
-}
-
-wchar_t *wcscpy(wchar_t *__restrict dest, const wchar_t *__restrict src) {
- wchar_t *a = dest;
- while((*dest++ = *src++));
- return a;
-}
-
-wchar_t *wcsncpy(wchar_t *__restrict dest, const wchar_t *__restrict src, size_t n) {
- wchar_t *a = dest;
- while(n && *src)
- n--, *dest++ = *src++;
- wmemset(dest, 0, n);
- return a;
-}
-
-wchar_t *wmemcpy(wchar_t *__restrict dest, const wchar_t *__restrict src, size_t n) {
- memcpy(dest, src, n * sizeof(wchar_t));
- return dest;
-}
-
-wchar_t *wmemmove(wchar_t *dest, const wchar_t *src, size_t n) {
- memmove(dest, src, n * sizeof(wchar_t));
- return dest;
-}
-
-wchar_t *wcscat(wchar_t *__restrict dest, const wchar_t *__restrict src) {
- wcscpy(dest + wcslen(dest), src);
- return dest;
-}
-
-wchar_t *wcsncat(wchar_t *__restrict, const wchar_t *__restrict, size_t) MLIBC_STUB_BODY
-
-int wcscmp(const wchar_t *l, const wchar_t *r) {
- for(; *l == *r && *l && *r; l++, r++);
- return *l - *r;
-}
-
-int wcscoll(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY
-int wcsncmp(const wchar_t *, const wchar_t *, size_t) MLIBC_STUB_BODY
-int wcsxfrm(wchar_t *__restrict, const wchar_t *__restrict, size_t) MLIBC_STUB_BODY
-
-int wmemcmp(const wchar_t *a, const wchar_t *b, size_t size) {
- for(size_t i = 0; i < size; i++) {
- auto a_byte = a[i];
- auto b_byte = b[i];
- if(a_byte < b_byte)
- return -1;
- if(a_byte > b_byte)
- return 1;
- }
- return 0;
-}
-
-wchar_t *wcschr(const wchar_t *s, wchar_t c) {
- if(!c)
- return (wchar_t *)s + wcslen(s);
- for(; *s && *s != c; s++);
- return *s ? (wchar_t *)s : 0;
-}
-
-size_t wcscspn(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY
-wchar_t *wcspbrk(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY
-
-wchar_t *wcsrchr(const wchar_t *s, wchar_t c) {
- const wchar_t *p;
- for(p = s + wcslen(s); p >= s && *p != c; p--);
- return p >= s ? (wchar_t *)p : 0;
-}
-
-size_t wcsspn(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY
-wchar_t *wcsstr(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY
-wchar_t *wcstok(wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY
-
-wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t size) {
- auto s_bytes = s;
- for(size_t i = 0; i < size; i++)
- if(s_bytes[i] == c)
- return const_cast<wchar_t *>(s_bytes + i);
- return nullptr;
-}
-
-size_t wcslen(const wchar_t *s) {
- const wchar_t *a;
- for(a = s; *s; s++);
- return s-a;
-}
-
-wchar_t *wmemset(wchar_t *d, wchar_t c, size_t n) {
- wchar_t *ret = d;
- while(n--)
- *d++ = c;
- return ret;
-}
-
-char *strerror(int e) {
- const char *s;
- switch(e) {
- case EAGAIN: s = "Operation would block (EAGAIN)"; break;
- case EACCES: s = "Access denied (EACCESS)"; break;
- case EBADF: s = "Bad file descriptor (EBADF)"; break;
- case EEXIST: s = "File exists already (EEXIST)"; break;
- case EFAULT: s = "Access violation (EFAULT)"; break;
- case EINTR: s = "Operation interrupted (EINTR)"; break;
- case EINVAL: s = "Invalid argument (EINVAL)"; break;
- case EIO: s = "I/O error (EIO)"; break;
- case EISDIR: s = "Resource is directory (EISDIR)"; break;
- case ENOENT: s = "No such file or directory (ENOENT)"; break;
- case ENOMEM: s = "Out of memory (ENOMEM)"; break;
- case ENOTDIR: s = "Expected directory instead of file (ENOTDIR)"; break;
- case ENOSYS: s = "Operation not implemented (ENOSYS)"; break;
- case EPERM: s = "Operation not permitted (EPERM)"; break;
- case EPIPE: s = "Broken pipe (EPIPE)"; break;
- case ESPIPE: s = "Seek not possible (ESPIPE)"; break;
- case ENXIO: s = "No such device or address (ENXIO)"; break;
- case ENOEXEC: s = "Exec format error (ENOEXEC)"; break;
- case ENOSPC: s = "No space left on device (ENOSPC)"; break;
- case ENOTSOCK: s = "Socket operation on non-socket (ENOTSOCK)"; break;
- case ENOTCONN: s = "Transport endpoint is not connected (ENOTCONN)"; break;
- case EDOM: s = "Numerical argument out of domain (EDOM)"; break;
- case EILSEQ: s = "Invalid or incomplete multibyte or wide character (EILSEQ)"; break;
- case ERANGE: s = "Numerical result out of range (ERANGE)"; break;
- case E2BIG: s = "Argument list too long (E2BIG)"; break;
- case EADDRINUSE: s = "Address already in use (EADDRINUSE)"; break;
- case EADDRNOTAVAIL: s = "Cannot assign requested address (EADDRNOTAVAIL)"; break;
- case EAFNOSUPPORT: s = "Address family not supported by protocol (EAFNOSUPPORT)"; break;
- case EALREADY: s = "Operation already in progress (EALREADY)"; break;
- case EBADMSG: s = "Bad message (EBADMSG)"; break;
- case EBUSY: s = "Device or resource busy (EBUSY)"; break;
- case ECANCELED: s = "Operation canceled (ECANCELED)"; break;
- case ECHILD: s = "No child processes (ECHILD)"; break;
- case ECONNABORTED: s = "Software caused connection abort (ECONNABORTED)"; break;
- case ECONNREFUSED: s = "Connection refused (ECONNREFUSED)"; break;
- case ECONNRESET: s = "Connection reset by peer (ECONNRESET)"; break;
- case EDEADLK: s = "Resource deadlock avoided (EDEADLK)"; break;
- case EDESTADDRREQ: s = "Destination address required (EDESTADDRREQ)"; break;
- case EDQUOT: s = "Disk quota exceeded (EDQUOT)"; break;
- case EFBIG: s = "File too large (EFBIG)"; break;
- case EHOSTUNREACH: s = "No route to host (EHOSTUNREACH)"; break;
- case EIDRM: s = "Identifier removed (EIDRM)"; break;
- case EINPROGRESS: s = "Operation now in progress (EINPROGRESS)"; break;
- case EISCONN: s = "Transport endpoint is already connected (EISCONN)"; break;
- case ELOOP: s = "Too many levels of symbolic links (ELOOP)"; break;
- case EMFILE: s = "Too many open files (EMFILE)"; break;
- case EMLINK: s = "Too many links (EMLINK)"; break;
- case EMSGSIZE: s = "Message too long (EMSGSIZE)"; break;
- case EMULTIHOP: s = "Multihop attempted (EMULTIHOP)"; break;
- case ENAMETOOLONG: s = "File name too long (ENAMETOOLONG)"; break;
- case ENETDOWN: s = "Network is down (ENETDOWN)"; break;
- case ENETRESET: s = "Network dropped connection on reset (ENETRESET)"; break;
- case ENETUNREACH: s = "Network is unreachable (ENETUNREACH)"; break;
- case ENFILE: s = "Too many open files in system (ENFILE)"; break;
- case ENOBUFS: s = "No buffer space available (ENOBUFS)"; break;
- case ENODEV: s = "No such device (ENODEV)"; break;
- case ENOLCK: s = "No locks available (ENOLCK)"; break;
- case ENOLINK: s = "Link has been severed (ENOLINK)"; break;
- case ENOMSG: s = "No message of desired type (ENOMSG)"; break;
- case ENOPROTOOPT: s = "Protocol not available (ENOPROTOOPT)"; break;
- case ENOTEMPTY: s = "Directory not empty (ENOTEMPTY)"; break;
- case ENOTRECOVERABLE: s = "Sate not recoverable (ENOTRECOVERABLE)"; break;
- case ENOTSUP: s = "Operation not supported (ENOTSUP)"; break;
- case ENOTTY: s = "Inappropriate ioctl for device (ENOTTY)"; break;
- case EOVERFLOW: s = "Value too large for defined datatype (EOVERFLOW)"; break;
-#if EOPNOTSUPP != ENOTSUP
- /* these are aliases on the mlibc abi */
- case EOPNOTSUPP: s = "Operation not supported (EOPNOTSUP)"; break;
-#endif
- case EOWNERDEAD: s = "Owner died (EOWNERDEAD)"; break;
- case EPROTO: s = "Protocol error (EPROTO)"; break;
- case EPROTONOSUPPORT: s = "Protocol not supported (EPROTONOSUPPORT)"; break;
- case EPROTOTYPE: s = "Protocol wrong type for socket (EPROTOTYPE)"; break;
- case EROFS: s = "Read-only file system (EROFS)"; break;
- case ESRCH: s = "No such process (ESRCH)"; break;
- case ESTALE: s = "Stale file handle (ESTALE)"; break;
- case ETIMEDOUT: s = "Connection timed out (ETIMEDOUT)"; break;
- case ETXTBSY: s = "Text file busy (ETXTBSY)"; break;
- case EXDEV: s = "Invalid cross-device link (EXDEV)"; break;
- case ENODATA: s = "No data available (ENODATA)"; break;
- case ETIME: s = "Timer expired (ETIME)"; break;
- case ENOKEY: s = "Required key not available (ENOKEY)"; break;
- case ESHUTDOWN: s = "Cannot send after transport endpoint shutdown (ESHUTDOWN)"; break;
- case EHOSTDOWN: s = "Host is down (EHOSTDOWN)"; break;
- case EBADFD: s = "File descriptor in bad state (EBADFD)"; break;
- case ENOMEDIUM: s = "No medium found (ENOMEDIUM)"; break;
- case ENOTBLK: s = "Block device required (ENOTBLK)"; break;
- case ENONET: s = "Machine is not on the network (ENONET)"; break;
- case EPFNOSUPPORT: s = "Protocol family not supported (EPFNOSUPPORT)"; break;
- case ESOCKTNOSUPPORT: s = "Socket type not supported (ESOCKTNOSUPPORT)"; break;
- case ESTRPIPE: s = "Streams pipe error (ESTRPIPE)"; break;
- case EREMOTEIO: s = "Remote I/O error (EREMOTEIO)"; break;
- case ERFKILL: s = "Operation not possible due to RF-kill (ERFKILL)"; break;
- case EBADR: s = "Invalid request descriptor (EBADR)"; break;
- case EUNATCH: s = "Protocol driver not attached (EUNATCH)"; break;
- case EMEDIUMTYPE: s = "Wrong medium type (EMEDIUMTYPE)"; break;
- case EREMOTE: s = "Object is remote (EREMOTE)"; break;
- case EKEYREJECTED: s = "Key was rejected by service (EKEYREJECTED)"; break;
- case EUCLEAN: s = "Structure needs cleaning (EUCLEAN)"; break;
- case EBADSLT: s = "Invalid slot (EBADSLT)"; break;
- case ENOANO: s = "No anode (ENOANO)"; break;
- case ENOCSI: s = "No CSI structure available (ENOCSI)"; break;
- case ENOSTR: s = "Device not a stream (ENOSTR)"; break;
- case ETOOMANYREFS: s = "Too many references: cannot splice (ETOOMANYREFS)"; break;
- case ENOPKG: s = "Package not installed (ENOPKG)"; break;
- case EKEYREVOKED: s = "Key has been revoked (EKEYREVOKED)"; break;
- case EXFULL: s = "Exchange full (EXFULL)"; break;
- case ELNRNG: s = "Link number out of range (ELNRNG)"; break;
- case ENOTUNIQ: s = "Name not unique on network (ENOTUNIQ)"; break;
- case ERESTART: s = "Interrupted system call should be restarted (ERESTART)"; break;
- case EUSERS: s = "Too many users (EUSERS)"; break;
-
-#ifdef EIEIO
- case EIEIO: s = "Computer bought the farm; OS internal error (EIEIO)"; break;
-#endif
-
- default:
- s = "Unknown error code (?)";
- }
- return const_cast<char *>(s);
-}
-// strlen() is defined in options/internals.
-
-// POSIX extensions.
-
-int strerror_r(int e, char *buffer, size_t bufsz) {
- auto s = strerror(e);
- strncpy(buffer, s, bufsz);
- // Note that strerror_r does not set errno on error!
- if(strlen(s) >= bufsz)
- return ERANGE;
- return 0;
-}
-
-void *mempcpy(void *dest, const void *src, size_t len) {
- return (char *)memcpy(dest, src, len) + len;
-}
-
-// GNU extensions.
-// Taken from musl.
-int strverscmp(const char *l0, const char *r0) {
- const unsigned char *l = (const unsigned char *)l0;
- const unsigned char *r = (const unsigned char *)r0;
- size_t i, dp, j;
- int z = 1;
-
- /* Find maximal matching prefix and track its maximal digit
- * suffix and whether those digits are all zeros. */
- for(dp = i = 0; l[i] == r[i]; i++) {
- int c = l[i];
- if(!c)
- return 0;
- if(!isdigit(c))
- dp = i + 1, z = 1;
- else if(c != '0')
- z = 0;
- }
-
- if(l[dp] != '0' && r[dp] != '0') {
- /* If we're not looking at a digit sequence that began
- * with a zero, longest digit string is greater. */
- for(j = i; isdigit(l[j]); j++) {
- if(!isdigit(r[j]))
- return 1;
- }
- if(isdigit(r[j]))
- return -1;
- } else if(z && dp < i && (isdigit(l[i]) || isdigit(r[i]))) {
- /* Otherwise, if common prefix of digit sequence is
- * all zeros, digits order less than non-digits. */
- return (unsigned char)(l[i] - '0') - (unsigned char)(r[i] - '0');
- }
-
- return l[i] - r[i];
-}
-
-void *memmem(const void *hs, size_t haystackLen, const void *nd, size_t needleLen) {
- const char *haystack = static_cast<const char *>(hs);
- const char *needle = static_cast<const char *>(nd);
-
- for (size_t i = 0; i < haystackLen; i++) {
- bool found = true;
-
- for (size_t j = 0; j < needleLen; j++) {
- if (i + j >= haystackLen || haystack[i + j] != needle[j]) {
- found = false;
- break;
- }
- }
-
- if(found)
- return const_cast<char *>(&haystack[i]);
- }
-
- return nullptr;
-}
diff --git a/lib/mlibc/options/ansi/generic/threads.cpp b/lib/mlibc/options/ansi/generic/threads.cpp
deleted file mode 100644
index 70fa055..0000000
--- a/lib/mlibc/options/ansi/generic/threads.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <abi-bits/errno.h>
-#include <bits/ensure.h>
-#include <mlibc/debug.hpp>
-#include <mlibc/thread.hpp>
-#include <mlibc/threads.hpp>
-#include <threads.h>
-
-int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) {
- int res = mlibc::thread_create(thr, 0, reinterpret_cast<void *>(func), arg, true);
-
- if(!res) {
- return thrd_success;
- }
-
- return (res == ENOMEM) ? thrd_nomem : thrd_error;
-}
-
-int thrd_equal(thrd_t t1, thrd_t t2) {
- if(t1 == t2) {
- return 1;
- }
- return 0;
-}
-
-thrd_t thrd_current(void) {
- return reinterpret_cast<thrd_t>(mlibc::get_current_tcb());
-}
-
-int thrd_sleep(const struct timespec *, struct timespec *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-void thrd_yield(void) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int thrd_detach(thrd_t) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int thrd_join(thrd_t thr, int *res) {
- if(mlibc::thread_join(thr, res) != 0) {
- return thrd_error;
- }
-
- return thrd_success;
-}
-
-__attribute__((__noreturn__)) void thrd_exit(int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int mtx_init(mtx_t *mtx, int type) {
- struct __mlibc_mutexattr attr;
- mlibc::thread_mutexattr_init(&attr);
-
- if(type & mtx_recursive) {
- mlibc::thread_mutexattr_settype(&attr, __MLIBC_THREAD_MUTEX_RECURSIVE);
- }
-
- int res = mlibc::thread_mutex_init(mtx, &attr) == 0 ? thrd_success : thrd_error;
- mlibc::thread_mutexattr_destroy(&attr);
-
- return res;
-}
-
-void mtx_destroy(mtx_t *mtx) {
- mlibc::thread_mutex_destroy(mtx);
-}
-
-int mtx_lock(mtx_t *mtx) {
- return mlibc::thread_mutex_lock(mtx) == 0 ? thrd_success : thrd_error;
-}
-
-int mtx_unlock(mtx_t *mtx) {
- return mlibc::thread_mutex_unlock(mtx) == 0 ? thrd_success : thrd_error;
-}
-
-int cnd_init(cnd_t *cond) {
- return mlibc::thread_cond_init(cond, 0) == 0 ? thrd_success : thrd_error;
-}
-
-void cnd_destroy(cnd_t *cond) {
- mlibc::thread_cond_destroy(cond);
-}
-
-int cnd_broadcast(cnd_t *cond) {
- return mlibc::thread_cond_broadcast(cond) == 0 ? thrd_success : thrd_error;
-}
-
-int cnd_wait(cnd_t *cond, mtx_t *mtx) {
- return mlibc::thread_cond_timedwait(cond, mtx, nullptr) == 0 ? thrd_success : thrd_error;
-}
diff --git a/lib/mlibc/options/ansi/generic/time-stubs.cpp b/lib/mlibc/options/ansi/generic/time-stubs.cpp
deleted file mode 100644
index b8c7cf5..0000000
--- a/lib/mlibc/options/ansi/generic/time-stubs.cpp
+++ /dev/null
@@ -1,729 +0,0 @@
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <limits.h>
-#include <wchar.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include <bits/ensure.h>
-#include <mlibc/debug.hpp>
-#include <mlibc/file-window.hpp>
-#include <mlibc/ansi-sysdeps.hpp>
-#include <mlibc/allocator.hpp>
-#include <mlibc/lock.hpp>
-#include <mlibc/locale.hpp>
-#include <mlibc/bitutil.hpp>
-#include <mlibc/strings.hpp>
-
-#include <frg/mutex.hpp>
-
-const char __utc[] = "UTC";
-
-// Variables defined by POSIX.
-int daylight;
-long timezone;
-char *tzname[2];
-
-static FutexLock __time_lock;
-static file_window *get_localtime_window() {
- static file_window window{"/etc/localtime"};
- return &window;
-}
-
-// Function taken from musl
-clock_t clock(void) {
- struct timespec ts;
-
- if(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
- return -1;
-
- if(ts.tv_sec > LONG_MAX / 1000000 || ts.tv_nsec / 1000 > LONG_MAX - 1000000 * ts.tv_sec)
- return -1;
-
- return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
-}
-
-double difftime(time_t a, time_t b) {
- return a - b;
-}
-
-time_t mktime(struct tm *tm) {
- return timegm(tm);
-}
-
-/* There is no other implemented value than TIME_UTC; all other values
- * are considered erroneous. */
-// Function taken from musl
-int timespec_get(struct timespec *ts, int base) {
- if(base != TIME_UTC)
- return 0;
- int ret = clock_gettime(CLOCK_REALTIME, ts);
- return ret < 0 ? 0 : base;
-}
-
-char *asctime(const struct tm *ptr) {
- static char buf[26];
- return asctime_r(ptr, buf);
-}
-
-char *ctime(const time_t *timer) {
- struct tm *tm = localtime(timer);
- if(!tm) {
- return 0;
- }
- return asctime(tm);
-}
-
-struct tm *gmtime(const time_t *unix_gmt) {
- static thread_local struct tm per_thread_tm;
- return gmtime_r(unix_gmt, &per_thread_tm);
-}
-
-struct tm *localtime(const time_t *unix_gmt) {
- tzset();
- static thread_local struct tm per_thread_tm;
- return localtime_r(unix_gmt, &per_thread_tm);
-}
-
-size_t strftime(char *__restrict dest, size_t max_size,
- const char *__restrict format, const struct tm *__restrict tm) {
- auto c = format;
- auto p = dest;
-
- while(*c) {
- int chunk;
- auto space = (dest + max_size) - p;
- __ensure(space >= 0);
-
- if(*c != '%') {
- if(!space)
- return 0;
- *p = *c;
- c++;
- p++;
- continue;
- }
-
- switch(*++c) {
- case 'Y': {
- chunk = snprintf(p, space, "%d", 1900 + tm->tm_year);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'm': {
- chunk = snprintf(p, space, "%.2d", tm->tm_mon + 1);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'd': {
- chunk = snprintf(p, space, "%.2d", tm->tm_mday);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'Z': {
- chunk = snprintf(p, space, "%s", "GMT");
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'H': {
- chunk = snprintf(p, space, "%.2i", tm->tm_hour);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'M': {
- chunk = snprintf(p, space, "%.2i", tm->tm_min);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'S': {
- chunk = snprintf(p, space, "%.2d", tm->tm_sec);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'R': {
- chunk = snprintf(p, space, "%.2i:%.2i", tm->tm_hour, tm->tm_min);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'T': {
- chunk = snprintf(p, space, "%.2i:%.2i:%.2i", tm->tm_hour, tm->tm_min, tm->tm_sec);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'F': {
- chunk = snprintf(p, space, "%d-%.2d-%.2d", 1900 + tm->tm_year, tm->tm_mon + 1,
- tm->tm_mday);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'D': {
- chunk = snprintf(p, space, "%.2d/%.2d/%.2d", tm->tm_mon + 1, tm->tm_mday, tm->tm_year % 100);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'a': {
- int day = tm->tm_wday;
- if(day < 0 || day > 6)
- __ensure(!"Day not in bounds.");
-
- chunk = snprintf(p, space, "%s", mlibc::nl_langinfo(ABDAY_1 + day));
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'b':
- case 'B':
- case 'h': {
- int mon = tm->tm_mon;
- if(mon < 0 || mon > 11)
- __ensure(!"Month not in bounds.");
-
- nl_item item = (*c == 'B') ? MON_1 : ABMON_1;
-
- chunk = snprintf(p, space, "%s", mlibc::nl_langinfo(item + mon));
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'c': {
- chunk = snprintf(p, space, "%d/%.2d/%.2d %.2d:%.2d:%.2d", 1900 + tm->tm_year,
- tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'e': {
- chunk = snprintf(p, space, "%2d", tm->tm_mday);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'l': {
- int hour = tm->tm_hour;
- if(!hour)
- hour = 12;
- if(hour > 12)
- hour -= 12;
- chunk = snprintf(p, space, "%2d", hour);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'I': {
- int hour = tm->tm_hour;
- if(!hour)
- hour = 12;
- if(hour > 12)
- hour -= 12;
- chunk = snprintf(p, space, "%.2d", hour);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'p': {
- chunk = snprintf(p, space, "%s", mlibc::nl_langinfo((tm->tm_hour < 12) ? AM_STR : PM_STR));
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'C': {
- chunk = snprintf(p, space, "%.2d", (1900 + tm->tm_year) / 100);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'y': {
- chunk = snprintf(p, space, "%.2d", (1900 + tm->tm_year) % 100);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'j': {
- chunk = snprintf(p, space, "%.3d", tm->tm_yday + 1);
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'A': {
- chunk = snprintf(p, space, "%s", mlibc::nl_langinfo(DAY_1 + tm->tm_wday));
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'r': {
- int hour = tm->tm_hour;
- if(!hour)
- hour = 12;
- if(hour > 12)
- hour -= 12;
- chunk = snprintf(p, space, "%.2i:%.2i:%.2i %s", hour, tm->tm_min, tm->tm_sec,
- mlibc::nl_langinfo((tm->tm_hour < 12) ? AM_STR : PM_STR));
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case '%': {
- chunk = snprintf(p, space, "%%");
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 't': {
- chunk = snprintf(p, space, "\t");
- if(chunk >= space)
- return 0;
- p += chunk;
- c++;
- break;
- }
- case 'x': {
- return strftime(dest, max_size, mlibc::nl_langinfo(D_FMT), tm);
- }
- case 'X': {
- return strftime(dest, max_size, mlibc::nl_langinfo(T_FMT), tm);
- }
- case '\0': {
- chunk = snprintf(p, space, "%%");
- if(chunk >= space)
- return 0;
- p += chunk;
- break;
- }
- default:
- mlibc::panicLogger() << "mlibc: strftime unknown format type: " << c << frg::endlog;
- }
- }
-
- auto space = (dest + max_size) - p;
- if(!space)
- return 0;
-
- *p = '\0';
- return (p - dest);
-}
-
-size_t wcsftime(wchar_t *__restrict, size_t, const wchar_t *__restrict,
- const struct tm *__restrict) {
- mlibc::infoLogger() << "mlibc: wcsftime is a stub" << frg::endlog;
- return 0;
-}
-
-namespace {
-
-struct tzfile {
- uint8_t magic[4];
- uint8_t version;
- uint8_t reserved[15];
- uint32_t tzh_ttisgmtcnt;
- uint32_t tzh_ttisstdcnt;
- uint32_t tzh_leapcnt;
- uint32_t tzh_timecnt;
- uint32_t tzh_typecnt;
- uint32_t tzh_charcnt;
-};
-
-struct[[gnu::packed]] ttinfo {
- int32_t tt_gmtoff;
- unsigned char tt_isdst;
- unsigned char tt_abbrind;
-};
-
-}
-
-// TODO(geert): this function doesn't parse the TZ environment variable
-// or properly handle the case where information might be missing from /etc/localtime
-// also we should probably unify the code for this and unix_local_from_gmt()
-void tzset(void) {
- frg::unique_lock<FutexLock> lock(__time_lock);
- // TODO(geert): we can probably cache this somehow
- tzfile tzfile_time;
- memcpy(&tzfile_time, reinterpret_cast<char *>(get_localtime_window()->get()), sizeof(tzfile));
- tzfile_time.tzh_ttisgmtcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_ttisgmtcnt);
- tzfile_time.tzh_ttisstdcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_ttisstdcnt);
- tzfile_time.tzh_leapcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_leapcnt);
- tzfile_time.tzh_timecnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_timecnt);
- tzfile_time.tzh_typecnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_typecnt);
- tzfile_time.tzh_charcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_charcnt);
-
- if(tzfile_time.magic[0] != 'T' || tzfile_time.magic[1] != 'Z' || tzfile_time.magic[2] != 'i'
- || tzfile_time.magic[3] != 'f') {
- mlibc::infoLogger() << "mlibc: /etc/localtime is not a valid TZinfo file" << frg::endlog;
- return;
- }
-
- if(tzfile_time.version != '\0' && tzfile_time.version != '2' && tzfile_time.version != '3') {
- mlibc::infoLogger() << "mlibc: /etc/localtime has an invalid TZinfo version"
- << frg::endlog;
- return;
- }
-
- // There should be at least one entry in the ttinfo table.
- // TODO: If there is not, we might want to fall back to UTC, no DST (?).
- __ensure(tzfile_time.tzh_typecnt);
-
- char *abbrevs = reinterpret_cast<char *>(get_localtime_window()->get()) + sizeof(tzfile)
- + tzfile_time.tzh_timecnt * sizeof(int32_t)
- + tzfile_time.tzh_timecnt * sizeof(uint8_t)
- + tzfile_time.tzh_typecnt * sizeof(struct ttinfo);
- // start from the last ttinfo entry, this matches the behaviour of glibc and musl
- for (int i = tzfile_time.tzh_typecnt; i > 0; i--) {
- ttinfo time_info;
- memcpy(&time_info, reinterpret_cast<char *>(get_localtime_window()->get()) + sizeof(tzfile)
- + tzfile_time.tzh_timecnt * sizeof(int32_t)
- + tzfile_time.tzh_timecnt * sizeof(uint8_t)
- + i * sizeof(ttinfo), sizeof(ttinfo));
- time_info.tt_gmtoff = mlibc::bit_util<uint32_t>::byteswap(time_info.tt_gmtoff);
- if (!time_info.tt_isdst && !tzname[0]) {
- tzname[0] = abbrevs + time_info.tt_abbrind;
- timezone = -time_info.tt_gmtoff;
- }
- if (time_info.tt_isdst && !tzname[1]) {
- tzname[1] = abbrevs + time_info.tt_abbrind;
- timezone = -time_info.tt_gmtoff;
- daylight = 1;
- }
- }
-}
-
-// POSIX extensions.
-
-int nanosleep(const struct timespec *req, struct timespec *) {
- if (req->tv_sec < 0 || req->tv_nsec > 999999999 || req->tv_nsec < 0) {
- errno = EINVAL;
- return -1;
- }
-
- if(!mlibc::sys_sleep) {
- MLIBC_MISSING_SYSDEP();
- __ensure(!"Cannot continue without sys_sleep()");
- }
-
- struct timespec tmp = *req;
-
- int e = mlibc::sys_sleep(&tmp.tv_sec, &tmp.tv_nsec);
- if (!e) {
- return 0;
- } else {
- errno = e;
- return -1;
- }
-}
-
-int clock_getres(clockid_t clockid, struct timespec *res) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_clock_getres, -1);
- if(int e = mlibc::sys_clock_getres(clockid, &res->tv_sec, &res->tv_nsec); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-int clock_gettime(clockid_t clock, struct timespec *time) {
- if(int e = mlibc::sys_clock_get(clock, &time->tv_sec, &time->tv_nsec); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-int clock_nanosleep(clockid_t clockid, int, const struct timespec *req, struct timespec *) {
- mlibc::infoLogger() << "clock_nanosleep is implemented as nanosleep!" << frg::endlog;
- __ensure(clockid == CLOCK_REALTIME || clockid == CLOCK_MONOTONIC);
- return nanosleep(req, nullptr);
-}
-
-int clock_settime(clockid_t, const struct timespec *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-time_t time(time_t *out) {
- time_t secs;
- long nanos;
- if(int e = mlibc::sys_clock_get(CLOCK_REALTIME, &secs, &nanos); e) {
- errno = e;
- return (time_t)-1;
- }
- if(out)
- *out = secs;
- return secs;
-}
-
-namespace {
-
-void civil_from_days(time_t days_since_epoch, int *year, unsigned int *month, unsigned int *day) {
- time_t time = days_since_epoch + 719468;
- int era = (time >= 0 ? time : time - 146096) / 146097;
- unsigned int doe = static_cast<unsigned int>(time - era * 146097);
- unsigned int yoe = (doe - doe/1460 + doe/36524 - doe/146096) / 365;
- int y = static_cast<int>(yoe) + era * 400;
- unsigned int doy = doe - (365*yoe + yoe/4 - yoe/100);
- unsigned int mp = (5*doy + 2)/153;
- unsigned int d = doy - (153*mp+2)/5 + 1;
- unsigned int m = mp + (mp < 10 ? 3 : -9);
-
- *year = y + (m <= 2);
- *month = m;
- *day = d;
-}
-
-void weekday_from_days(time_t days_since_epoch, unsigned int *weekday) {
- *weekday = static_cast<unsigned int>(days_since_epoch >= -4 ?
- (days_since_epoch+4) % 7 : (days_since_epoch+5) % 7 + 6);
-}
-
-void yearday_from_date(unsigned int year, unsigned int month, unsigned int day, unsigned int *yday) {
- unsigned int n1 = 275 * month / 9;
- unsigned int n2 = (month + 9) / 12;
- unsigned int n3 = (1 + (year - 4 * year / 4 + 2) / 3);
- *yday = n1 - (n2 * n3) + day - 30;
-}
-
-// Looks up the local time rules for a given
-// UNIX GMT timestamp (seconds since 1970 GMT, ignoring leap seconds).
-// This function assumes the __time_lock has been taken
-// TODO(geert): if /etc/localtime isn't available this will fail... In that case
-// we should call tzset() and use the variables to compute the variables from
-// the tzset() global variables. Look at the musl code for how to do that
-int unix_local_from_gmt(time_t unix_gmt, time_t *offset, bool *dst, char **tm_zone) {
- tzfile tzfile_time;
- memcpy(&tzfile_time, reinterpret_cast<char *>(get_localtime_window()->get()), sizeof(tzfile));
- tzfile_time.tzh_ttisgmtcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_ttisgmtcnt);
- tzfile_time.tzh_ttisstdcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_ttisstdcnt);
- tzfile_time.tzh_leapcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_leapcnt);
- tzfile_time.tzh_timecnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_timecnt);
- tzfile_time.tzh_typecnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_typecnt);
- tzfile_time.tzh_charcnt = mlibc::bit_util<uint32_t>::byteswap(tzfile_time.tzh_charcnt);
-
- if(tzfile_time.magic[0] != 'T' || tzfile_time.magic[1] != 'Z' || tzfile_time.magic[2] != 'i'
- || tzfile_time.magic[3] != 'f') {
- mlibc::infoLogger() << "mlibc: /etc/localtime is not a valid TZinfo file" << frg::endlog;
- return -1;
- }
-
- if(tzfile_time.version != '\0' && tzfile_time.version != '2' && tzfile_time.version != '3') {
- mlibc::infoLogger() << "mlibc: /etc/localtime has an invalid TZinfo version"
- << frg::endlog;
- return -1;
- }
-
- int index = -1;
- for(size_t i = 0; i < tzfile_time.tzh_timecnt; i++) {
- int32_t ttime;
- memcpy(&ttime, reinterpret_cast<char *>(get_localtime_window()->get()) + sizeof(tzfile)
- + i * sizeof(int32_t), sizeof(int32_t));
- ttime = mlibc::bit_util<uint32_t>::byteswap(ttime);
- // If we are before the first transition, the format dicates that
- // the first ttinfo entry should be used (and not the ttinfo entry pointed
- // to by the first transition time).
- if(i && ttime > unix_gmt) {
- index = i - 1;
- break;
- }
- }
-
- // The format dictates that if no transition is applicable,
- // the first entry in the file is chosen.
- uint8_t ttinfo_index = 0;
- if(index >= 0) {
- memcpy(&ttinfo_index, reinterpret_cast<char *>(get_localtime_window()->get()) + sizeof(tzfile)
- + tzfile_time.tzh_timecnt * sizeof(int32_t)
- + index * sizeof(uint8_t), sizeof(uint8_t));
- }
-
- // There should be at least one entry in the ttinfo table.
- // TODO: If there is not, we might want to fall back to UTC, no DST (?).
- __ensure(tzfile_time.tzh_typecnt);
-
- ttinfo time_info;
- memcpy(&time_info, reinterpret_cast<char *>(get_localtime_window()->get()) + sizeof(tzfile)
- + tzfile_time.tzh_timecnt * sizeof(int32_t)
- + tzfile_time.tzh_timecnt * sizeof(uint8_t)
- + ttinfo_index * sizeof(ttinfo), sizeof(ttinfo));
- time_info.tt_gmtoff = mlibc::bit_util<uint32_t>::byteswap(time_info.tt_gmtoff);
-
- char *abbrevs = reinterpret_cast<char *>(get_localtime_window()->get()) + sizeof(tzfile)
- + tzfile_time.tzh_timecnt * sizeof(int32_t)
- + tzfile_time.tzh_timecnt * sizeof(uint8_t)
- + tzfile_time.tzh_typecnt * sizeof(struct ttinfo);
-
- *offset = time_info.tt_gmtoff;
- *dst = time_info.tt_isdst;
- *tm_zone = abbrevs + time_info.tt_abbrind;
- return 0;
-}
-
-} //anonymous namespace
-
-struct tm *gmtime_r(const time_t *unix_gmt, struct tm *res) {
- int year;
- unsigned int month;
- unsigned int day;
- unsigned int weekday;
- unsigned int yday;
-
- time_t unix_local = *unix_gmt;
-
- int days_since_epoch = unix_local / (60*60*24);
- civil_from_days(days_since_epoch, &year, &month, &day);
- weekday_from_days(days_since_epoch, &weekday);
- yearday_from_date(year, month, day, &yday);
-
- res->tm_sec = unix_local % 60;
- res->tm_min = (unix_local / 60) % 60;
- res->tm_hour = (unix_local / (60*60)) % 24;
- res->tm_mday = day;
- res->tm_mon = month - 1;
- res->tm_year = year - 1900;
- res->tm_wday = weekday;
- res->tm_yday = yday - 1;
- res->tm_isdst = -1;
- res->tm_zone = __utc;
- res->tm_gmtoff = 0;
-
- return res;
-}
-
-struct tm *localtime_r(const time_t *unix_gmt, struct tm *res) {
- int year;
- unsigned int month;
- unsigned int day;
- unsigned int weekday;
- unsigned int yday;
-
- time_t offset = 0;
- bool dst;
- char *tm_zone;
- frg::unique_lock<FutexLock> lock(__time_lock);
- // TODO: Set errno if the conversion fails.
- if(unix_local_from_gmt(*unix_gmt, &offset, &dst, &tm_zone)) {
- __ensure(!"Error parsing /etc/localtime");
- __builtin_unreachable();
- }
- time_t unix_local = *unix_gmt + offset;
-
- int days_since_epoch = unix_local / (60*60*24);
- civil_from_days(days_since_epoch, &year, &month, &day);
- weekday_from_days(days_since_epoch, &weekday);
- yearday_from_date(year, month, day, &yday);
-
- res->tm_sec = unix_local % 60;
- res->tm_min = (unix_local / 60) % 60;
- res->tm_hour = (unix_local / (60*60)) % 24;
- res->tm_mday = day;
- res->tm_mon = month - 1;
- res->tm_year = year - 1900;
- res->tm_wday = weekday;
- res->tm_yday = yday - 1;
- res->tm_isdst = dst;
- res->tm_zone = tm_zone;
- res->tm_gmtoff = offset;
-
- return res;
-}
-
-// This implementation of asctime_r is taken from sortix
-char *asctime_r(const struct tm *tm, char *buf) {
- static char weekday_names[7][4] =
- { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
- static char month_names[12][4] =
- { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
- "Nov", "Dec" };
- sprintf(buf, "%.3s %.3s%3d %.2d:%.2d%.2d %d\n",
- weekday_names[tm->tm_wday],
- month_names[tm->tm_mon],
- tm->tm_mday,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec,
- tm->tm_year + 1900);
- return buf;
-}
-
-char *ctime_r(const time_t *clock, char *buf) {
- return asctime_r(localtime(clock), buf);
-}
-
-time_t timelocal(struct tm *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-constexpr static int days_from_civil(int y, unsigned m, unsigned d) noexcept {
- y -= m <= 2;
- const int era = (y >= 0 ? y : y - 399) / 400;
- const unsigned yoe = static_cast<unsigned>(y - era * 400); // [0, 399]
- const unsigned doy = (153 * (m > 2 ? m - 3 : m + 9) + 2) / 5 + d - 1; // [0, 365]
- const unsigned doe = yoe * 365 + yoe / 4 - yoe / 100 + doy; // [0, 146096]
- return era * 146097 + static_cast<int>(doe) - 719468;
-}
-
-time_t timegm(struct tm *tm) {
- time_t year = tm->tm_year + 1900;
- time_t month = tm->tm_mon + 1;
- time_t days = days_from_civil(year, month, tm->tm_mday);
- time_t secs = (days * 86400) + (tm->tm_hour * 60 * 60) + (tm->tm_min * 60) + tm->tm_sec;
- return secs;
-}
diff --git a/lib/mlibc/options/ansi/generic/uchar.cpp b/lib/mlibc/options/ansi/generic/uchar.cpp
deleted file mode 100644
index cb13c12..0000000
--- a/lib/mlibc/options/ansi/generic/uchar.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <bits/ensure.h>
-#include <uchar.h>
-#include <wchar.h>
-
-size_t c32rtomb(char *, char32_t, mbstate_t *) MLIBC_STUB_BODY
-
-size_t mbrtoc32(char32_t *__restrict pc32, const char *__restrict pmb, size_t max, mbstate_t *__restrict ps) {
- static mbstate_t internal_state;
-
- if(!ps)
- ps = &internal_state;
-
- if(!pmb)
- return mbrtoc32(0, "", 1, ps);
-
- wchar_t wc;
- size_t ret = mbrtowc(&wc, pmb, max, ps);
-
- if (ret <= 4 && pc32)
- *pc32 = wc;
-
- return ret;
-}
diff --git a/lib/mlibc/options/ansi/generic/wchar-stubs.cpp b/lib/mlibc/options/ansi/generic/wchar-stubs.cpp
deleted file mode 100644
index d9f6598..0000000
--- a/lib/mlibc/options/ansi/generic/wchar-stubs.cpp
+++ /dev/null
@@ -1,783 +0,0 @@
-
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <wchar.h>
-#include <wctype.h>
-#include <bits/ensure.h>
-
-#include <mlibc/charcode.hpp>
-#include <mlibc/debug.hpp>
-
-namespace {
- // All conversion functions mbrlen(), mbrtowc(), wcrtomb(),
- // mbsrtowcs() and wcsrtombs() have an internal state.
- __mlibc_mbstate mbrlen_state = __MLIBC_MBSTATE_INITIALIZER;
- __mlibc_mbstate mbrtowc_state = __MLIBC_MBSTATE_INITIALIZER;
- __mlibc_mbstate mbsrtowcs_state = __MLIBC_MBSTATE_INITIALIZER;
- __mlibc_mbstate wcsrtombs_state = __MLIBC_MBSTATE_INITIALIZER;
-}
-
-wint_t btowc(int c) {
- if(c == EOF)
- return WEOF;
-
- char nc = c;
- auto cc = mlibc::current_charcode();
- wchar_t wc;
- if(auto e = cc->promote_wtranscode(nc, wc); e != mlibc::charcode_error::null)
- return WEOF;
- return wc;
-}
-
-int wctob(wint_t wc) {
- // TODO: Revisit this once we have character encoding functions.
- return wc;
-}
-
-int mbsinit(const mbstate_t *stp) {
- if(!stp)
- return -1;
- return !stp->__progress && !stp->__shift;
-}
-
-size_t mbrlen(const char *mbs, size_t mb_limit, mbstate_t *stp) {
- auto cc = mlibc::current_charcode();
- wchar_t wc;
-
- if(!stp)
- stp = &mbrlen_state;
- if(!mbs) {
- *stp = __MLIBC_MBSTATE_INITIALIZER;
- return 0;
- }
-
- mlibc::code_seq<const char> nseq{mbs, mbs + mb_limit};
- mlibc::code_seq<wchar_t> wseq{&wc, &wc + 1};
- if(auto e = cc->decode_wtranscode(nseq, wseq, *stp); e != mlibc::charcode_error::null)
- __ensure(!"decode_wtranscode() errors are not handled");
- return nseq.it - mbs;
-}
-
-size_t mbrtowc(wchar_t *wcp, const char *mbs, size_t mb_limit, mbstate_t *stp) {
- auto cc = mlibc::current_charcode();
-
- if(!stp)
- stp = &mbrtowc_state;
- if(!mbs) {
- *stp = __MLIBC_MBSTATE_INITIALIZER;
- return 0;
- }
-
- wchar_t temp = 0;
- if(!wcp)
- wcp = &temp;
-
- mlibc::code_seq<const char> nseq{mbs, mbs + mb_limit};
- mlibc::code_seq<wchar_t> wseq{wcp, wcp + 1};
- if(auto e = cc->decode_wtranscode(nseq, wseq, *stp); e != mlibc::charcode_error::null) {
- if(e == mlibc::charcode_error::input_underflow)
- return static_cast<size_t>(-2);
- __ensure(e == mlibc::charcode_error::illegal_input);
- errno = EILSEQ;
- return static_cast<size_t>(-1);
- }else{
- if (*mbs) {
- return nseq.it - mbs;
- } else {
- *stp = __MLIBC_MBSTATE_INITIALIZER;
- *wcp = 0;
- return 0;
- }
- }
-}
-
-size_t wcrtomb(char *mbs, wchar_t wc, mbstate_t *stp) {
- auto cc = mlibc::current_charcode();
-
- // wcrtomb() always takes a mbstate_t.
- __ensure(stp);
-
- // TODO: Implement the following case:
- __ensure(mbs);
-
- mlibc::code_seq<const wchar_t> wseq{&wc, &wc + 1};
- mlibc::code_seq<char> nseq{mbs, mbs + 4}; // TODO: Replace 4 by some named constant.
- if(auto e = cc->encode_wtranscode(nseq, wseq, *stp); e != mlibc::charcode_error::null) {
- __ensure(!"encode_wtranscode() errors are not handled");
- __builtin_unreachable();
- }else{
- size_t n = nseq.it - mbs;
- if(!n) // Null-terminate resulting wide string.
- *mbs = 0;
- return n;
- }
-}
-
-size_t mbsrtowcs(wchar_t *wcs, const char **mbsp, size_t wc_limit, mbstate_t *stp) {
- __ensure(mbsp);
-
- auto cc = mlibc::current_charcode();
- __mlibc_mbstate st = __MLIBC_MBSTATE_INITIALIZER;
- mlibc::code_seq<const char> nseq{*mbsp, nullptr};
- mlibc::code_seq<wchar_t> wseq{wcs, wcs + wc_limit};
-
- if(!stp)
- stp = &mbsrtowcs_state;
-
- if(!wcs) {
- size_t size;
- if(auto e = cc->decode_wtranscode_length(nseq, &size, st); e != mlibc::charcode_error::null)
- __ensure(!"decode_wtranscode() errors are not handled");
- return size;
- }
-
- if(auto e = cc->decode_wtranscode(nseq, wseq, st); e != mlibc::charcode_error::null) {
- __ensure(!"decode_wtranscode() errors are not handled");
- __builtin_unreachable();
- }else{
- size_t n = wseq.it - wcs;
- if(n < wc_limit) // Null-terminate resulting wide string.
- wcs[n] = 0;
- *mbsp = nullptr;
- return n;
- }
-}
-
-size_t mbsnrtowcs(wchar_t *wcs, const char **mbsp, size_t mb_limit, size_t wc_limit, mbstate_t *stp) {
- __ensure(mbsp);
-
- auto cc = mlibc::current_charcode();
- __mlibc_mbstate st = __MLIBC_MBSTATE_INITIALIZER;
- mlibc::code_seq<const char> nseq{*mbsp, (*mbsp) + mb_limit};
- mlibc::code_seq<wchar_t> wseq{wcs, wcs + wc_limit};
-
- if(!stp)
- stp = &mbsrtowcs_state;
-
- if(!wcs) {
- size_t size;
- if(auto e = cc->decode_wtranscode_length(nseq, &size, st); e != mlibc::charcode_error::null)
- __ensure(!"decode_wtranscode() errors are not handled");
- return size;
- }
-
- if(auto e = cc->decode_wtranscode(nseq, wseq, st); e != mlibc::charcode_error::null) {
- __ensure(!"decode_wtranscode() errors are not handled");
- __builtin_unreachable();
- }else{
- size_t n = wseq.it - wcs;
- if(n < wc_limit) // Null-terminate resulting wide string.
- wcs[n] = 0;
- *mbsp = nullptr;
- return n;
- }
-}
-
-size_t wcsrtombs(char *mbs, const wchar_t **wcsp, size_t mb_limit, mbstate_t *stp) {
- __ensure(wcsp && "wcsrtombs() with null input");
- auto cc = mlibc::current_charcode();
- mlibc::code_seq<char> nseq{mbs, mbs + mb_limit};
- mlibc::code_seq<const wchar_t> wseq{*wcsp, nullptr};
-
- if(!stp)
- stp = &wcsrtombs_state;
-
- if(!mbs) {
- size_t size;
- if(auto e = cc->encode_wtranscode_length(wseq, &size, *stp); e != mlibc::charcode_error::null)
- __ensure(!"decode_wtranscode() errors are not handled");
- return size;
- }
-
- if(auto e = cc->encode_wtranscode(nseq, wseq, *stp); e != mlibc::charcode_error::null) {
- __ensure(!"encode_wtranscode() errors are not handled");
- __builtin_unreachable();
- }else{
- *wcsp = wseq.it;
- size_t n = nseq.it - mbs;
- if(n < mb_limit) // Null-terminate resulting narrow string.
- mbs[n] = 0;
- return n;
- }
-}
-
-size_t wcsnrtombs(char *mbs, const wchar_t **wcsp, size_t wc_limit, size_t mb_limit, mbstate_t *stp) {
- __ensure(wcsp && "wcsrtombs() with null input");
- auto cc = mlibc::current_charcode();
- mlibc::code_seq<char> nseq{mbs, mbs + mb_limit};
- mlibc::code_seq<const wchar_t> wseq{*wcsp, (*wcsp) + wc_limit};
-
- if(!stp)
- stp = &wcsrtombs_state;
-
- if(!mbs) {
- size_t size;
- if(auto e = cc->encode_wtranscode_length(wseq, &size, *stp); e != mlibc::charcode_error::null)
- __ensure(!"decode_wtranscode() errors are not handled");
- return size;
- }
-
- if(auto e = cc->encode_wtranscode(nseq, wseq, *stp); e != mlibc::charcode_error::null) {
- __ensure(!"encode_wtranscode() errors are not handled");
- __builtin_unreachable();
- }else{
- *wcsp = wseq.it;
- size_t n = nseq.it - mbs;
- if(n < mb_limit) // Null-terminate resulting narrow string.
- mbs[n] = 0;
- return n;
- }
-}
-
-/*
- * The code in this anonymous namespace and the wcwidth function below
- * are taken from https://github.com/termux/wcwidth/, under the following license:
- *
- * Copyright (C) Fredrik Fornwall 2016.
- * Distributed under the MIT License.
- *
- * Implementation of wcwidth(3) as a C port of:
- * https://github.com/jquast/wcwidth
- *
- * Report issues at:
- * https://github.com/termux/wcwidth
- */
-
-namespace {
-
-struct width_interval {
- int start;
- int end;
-};
-
-// From https://github.com/jquast/wcwidth/blob/master/wcwidth/table_zero.py
-// at commit b29897e5a1b403a0e36f7fc991614981cbc42475 (2020-07-14):
-struct width_interval ZERO_WIDTH[] = {
- {0x00300, 0x0036f}, // Combining Grave Accent ..Combining Latin Small Le
- {0x00483, 0x00489}, // Combining Cyrillic Titlo..Combining Cyrillic Milli
- {0x00591, 0x005bd}, // Hebrew Accent Etnahta ..Hebrew Point Meteg
- {0x005bf, 0x005bf}, // Hebrew Point Rafe ..Hebrew Point Rafe
- {0x005c1, 0x005c2}, // Hebrew Point Shin Dot ..Hebrew Point Sin Dot
- {0x005c4, 0x005c5}, // Hebrew Mark Upper Dot ..Hebrew Mark Lower Dot
- {0x005c7, 0x005c7}, // Hebrew Point Qamats Qata..Hebrew Point Qamats Qata
- {0x00610, 0x0061a}, // Arabic Sign Sallallahou ..Arabic Small Kasra
- {0x0064b, 0x0065f}, // Arabic Fathatan ..Arabic Wavy Hamza Below
- {0x00670, 0x00670}, // Arabic Letter Superscrip..Arabic Letter Superscrip
- {0x006d6, 0x006dc}, // Arabic Small High Ligatu..Arabic Small High Seen
- {0x006df, 0x006e4}, // Arabic Small High Rounde..Arabic Small High Madda
- {0x006e7, 0x006e8}, // Arabic Small High Yeh ..Arabic Small High Noon
- {0x006ea, 0x006ed}, // Arabic Empty Centre Low ..Arabic Small Low Meem
- {0x00711, 0x00711}, // Syriac Letter Superscrip..Syriac Letter Superscrip
- {0x00730, 0x0074a}, // Syriac Pthaha Above ..Syriac Barrekh
- {0x007a6, 0x007b0}, // Thaana Abafili ..Thaana Sukun
- {0x007eb, 0x007f3}, // Nko Combining Short High..Nko Combining Double Dot
- {0x007fd, 0x007fd}, // Nko Dantayalan ..Nko Dantayalan
- {0x00816, 0x00819}, // Samaritan Mark In ..Samaritan Mark Dagesh
- {0x0081b, 0x00823}, // Samaritan Mark Epentheti..Samaritan Vowel Sign A
- {0x00825, 0x00827}, // Samaritan Vowel Sign Sho..Samaritan Vowel Sign U
- {0x00829, 0x0082d}, // Samaritan Vowel Sign Lon..Samaritan Mark Nequdaa
- {0x00859, 0x0085b}, // Mandaic Affrication Mark..Mandaic Gemination Mark
- {0x008d3, 0x008e1}, // Arabic Small Low Waw ..Arabic Small High Sign S
- {0x008e3, 0x00902}, // Arabic Turned Damma Belo..Devanagari Sign Anusvara
- {0x0093a, 0x0093a}, // Devanagari Vowel Sign Oe..Devanagari Vowel Sign Oe
- {0x0093c, 0x0093c}, // Devanagari Sign Nukta ..Devanagari Sign Nukta
- {0x00941, 0x00948}, // Devanagari Vowel Sign U ..Devanagari Vowel Sign Ai
- {0x0094d, 0x0094d}, // Devanagari Sign Virama ..Devanagari Sign Virama
- {0x00951, 0x00957}, // Devanagari Stress Sign U..Devanagari Vowel Sign Uu
- {0x00962, 0x00963}, // Devanagari Vowel Sign Vo..Devanagari Vowel Sign Vo
- {0x00981, 0x00981}, // Bengali Sign Candrabindu..Bengali Sign Candrabindu
- {0x009bc, 0x009bc}, // Bengali Sign Nukta ..Bengali Sign Nukta
- {0x009c1, 0x009c4}, // Bengali Vowel Sign U ..Bengali Vowel Sign Vocal
- {0x009cd, 0x009cd}, // Bengali Sign Virama ..Bengali Sign Virama
- {0x009e2, 0x009e3}, // Bengali Vowel Sign Vocal..Bengali Vowel Sign Vocal
- {0x009fe, 0x009fe}, // Bengali Sandhi Mark ..Bengali Sandhi Mark
- {0x00a01, 0x00a02}, // Gurmukhi Sign Adak Bindi..Gurmukhi Sign Bindi
- {0x00a3c, 0x00a3c}, // Gurmukhi Sign Nukta ..Gurmukhi Sign Nukta
- {0x00a41, 0x00a42}, // Gurmukhi Vowel Sign U ..Gurmukhi Vowel Sign Uu
- {0x00a47, 0x00a48}, // Gurmukhi Vowel Sign Ee ..Gurmukhi Vowel Sign Ai
- {0x00a4b, 0x00a4d}, // Gurmukhi Vowel Sign Oo ..Gurmukhi Sign Virama
- {0x00a51, 0x00a51}, // Gurmukhi Sign Udaat ..Gurmukhi Sign Udaat
- {0x00a70, 0x00a71}, // Gurmukhi Tippi ..Gurmukhi Addak
- {0x00a75, 0x00a75}, // Gurmukhi Sign Yakash ..Gurmukhi Sign Yakash
- {0x00a81, 0x00a82}, // Gujarati Sign Candrabind..Gujarati Sign Anusvara
- {0x00abc, 0x00abc}, // Gujarati Sign Nukta ..Gujarati Sign Nukta
- {0x00ac1, 0x00ac5}, // Gujarati Vowel Sign U ..Gujarati Vowel Sign Cand
- {0x00ac7, 0x00ac8}, // Gujarati Vowel Sign E ..Gujarati Vowel Sign Ai
- {0x00acd, 0x00acd}, // Gujarati Sign Virama ..Gujarati Sign Virama
- {0x00ae2, 0x00ae3}, // Gujarati Vowel Sign Voca..Gujarati Vowel Sign Voca
- {0x00afa, 0x00aff}, // Gujarati Sign Sukun ..Gujarati Sign Two-circle
- {0x00b01, 0x00b01}, // Oriya Sign Candrabindu ..Oriya Sign Candrabindu
- {0x00b3c, 0x00b3c}, // Oriya Sign Nukta ..Oriya Sign Nukta
- {0x00b3f, 0x00b3f}, // Oriya Vowel Sign I ..Oriya Vowel Sign I
- {0x00b41, 0x00b44}, // Oriya Vowel Sign U ..Oriya Vowel Sign Vocalic
- {0x00b4d, 0x00b4d}, // Oriya Sign Virama ..Oriya Sign Virama
- {0x00b55, 0x00b56}, // (nil) ..Oriya Ai Length Mark
- {0x00b62, 0x00b63}, // Oriya Vowel Sign Vocalic..Oriya Vowel Sign Vocalic
- {0x00b82, 0x00b82}, // Tamil Sign Anusvara ..Tamil Sign Anusvara
- {0x00bc0, 0x00bc0}, // Tamil Vowel Sign Ii ..Tamil Vowel Sign Ii
- {0x00bcd, 0x00bcd}, // Tamil Sign Virama ..Tamil Sign Virama
- {0x00c00, 0x00c00}, // Telugu Sign Combining Ca..Telugu Sign Combining Ca
- {0x00c04, 0x00c04}, // Telugu Sign Combining An..Telugu Sign Combining An
- {0x00c3e, 0x00c40}, // Telugu Vowel Sign Aa ..Telugu Vowel Sign Ii
- {0x00c46, 0x00c48}, // Telugu Vowel Sign E ..Telugu Vowel Sign Ai
- {0x00c4a, 0x00c4d}, // Telugu Vowel Sign O ..Telugu Sign Virama
- {0x00c55, 0x00c56}, // Telugu Length Mark ..Telugu Ai Length Mark
- {0x00c62, 0x00c63}, // Telugu Vowel Sign Vocali..Telugu Vowel Sign Vocali
- {0x00c81, 0x00c81}, // Kannada Sign Candrabindu..Kannada Sign Candrabindu
- {0x00cbc, 0x00cbc}, // Kannada Sign Nukta ..Kannada Sign Nukta
- {0x00cbf, 0x00cbf}, // Kannada Vowel Sign I ..Kannada Vowel Sign I
- {0x00cc6, 0x00cc6}, // Kannada Vowel Sign E ..Kannada Vowel Sign E
- {0x00ccc, 0x00ccd}, // Kannada Vowel Sign Au ..Kannada Sign Virama
- {0x00ce2, 0x00ce3}, // Kannada Vowel Sign Vocal..Kannada Vowel Sign Vocal
- {0x00d00, 0x00d01}, // Malayalam Sign Combining..Malayalam Sign Candrabin
- {0x00d3b, 0x00d3c}, // Malayalam Sign Vertical ..Malayalam Sign Circular
- {0x00d41, 0x00d44}, // Malayalam Vowel Sign U ..Malayalam Vowel Sign Voc
- {0x00d4d, 0x00d4d}, // Malayalam Sign Virama ..Malayalam Sign Virama
- {0x00d62, 0x00d63}, // Malayalam Vowel Sign Voc..Malayalam Vowel Sign Voc
- {0x00d81, 0x00d81}, // (nil) ..(nil)
- {0x00dca, 0x00dca}, // Sinhala Sign Al-lakuna ..Sinhala Sign Al-lakuna
- {0x00dd2, 0x00dd4}, // Sinhala Vowel Sign Ketti..Sinhala Vowel Sign Ketti
- {0x00dd6, 0x00dd6}, // Sinhala Vowel Sign Diga ..Sinhala Vowel Sign Diga
- {0x00e31, 0x00e31}, // Thai Character Mai Han-a..Thai Character Mai Han-a
- {0x00e34, 0x00e3a}, // Thai Character Sara I ..Thai Character Phinthu
- {0x00e47, 0x00e4e}, // Thai Character Maitaikhu..Thai Character Yamakkan
- {0x00eb1, 0x00eb1}, // Lao Vowel Sign Mai Kan ..Lao Vowel Sign Mai Kan
- {0x00eb4, 0x00ebc}, // Lao Vowel Sign I ..Lao Semivowel Sign Lo
- {0x00ec8, 0x00ecd}, // Lao Tone Mai Ek ..Lao Niggahita
- {0x00f18, 0x00f19}, // Tibetan Astrological Sig..Tibetan Astrological Sig
- {0x00f35, 0x00f35}, // Tibetan Mark Ngas Bzung ..Tibetan Mark Ngas Bzung
- {0x00f37, 0x00f37}, // Tibetan Mark Ngas Bzung ..Tibetan Mark Ngas Bzung
- {0x00f39, 0x00f39}, // Tibetan Mark Tsa -phru ..Tibetan Mark Tsa -phru
- {0x00f71, 0x00f7e}, // Tibetan Vowel Sign Aa ..Tibetan Sign Rjes Su Nga
- {0x00f80, 0x00f84}, // Tibetan Vowel Sign Rever..Tibetan Mark Halanta
- {0x00f86, 0x00f87}, // Tibetan Sign Lci Rtags ..Tibetan Sign Yang Rtags
- {0x00f8d, 0x00f97}, // Tibetan Subjoined Sign L..Tibetan Subjoined Letter
- {0x00f99, 0x00fbc}, // Tibetan Subjoined Letter..Tibetan Subjoined Letter
- {0x00fc6, 0x00fc6}, // Tibetan Symbol Padma Gda..Tibetan Symbol Padma Gda
- {0x0102d, 0x01030}, // Myanmar Vowel Sign I ..Myanmar Vowel Sign Uu
- {0x01032, 0x01037}, // Myanmar Vowel Sign Ai ..Myanmar Sign Dot Below
- {0x01039, 0x0103a}, // Myanmar Sign Virama ..Myanmar Sign Asat
- {0x0103d, 0x0103e}, // Myanmar Consonant Sign M..Myanmar Consonant Sign M
- {0x01058, 0x01059}, // Myanmar Vowel Sign Vocal..Myanmar Vowel Sign Vocal
- {0x0105e, 0x01060}, // Myanmar Consonant Sign M..Myanmar Consonant Sign M
- {0x01071, 0x01074}, // Myanmar Vowel Sign Geba ..Myanmar Vowel Sign Kayah
- {0x01082, 0x01082}, // Myanmar Consonant Sign S..Myanmar Consonant Sign S
- {0x01085, 0x01086}, // Myanmar Vowel Sign Shan ..Myanmar Vowel Sign Shan
- {0x0108d, 0x0108d}, // Myanmar Sign Shan Counci..Myanmar Sign Shan Counci
- {0x0109d, 0x0109d}, // Myanmar Vowel Sign Aiton..Myanmar Vowel Sign Aiton
- {0x0135d, 0x0135f}, // Ethiopic Combining Gemin..Ethiopic Combining Gemin
- {0x01712, 0x01714}, // Tagalog Vowel Sign I ..Tagalog Sign Virama
- {0x01732, 0x01734}, // Hanunoo Vowel Sign I ..Hanunoo Sign Pamudpod
- {0x01752, 0x01753}, // Buhid Vowel Sign I ..Buhid Vowel Sign U
- {0x01772, 0x01773}, // Tagbanwa Vowel Sign I ..Tagbanwa Vowel Sign U
- {0x017b4, 0x017b5}, // Khmer Vowel Inherent Aq ..Khmer Vowel Inherent Aa
- {0x017b7, 0x017bd}, // Khmer Vowel Sign I ..Khmer Vowel Sign Ua
- {0x017c6, 0x017c6}, // Khmer Sign Nikahit ..Khmer Sign Nikahit
- {0x017c9, 0x017d3}, // Khmer Sign Muusikatoan ..Khmer Sign Bathamasat
- {0x017dd, 0x017dd}, // Khmer Sign Atthacan ..Khmer Sign Atthacan
- {0x0180b, 0x0180d}, // Mongolian Free Variation..Mongolian Free Variation
- {0x01885, 0x01886}, // Mongolian Letter Ali Gal..Mongolian Letter Ali Gal
- {0x018a9, 0x018a9}, // Mongolian Letter Ali Gal..Mongolian Letter Ali Gal
- {0x01920, 0x01922}, // Limbu Vowel Sign A ..Limbu Vowel Sign U
- {0x01927, 0x01928}, // Limbu Vowel Sign E ..Limbu Vowel Sign O
- {0x01932, 0x01932}, // Limbu Small Letter Anusv..Limbu Small Letter Anusv
- {0x01939, 0x0193b}, // Limbu Sign Mukphreng ..Limbu Sign Sa-i
- {0x01a17, 0x01a18}, // Buginese Vowel Sign I ..Buginese Vowel Sign U
- {0x01a1b, 0x01a1b}, // Buginese Vowel Sign Ae ..Buginese Vowel Sign Ae
- {0x01a56, 0x01a56}, // Tai Tham Consonant Sign ..Tai Tham Consonant Sign
- {0x01a58, 0x01a5e}, // Tai Tham Sign Mai Kang L..Tai Tham Consonant Sign
- {0x01a60, 0x01a60}, // Tai Tham Sign Sakot ..Tai Tham Sign Sakot
- {0x01a62, 0x01a62}, // Tai Tham Vowel Sign Mai ..Tai Tham Vowel Sign Mai
- {0x01a65, 0x01a6c}, // Tai Tham Vowel Sign I ..Tai Tham Vowel Sign Oa B
- {0x01a73, 0x01a7c}, // Tai Tham Vowel Sign Oa A..Tai Tham Sign Khuen-lue
- {0x01a7f, 0x01a7f}, // Tai Tham Combining Crypt..Tai Tham Combining Crypt
- {0x01ab0, 0x01ac0}, // Combining Doubled Circum..(nil)
- {0x01b00, 0x01b03}, // Balinese Sign Ulu Ricem ..Balinese Sign Surang
- {0x01b34, 0x01b34}, // Balinese Sign Rerekan ..Balinese Sign Rerekan
- {0x01b36, 0x01b3a}, // Balinese Vowel Sign Ulu ..Balinese Vowel Sign Ra R
- {0x01b3c, 0x01b3c}, // Balinese Vowel Sign La L..Balinese Vowel Sign La L
- {0x01b42, 0x01b42}, // Balinese Vowel Sign Pepe..Balinese Vowel Sign Pepe
- {0x01b6b, 0x01b73}, // Balinese Musical Symbol ..Balinese Musical Symbol
- {0x01b80, 0x01b81}, // Sundanese Sign Panyecek ..Sundanese Sign Panglayar
- {0x01ba2, 0x01ba5}, // Sundanese Consonant Sign..Sundanese Vowel Sign Pan
- {0x01ba8, 0x01ba9}, // Sundanese Vowel Sign Pam..Sundanese Vowel Sign Pan
- {0x01bab, 0x01bad}, // Sundanese Sign Virama ..Sundanese Consonant Sign
- {0x01be6, 0x01be6}, // Batak Sign Tompi ..Batak Sign Tompi
- {0x01be8, 0x01be9}, // Batak Vowel Sign Pakpak ..Batak Vowel Sign Ee
- {0x01bed, 0x01bed}, // Batak Vowel Sign Karo O ..Batak Vowel Sign Karo O
- {0x01bef, 0x01bf1}, // Batak Vowel Sign U For S..Batak Consonant Sign H
- {0x01c2c, 0x01c33}, // Lepcha Vowel Sign E ..Lepcha Consonant Sign T
- {0x01c36, 0x01c37}, // Lepcha Sign Ran ..Lepcha Sign Nukta
- {0x01cd0, 0x01cd2}, // Vedic Tone Karshana ..Vedic Tone Prenkha
- {0x01cd4, 0x01ce0}, // Vedic Sign Yajurvedic Mi..Vedic Tone Rigvedic Kash
- {0x01ce2, 0x01ce8}, // Vedic Sign Visarga Svari..Vedic Sign Visarga Anuda
- {0x01ced, 0x01ced}, // Vedic Sign Tiryak ..Vedic Sign Tiryak
- {0x01cf4, 0x01cf4}, // Vedic Tone Candra Above ..Vedic Tone Candra Above
- {0x01cf8, 0x01cf9}, // Vedic Tone Ring Above ..Vedic Tone Double Ring A
- {0x01dc0, 0x01df9}, // Combining Dotted Grave A..Combining Wide Inverted
- {0x01dfb, 0x01dff}, // Combining Deletion Mark ..Combining Right Arrowhea
- {0x020d0, 0x020f0}, // Combining Left Harpoon A..Combining Asterisk Above
- {0x02cef, 0x02cf1}, // Coptic Combining Ni Abov..Coptic Combining Spiritu
- {0x02d7f, 0x02d7f}, // Tifinagh Consonant Joine..Tifinagh Consonant Joine
- {0x02de0, 0x02dff}, // Combining Cyrillic Lette..Combining Cyrillic Lette
- {0x0302a, 0x0302d}, // Ideographic Level Tone M..Ideographic Entering Ton
- {0x03099, 0x0309a}, // Combining Katakana-hirag..Combining Katakana-hirag
- {0x0a66f, 0x0a672}, // Combining Cyrillic Vzmet..Combining Cyrillic Thous
- {0x0a674, 0x0a67d}, // Combining Cyrillic Lette..Combining Cyrillic Payer
- {0x0a69e, 0x0a69f}, // Combining Cyrillic Lette..Combining Cyrillic Lette
- {0x0a6f0, 0x0a6f1}, // Bamum Combining Mark Koq..Bamum Combining Mark Tuk
- {0x0a802, 0x0a802}, // Syloti Nagri Sign Dvisva..Syloti Nagri Sign Dvisva
- {0x0a806, 0x0a806}, // Syloti Nagri Sign Hasant..Syloti Nagri Sign Hasant
- {0x0a80b, 0x0a80b}, // Syloti Nagri Sign Anusva..Syloti Nagri Sign Anusva
- {0x0a825, 0x0a826}, // Syloti Nagri Vowel Sign ..Syloti Nagri Vowel Sign
- {0x0a82c, 0x0a82c}, // (nil) ..(nil)
- {0x0a8c4, 0x0a8c5}, // Saurashtra Sign Virama ..Saurashtra Sign Candrabi
- {0x0a8e0, 0x0a8f1}, // Combining Devanagari Dig..Combining Devanagari Sig
- {0x0a8ff, 0x0a8ff}, // Devanagari Vowel Sign Ay..Devanagari Vowel Sign Ay
- {0x0a926, 0x0a92d}, // Kayah Li Vowel Ue ..Kayah Li Tone Calya Plop
- {0x0a947, 0x0a951}, // Rejang Vowel Sign I ..Rejang Consonant Sign R
- {0x0a980, 0x0a982}, // Javanese Sign Panyangga ..Javanese Sign Layar
- {0x0a9b3, 0x0a9b3}, // Javanese Sign Cecak Telu..Javanese Sign Cecak Telu
- {0x0a9b6, 0x0a9b9}, // Javanese Vowel Sign Wulu..Javanese Vowel Sign Suku
- {0x0a9bc, 0x0a9bd}, // Javanese Vowel Sign Pepe..Javanese Consonant Sign
- {0x0a9e5, 0x0a9e5}, // Myanmar Sign Shan Saw ..Myanmar Sign Shan Saw
- {0x0aa29, 0x0aa2e}, // Cham Vowel Sign Aa ..Cham Vowel Sign Oe
- {0x0aa31, 0x0aa32}, // Cham Vowel Sign Au ..Cham Vowel Sign Ue
- {0x0aa35, 0x0aa36}, // Cham Consonant Sign La ..Cham Consonant Sign Wa
- {0x0aa43, 0x0aa43}, // Cham Consonant Sign Fina..Cham Consonant Sign Fina
- {0x0aa4c, 0x0aa4c}, // Cham Consonant Sign Fina..Cham Consonant Sign Fina
- {0x0aa7c, 0x0aa7c}, // Myanmar Sign Tai Laing T..Myanmar Sign Tai Laing T
- {0x0aab0, 0x0aab0}, // Tai Viet Mai Kang ..Tai Viet Mai Kang
- {0x0aab2, 0x0aab4}, // Tai Viet Vowel I ..Tai Viet Vowel U
- {0x0aab7, 0x0aab8}, // Tai Viet Mai Khit ..Tai Viet Vowel Ia
- {0x0aabe, 0x0aabf}, // Tai Viet Vowel Am ..Tai Viet Tone Mai Ek
- {0x0aac1, 0x0aac1}, // Tai Viet Tone Mai Tho ..Tai Viet Tone Mai Tho
- {0x0aaec, 0x0aaed}, // Meetei Mayek Vowel Sign ..Meetei Mayek Vowel Sign
- {0x0aaf6, 0x0aaf6}, // Meetei Mayek Virama ..Meetei Mayek Virama
- {0x0abe5, 0x0abe5}, // Meetei Mayek Vowel Sign ..Meetei Mayek Vowel Sign
- {0x0abe8, 0x0abe8}, // Meetei Mayek Vowel Sign ..Meetei Mayek Vowel Sign
- {0x0abed, 0x0abed}, // Meetei Mayek Apun Iyek ..Meetei Mayek Apun Iyek
- {0x0fb1e, 0x0fb1e}, // Hebrew Point Judeo-spani..Hebrew Point Judeo-spani
- {0x0fe00, 0x0fe0f}, // Variation Selector-1 ..Variation Selector-16
- {0x0fe20, 0x0fe2f}, // Combining Ligature Left ..Combining Cyrillic Titlo
- {0x101fd, 0x101fd}, // Phaistos Disc Sign Combi..Phaistos Disc Sign Combi
- {0x102e0, 0x102e0}, // Coptic Epact Thousands M..Coptic Epact Thousands M
- {0x10376, 0x1037a}, // Combining Old Permic Let..Combining Old Permic Let
- {0x10a01, 0x10a03}, // Kharoshthi Vowel Sign I ..Kharoshthi Vowel Sign Vo
- {0x10a05, 0x10a06}, // Kharoshthi Vowel Sign E ..Kharoshthi Vowel Sign O
- {0x10a0c, 0x10a0f}, // Kharoshthi Vowel Length ..Kharoshthi Sign Visarga
- {0x10a38, 0x10a3a}, // Kharoshthi Sign Bar Abov..Kharoshthi Sign Dot Belo
- {0x10a3f, 0x10a3f}, // Kharoshthi Virama ..Kharoshthi Virama
- {0x10ae5, 0x10ae6}, // Manichaean Abbreviation ..Manichaean Abbreviation
- {0x10d24, 0x10d27}, // Hanifi Rohingya Sign Har..Hanifi Rohingya Sign Tas
- {0x10eab, 0x10eac}, // (nil) ..(nil)
- {0x10f46, 0x10f50}, // Sogdian Combining Dot Be..Sogdian Combining Stroke
- {0x11001, 0x11001}, // Brahmi Sign Anusvara ..Brahmi Sign Anusvara
- {0x11038, 0x11046}, // Brahmi Vowel Sign Aa ..Brahmi Virama
- {0x1107f, 0x11081}, // Brahmi Number Joiner ..Kaithi Sign Anusvara
- {0x110b3, 0x110b6}, // Kaithi Vowel Sign U ..Kaithi Vowel Sign Ai
- {0x110b9, 0x110ba}, // Kaithi Sign Virama ..Kaithi Sign Nukta
- {0x11100, 0x11102}, // Chakma Sign Candrabindu ..Chakma Sign Visarga
- {0x11127, 0x1112b}, // Chakma Vowel Sign A ..Chakma Vowel Sign Uu
- {0x1112d, 0x11134}, // Chakma Vowel Sign Ai ..Chakma Maayyaa
- {0x11173, 0x11173}, // Mahajani Sign Nukta ..Mahajani Sign Nukta
- {0x11180, 0x11181}, // Sharada Sign Candrabindu..Sharada Sign Anusvara
- {0x111b6, 0x111be}, // Sharada Vowel Sign U ..Sharada Vowel Sign O
- {0x111c9, 0x111cc}, // Sharada Sandhi Mark ..Sharada Extra Short Vowe
- {0x111cf, 0x111cf}, // (nil) ..(nil)
- {0x1122f, 0x11231}, // Khojki Vowel Sign U ..Khojki Vowel Sign Ai
- {0x11234, 0x11234}, // Khojki Sign Anusvara ..Khojki Sign Anusvara
- {0x11236, 0x11237}, // Khojki Sign Nukta ..Khojki Sign Shadda
- {0x1123e, 0x1123e}, // Khojki Sign Sukun ..Khojki Sign Sukun
- {0x112df, 0x112df}, // Khudawadi Sign Anusvara ..Khudawadi Sign Anusvara
- {0x112e3, 0x112ea}, // Khudawadi Vowel Sign U ..Khudawadi Sign Virama
- {0x11300, 0x11301}, // Grantha Sign Combining A..Grantha Sign Candrabindu
- {0x1133b, 0x1133c}, // Combining Bindu Below ..Grantha Sign Nukta
- {0x11340, 0x11340}, // Grantha Vowel Sign Ii ..Grantha Vowel Sign Ii
- {0x11366, 0x1136c}, // Combining Grantha Digit ..Combining Grantha Digit
- {0x11370, 0x11374}, // Combining Grantha Letter..Combining Grantha Letter
- {0x11438, 0x1143f}, // Newa Vowel Sign U ..Newa Vowel Sign Ai
- {0x11442, 0x11444}, // Newa Sign Virama ..Newa Sign Anusvara
- {0x11446, 0x11446}, // Newa Sign Nukta ..Newa Sign Nukta
- {0x1145e, 0x1145e}, // Newa Sandhi Mark ..Newa Sandhi Mark
- {0x114b3, 0x114b8}, // Tirhuta Vowel Sign U ..Tirhuta Vowel Sign Vocal
- {0x114ba, 0x114ba}, // Tirhuta Vowel Sign Short..Tirhuta Vowel Sign Short
- {0x114bf, 0x114c0}, // Tirhuta Sign Candrabindu..Tirhuta Sign Anusvara
- {0x114c2, 0x114c3}, // Tirhuta Sign Virama ..Tirhuta Sign Nukta
- {0x115b2, 0x115b5}, // Siddham Vowel Sign U ..Siddham Vowel Sign Vocal
- {0x115bc, 0x115bd}, // Siddham Sign Candrabindu..Siddham Sign Anusvara
- {0x115bf, 0x115c0}, // Siddham Sign Virama ..Siddham Sign Nukta
- {0x115dc, 0x115dd}, // Siddham Vowel Sign Alter..Siddham Vowel Sign Alter
- {0x11633, 0x1163a}, // Modi Vowel Sign U ..Modi Vowel Sign Ai
- {0x1163d, 0x1163d}, // Modi Sign Anusvara ..Modi Sign Anusvara
- {0x1163f, 0x11640}, // Modi Sign Virama ..Modi Sign Ardhacandra
- {0x116ab, 0x116ab}, // Takri Sign Anusvara ..Takri Sign Anusvara
- {0x116ad, 0x116ad}, // Takri Vowel Sign Aa ..Takri Vowel Sign Aa
- {0x116b0, 0x116b5}, // Takri Vowel Sign U ..Takri Vowel Sign Au
- {0x116b7, 0x116b7}, // Takri Sign Nukta ..Takri Sign Nukta
- {0x1171d, 0x1171f}, // Ahom Consonant Sign Medi..Ahom Consonant Sign Medi
- {0x11722, 0x11725}, // Ahom Vowel Sign I ..Ahom Vowel Sign Uu
- {0x11727, 0x1172b}, // Ahom Vowel Sign Aw ..Ahom Sign Killer
- {0x1182f, 0x11837}, // Dogra Vowel Sign U ..Dogra Sign Anusvara
- {0x11839, 0x1183a}, // Dogra Sign Virama ..Dogra Sign Nukta
- {0x1193b, 0x1193c}, // (nil) ..(nil)
- {0x1193e, 0x1193e}, // (nil) ..(nil)
- {0x11943, 0x11943}, // (nil) ..(nil)
- {0x119d4, 0x119d7}, // Nandinagari Vowel Sign U..Nandinagari Vowel Sign V
- {0x119da, 0x119db}, // Nandinagari Vowel Sign E..Nandinagari Vowel Sign A
- {0x119e0, 0x119e0}, // Nandinagari Sign Virama ..Nandinagari Sign Virama
- {0x11a01, 0x11a0a}, // Zanabazar Square Vowel S..Zanabazar Square Vowel L
- {0x11a33, 0x11a38}, // Zanabazar Square Final C..Zanabazar Square Sign An
- {0x11a3b, 0x11a3e}, // Zanabazar Square Cluster..Zanabazar Square Cluster
- {0x11a47, 0x11a47}, // Zanabazar Square Subjoin..Zanabazar Square Subjoin
- {0x11a51, 0x11a56}, // Soyombo Vowel Sign I ..Soyombo Vowel Sign Oe
- {0x11a59, 0x11a5b}, // Soyombo Vowel Sign Vocal..Soyombo Vowel Length Mar
- {0x11a8a, 0x11a96}, // Soyombo Final Consonant ..Soyombo Sign Anusvara
- {0x11a98, 0x11a99}, // Soyombo Gemination Mark ..Soyombo Subjoiner
- {0x11c30, 0x11c36}, // Bhaiksuki Vowel Sign I ..Bhaiksuki Vowel Sign Voc
- {0x11c38, 0x11c3d}, // Bhaiksuki Vowel Sign E ..Bhaiksuki Sign Anusvara
- {0x11c3f, 0x11c3f}, // Bhaiksuki Sign Virama ..Bhaiksuki Sign Virama
- {0x11c92, 0x11ca7}, // Marchen Subjoined Letter..Marchen Subjoined Letter
- {0x11caa, 0x11cb0}, // Marchen Subjoined Letter..Marchen Vowel Sign Aa
- {0x11cb2, 0x11cb3}, // Marchen Vowel Sign U ..Marchen Vowel Sign E
- {0x11cb5, 0x11cb6}, // Marchen Sign Anusvara ..Marchen Sign Candrabindu
- {0x11d31, 0x11d36}, // Masaram Gondi Vowel Sign..Masaram Gondi Vowel Sign
- {0x11d3a, 0x11d3a}, // Masaram Gondi Vowel Sign..Masaram Gondi Vowel Sign
- {0x11d3c, 0x11d3d}, // Masaram Gondi Vowel Sign..Masaram Gondi Vowel Sign
- {0x11d3f, 0x11d45}, // Masaram Gondi Vowel Sign..Masaram Gondi Virama
- {0x11d47, 0x11d47}, // Masaram Gondi Ra-kara ..Masaram Gondi Ra-kara
- {0x11d90, 0x11d91}, // Gunjala Gondi Vowel Sign..Gunjala Gondi Vowel Sign
- {0x11d95, 0x11d95}, // Gunjala Gondi Sign Anusv..Gunjala Gondi Sign Anusv
- {0x11d97, 0x11d97}, // Gunjala Gondi Virama ..Gunjala Gondi Virama
- {0x11ef3, 0x11ef4}, // Makasar Vowel Sign I ..Makasar Vowel Sign U
- {0x16af0, 0x16af4}, // Bassa Vah Combining High..Bassa Vah Combining High
- {0x16b30, 0x16b36}, // Pahawh Hmong Mark Cim Tu..Pahawh Hmong Mark Cim Ta
- {0x16f4f, 0x16f4f}, // Miao Sign Consonant Modi..Miao Sign Consonant Modi
- {0x16f8f, 0x16f92}, // Miao Tone Right ..Miao Tone Below
- {0x16fe4, 0x16fe4}, // (nil) ..(nil)
- {0x1bc9d, 0x1bc9e}, // Duployan Thick Letter Se..Duployan Double Mark
- {0x1d167, 0x1d169}, // Musical Symbol Combining..Musical Symbol Combining
- {0x1d17b, 0x1d182}, // Musical Symbol Combining..Musical Symbol Combining
- {0x1d185, 0x1d18b}, // Musical Symbol Combining..Musical Symbol Combining
- {0x1d1aa, 0x1d1ad}, // Musical Symbol Combining..Musical Symbol Combining
- {0x1d242, 0x1d244}, // Combining Greek Musical ..Combining Greek Musical
- {0x1da00, 0x1da36}, // Signwriting Head Rim ..Signwriting Air Sucking
- {0x1da3b, 0x1da6c}, // Signwriting Mouth Closed..Signwriting Excitement
- {0x1da75, 0x1da75}, // Signwriting Upper Body T..Signwriting Upper Body T
- {0x1da84, 0x1da84}, // Signwriting Location Hea..Signwriting Location Hea
- {0x1da9b, 0x1da9f}, // Signwriting Fill Modifie..Signwriting Fill Modifie
- {0x1daa1, 0x1daaf}, // Signwriting Rotation Mod..Signwriting Rotation Mod
- {0x1e000, 0x1e006}, // Combining Glagolitic Let..Combining Glagolitic Let
- {0x1e008, 0x1e018}, // Combining Glagolitic Let..Combining Glagolitic Let
- {0x1e01b, 0x1e021}, // Combining Glagolitic Let..Combining Glagolitic Let
- {0x1e023, 0x1e024}, // Combining Glagolitic Let..Combining Glagolitic Let
- {0x1e026, 0x1e02a}, // Combining Glagolitic Let..Combining Glagolitic Let
- {0x1e130, 0x1e136}, // Nyiakeng Puachue Hmong T..Nyiakeng Puachue Hmong T
- {0x1e2ec, 0x1e2ef}, // Wancho Tone Tup ..Wancho Tone Koini
- {0x1e8d0, 0x1e8d6}, // Mende Kikakui Combining ..Mende Kikakui Combining
- {0x1e944, 0x1e94a}, // Adlam Alif Lengthener ..Adlam Nukta
- {0xe0100, 0xe01ef}, // Variation Selector-17 ..Variation Selector-256
-};
-
-// https://github.com/jquast/wcwidth/blob/master/wcwidth/table_wide.py
-// at commit b29897e5a1b403a0e36f7fc991614981cbc42475 (2020-07-14):
-struct width_interval WIDE_EASTASIAN[] = {
- {0x01100, 0x0115f}, // Hangul Choseong Kiyeok ..Hangul Choseong Filler
- {0x0231a, 0x0231b}, // Watch ..Hourglass
- {0x02329, 0x0232a}, // Left-pointing Angle Brac..Right-pointing Angle Bra
- {0x023e9, 0x023ec}, // Black Right-pointing Dou..Black Down-pointing Doub
- {0x023f0, 0x023f0}, // Alarm Clock ..Alarm Clock
- {0x023f3, 0x023f3}, // Hourglass With Flowing S..Hourglass With Flowing S
- {0x025fd, 0x025fe}, // White Medium Small Squar..Black Medium Small Squar
- {0x02614, 0x02615}, // Umbrella With Rain Drops..Hot Beverage
- {0x02648, 0x02653}, // Aries ..Pisces
- {0x0267f, 0x0267f}, // Wheelchair Symbol ..Wheelchair Symbol
- {0x02693, 0x02693}, // Anchor ..Anchor
- {0x026a1, 0x026a1}, // High Voltage Sign ..High Voltage Sign
- {0x026aa, 0x026ab}, // Medium White Circle ..Medium Black Circle
- {0x026bd, 0x026be}, // Soccer Ball ..Baseball
- {0x026c4, 0x026c5}, // Snowman Without Snow ..Sun Behind Cloud
- {0x026ce, 0x026ce}, // Ophiuchus ..Ophiuchus
- {0x026d4, 0x026d4}, // No Entry ..No Entry
- {0x026ea, 0x026ea}, // Church ..Church
- {0x026f2, 0x026f3}, // Fountain ..Flag In Hole
- {0x026f5, 0x026f5}, // Sailboat ..Sailboat
- {0x026fa, 0x026fa}, // Tent ..Tent
- {0x026fd, 0x026fd}, // Fuel Pump ..Fuel Pump
- {0x02705, 0x02705}, // White Heavy Check Mark ..White Heavy Check Mark
- {0x0270a, 0x0270b}, // Raised Fist ..Raised Hand
- {0x02728, 0x02728}, // Sparkles ..Sparkles
- {0x0274c, 0x0274c}, // Cross Mark ..Cross Mark
- {0x0274e, 0x0274e}, // Negative Squared Cross M..Negative Squared Cross M
- {0x02753, 0x02755}, // Black Question Mark Orna..White Exclamation Mark O
- {0x02757, 0x02757}, // Heavy Exclamation Mark S..Heavy Exclamation Mark S
- {0x02795, 0x02797}, // Heavy Plus Sign ..Heavy Division Sign
- {0x027b0, 0x027b0}, // Curly Loop ..Curly Loop
- {0x027bf, 0x027bf}, // Double Curly Loop ..Double Curly Loop
- {0x02b1b, 0x02b1c}, // Black Large Square ..White Large Square
- {0x02b50, 0x02b50}, // White Medium Star ..White Medium Star
- {0x02b55, 0x02b55}, // Heavy Large Circle ..Heavy Large Circle
- {0x02e80, 0x02e99}, // Cjk Radical Repeat ..Cjk Radical Rap
- {0x02e9b, 0x02ef3}, // Cjk Radical Choke ..Cjk Radical C-simplified
- {0x02f00, 0x02fd5}, // Kangxi Radical One ..Kangxi Radical Flute
- {0x02ff0, 0x02ffb}, // Ideographic Description ..Ideographic Description
- {0x03000, 0x0303e}, // Ideographic Space ..Ideographic Variation In
- {0x03041, 0x03096}, // Hiragana Letter Small A ..Hiragana Letter Small Ke
- {0x03099, 0x030ff}, // Combining Katakana-hirag..Katakana Digraph Koto
- {0x03105, 0x0312f}, // Bopomofo Letter B ..Bopomofo Letter Nn
- {0x03131, 0x0318e}, // Hangul Letter Kiyeok ..Hangul Letter Araeae
- {0x03190, 0x031e3}, // Ideographic Annotation L..Cjk Stroke Q
- {0x031f0, 0x0321e}, // Katakana Letter Small Ku..Parenthesized Korean Cha
- {0x03220, 0x03247}, // Parenthesized Ideograph ..Circled Ideograph Koto
- {0x03250, 0x04dbf}, // Partnership Sign ..(nil)
- {0x04e00, 0x0a48c}, // Cjk Unified Ideograph-4e..Yi Syllable Yyr
- {0x0a490, 0x0a4c6}, // Yi Radical Qot ..Yi Radical Ke
- {0x0a960, 0x0a97c}, // Hangul Choseong Tikeut-m..Hangul Choseong Ssangyeo
- {0x0ac00, 0x0d7a3}, // Hangul Syllable Ga ..Hangul Syllable Hih
- {0x0f900, 0x0faff}, // Cjk Compatibility Ideogr..(nil)
- {0x0fe10, 0x0fe19}, // Presentation Form For Ve..Presentation Form For Ve
- {0x0fe30, 0x0fe52}, // Presentation Form For Ve..Small Full Stop
- {0x0fe54, 0x0fe66}, // Small Semicolon ..Small Equals Sign
- {0x0fe68, 0x0fe6b}, // Small Reverse Solidus ..Small Commercial At
- {0x0ff01, 0x0ff60}, // Fullwidth Exclamation Ma..Fullwidth Right White Pa
- {0x0ffe0, 0x0ffe6}, // Fullwidth Cent Sign ..Fullwidth Won Sign
- {0x16fe0, 0x16fe4}, // Tangut Iteration Mark ..(nil)
- {0x16ff0, 0x16ff1}, // (nil) ..(nil)
- {0x17000, 0x187f7}, // (nil) ..(nil)
- {0x18800, 0x18cd5}, // Tangut Component-001 ..(nil)
- {0x18d00, 0x18d08}, // (nil) ..(nil)
- {0x1b000, 0x1b11e}, // Katakana Letter Archaic ..Hentaigana Letter N-mu-m
- {0x1b150, 0x1b152}, // Hiragana Letter Small Wi..Hiragana Letter Small Wo
- {0x1b164, 0x1b167}, // Katakana Letter Small Wi..Katakana Letter Small N
- {0x1b170, 0x1b2fb}, // Nushu Character-1b170 ..Nushu Character-1b2fb
- {0x1f004, 0x1f004}, // Mahjong Tile Red Dragon ..Mahjong Tile Red Dragon
- {0x1f0cf, 0x1f0cf}, // Playing Card Black Joker..Playing Card Black Joker
- {0x1f18e, 0x1f18e}, // Negative Squared Ab ..Negative Squared Ab
- {0x1f191, 0x1f19a}, // Squared Cl ..Squared Vs
- {0x1f200, 0x1f202}, // Square Hiragana Hoka ..Squared Katakana Sa
- {0x1f210, 0x1f23b}, // Squared Cjk Unified Ideo..Squared Cjk Unified Ideo
- {0x1f240, 0x1f248}, // Tortoise Shell Bracketed..Tortoise Shell Bracketed
- {0x1f250, 0x1f251}, // Circled Ideograph Advant..Circled Ideograph Accept
- {0x1f260, 0x1f265}, // Rounded Symbol For Fu ..Rounded Symbol For Cai
- {0x1f300, 0x1f320}, // Cyclone ..Shooting Star
- {0x1f32d, 0x1f335}, // Hot Dog ..Cactus
- {0x1f337, 0x1f37c}, // Tulip ..Baby Bottle
- {0x1f37e, 0x1f393}, // Bottle With Popping Cork..Graduation Cap
- {0x1f3a0, 0x1f3ca}, // Carousel Horse ..Swimmer
- {0x1f3cf, 0x1f3d3}, // Cricket Bat And Ball ..Table Tennis Paddle And
- {0x1f3e0, 0x1f3f0}, // House Building ..European Castle
- {0x1f3f4, 0x1f3f4}, // Waving Black Flag ..Waving Black Flag
- {0x1f3f8, 0x1f43e}, // Badminton Racquet And Sh..Paw Prints
- {0x1f440, 0x1f440}, // Eyes ..Eyes
- {0x1f442, 0x1f4fc}, // Ear ..Videocassette
- {0x1f4ff, 0x1f53d}, // Prayer Beads ..Down-pointing Small Red
- {0x1f54b, 0x1f54e}, // Kaaba ..Menorah With Nine Branch
- {0x1f550, 0x1f567}, // Clock Face One Oclock ..Clock Face Twelve-thirty
- {0x1f57a, 0x1f57a}, // Man Dancing ..Man Dancing
- {0x1f595, 0x1f596}, // Reversed Hand With Middl..Raised Hand With Part Be
- {0x1f5a4, 0x1f5a4}, // Black Heart ..Black Heart
- {0x1f5fb, 0x1f64f}, // Mount Fuji ..Person With Folded Hands
- {0x1f680, 0x1f6c5}, // Rocket ..Left Luggage
- {0x1f6cc, 0x1f6cc}, // Sleeping Accommodation ..Sleeping Accommodation
- {0x1f6d0, 0x1f6d2}, // Place Of Worship ..Shopping Trolley
- {0x1f6d5, 0x1f6d7}, // Hindu Temple ..(nil)
- {0x1f6eb, 0x1f6ec}, // Airplane Departure ..Airplane Arriving
- {0x1f6f4, 0x1f6fc}, // Scooter ..(nil)
- {0x1f7e0, 0x1f7eb}, // Large Orange Circle ..Large Brown Square
- {0x1f90c, 0x1f93a}, // (nil) ..Fencer
- {0x1f93c, 0x1f945}, // Wrestlers ..Goal Net
- {0x1f947, 0x1f978}, // First Place Medal ..(nil)
- {0x1f97a, 0x1f9cb}, // Face With Pleading Eyes ..(nil)
- {0x1f9cd, 0x1f9ff}, // Standing Person ..Nazar Amulet
- {0x1fa70, 0x1fa74}, // Ballet Shoes ..(nil)
- {0x1fa78, 0x1fa7a}, // Drop Of Blood ..Stethoscope
- {0x1fa80, 0x1fa86}, // Yo-yo ..(nil)
- {0x1fa90, 0x1faa8}, // Ringed Planet ..(nil)
- {0x1fab0, 0x1fab6}, // (nil) ..(nil)
- {0x1fac0, 0x1fac2}, // (nil) ..(nil)
- {0x1fad0, 0x1fad6}, // (nil) ..(nil)
- {0x20000, 0x2fffd}, // Cjk Unified Ideograph-20..(nil)
- {0x30000, 0x3fffd}, // (nil) ..(nil)
-};
-
-bool intable(struct width_interval* table, int table_length, int c) {
- // First quick check for Latin1 etc. characters.
- if (c < table[0].start) return false;
-
- // Binary search in table.
- int bot = 0;
- int top = table_length - 1;
- while (top >= bot) {
- int mid = (bot + top) / 2;
- if (table[mid].end < c) {
- bot = mid + 1;
- } else if (table[mid].start > c) {
- top = mid - 1;
- } else {
- return true;
- }
- }
- return false;
-}
-
-}
-
-int wcwidth(wchar_t ucs) {
- // NOTE: created by hand, there isn't anything identifiable other than
- // general Cf category code to identify these, and some characters in Cf
- // category code are of non-zero width.
- if (ucs == 0 || ucs == 0x034F || (0x200B <= ucs && ucs <= 0x200F) ||
- ucs == 0x2028 || ucs == 0x2029 || (0x202A <= ucs && ucs <= 0x202E) ||
- (0x2060 <= ucs && ucs <= 0x2063)) {
- return 0;
- }
-
- // C0/C1 control characters.
- if (ucs < 32 || (0x07F <= ucs && ucs < 0x0A0)) return -1;
-
- // Combining characters with zero width.
- if (intable(ZERO_WIDTH, sizeof(ZERO_WIDTH) / sizeof(struct width_interval), ucs)) return 0;
-
- return intable(WIDE_EASTASIAN, sizeof(WIDE_EASTASIAN) / sizeof(struct width_interval), ucs) ? 2 : 1;
-}
-
-int wcswidth(const wchar_t *wcs, size_t n) {
- int ret = 0;
- for(size_t i = 0; i < n && wcs[i]; i++) {
- int cols = wcwidth(wcs[i]);
- if (cols < 0)
- return -1;
- ret += cols;
- }
-
- return ret;
-}
-
-wchar_t *wcsdup(const wchar_t *s) {
- size_t len = wcslen(s);
- wchar_t *ret = (wchar_t *) malloc(sizeof(wchar_t) * (len + 1));
- if(!ret)
- return NULL;
- wmemcpy(ret, s, len + 1);
- return ret;
-}
-
-int wcsncasecmp(const wchar_t* s1, const wchar_t* s2, size_t n) {
- for(size_t i = 0; i < n; i++) {
- wint_t c1 = towlower(s1[i]);
- wint_t c2 = towlower(s2[i]);
- if(c1 == L'\0' && c2 == L'\0')
- return 0;
- if(c1 < c2)
- return -1;
- if(c1 > c2)
- return 1;
- }
- return 0;
-}
-
-int wcscasecmp(const wchar_t *, const wchar_t *) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
diff --git a/lib/mlibc/options/ansi/generic/wctype.cpp b/lib/mlibc/options/ansi/generic/wctype.cpp
deleted file mode 100644
index 57dcbc9..0000000
--- a/lib/mlibc/options/ansi/generic/wctype.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#include <wctype.h>
-#include <bits/ensure.h>
-#include <mlibc/debug.hpp>
-#include <frg/string.hpp>
-
-wctrans_t wctrans(const char *) MLIBC_STUB_BODY
-wint_t towctrans(wint_t, wctrans_t) MLIBC_STUB_BODY
-
diff --git a/lib/mlibc/options/ansi/include/alloca.h b/lib/mlibc/options/ansi/include/alloca.h
deleted file mode 100644
index 0cc6bcb..0000000
--- a/lib/mlibc/options/ansi/include/alloca.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#ifndef _ALLOCA_H
-#define _ALLOCA_H
-
-#define alloca __builtin_alloca
-
-#endif // _ALLOCA_H
-
diff --git a/lib/mlibc/options/ansi/include/assert.h b/lib/mlibc/options/ansi/include/assert.h
deleted file mode 100644
index 7eccae0..0000000
--- a/lib/mlibc/options/ansi/include/assert.h
+++ /dev/null
@@ -1,46 +0,0 @@
-
-#ifndef _ASSERT_H
-#define _ASSERT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-// NOTE: This is not ISO C. Declared in LSB
-__attribute__ ((__noreturn__)) void __assert_fail(const char *assertion, const char *file, unsigned int line,
- const char *function);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _ASSERT_H
-
-#include <mlibc-config.h>
-
-#if __MLIBC_GLIBC_OPTION
-# include <bits/glibc/glibc_assert.h>
-#endif
-
-// NOTE: [7.2] requires this be outside the include guard
-#ifdef NDEBUG
-
-#undef assert
-#define assert(ignore) ((void)0)
-
-#else // NDEBUG
-
-#undef assert
-#define assert(assertion) ((void)((assertion) \
- || (__assert_fail(#assertion, __FILE__, __LINE__, __func__), 0)))
-
-#endif // NDEBUG
-
-#ifndef __cplusplus
-#undef static_assert
-#define static_assert _Static_assert
-#endif
diff --git a/lib/mlibc/options/ansi/include/bits/ansi/fenv.h b/lib/mlibc/options/ansi/include/bits/ansi/fenv.h
deleted file mode 100644
index 677ddaa..0000000
--- a/lib/mlibc/options/ansi/include/bits/ansi/fenv.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef MLIBC_FENV_H
-#define MLIBC_FENV_H
-
-#if defined(__x86_64__) || defined(__i386__)
-
-#define FE_DENORMAL 2
-#define FE_DIVBYZERO 4
-#define FE_INEXACT 32
-#define FE_INVALID 1
-#define FE_OVERFLOW 8
-#define FE_UNDERFLOW 16
-
-#define FE_ALL_EXCEPT (FE_DENORMAL | FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-#define FE_TONEAREST 0
-#define FE_DOWNWARD 0x400
-#define FE_UPWARD 0x800
-#define FE_TOWARDZERO 0xC00
-
-#elif defined(__aarch64__)
-
-#define FE_INVALID 1
-#define FE_DIVBYZERO 2
-#define FE_OVERFLOW 4
-#define FE_UNDERFLOW 8
-#define FE_INEXACT 16
-
-#define FE_ALL_EXCEPT 31
-
-#define FE_TONEAREST 0
-#define FE_UPWARD 0x400000
-#define FE_DOWNWARD 0x800000
-#define FE_TOWARDZERO 0xC00000
-
-#elif defined(__riscv) && __riscv_xlen == 64
-
-#define FE_INEXACT 1
-#define FE_UNDERFLOW 2
-#define FE_OVERFLOW 4
-#define FE_DIVBYZERO 8
-#define FE_INVALID 16
-
-#define FE_ALL_EXCEPT 31
-
-#define FE_TONEAREST 0
-#define FE_TOWARDZERO 1
-#define FE_DOWNWARD 2
-#define FE_UPWARD 3
-
-#else
-#error Unknown architecture
-#endif
-
-#endif // MLIBC_FENV_H
diff --git a/lib/mlibc/options/ansi/include/bits/ansi/time_t.h b/lib/mlibc/options/ansi/include/bits/ansi/time_t.h
deleted file mode 100644
index 1c29fa0..0000000
--- a/lib/mlibc/options/ansi/include/bits/ansi/time_t.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#ifndef MLIBC_TIME_T
-#define MLIBC_TIME_T
-
-typedef long time_t;
-
-#endif
-
diff --git a/lib/mlibc/options/ansi/include/bits/ansi/timespec.h b/lib/mlibc/options/ansi/include/bits/ansi/timespec.h
deleted file mode 100644
index d34aa64..0000000
--- a/lib/mlibc/options/ansi/include/bits/ansi/timespec.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#ifndef MLIBC_TIMESPEC_H
-#define MLIBC_TIMESPEC_H
-
-#include <bits/ansi/time_t.h>
-
-struct timespec {
- time_t tv_sec;
- long tv_nsec;
-};
-
-#endif // MLIBC_TIMESPEC_H
-
diff --git a/lib/mlibc/options/ansi/include/complex.h b/lib/mlibc/options/ansi/include/complex.h
deleted file mode 100644
index 6191f28..0000000
--- a/lib/mlibc/options/ansi/include/complex.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* $NetBSD: complex.h,v 1.3 2010/09/15 16:11:30 christos Exp $ */
-
-/*
- * Written by Matthias Drochner.
- * Public domain.
- */
-
-#ifndef _COMPLEX_H
-#define _COMPLEX_H
-
-#define complex _Complex
-#define _Complex_I 1.0fi
-#define I _Complex_I
-
-#define CMPLX(x, y) ((double complex)__builtin_complex((double)(x), (double)(y)))
-#define CMPLXF(x, y) ((float complex)__builtin_complex((float)(x), (float)(y)))
-#define CMPLXL(x, y) ((long double complex)__builtin_complex((long double)(x), (long double)(y)))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-/* 7.3.5 Trigonometric functions */
-/* 7.3.5.1 The cacos functions */
-double complex cacos(double complex);
-float complex cacosf(float complex);
-
-/* 7.3.5.2 The casin functions */
-double complex casin(double complex);
-float complex casinf(float complex);
-
-/* 7.3.5.1 The catan functions */
-double complex catan(double complex);
-float complex catanf(float complex);
-
-/* 7.3.5.1 The ccos functions */
-double complex ccos(double complex);
-float complex ccosf(float complex);
-
-/* 7.3.5.1 The csin functions */
-double complex csin(double complex);
-float complex csinf(float complex);
-
-/* 7.3.5.1 The ctan functions */
-double complex ctan(double complex);
-float complex ctanf(float complex);
-
-/* 7.3.6 Hyperbolic functions */
-/* 7.3.6.1 The cacosh functions */
-double complex cacosh(double complex);
-float complex cacoshf(float complex);
-
-/* 7.3.6.2 The casinh functions */
-double complex casinh(double complex);
-float complex casinhf(float complex);
-
-/* 7.3.6.3 The catanh functions */
-double complex catanh(double complex);
-float complex catanhf(float complex);
-
-/* 7.3.6.4 The ccosh functions */
-double complex ccosh(double complex);
-float complex ccoshf(float complex);
-
-/* 7.3.6.5 The csinh functions */
-double complex csinh(double complex);
-float complex csinhf(float complex);
-
-/* 7.3.6.6 The ctanh functions */
-double complex ctanh(double complex);
-float complex ctanhf(float complex);
-
-/* 7.3.7 Exponential and logarithmic functions */
-/* 7.3.7.1 The cexp functions */
-double complex cexp(double complex);
-float complex cexpf(float complex);
-
-/* 7.3.7.2 The clog functions */
-double complex clog(double complex);
-float complex clogf(float complex);
-
-/* 7.3.8 Power and absolute-value functions */
-/* 7.3.8.1 The cabs functions */
-/*#ifndef __LIBM0_SOURCE__ */
-/* avoid conflict with historical cabs(struct complex) */
-/* double cabs(double complex) __RENAME(__c99_cabs);
- float cabsf(float complex) __RENAME(__c99_cabsf);
- #endif
-*/
-double cabs(double complex) ;
-float cabsf(float complex) ;
-
-/* 7.3.8.2 The cpow functions */
-double complex cpow(double complex, double complex);
-float complex cpowf(float complex, float complex);
-
-/* 7.3.8.3 The csqrt functions */
-double complex csqrt(double complex);
-float complex csqrtf(float complex);
-
-/* 7.3.9 Manipulation functions */
-/* 7.3.9.1 The carg functions */
-double carg(double complex);
-float cargf(float complex);
-
-/* 7.3.9.2 The cimag functions */
-double cimag(double complex);
-float cimagf(float complex);
-long double cimagl(long double complex);
-
-/* 7.3.9.3 The conj functions */
-double complex conj(double complex);
-float complex conjf(float complex);
-/*long double complex conjl(long double complex); */
-
-/* 7.3.9.4 The cproj functions */
-double complex cproj(double complex);
-float complex cprojf(float complex);
-/*long double complex cprojl(long double complex); */
-
-/* 7.3.9.5 The creal functions */
-double creal(double complex);
-float crealf(float complex);
-long double creall(long double complex);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ! _COMPLEX_H */
diff --git a/lib/mlibc/options/ansi/include/ctype.h b/lib/mlibc/options/ansi/include/ctype.h
deleted file mode 100644
index 7cd1ec8..0000000
--- a/lib/mlibc/options/ansi/include/ctype.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef _CTYPE_H
-#define _CTYPE_H
-
-#include <mlibc-config.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-// Character classification function [7.4.1]
-int isalnum(int c);
-int isalpha(int c);
-int isblank(int c);
-int iscntrl(int c);
-int isdigit(int c);
-int isgraph(int c);
-int islower(int c);
-int isprint(int c);
-int ispunct(int c);
-int isspace(int c);
-int isupper(int c);
-int isxdigit(int c);
-
-// glibc extensions.
-int isascii(int c);
-
-// Character case mapping functions [7.4.2]
-int tolower(int c);
-int toupper(int c);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-// Borrowed from glibc
-#define toascii(c) ((c) & 0x7f)
-
-#ifdef __cplusplus
-}
-#endif
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_ctype.h>
-#endif
-
-#endif // _CTYPE_H
diff --git a/lib/mlibc/options/ansi/include/errno.h b/lib/mlibc/options/ansi/include/errno.h
deleted file mode 100644
index 7730b16..0000000
--- a/lib/mlibc/options/ansi/include/errno.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _ERRNO_H
-#define _ERRNO_H
-
-#include <abi-bits/errno.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-// Some programs define their own errno as an "extern int" if it is not a macro.
-#define errno __mlibc_errno
-extern __thread int __mlibc_errno;
-
-int *__errno_location(void);
-
-// Linux extensions.
-
-extern char *program_invocation_name;
-extern char *program_invocation_short_name;
-extern char *__progname;
-extern char *__progname_full;
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _ERRNO_H
diff --git a/lib/mlibc/options/ansi/include/fenv.h b/lib/mlibc/options/ansi/include/fenv.h
deleted file mode 100644
index 11e38f3..0000000
--- a/lib/mlibc/options/ansi/include/fenv.h
+++ /dev/null
@@ -1,44 +0,0 @@
-
-#ifndef _FENV_H
-#define _FENV_H
-
-#include <bits/types.h>
-#include <bits/ansi/fenv.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- __mlibc_uint32 __control_word;
- __mlibc_uint32 __status_word;
- __mlibc_uint32 __unused[5];
- __mlibc_uint32 __mxcsr;
-} fenv_t;
-
-typedef __mlibc_uint16 fexcept_t;
-
-#ifndef __MLIBC_ABI_ONLY
-
-int feclearexcept(int);
-int fegetenv(fenv_t *);
-int fegetexceptflag(fexcept_t *, int);
-int fegetround(void);
-int feholdexcept(fenv_t *);
-int feraiseexcept(int);
-int fesetenv(const fenv_t *);
-int fesetexceptflag(const fexcept_t *, int);
-int fesetround(int);
-int fetestexcept(int);
-int feupdateenv(const fenv_t *);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#define FE_DFL_ENV ((const fenv_t *) -1)
-
-#endif // _FENV_H
-
diff --git a/lib/mlibc/options/ansi/include/inttypes.h b/lib/mlibc/options/ansi/include/inttypes.h
deleted file mode 100644
index 5495440..0000000
--- a/lib/mlibc/options/ansi/include/inttypes.h
+++ /dev/null
@@ -1,146 +0,0 @@
-#ifndef _STDINT_H
-#define _STDINT_H
-
-#include <stdint.h>
-
-/* Even though this is not strictly not-ABI, it is mlibc-printf specific therefore */
-/* gate behind !__MLIBC_ABI_ONLY */
-#ifndef __MLIBC_ABI_ONLY
-
-#if UINTPTR_MAX == UINT64_MAX
-# define __PRI64 "l"
-# define __PRIPTR "l"
-#else
-# define __PRI64 "ll"
-# define __PRIPTR ""
-#endif
-
-// TODO: This is extremly unelegant and fragile.
-#define PRId8 "d"
-#define PRIi8 "i"
-#define PRIdLEAST8 "d"
-#define PRIiLEAST8 "i"
-#define PRIdFAST8 "d"
-#define PRIiFAST8 "i"
-#define PRId16 "d"
-#define PRIi16 "i"
-#define PRIdLEAST16 "d"
-#define PRIiLEAST16 "i"
-#define PRIdFAST16 "ld"
-#define PRIiFAST16 "li"
-#define PRId32 "d"
-#define PRIi32 "i"
-#define PRIdLEAST32 "d"
-#define PRIiLEAST32 "i"
-#define PRIdFAST32 "ld"
-#define PRIiFAST32 "li"
-#define PRId64 __PRI64 "d"
-#define PRIi64 __PRI64 "i"
-#define PRIdLEAST64 __PRI64 "d"
-#define PRIiLEAST64 __PRI64 "i"
-#define PRIdFAST64 __PRI64 "d"
-#define PRIiFAST64 __PRI64 "i"
-#define PRIdMAX __PRI64 "d"
-#define PRIiMAX __PRI64 "i"
-#define PRIdPTR __PRIPTR "d"
-#define PRIiPTR __PRIPTR "i"
-#define PRIo8 "o"
-#define PRIu8 "u"
-#define PRIx8 "x"
-#define PRIX8 "X"
-#define PRIoLEAST8 "o"
-#define PRIuLEAST8 "u"
-#define PRIxLEAST8 "x"
-#define PRIXLEAST8 "X"
-#define PRIoFAST8 "o"
-#define PRIuFAST8 "u"
-#define PRIxFAST8 "x"
-#define PRIXFAST8 "X"
-#define PRIo16 "o"
-#define PRIu16 "u"
-#define PRIx16 "x"
-#define PRIX16 "X"
-#define PRIoLEAST16 "o"
-#define PRIuLEAST16 "u"
-#define PRIxLEAST16 "x"
-#define PRIXLEAST16 "X"
-#define PRIoFAST16 "lo"
-#define PRIuFAST16 "lu"
-#define PRIxFAST16 "lx"
-#define PRIXFAST16 "lX"
-#define PRIo32 "o"
-#define PRIu32 "u"
-#define PRIx32 "x"
-#define PRIX32 "X"
-#define PRIoLEAST32 "o"
-#define PRIuLEAST32 "u"
-#define PRIxLEAST32 "x"
-#define PRIXLEAST32 "X"
-#define PRIoFAST32 "lo"
-#define PRIuFAST32 "lu"
-#define PRIxFAST32 "lx"
-#define PRIXFAST32 "lX"
-#define PRIo64 __PRI64 "o"
-#define PRIu64 __PRI64 "u"
-#define PRIx64 __PRI64 "x"
-#define PRIX64 __PRI64 "X"
-#define PRIoLEAST64 __PRI64 "o"
-#define PRIuLEAST64 __PRI64 "u"
-#define PRIxLEAST64 __PRI64 "x"
-#define PRIXLEAST64 __PRI64 "X"
-#define PRIoFAST64 __PRI64 "o"
-#define PRIuFAST64 __PRI64 "u"
-#define PRIxFAST64 __PRI64 "x"
-#define PRIXFAST64 __PRI64 "X"
-#define PRIoMAX __PRI64 "o"
-#define PRIuMAX __PRI64 "u"
-#define PRIxMAX __PRI64 "x"
-#define PRIXMAX __PRI64 "X"
-#define PRIoPTR __PRIPTR "o"
-#define PRIuPTR __PRIPTR "u"
-#define PRIxPTR __PRIPTR "x"
-#define PRIXPTR __PRIPTR "X"
-
-#define SCNu32 "u"
-#define SCNu64 __PRI64 "u"
-#define SCNuMAX __PRI64 "u"
-#define SCNx16 "hx"
-#define SCNx32 "x"
-#define SCNx64 __PRI64 "x"
-#define SCNxMAX __PRI64 "x"
-#define SCNi8 "hhi"
-#define SCNxPTR __PRIPTR "x"
-
-#define SCNi8 "hhi"
-#define SCNi64 __PRI64 "i"
-
-#define SCNd32 "d"
-#define SCNd64 __PRI64 "d"
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- intmax_t quot;
- intmax_t rem;
-} imaxdiv_t;
-
-#ifndef __MLIBC_ABI_ONLY
-
-intmax_t imaxabs(intmax_t);
-imaxdiv_t imaxdiv(intmax_t, intmax_t);
-intmax_t strtoimax(const char *__restrict, char **__restrict, int);
-uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
-intmax_t wcstoimax(const __WCHAR_TYPE__ *__restrict, __WCHAR_TYPE__ **__restrict, int);
-uintmax_t wcstoumax(const __WCHAR_TYPE__ *__restrict, __WCHAR_TYPE__ **__restrict, int);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _STDINT_H
diff --git a/lib/mlibc/options/ansi/include/limits.h b/lib/mlibc/options/ansi/include/limits.h
deleted file mode 100644
index 86b786e..0000000
--- a/lib/mlibc/options/ansi/include/limits.h
+++ /dev/null
@@ -1,117 +0,0 @@
-#ifndef _LIMITS_H
-#define _LIMITS_H
-
-#define CHAR_BIT 8
-
-#ifndef MB_LEN_MAX
-# define MB_LEN_MAX 4
-#endif
-
-#ifdef LONG_MAX
-# ifdef LONG_MAX == INT32_MAX
-# define LONG_BIT 32
-# else
-// Safe assumption
-# define LONG_BIT 64
-# endif
-#elif defined __LONG_MAX__
-# if __LONG_MAX__ == INT32_MAX
-# define LONG_BIT 32
-# else
-// Safe assumption
-# define LONG_BIT 64
-# endif
-#else
-# error "Unsupported configuration, please define either LONG_MAX or __LONG_MAX__"
-#endif
-
-#undef SCHAR_MIN
-#undef SCHAR_MAX
-#undef CHAR_MIN
-#undef CHAR_MAX
-#undef UCHAR_MAX
-#undef SHRT_MIN
-#undef SHRT_MAX
-#undef USHRT_MAX
-#undef INT_MIN
-#undef INT_MAX
-#undef UINT_MAX
-#undef LONG_MIN
-#undef LONG_MAX
-#undef ULONG_MAX
-#undef LLONG_MIN
-#undef LLONG_MAX
-#undef ULLONG_MAX
-
-#define SCHAR_MIN (-__SCHAR_MAX__ - 1)
-#define SCHAR_MAX __SCHAR_MAX__
-#if __SCHAR_MAX__ == __INT_MAX__
-# define UCHAR_MAX (__SCHAR_MAX__ * 2U + 1U)
-#else
-# define UCHAR_MAX (__SCHAR_MAX__ * 2 + 1)
-#endif
-
-#ifdef __CHAR_UNSIGNED__
-# define CHAR_MAX UCHAR_MAX
-# if __SCHAR_MAX__ == __INT_MAX__
-# define CHAR_MIN 0U
-# else
-# define CHAR_MIN 0
-# endif
-#else
-# define CHAR_MAX SCHAR_MAX
-# define CHAR_MIN SCHAR_MIN
-#endif
-
-#define SHRT_MIN (-__SHRT_MAX__ - 1)
-#define SHRT_MAX __SHRT_MAX__
-#if __SHRT_MAX_ == __INT_MAX__
-# define USHRT_MAX (__SHRT_MAX__ * 2U + 1U)
-#else
-# define USHRT_MAX (__SHRT_MAX__ * 2 + 1)
-#endif
-
-#define INT_MIN (-__INT_MAX__ - 1)
-#define INT_MAX __INT_MAX__
-#define UINT_MAX (__INT_MAX__ * 2 + 1)
-
-#define LONG_MIN (-__LONG_MAX__ - 1L)
-#define LONG_MAX __LONG_MAX__
-#define ULONG_MAX (__LONG_MAX__ * 2UL + 1UL)
-
-#define LLONG_MIN (-__LONG_LONG_MAX__ - 1LL)
-#define LLONG_MAX __LONG_LONG_MAX__
-#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
-
-#define NAME_MAX 255
-#define PATH_MAX 4096
-#define LINE_MAX 4096
-#define PIPE_BUF 4096
-
-#define CHARCLASS_NAME_MAX 14
-#define RE_DUP_MAX 255
-
-// This value is a guaranteed minimum, get the current maximum from sysconf
-#define NGROUPS_MAX 8
-// POSIX states 9 is the minimum for NL_ARGMAX
-#define NL_ARGMAX 9
-
-#if INTPTR_MAX == INT64_MAX
-# define SSIZE_MAX LONG_MAX
-#elif INTPTR_MAX == INT32_MAX
-# define SSIZE_MAX INT_MAX
-#endif
-
-#define _POSIX_ARG_MAX 4096
-#define _POSIX_OPEN_MAX 16
-#define _POSIX_HOST_NAME_MAX 255
-#define _POSIX_NAME_MAX 14
-#define _POSIX_TZNAME_MAX 6
-#define _XOPEN_NAME_MAX 255
-
-#define PTHREAD_STACK_MIN 16384
-#define PTHREAD_KEYS_MAX 1024
-
-#include <abi-bits/limits.h>
-
-#endif // _LIMITS_H
diff --git a/lib/mlibc/options/ansi/include/locale.h b/lib/mlibc/options/ansi/include/locale.h
deleted file mode 100644
index 3b4773d..0000000
--- a/lib/mlibc/options/ansi/include/locale.h
+++ /dev/null
@@ -1,81 +0,0 @@
-
-#ifndef _LOCALE_H
-#define _LOCALE_H
-
-#include <mlibc-config.h>
-
-#include <bits/null.h>
-
-#define LC_ALL 1
-#define LC_COLLATE 2
-#define LC_CTYPE 3
-#define LC_MONETARY 4
-#define LC_NUMERIC 5
-#define LC_TIME 6
-#define LC_MESSAGES 7
-
-#define LC_GLOBAL_LOCALE ((locale_t) -1L)
-
-#define LC_CTYPE_MASK (1<<LC_CTYPE)
-#define LC_NUMERIC_MASK (1<<LC_NUMERIC)
-#define LC_TIME_MASK (1<<LC_TIME)
-#define LC_COLLATE_MASK (1<<LC_COLLATE)
-#define LC_MONETARY_MASK (1<<LC_MONETARY)
-#define LC_MESSAGES_MASK (1<<LC_MESSAGES)
-#define LC_ALL_MASK 0x7FFFFFFF
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct lconv {
- char *decimal_point;
- char *thousands_sep;
- char *grouping;
- char *mon_decimal_point;
- char *mon_thousands_sep;
- char *mon_grouping;
- char *positive_sign;
- char *negative_sign;
- char *currency_symbol;
- char frac_digits;
- char p_cs_precedes;
- char n_cs_precedes;
- char p_sep_by_space;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char *int_curr_symbol;
- char int_frac_digits;
- char int_p_cs_precedes;
- char int_n_cs_precedes;
- char int_p_sep_by_space;
- char int_n_sep_by_space;
- char int_p_sign_posn;
- char int_n_sign_posn;
-};
-
-#ifndef __MLIBC_ABI_ONLY
-
-// [C11/7.11.1] setlocale() function
-
-char *setlocale(int category, const char *locale);
-
-// [C11/7.11.2] Locale inquiry function
-
-struct lconv *localeconv(void);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-// posix extension
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_locale.h>
-#endif // __MLIBC_POSIX_OPTION
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _LOCALE_H
-
diff --git a/lib/mlibc/options/ansi/include/math.h b/lib/mlibc/options/ansi/include/math.h
deleted file mode 100644
index 7d7ab3c..0000000
--- a/lib/mlibc/options/ansi/include/math.h
+++ /dev/null
@@ -1,383 +0,0 @@
-
-#ifndef _MATH_H
-#define _MATH_H
-
-#include <bits/inline-definition.h>
-
-// this is a posix extension
-#define M_E 2.7182818284590452354
-#define M_LOG2E 1.4426950408889634074
-#define M_LOG10E 0.43429448190325182765
-#define M_LN2 0.69314718055994530942
-#define M_LN10 2.30258509299404568402
-#define M_PI 3.14159265358979323846
-#define M_PI_2 1.57079632679489661923
-#define M_PI_4 0.78539816339744830962
-#define M_1_PI 0.31830988618379067154
-#define M_2_PI 0.63661977236758134308
-#define M_2_SQRTPI 1.12837916709551257390
-#define M_SQRT2 1.41421356237309504880
-#define M_SQRT1_2 0.70710678118654752440
-#define M_PIl 3.141592653589793238462643383279502884L
-
-// The following two definitions are from musl.
-#define FP_ILOGBNAN (-1 - (int)(((unsigned)-1) >> 1))
-#define FP_ILOGB0 FP_ILOGBNAN
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef double double_t;
-typedef float float_t;
-
-#define HUGE_VAL (__builtin_huge_val())
-#define HUGE_VALF (__builtin_huge_valf())
-#define HUGE_VALL (__builtin_huge_vall())
-#define INFINITY (__builtin_inff())
-#define NAN (__builtin_nanf(""))
-
-// [C11/7.12.1 Treatment of error conditions]
-
-#define MATH_ERRNO 1
-#define MATH_ERREXCEPT 2
-#define math_errhandling 3
-
-// [C11/7.12.3 Classification macros]
-
-// NOTE: fpclassify always returns exactly one of those constants
-// However making them bitwise disjoint simplifies isfinite() etc.
-#define FP_INFINITE 1
-#define FP_NAN 2
-#define FP_NORMAL 4
-#define FP_SUBNORMAL 8
-#define FP_ZERO 16
-
-#ifndef __MLIBC_ABI_ONLY
-
-int __fpclassify(double x);
-int __fpclassifyf(float x);
-int __fpclassifyl(long double x);
-
-#define fpclassify(x) \
- (sizeof(x) == sizeof(double) ? __fpclassify(x) : \
- (sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
- (sizeof(x) == sizeof(long double) ? __fpclassifyl(x) : \
- 0)))
-
-#define isfinite(x) (fpclassify(x) & (FP_NORMAL | FP_SUBNORMAL | FP_ZERO))
-#define isnan(x) (fpclassify(x) == FP_NAN)
-#define isinf(x) (fpclassify(x) == FP_INFINITE)
-#define isnormal(x) (fpclassify(x) == FP_NORMAL)
-
-// FIXME: this is gcc specific
-#define signbit(x) (__builtin_signbit(x))
-
-// [C11/7.12.14 Comparison macros]
-#define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
-
-__MLIBC_INLINE_DEFINITION int __mlibc_isless(double_t x, double_t y) { return !isunordered(x, y) && x < y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessf(float_t x, float_t y) { return !isunordered(x, y) && x < y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessl(long double x, long double y) { return !isunordered(x, y) && x < y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessequal(double_t x, double_t y) { return !isunordered(x, y) && x <= y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessequalf(float_t x, float_t y) { return !isunordered(x, y) && x <= y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessequall(long double x, long double y) { return !isunordered(x, y) && x <= y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessgreater(double_t x, double_t y) { return !isunordered(x, y) && x != y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessgreaterf(float_t x, float_t y) { return !isunordered(x, y) && x != y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_islessgreaterl(long double x, long double y) { return !isunordered(x, y) && x != y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_isgreater(double_t x, double_t y) { return !isunordered(x, y) && x > y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_isgreaterf(float_t x, float_t y) { return !isunordered(x, y) && x > y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_isgreaterl(long double x, long double y) { return !isunordered(x, y) && x > y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_isgreaterequal(double_t x, double_t y) { return !isunordered(x, y) && x >= y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_isgreaterequalf(float_t x, float_t y) { return !isunordered(x, y) && x >= y; }
-__MLIBC_INLINE_DEFINITION int __mlibc_isgreaterequall(long double x, long double y) { return !isunordered(x, y) && x >= y; }
-
-// TODO: We chould use _Generic here but that does not work in C++ code.
-#define __MLIBC_CHOOSE_COMPARISON(x, y, p) ( \
- sizeof((x)+(y)) == sizeof(float) ? p##f(x, y) : \
- sizeof((x)+(y)) == sizeof(double) ? p(x, y) : \
- p##l(x, y) )
-
-#define isless(x, y) __MLIBC_CHOOSE_COMPARISON(x, y, __mlibc_isless)
-#define islessequal(x, y) __MLIBC_CHOOSE_COMPARISON(x, y, __mlibc_islessequal)
-#define islessgreater(x, y) __MLIBC_CHOOSE_COMPARISON(x, y, __mlibc_islessgreater)
-#define isgreater(x, y) __MLIBC_CHOOSE_COMPARISON(x, y, __mlibc_isgreater)
-#define isgreaterequal(x, y) __MLIBC_CHOOSE_COMPARISON(x, y, __mlibc_isgreaterequal)
-
-// this is a gnu extension
-void sincos(double, double *, double *);
-void sincosf(float, float *, float *);
-void sincosl(long double, long double *, long double *);
-
-double exp10(double);
-float exp10f(float);
-long double exp10l(long double);
-
-double pow10(double);
-float pow10f(float);
-long double pow10l(long double);
-
-// [C11/7.12.4 Trigonometric functions]
-
-double acos(double x);
-float acosf(float x);
-long double acosl(long double x);
-
-double asin(double x);
-float asinf(float x);
-long double asinl(long double x);
-
-double atan(double x);
-float atanf(float x);
-long double atanl(long double x);
-
-double atan2(double x, double y);
-float atan2f(float x, float y);
-long double atan2l(long double x, long double y);
-
-double cos(double x);
-float cosf(float x);
-long double cosl(long double x);
-
-double sin(double x);
-float sinf(float x);
-long double sinl(long double x);
-
-double tan(double x);
-float tanf(float x);
-long double tanl(long double x);
-
-// [C11/7.12.5 Hyperbolic functions]
-
-double acosh(double x);
-float acoshf(float x);
-long double acoshl(long double x);
-
-double asinh(double x);
-float asinhf(float x);
-long double asinhl(long double x);
-
-double atanh(double x);
-float atanhf(float x);
-long double atanhl(long double x);
-
-double cosh(double x);
-float coshf(float x);
-long double coshl(long double x);
-
-double sinh(double x);
-float sinhf(float x);
-long double sinhl(long double x);
-
-double tanh(double x);
-float tanhf(float x);
-long double tanhl(long double x);
-
-// [C11/7.12.6 Exponential and logarithmic functions]
-
-double exp(double x);
-float expf(float x);
-long double expl(long double x);
-
-double exp2(double x);
-float exp2f(float x);
-long double exp2l(long double x);
-
-double expm1(double x);
-float expm1f(float x);
-long double expm1l(long double x);
-
-double frexp(double x, int *power);
-float frexpf(float x, int *power);
-long double frexpl(long double x, int *power);
-
-int ilogb(double x);
-int ilogbf(float x);
-int ilogbl(long double x);
-
-double ldexp(double x, int power);
-float ldexpf(float x, int power);
-long double ldexpl(long double x, int power);
-
-double log(double x);
-float logf(float x);
-long double logl(long double x);
-
-double log10(double x);
-float log10f(float x);
-long double log10l(long double x);
-
-double log1p(double x);
-float log1pf(float x);
-long double log1pl(long double x);
-
-double log2(double x);
-float log2f(float x);
-long double log2l(long double x);
-
-double logb(double x);
-float logbf(float x);
-long double logbl(long double x);
-
-double modf(double x, double *integral);
-float modff(float x, float *integral);
-long double modfl(long double x, long double *integral);
-
-double scalbn(double x, int power);
-float scalbnf(float x, int power);
-long double scalbnl(long double x, int power);
-
-double scalbln(double x, long power);
-float scalblnf(float x, long power);
-long double scalblnl(long double x, long power);
-
-// [C11/7.12.7 Power and absolute-value functions]
-
-double cbrt(double x);
-float cbrtf(float x);
-long double cbrtl(long double x);
-
-double fabs(double x);
-float fabsf(float x);
-long double fabsl(long double x);
-
-double hypot(double x, double y);
-float hypotf(float x, float y);
-long double hypotl(long double x, long double y);
-
-double pow(double x, double y);
-float powf(float x, float y);
-long double powl(long double x, long double y);
-
-double sqrt(double x);
-float sqrtf(float x);
-long double sqrtl(long double x);
-
-// [C11/7.12.8 Error and gamma functions]
-
-double erf(double x);
-float erff(float x);
-long double erfl(long double x);
-
-double erfc(double x);
-float erfcf(float x);
-long double erfcl(long double x);
-
-double lgamma(double x);
-float lgammaf(float x);
-long double lgammal(long double x);
-
-double tgamma(double x);
-float tgammaf(float x);
-long double tgammal(long double x);
-
-// [C11/7.12.9 Nearest integer functions]
-
-double ceil(double x);
-float ceilf(float x);
-long double ceill(long double x);
-
-double floor(double x);
-float floorf(float x);
-long double floorl(long double x);
-
-double nearbyint(double x);
-float nearbyintf(float x);
-long double nearbyintl(long double x);
-
-double rint(double x);
-float rintf(float x);
-long double rintl(long double x);
-
-long lrint(double x);
-long lrintf(float x);
-long lrintl(long double x);
-
-long long llrint(double x);
-long long llrintf(float x);
-long long llrintl(long double x);
-
-double round(double x);
-float roundf(float x);
-long double roundl(long double x);
-
-long lround(double x);
-long lroundf(float x);
-long lroundl(long double x);
-
-long long llround(double x);
-long long llroundf(float x);
-long long llroundl(long double x);
-
-double trunc(double x);
-float truncf(float x);
-long double truncl(long double x);
-
-// [C11/7.12.10 Remainder functions]
-
-double fmod(double x, double y);
-float fmodf(float x, float y);
-long double fmodl(long double x, long double y);
-
-double remainder(double x, double y);
-float remainderf(float x, float y);
-long double remainderl(long double x, long double y);
-
-double remquo(double x, double y, int *quotient);
-float remquof(float x, float y, int *quotient);
-long double remquol(long double x, long double y, int *quotient);
-
-// [C11/7.12.11 Manipulation functions]
-
-double copysign(double x, double sign);
-float copysignf(float x, float sign);
-long double copysignl(long double x, long double sign);
-
-double nan(const char *tag);
-float nanf(const char *tag);
-long double nanl(const char *tag);
-
-double nextafter(double x, double dir);
-float nextafterf(float x, float dir);
-long double nextafterl(long double x, long double dir);
-
-double nexttoward(double x, long double dir);
-float nexttowardf(float x, long double dir);
-long double nexttowardl(long double x, long double dir);
-
-// [C11/7.12.12 Maximum, minimum and positive difference functions]
-
-double fdim(double x, double y);
-float fdimf(float x, float y);
-long double fdiml(long double x, long double y);
-
-double fmax(double x, double y);
-float fmaxf(float x, float y);
-long double fmaxl(long double x, long double y);
-
-double fmin(double x, double y);
-float fminf(float x, float y);
-long double fminl(long double x, long double y);
-
-// [C11/7.12.13 Floating multiply-add]
-
-double fma(double, double, double);
-float fmaf(float, float, float);
-long double fmal(long double, long double, long double);
-
-extern int signgam;
-#define __signgam signgam
-
-// BSD floating-point classification functions - obsolete
-
-int finite(double x);
-int finitef(float x);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _MATH_H
-
diff --git a/lib/mlibc/options/ansi/include/mlibc/ansi-sysdeps.hpp b/lib/mlibc/options/ansi/include/mlibc/ansi-sysdeps.hpp
deleted file mode 100644
index 203084e..0000000
--- a/lib/mlibc/options/ansi/include/mlibc/ansi-sysdeps.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef MLIBC_ANSI_SYSDEPS
-#define MLIBC_ANSI_SYSDEPS
-
-#include <stddef.h>
-
-#include <abi-bits/seek-whence.h>
-#include <abi-bits/vm-flags.h>
-#include <abi-bits/pid_t.h>
-#include <abi-bits/mode_t.h>
-#include <bits/off_t.h>
-#include <bits/ssize_t.h>
-#include <bits/ansi/time_t.h>
-#include <signal.h>
-#include <stdarg.h>
-
-struct rusage;
-
-namespace [[gnu::visibility("hidden")]] mlibc {
-
-[[noreturn]] void sys_exit(int status);
-[[noreturn, gnu::weak]] void sys_thread_exit();
-
-// If *stack is not null, it should point to the lowest addressable byte of the stack.
-// Returns the new stack pointer in *stack and the stack base in *stack_base.
-[[gnu::weak]] int sys_prepare_stack(void **stack, void *entry, void *user_arg, void* tcb, size_t *stack_size, size_t *guard_size, void **stack_base);
-[[gnu::weak]] int sys_clone(void *tcb, pid_t *pid_out, void *stack);
-
-int sys_futex_wait(int *pointer, int expected, const struct timespec *time);
-int sys_futex_wake(int *pointer);
-
-int sys_open(const char *pathname, int flags, mode_t mode, int *fd);
-[[gnu::weak]] int sys_flock(int fd, int options);
-
-[[gnu::weak]] int sys_open_dir(const char *path, int *handle);
-[[gnu::weak]] int sys_read_entries(int handle, void *buffer, size_t max_size,
- size_t *bytes_read);
-
-int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read);
-
-int sys_write(int fd, const void *buf, size_t count, ssize_t *bytes_written);
-[[gnu::weak]] int sys_pread(int fd, void *buf, size_t n, off_t off, ssize_t *bytes_read);
-
-int sys_seek(int fd, off_t offset, int whence, off_t *new_offset);
-int sys_close(int fd);
-
-int sys_clock_get(int clock, time_t *secs, long *nanos);
-[[gnu::weak]] int sys_clock_getres(int clock, time_t *secs, long *nanos);
-[[gnu::weak]] int sys_sleep(time_t *secs, long *nanos);
-// In contrast to the isatty() library function, the sysdep function uses return value
-// zero (and not one) to indicate that the file is a terminal.
-[[gnu::weak]] int sys_isatty(int fd);
-[[gnu::weak]] int sys_rmdir(const char *path);
-[[gnu::weak]] int sys_unlinkat(int dirfd, const char *path, int flags);
-[[gnu::weak]] int sys_rename(const char *path, const char *new_path);
-[[gnu::weak]] int sys_renameat(int olddirfd, const char *old_path, int newdirfd, const char *new_path);
-
-[[gnu::weak]] int sys_sigprocmask(int how, const sigset_t *__restrict set,
- sigset_t *__restrict retrieve);
-[[gnu::weak]] int sys_sigaction(int, const struct sigaction *__restrict,
- struct sigaction *__restrict);
-
-[[gnu::weak]] int sys_fork(pid_t *child);
-[[gnu::weak]] int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru, pid_t *ret_pid);
-[[gnu::weak]] int sys_execve(const char *path, char *const argv[], char *const envp[]);
-
-[[gnu::weak]] pid_t sys_getpid();
-[[gnu::weak]] int sys_kill(int, int);
-
-} //namespace mlibc
-
-#endif // MLIBC_ANSI_SYSDEPS
diff --git a/lib/mlibc/options/ansi/include/mlibc/environment.hpp b/lib/mlibc/options/ansi/include/mlibc/environment.hpp
deleted file mode 100644
index 7fd5cf9..0000000
--- a/lib/mlibc/options/ansi/include/mlibc/environment.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef MLIBC_ENVIRONMENT_HPP
-#define MLIBC_ENVIRONMENT_HPP
-
-namespace mlibc {
-
-int putenv(char *string);
-
-} // namespace mlibc
-
-#endif // MLIBC_ENVIRONMENT_HPP
diff --git a/lib/mlibc/options/ansi/include/mlibc/file-io.hpp b/lib/mlibc/options/ansi/include/mlibc/file-io.hpp
deleted file mode 100644
index 1155a2b..0000000
--- a/lib/mlibc/options/ansi/include/mlibc/file-io.hpp
+++ /dev/null
@@ -1,111 +0,0 @@
-#ifndef MLIBC_FILE_IO_HPP
-#define MLIBC_FILE_IO_HPP
-
-#include <stdio.h>
-
-#include <mlibc/lock.hpp>
-#include <mlibc/allocator.hpp>
-#include <frg/list.hpp>
-
-namespace mlibc {
-
-enum class stream_type {
- unknown,
- file_like,
- pipe_like
-};
-
-enum class buffer_mode {
- unknown,
- no_buffer,
- line_buffer,
- full_buffer
-};
-
-struct abstract_file : __mlibc_file_base {
-public:
- abstract_file(void (*do_dispose)(abstract_file *) = nullptr);
-
- abstract_file(const abstract_file &) = delete;
-
- abstract_file &operator= (const abstract_file &) = delete;
-
- virtual ~abstract_file();
-
- void dispose();
-
- virtual int close() = 0;
- virtual int reopen(const char *path, const char *mode) = 0;
-
- int read(char *buffer, size_t max_size, size_t *actual_size);
- int write(const char *buffer, size_t max_size, size_t *actual_size);
- int unget(char c);
-
- int update_bufmode(buffer_mode mode);
-
- void purge();
- int flush();
-
- int tell(off_t *current_offset);
- int seek(off_t offset, int whence);
-
-protected:
- virtual int determine_type(stream_type *type) = 0;
- virtual int determine_bufmode(buffer_mode *mode) = 0;
- virtual int io_read(char *buffer, size_t max_size, size_t *actual_size) = 0;
- virtual int io_write(const char *buffer, size_t max_size, size_t *actual_size) = 0;
- virtual int io_seek(off_t offset, int whence, off_t *new_offset) = 0;
-
- int _reset();
-private:
- int _init_type();
- int _init_bufmode();
-
- int _write_back();
- int _save_pos();
-
- void _ensure_allocation();
-
- stream_type _type;
- buffer_mode _bufmode;
- void (*_do_dispose)(abstract_file *);
-
-public:
- // lock for file operations
- RecursiveFutexLock _lock;
- // All files are stored in a global linked list, so that they can be flushed at exit().
- frg::default_list_hook<abstract_file> _list_hook;
-};
-
-struct fd_file : abstract_file {
- fd_file(int fd, void (*do_dispose)(abstract_file *) = nullptr, bool force_unbuffered = false);
-
- int fd();
-
- int close() override;
- int reopen(const char *path, const char *mode) override;
-
- static int parse_modestring(const char *mode);
-
-protected:
- int determine_type(stream_type *type) override;
- int determine_bufmode(buffer_mode *mode) override;
-
- int io_read(char *buffer, size_t max_size, size_t *actual_size) override;
- int io_write(const char *buffer, size_t max_size, size_t *actual_size) override;
- int io_seek(off_t offset, int whence, off_t *new_offset) override;
-
-private:
- // Underlying file descriptor.
- int _fd;
- bool _force_unbuffered;
-};
-
-template <typename T>
-void file_dispose_cb(abstract_file *base) {
- frg::destruct(getAllocator(), static_cast<T *>(base));
-}
-
-} // namespace mlibc
-
-#endif // MLIBC_FILE_IO_HPP
diff --git a/lib/mlibc/options/ansi/include/setjmp.h b/lib/mlibc/options/ansi/include/setjmp.h
deleted file mode 100644
index 30346f0..0000000
--- a/lib/mlibc/options/ansi/include/setjmp.h
+++ /dev/null
@@ -1,48 +0,0 @@
-
-#ifndef _SETJMP_H
-#define _SETJMP_H
-
-#include <mlibc-config.h>
-#include <bits/machine.h>
-#include <abi-bits/signal.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// [C11/7.13] Non-local jumps
-
-typedef struct __jmp_buf {
- struct __mlibc_jmpbuf_register_state reg_state;
-} jmp_buf[1];
-
-#ifndef __MLIBC_ABI_ONLY
-
-__attribute__((__returns_twice__)) int setjmp(jmp_buf buffer);
-__attribute__((__noreturn__)) void longjmp(jmp_buf buffer, int value);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-// POSIX Non-local jumps signal extensions
-
-typedef struct __sigjmp_buf {
- struct __mlibc_jmpbuf_register_state reg_state;
- int savesigs;
- sigset_t sigset;
-} sigjmp_buf[1];
-
-#ifndef __MLIBC_ABI_ONLY
-
-#if __MLIBC_POSIX_OPTION
-__attribute__((__returns_twice__)) int sigsetjmp(sigjmp_buf buffer, int savesigs);
-__attribute__((__noreturn__)) void siglongjmp(sigjmp_buf buffer, int value);
-#endif // __MLIBC_POSIX_OPTION
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _SETJMP_H
-
diff --git a/lib/mlibc/options/ansi/include/signal.h b/lib/mlibc/options/ansi/include/signal.h
deleted file mode 100644
index e27592b..0000000
--- a/lib/mlibc/options/ansi/include/signal.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef _SIGNAL_H
-#define _SIGNAL_H
-
-#include <abi-bits/signal.h>
-#include <mlibc-config.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// [7.14] Signal handling basics
-
-typedef int sig_atomic_t;
-
-#define CLD_EXITED 1
-#define CLD_KILLED 2
-#define CLD_DUMPED 3
-#define CLD_TRAPPED 4
-#define CLD_STOPPED 5
-#define CLD_CONTINUED 6
-
-#ifndef __MLIBC_ABI_ONLY
-
-// [7.14.1] signal() function
-
-__sighandler signal(int sig, __sighandler handler);
-
-// [7.14.2] raise() function
-
-int raise(int sig);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#define _NSIG NSIG
-
-#ifdef __cplusplus
-}
-#endif
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_signal.h>
-#endif
-
-#if __MLIBC_GLIBC_OPTION
-# include <bits/glibc/glibc_signal.h>
-#endif
-
-#endif // _SIGNAL_H
diff --git a/lib/mlibc/options/ansi/include/stdc-predef.h b/lib/mlibc/options/ansi/include/stdc-predef.h
deleted file mode 100644
index a0e3e92..0000000
--- a/lib/mlibc/options/ansi/include/stdc-predef.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _STDC_PREDEF_H
-#define _STDC_PREDEF_H
-
-#define __STDC_ISO_10646__ 201206L
-
-#endif /* _STDC_PREDEF_H */
diff --git a/lib/mlibc/options/ansi/include/stdio.h b/lib/mlibc/options/ansi/include/stdio.h
deleted file mode 100644
index 168a3c7..0000000
--- a/lib/mlibc/options/ansi/include/stdio.h
+++ /dev/null
@@ -1,229 +0,0 @@
-
-#ifndef _STDIO_H
-#define _STDIO_H
-
-#include <abi-bits/seek-whence.h>
-#include <bits/null.h>
-#include <bits/size_t.h>
-#include <mlibc-config.h>
-
-// Glibc extensions require ssize_t.
-#include <bits/ssize_t.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// [C11-7.21.1] I/O related types
-
-#define __MLIBC_EOF_BIT 1
-#define __MLIBC_ERROR_BIT 2
-
-struct __mlibc_file_base {
- // Buffer for I/O operations.
- // We reserve a few extra bytes for ungetc operations. This means
- // that __buffer_ptr will point a few bytes *into* the allocation.
- char *__buffer_ptr;
-
- // Number of bytes the buffer can hold.
- size_t __buffer_size;
-
- // Current offset inside the buffer.
- size_t __offset;
-
- // Position inside the buffer that matches the current file pointer.
- size_t __io_offset;
-
- // Valid region of the buffer.
- size_t __valid_limit;
-
- // Begin and end of the dirty region inside the buffer.
- size_t __dirty_begin;
- size_t __dirty_end;
-
- // This points to the same place as __buffer_ptr, or a few bytes earlier
- // if there are bytes pushed by ungetc. If buffering is disabled, calls
- // to ungetc will trigger an allocation.
- char *__unget_ptr;
-
- // 0 if we are currently reading from the buffer.
- // 1 if we are currently writing to the buffer.
- // This is only really important for pipe-like streams.
- int __io_mode;
-
- // EOF and error bits.
- int __status_bits;
-};
-
-typedef struct __mlibc_file_base FILE;
-typedef size_t fpos_t;
-
-// [C11-7.21.1] I/O related macros
-
-#define _IOFBF 1
-#define _IOLBF 2
-#define _IONBF 3
-
-#define BUFSIZ 512
-
-#define EOF (-1)
-
-#define FOPEN_MAX 1024
-#define FILENAME_MAX 256
-#define L_tmpnam 256
-
-#define TMP_MAX 1024
-
-#ifndef __MLIBC_ABI_ONLY
-
-extern FILE *stderr;
-extern FILE *stdin;
-extern FILE *stdout;
-
-// [C11-7.21.4] Operations on files
-
-int remove(const char *filename);
-int rename(const char *old_path, const char *new_path);
-int renameat(int olddirfd, const char *old_path, int newdirfd, const char *new_path);
-FILE *tmpfile(void);
-char *tmpnam(char *buffer);
-
-// [C11-7.21.5] File access functions
-
-int fclose(FILE *stream);
-int fflush(FILE *stream);
-FILE *fopen(const char *__restrict filename, const char *__restrict mode);
-FILE *freopen(const char *__restrict filename, const char *__restrict mode, FILE *__restrict stream);
-void setbuf(FILE *__restrict stream, char *__restrict buffer);
-int setvbuf(FILE *__restrict stream, char *__restrict buffer, int mode, size_t size);
-void setlinebuf(FILE *stream);
-void setbuffer(FILE *, char *, size_t);
-
-// [C11-7.21.6] Formatted input/output functions
-
-__attribute__((__format__(printf, 2, 3)))
-int fprintf(FILE *__restrict stream, const char *__restrict format, ...);
-
-__attribute__((__format__(scanf, 2, 3)))
-int fscanf(FILE *__restrict stream, const char *__restrict format, ...);
-
-__attribute__((__format__(printf, 1, 2)))
-int printf(const char *__restrict format, ...);
-
-__attribute__((__format__(scanf, 1, 2)))
-int scanf(const char *__restrict format, ...);
-
-__attribute__((__format__(printf, 3, 4)))
-int snprintf(char *__restrict buffer, size_t max_size, const char *__restrict format, ...);
-
-__attribute__((__format__(printf, 2, 3)))
-int sprintf(char *__restrict buffer, const char *__restrict format, ...);
-
-__attribute__((__format__(scanf, 2, 3)))
-int sscanf(const char *__restrict buffer, const char *__restrict format, ...);
-
-__attribute__((__format__(printf, 2, 0)))
-int vfprintf(FILE *__restrict stream, const char *__restrict format, __builtin_va_list args);
-
-__attribute__((__format__(scanf, 2, 0)))
-int vfscanf(FILE *__restrict stream, const char *__restrict format, __builtin_va_list args);
-
-__attribute__((__format__(printf, 1, 0)))
-int vprintf(const char *__restrict format, __builtin_va_list args);
-
-__attribute__((__format__(scanf, 1, 0)))
-int vscanf(const char *__restrict format, __builtin_va_list args);
-
-__attribute__((__format__(printf, 3, 0)))
-int vsnprintf(char *__restrict buffer, size_t max_size,
- const char *__restrict format, __builtin_va_list args);
-
-__attribute__((__format__(printf, 2, 0)))
-int vsprintf(char *__restrict buffer, const char *__restrict format, __builtin_va_list args);
-
-__attribute__((__format__(scanf, 2, 0)))
-int vsscanf(const char *__restrict buffer, const char *__restrict format, __builtin_va_list args);
-
-// this is a gnu extension
-__attribute__((__format__(printf, 2, 0)))
-int vasprintf(char **, const char *, __builtin_va_list);
-
-// [C11-7.21.7] Character input/output functions
-
-int fgetc(FILE *stream);
-char *fgets(char *__restrict buffer, size_t max_size, FILE *__restrict stream);
-int fputc(int c, FILE *stream);
-int fputs(const char *__restrict string, FILE *__restrict stream);
-char *gets(char *s);
-int getc(FILE *stream);
-int getchar(void);
-int putc(int c, FILE *stream);
-int putchar(int c);
-int puts(const char *string);
-int ungetc(int c, FILE *stream);
-
-// [C11-7.21.8] Direct input/output functions
-
-size_t fread(void *__restrict buffer, size_t size, size_t count, FILE *__restrict stream);
-size_t fwrite(const void *__restrict buffer, size_t size, size_t count, FILE *__restrict stream);
-
-// [C11-7.21.9] File positioning functions
-
-int fgetpos(FILE *__restrict stream, fpos_t *__restrict position);
-int fseek(FILE *stream, long offset, int whence);
-int fsetpos(FILE *stream, const fpos_t *position);
-long ftell(FILE *stream);
-void rewind(FILE *stream);
-
-// [C11-7.21.10] Error handling functions
-
-void clearerr(FILE *stream);
-int feof(FILE *stream);
-int ferror(FILE *stream);
-void perror(const char *string);
-
-// POSIX unlocked I/O extensions.
-
-int getc_unlocked(FILE *);
-int getchar_unlocked(void);
-int putc_unlocked(int, FILE *);
-int putchar_unlocked(int);
-
-// GLIBC extensions.
-
-ssize_t getline(char **, size_t *, FILE *);
-ssize_t getdelim(char **, size_t *, int, FILE *);
-
-int asprintf(char **, const char *, ...);
-
-// Linux unlocked I/O extensions.
-
-void flockfile(FILE *);
-void funlockfile(FILE *);
-int ftrylockfile(FILE *);
-
-void clearerr_unlocked(FILE *);
-int feof_unlocked(FILE *);
-int ferror_unlocked(FILE *);
-int fileno_unlocked(FILE *);
-int fflush_unlocked(FILE *);
-int fgetc_unlocked(FILE *);
-int fputc_unlocked(int, FILE *);
-size_t fread_unlocked(void *__restrict, size_t, size_t, FILE *__restrict);
-size_t fwrite_unlocked(const void *__restrict, size_t, size_t, FILE *__restrict);
-
-char *fgets_unlocked(char *, int, FILE *);
-int fputs_unlocked(const char *, FILE *);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_stdio.h>
-#endif
-
-#endif // _STDIO_H
-
diff --git a/lib/mlibc/options/ansi/include/stdlib.h b/lib/mlibc/options/ansi/include/stdlib.h
deleted file mode 100644
index d0e916a..0000000
--- a/lib/mlibc/options/ansi/include/stdlib.h
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#include <alloca.h>
-#include <mlibc-config.h>
-#include <bits/null.h>
-#include <bits/size_t.h>
-#include <bits/wchar_t.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// [7.22] General utilities
-
-typedef struct {
- int quot, rem;
-} div_t;
-
-typedef struct {
- long quot, rem;
-} ldiv_t;
-
-typedef struct {
- long long quot, rem;
-} lldiv_t;
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#define RAND_MAX 0x7FFFFFFF
-
-// TODO: this should not be a compile-time constant
-#define MB_CUR_MAX 4
-
-#ifndef __MLIBC_ABI_ONLY
-
-// [7.22.1] Numeric conversion functions
-
-double atof(const char *string);
-int atoi(const char *string);
-long atol(const char *string);
-long long atoll(const char *string);
-double strtod(const char *__restrict string, char **__restrict end);
-float strtof(const char *__restrict string, char **__restrict end);
-long double strtold(const char *__restrict string, char **__restrict end);
-long strtol(const char *__restrict string, char **__restrict end, int base);
-long long strtoll(const char *__restrict string, char **__restrict end, int base);
-unsigned long strtoul(const char *__restrict string, char **__restrict end, int base);
-unsigned long long strtoull(const char *__restrict string, char **__restrict end, int base);
-
-// [7.22.2] Pseudo-random sequence generation functions
-
-int rand(void);
-int rand_r(unsigned *);
-void srand(unsigned int);
-
-// [7.22.3] Memory management functions
-
-void *aligned_alloc(size_t alignment, size_t size);
-void *calloc(size_t count, size_t size);
-void free(void *pointer);
-void *malloc(size_t size);
-void *realloc(void *pointer, size_t size);
-
-int posix_memalign(void **, size_t, size_t);
-
-// [7.22.4] Communication with the environment
-
-__attribute__((__noreturn__)) void abort(void);
-int atexit(void (*func)(void));
-int at_quick_exit(void (*func)(void));
-__attribute__((__noreturn__)) void exit(int status);
-__attribute__((__noreturn__)) void _Exit(int status);
-char *getenv(const char *name);
-__attribute__((__noreturn__)) void quick_exit(int status);
-int system(const char *string);
-
-// GLIBC extension.
-char *mktemp(char *);
-
-// [7.22.5] Searching and sorting utilities
-
-void *bsearch(const void *key, const void *base, size_t count, size_t size,
- int (*compare)(const void *, const void *));
-void qsort(void *base, size_t count, size_t size,
- int (*compare)(const void *, const void *));
-void qsort_r(void *base, size_t nmemb, size_t size,
- int (*compar)(const void *, const void *, void *),
- void *arg);
-
-// [7.22.6] Integer arithmetic functions
-
-int abs(int number);
-long labs(long number);
-long long llabs(long long number);
-
-div_t div(int number, int denom);
-ldiv_t ldiv(long number, long denom);
-lldiv_t lldiv(long long number, long long denom);
-
-// [7.22.7] Multibyte character conversion functions
-
-int mblen(const char *, size_t);
-int mbtowc(wchar_t *__restrict wc, const char *__restrict mb_chr, size_t max_size);
-int wctomb(char *mb_chr, wchar_t wc);
-
-// [7.22.8] Multibyte string conversion functions
-
-size_t mbstowcs(wchar_t *__restrict wc_string, const char *__restrict mb_string, size_t max_size);
-size_t wcstombs(char *mb_string, const wchar_t *__restrict wc_string, size_t max_size);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#if __MLIBC_GLIBC_OPTION
-typedef int (*comparison_fn_t) (const void *, const void *);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_stdlib.h>
-#endif
-
-#endif // _STDLIB_H
-
diff --git a/lib/mlibc/options/ansi/include/string.h b/lib/mlibc/options/ansi/include/string.h
deleted file mode 100644
index 5297e36..0000000
--- a/lib/mlibc/options/ansi/include/string.h
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifndef _STRING_H
-#define _STRING_H
-
-#include <mlibc-config.h>
-#include <bits/null.h>
-#include <bits/size_t.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-// [7.24.2] Copying functions
-
-void *memcpy(void *__restrict dest, const void *__restrict src, size_t size);
-void *memmove(void *dest, const void *src, size_t size);
-char *strcpy(char *__restrict dest, const char *src);
-char *strncpy(char *__restrict dest, const char *src, size_t max_size);
-
-// [7.24.3] Concatenation functions
-
-char *strcat(char *__restrict dest, const char *__restrict src);
-char *strncat(char *__restrict dest, const char *__restrict src, size_t max_size);
-
-// [7.24.4] Comparison functions
-
-int memcmp(const void *a, const void *b, size_t size);
-int strcmp(const char *a, const char *b);
-int strcoll(const char *a, const char *b);
-int strncmp(const char *a, const char *b, size_t max_size);
-size_t strxfrm(char *__restrict dest, const char *__restrict src, size_t max_size);
-
-// [7.24.5] Search functions
-
-void *memchr(const void *s, int c, size_t size);
-char *strchr(const char *s, int c);
-size_t strcspn(const char *s, const char *chrs);
-char *strpbrk(const char *s, const char *chrs);
-char *strrchr(const char *s, int c);
-size_t strspn(const char *s, const char *chrs);
-char *strstr(const char *pattern, const char *s);
-char *strtok(char *__restrict s, const char *__restrict delimiter);
-
-// This is a GNU extension.
-char *strchrnul(const char *, int);
-
-// [7.24.6] Miscellaneous functions
-
-void *memset(void *dest, int c, size_t size);
-char *strerror(int errnum);
-size_t strlen(const char *s);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#if __MLIBC_POSIX_OPTION && (defined(_BSD_SOURCE) || defined(_GNU_SOURCE))
-#include <strings.h>
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-// POSIX extensions.
-int strerror_r(int, char *, size_t);
-void *mempcpy(void *, const void *, size_t);
-
-// GNU extensions.
-int strverscmp(const char *l0, const char *r0);
-int ffsl(long i);
-int ffsll(long long i);
-void *memmem(const void *, size_t, const void *, size_t);
-
-/* Handling the basename mess:
- * If <libgen.h> is included *at all*, we use the XPG-defined basename
- * implementation, otherwise, we use the GNU one. Since our ABI previously
- * provided the XPG one under basename, we'll have to diverge from GNU here and
- * provide __mlibc_gnu_basename instead.
- */
-#if __MLIBC_GLIBC_OPTION && defined(_GNU_SOURCE) && !defined(basename)
-char *__mlibc_gnu_basename_c(const char *path);
-
-# ifdef __cplusplus
-extern "C++" {
-static inline const char *__mlibc_gnu_basename(const char *path) {
- return __mlibc_gnu_basename_c(path);
-}
-static inline char *__mlibc_gnu_basename(char *path) {
- return __mlibc_gnu_basename_c(path);
-}
-}
-# else
-# define __mlibc_gnu_basename __mlibc_gnu_basename_c
-# endif
-
-#define basename __mlibc_gnu_basename
-#endif
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_string.h>
-#endif
-
-#endif // _STRING_H
diff --git a/lib/mlibc/options/ansi/include/threads.h b/lib/mlibc/options/ansi/include/threads.h
deleted file mode 100644
index f96abcd..0000000
--- a/lib/mlibc/options/ansi/include/threads.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef _THREADS_H
-#define _THREADS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <bits/threads.h>
-
-enum {
- mtx_plain,
- mtx_recursive,
- mtx_timed,
-};
-
-enum {
- thrd_success,
- thrd_timedout,
- thrd_busy,
- thrd_error,
- thrd_nomem,
-};
-
-typedef struct __mlibc_thread_data *thrd_t;
-typedef struct __mlibc_mutex mtx_t;
-typedef struct __mlibc_cond cnd_t;
-#ifndef __cplusplus
-#define thread_local _Thread_local
-#endif
-
-typedef int (*thrd_start_t)(void*);
-
-#ifndef __MLIBC_ABI_ONLY
-
-int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);
-int thrd_equal(thrd_t lhs, thrd_t rhs);
-thrd_t thrd_current(void);
-int thrd_sleep(const struct timespec *duration, struct timespec *remaining);
-void thrd_yield(void);
-int thrd_detach(thrd_t thr);
-int thrd_join(thrd_t thr, int *res);
-__attribute__((__noreturn__)) void thrd_exit(int res);
-
-int mtx_init(mtx_t *mtx, int type);
-void mtx_destroy(mtx_t *mtx);
-int mtx_lock(mtx_t *mtx);
-int mtx_unlock(mtx_t *mtx);
-
-int cnd_init(cnd_t *cond);
-void cnd_destroy(cnd_t *cond);
-int cnd_broadcast(cnd_t *cond);
-int cnd_wait(cnd_t *cond, mtx_t *mtx);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _THREADS_H */
-
diff --git a/lib/mlibc/options/ansi/include/time.h b/lib/mlibc/options/ansi/include/time.h
deleted file mode 100644
index a3239e9..0000000
--- a/lib/mlibc/options/ansi/include/time.h
+++ /dev/null
@@ -1,154 +0,0 @@
-#ifndef _TIME_H
-#define _TIME_H
-
-#include <bits/null.h>
-#include <bits/size_t.h>
-#include <bits/ansi/time_t.h>
-#include <bits/ansi/timespec.h>
-#include <mlibc-config.h>
-
-// [7.27.1] Components of time
-
-#define CLOCKS_PER_SEC ((clock_t)1000000)
-
-#define TIME_UTC 1
-
-// POSIX extensions.
-
-#define CLOCK_REALTIME 0
-#define CLOCK_MONOTONIC 1
-#define CLOCK_PROCESS_CPUTIME_ID 2
-#define CLOCK_THREAD_CPUTIME_ID 3
-#define CLOCK_MONOTONIC_RAW 4
-#define CLOCK_REALTIME_COARSE 5
-#define CLOCK_MONOTONIC_COARSE 6
-#define CLOCK_BOOTTIME 7
-#define CLOCK_REALTIME_ALARM 8
-#define CLOCK_BOOTTIME_ALARM 9
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// [7.27.1] Components of time
-
-typedef long clock_t; // Matches Linux' ABI.
-
-struct tm {
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- long int tm_gmtoff;
- const char *tm_zone;
-};
-
-#ifndef __MLIBC_ABI_ONLY
-
-// [7.27.2] Time manipulation functions
-
-clock_t clock(void);
-double difftime(time_t a, time_t b);
-time_t mktime(struct tm *ptr);
-time_t time(time_t *timer);
-int timespec_get(struct timespec *ptr, int base);
-
-// [7.27.3] Time conversion functions
-
-char *asctime(const struct tm *ptr);
-char *ctime(const time_t *timer);
-struct tm *gmtime(const time_t *timer);
-struct tm *gmtime_r(const time_t *__restrict timer, struct tm *__restrict result);
-struct tm *localtime(const time_t *timer);
-size_t strftime(char *__restrict dest, size_t max_size,
- const char *__restrict format, const struct tm *__restrict ptr);
-
-void tzset(void);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-// POSIX extensions.
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_time.h>
-# include <bits/posix/timer_t.h>
-#endif // __MLIBC_POSIX_OPTION
-
-#include <abi-bits/clockid_t.h>
-
-#define TIMER_ABSTIME 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-extern int daylight;
-extern long timezone;
-extern char *tzname[2];
-
-int nanosleep(const struct timespec *, struct timespec *);
-
-int clock_getres(clockid_t, struct timespec *);
-int clock_gettime(clockid_t, struct timespec *);
-int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
-int clock_settime(clockid_t, const struct timespec *);
-
-struct tm *localtime_r(const time_t *, struct tm *);
-char *asctime_r(const struct tm *tm, char *buf);
-char *ctime_r(const time_t *, char *);
-
-#if __MLIBC_POSIX_OPTION
-char *strptime(const char *__restrict, const char *__restrict,
- struct tm *__restrict);
-#endif /* __MLIBC_POSIX_OPTION */
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-// GNU extensions.
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __MLIBC_ABI_ONLY
-
-time_t timelocal(struct tm *);
-time_t timegm(struct tm *);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-// Linux extensions.
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct itimerspec {
- struct timespec it_interval;
- struct timespec it_value;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _TIME_H
diff --git a/lib/mlibc/options/ansi/include/uchar.h b/lib/mlibc/options/ansi/include/uchar.h
deleted file mode 100644
index 3651a60..0000000
--- a/lib/mlibc/options/ansi/include/uchar.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef _UCHAR_H
-#define _UCHAR_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <bits/mbstate.h>
-#include <bits/size_t.h>
-
-#ifndef __cplusplus
-typedef __CHAR16_TYPE__ char16_t;
-typedef __CHAR32_TYPE__ char32_t;
-#endif /* __cplusplus */
-
-typedef struct __mlibc_mbstate mbstate_t;
-
-#ifndef __MLIBC_ABI_ONLY
-
-size_t c32rtomb(char *pmb, char32_t c32, mbstate_t *ps);
-size_t mbrtoc32(char32_t *pc32, const char *pmb, size_t max, mbstate_t *ps);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _UCHAR_H */
diff --git a/lib/mlibc/options/ansi/include/wchar.h b/lib/mlibc/options/ansi/include/wchar.h
deleted file mode 100644
index 27198c5..0000000
--- a/lib/mlibc/options/ansi/include/wchar.h
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef _WCHAR_H
-#define _WCHAR_H
-
-#include <bits/null.h>
-#include <bits/size_t.h>
-#include <bits/wchar_t.h>
-#include <bits/wchar.h>
-#include <bits/wint_t.h>
-#include <bits/mbstate.h>
-
-#define WEOF 0xffffffffU
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct __mlibc_file_base FILE;
-
-typedef struct __mlibc_mbstate mbstate_t;
-
-// MISSING: struct tm
-
-#ifndef __MLIBC_ABI_ONLY
-
-// [7.28.2] Wide formatted I/O functions
-
-int fwprintf(FILE *__restrict, const wchar_t *__restrict, ...);
-int fwscanf(FILE *__restrict, const wchar_t *__restrict, ...);
-int vfwprintf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list);
-int vfwscanf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list);
-
-int swprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
-int swscanf(wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
-int vswprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, __builtin_va_list);
-int vswscanf(wchar_t *__restrict, size_t, const wchar_t *__restrict, __builtin_va_list);
-
-int wprintf(const wchar_t *__restrict, ...);
-int wscanf(const wchar_t *__restrict, ...);
-int vwprintf(const wchar_t *__restrict, __builtin_va_list);
-int vwscanf(const wchar_t *__restrict, __builtin_va_list);
-
-// [7.28.3] Wide character I/O functions
-
-wint_t fgetwc(FILE *);
-wchar_t *fgetws(wchar_t *__restrict, int, FILE *__restrict);
-wint_t fputwc(wchar_t, FILE *);
-int fputws(const wchar_t *__restrict, FILE *__restrict);
-int fwide(FILE *, int);
-wint_t getwc(FILE *);
-wint_t getwchar(void);
-wint_t putwc(wchar_t, FILE *);
-wint_t putwchar(wchar_t);
-wint_t ungetwc(wint_t, FILE *);
-
-// [7.28.4] Wide string functions
-
-double wcstod(const wchar_t *__restrict, wchar_t **__restrict);
-float wcstof(const wchar_t *__restrict, wchar_t **__restrict);
-long double wcstold(const wchar_t *__restrict, wchar_t **__restrict);
-
-long wcstol(const wchar_t *__restrict, wchar_t **__restrict, int);
-long long wcstoll(const wchar_t *__restrict, wchar_t **__restrict, int);
-unsigned long wcstoul(const wchar_t *__restrict, wchar_t **__restrict, int);
-unsigned long long wcstoull(const wchar_t *__restrict, wchar_t **__restrict, int);
-
-wchar_t *wcscpy(wchar_t *__restrict, const wchar_t *__restrict);
-wchar_t *wcsncpy(wchar_t *__restrict, const wchar_t *__restrict, size_t);
-wchar_t *wmemcpy(wchar_t *__restrict, const wchar_t *__restrict, size_t);
-wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
-
-wchar_t *wcscat(wchar_t *__restrict, const wchar_t *__restrict);
-wchar_t *wcsncat(wchar_t *__restrict, const wchar_t *__restrict, size_t);
-
-int wcscmp(const wchar_t *, const wchar_t *);
-int wcscoll(const wchar_t *, const wchar_t *);
-int wcsncmp(const wchar_t *, const wchar_t *, size_t);
-int wcsxfrm(wchar_t *__restrict, const wchar_t *__restrict, size_t);
-int wmemcmp(const wchar_t *, const wchar_t *, size_t);
-
-wchar_t *wcschr(const wchar_t *, wchar_t);
-size_t wcscspn(const wchar_t *, const wchar_t *);
-wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
-wchar_t *wcsrchr(const wchar_t *, wchar_t);
-size_t wcsspn(const wchar_t *, const wchar_t *);
-wchar_t *wcsstr(const wchar_t *, const wchar_t *);
-wchar_t *wcstok(wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict);
-wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
-
-size_t wcslen(const wchar_t *);
-wchar_t *wmemset(wchar_t *, wchar_t, size_t);
-
-// [7.28.5] Wide date/time functions
-
-/* POSIX says:
- * The tag tm is declared as naming an incomplete structure type, the contents of which are
- * described in the header <time.h>. */
-struct tm;
-size_t wcsftime(wchar_t *__restrict, size_t, const wchar_t *__restrict,
- const struct tm *__restrict);
-
-// [7.28.6] Wide conversion functions
-
-wint_t btowc(int c);
-int wctob(wint_t);
-
-int mbsinit(const mbstate_t *);
-size_t mbrlen(const char *__restrict, size_t, mbstate_t *__restrict);
-size_t mbrtowc(wchar_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
-size_t wcrtomb(char *__restrict, wchar_t, mbstate_t *__restrict);
-size_t mbsrtowcs(wchar_t *__restrict, const char **__restrict, size_t, mbstate_t *__restrict);
-size_t mbsnrtowcs(wchar_t *__restrict, const char **__restrict, size_t, size_t, mbstate_t *__restrict);
-size_t wcsrtombs(char *__restrict, const wchar_t **__restrict, size_t, mbstate_t *__restrict);
-size_t wcsnrtombs(char *__restrict, const wchar_t **__restrict, size_t, size_t, mbstate_t *__restrict);
-
-// POSIX extensions
-int wcwidth(wchar_t wc);
-int wcswidth(const wchar_t *, size_t);
-wchar_t *wcsdup(const wchar_t *s);
-int wcsncasecmp(const wchar_t*, const wchar_t*, size_t);
-int wcscasecmp(const wchar_t *, const wchar_t *);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _WCHAR_H
diff --git a/lib/mlibc/options/ansi/include/wctype.h b/lib/mlibc/options/ansi/include/wctype.h
deleted file mode 100644
index df5d37a..0000000
--- a/lib/mlibc/options/ansi/include/wctype.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef _WCTYPE_H
-#define _WCTYPE_H
-
-#include <mlibc-config.h>
-#include <bits/wint_t.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef unsigned long wctype_t;
-typedef unsigned long wctrans_t;
-
-#ifndef __MLIBC_ABI_ONLY
-
-// [C11/7.30.2.2] Extensible wide character classification functions.
-
-int iswalnum(wint_t);
-int iswalpha(wint_t);
-int iswblank(wint_t);
-int iswcntrl(wint_t);
-int iswdigit(wint_t);
-int iswgraph(wint_t);
-int iswlower(wint_t);
-int iswprint(wint_t);
-int iswpunct(wint_t);
-int iswspace(wint_t);
-int iswupper(wint_t);
-int iswxdigit(wint_t);
-
-wctype_t wctype(const char *);
-int iswctype(wint_t, wctype_t);
-
-// [C11/7.30.3] Wide character case mapping utilities.
-
-wint_t towlower(wint_t);
-wint_t towupper(wint_t);
-
-wctrans_t wctrans(const char *);
-wint_t towctrans(wint_t, wctrans_t);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#if __MLIBC_POSIX_OPTION
-# include <bits/posix/posix_wctype.h>
-#endif
-
-#endif // _WCTYPE_H
diff --git a/lib/mlibc/options/ansi/meson.build b/lib/mlibc/options/ansi/meson.build
deleted file mode 100644
index ae1d3ad..0000000
--- a/lib/mlibc/options/ansi/meson.build
+++ /dev/null
@@ -1,326 +0,0 @@
-
-if disable_ansi_option
- subdir_done()
-endif
-
-ansi_sources = files(
- 'generic/stdlib-stubs.cpp',
- 'generic/assert-stubs.cpp',
- 'generic/complex-stubs.c',
-
- 'generic/complex/csqrt.c',
- 'generic/complex/csinhf.c',
- 'generic/complex/ccoshf.c',
- 'generic/complex/cacosh.c',
- 'generic/complex/casinf.c',
- 'generic/complex/clogf.c',
- 'generic/complex/csqrtf.c',
- 'generic/complex/cimag.c',
- 'generic/complex/catanh.c',
- 'generic/complex/carg.c',
- 'generic/complex/cproj.c',
- 'generic/complex/cephes_subr.c',
- 'generic/complex/ccos.c',
- 'generic/complex/cexp.c',
- 'generic/complex/crealf.c',
- 'generic/complex/cabs.c',
- 'generic/complex/csinh.c',
- 'generic/complex/casinhf.c',
- 'generic/complex/cephes_subrf.c',
- 'generic/complex/creal.c',
- 'generic/complex/casin.c',
- 'generic/complex/conjf.c',
- 'generic/complex/cpowf.c',
- 'generic/complex/cacosf.c',
- 'generic/complex/csinf.c',
- 'generic/complex/ctanh.c',
- 'generic/complex/ctanhf.c',
- 'generic/complex/cargf.c',
- 'generic/complex/cabsf.c',
- 'generic/complex/cpow.c',
- 'generic/complex/csin.c',
- 'generic/complex/cprojf.c',
- 'generic/complex/catan.c',
- 'generic/complex/ctanf.c',
- 'generic/complex/ctan.c',
- 'generic/complex/clog.c',
- 'generic/complex/catanf.c',
- 'generic/complex/cacos.c',
- 'generic/complex/cexpf.c',
- 'generic/complex/ccosh.c',
- 'generic/complex/cimagf.c',
- 'generic/complex/cacoshf.c',
- 'generic/complex/conj.c',
- 'generic/complex/catanhf.c',
- 'generic/complex/ccosf.c',
- 'generic/complex/casinh.c',
-
- 'generic/ctype-stubs.cpp',
- 'generic/environment.cpp',
- 'generic/errno-stubs.cpp',
- 'generic/fenv-stubs.cpp',
- 'generic/file-io.cpp',
- 'generic/inttypes-stubs.cpp',
- 'generic/locale-stubs.cpp',
- 'generic/signal-stubs.cpp',
- 'generic/stdio-stubs.cpp',
- 'generic/stdlib-stubs.cpp',
- 'generic/string-stubs.cpp',
- 'generic/threads.cpp',
- 'generic/time-stubs.cpp',
- 'generic/uchar.cpp',
- 'generic/wchar-stubs.cpp',
- 'generic/wctype.cpp',
-)
-
-if not no_headers
- install_headers(
- 'include/alloca.h',
- 'include/assert.h',
- 'include/complex.h',
- 'include/ctype.h',
- 'include/errno.h',
- 'include/fenv.h',
- 'include/inttypes.h',
- 'include/limits.h',
- 'include/locale.h',
- 'include/math.h',
- 'include/setjmp.h',
- 'include/signal.h',
- 'include/stdc-predef.h',
- 'include/stdio.h',
- 'include/stdlib.h',
- 'include/string.h',
- 'include/threads.h',
- 'include/time.h',
- 'include/uchar.h',
- 'include/wchar.h',
- 'include/wctype.h',
- )
- install_headers(
- 'include/bits/ansi/timespec.h',
- 'include/bits/ansi/time_t.h',
- 'include/bits/ansi/fenv.h',
- subdir: 'bits/ansi'
- )
-endif
-
-if not headers_only
- libc_sublibs += static_library('mlibc-musl-math',
- 'musl-generic-math/acos.c',
- 'musl-generic-math/acosf.c',
- 'musl-generic-math/acosh.c',
- 'musl-generic-math/acoshf.c',
- 'musl-generic-math/acoshl.c',
- 'musl-generic-math/acosl.c',
- 'musl-generic-math/asin.c',
- 'musl-generic-math/asinf.c',
- 'musl-generic-math/asinh.c',
- 'musl-generic-math/asinhf.c',
- 'musl-generic-math/asinhl.c',
- 'musl-generic-math/asinl.c',
- 'musl-generic-math/atan2.c',
- 'musl-generic-math/atan2f.c',
- 'musl-generic-math/atan2l.c',
- 'musl-generic-math/atan.c',
- 'musl-generic-math/atanf.c',
- 'musl-generic-math/atanh.c',
- 'musl-generic-math/atanhf.c',
- 'musl-generic-math/atanhl.c',
- 'musl-generic-math/atanl.c',
- 'musl-generic-math/cbrt.c',
- 'musl-generic-math/cbrtf.c',
- 'musl-generic-math/cbrtl.c',
- 'musl-generic-math/ceil.c',
- 'musl-generic-math/ceilf.c',
- 'musl-generic-math/ceill.c',
- 'musl-generic-math/copysign.c',
- 'musl-generic-math/copysignf.c',
- 'musl-generic-math/copysignl.c',
- 'musl-generic-math/__cos.c',
- 'musl-generic-math/cos.c',
- 'musl-generic-math/__cosdf.c',
- 'musl-generic-math/cosf.c',
- 'musl-generic-math/cosh.c',
- 'musl-generic-math/coshf.c',
- 'musl-generic-math/coshl.c',
- 'musl-generic-math/__cosl.c',
- 'musl-generic-math/cosl.c',
- 'musl-generic-math/erf.c',
- 'musl-generic-math/erff.c',
- 'musl-generic-math/erfl.c',
- 'musl-generic-math/exp10.c',
- 'musl-generic-math/exp10f.c',
- 'musl-generic-math/exp10l.c',
- 'musl-generic-math/exp2.c',
- 'musl-generic-math/exp2f.c',
- 'musl-generic-math/exp2l.c',
- 'musl-generic-math/exp.c',
- 'musl-generic-math/expf.c',
- 'musl-generic-math/expl.c',
- 'musl-generic-math/expm1.c',
- 'musl-generic-math/expm1f.c',
- 'musl-generic-math/expm1l.c',
- 'musl-generic-math/__expo2.c',
- 'musl-generic-math/__expo2f.c',
- 'musl-generic-math/fabs.c',
- 'musl-generic-math/fabsf.c',
- 'musl-generic-math/fabsl.c',
- 'musl-generic-math/fdim.c',
- 'musl-generic-math/fdimf.c',
- 'musl-generic-math/fdiml.c',
- 'musl-generic-math/finite.c',
- 'musl-generic-math/finitef.c',
- 'musl-generic-math/floor.c',
- 'musl-generic-math/floorf.c',
- 'musl-generic-math/floorl.c',
- 'musl-generic-math/fma.c',
- 'musl-generic-math/fmaf.c',
- 'musl-generic-math/fmal.c',
- 'musl-generic-math/fmax.c',
- 'musl-generic-math/fmaxf.c',
- 'musl-generic-math/fmaxl.c',
- 'musl-generic-math/fmin.c',
- 'musl-generic-math/fminf.c',
- 'musl-generic-math/fminl.c',
- 'musl-generic-math/fmod.c',
- 'musl-generic-math/fmodf.c',
- 'musl-generic-math/fmodl.c',
- 'musl-generic-math/__fpclassify.c',
- 'musl-generic-math/__fpclassifyf.c',
- 'musl-generic-math/__fpclassifyl.c',
- 'musl-generic-math/frexp.c',
- 'musl-generic-math/frexpf.c',
- 'musl-generic-math/frexpl.c',
- 'musl-generic-math/hypot.c',
- 'musl-generic-math/hypotf.c',
- 'musl-generic-math/hypotl.c',
- 'musl-generic-math/ilogb.c',
- 'musl-generic-math/ilogbf.c',
- 'musl-generic-math/ilogbl.c',
- 'musl-generic-math/__invtrigl.c',
- 'musl-generic-math/j0.c',
- 'musl-generic-math/j0f.c',
- 'musl-generic-math/j1.c',
- 'musl-generic-math/j1f.c',
- 'musl-generic-math/jn.c',
- 'musl-generic-math/jnf.c',
- 'musl-generic-math/ldexp.c',
- 'musl-generic-math/ldexpf.c',
- 'musl-generic-math/ldexpl.c',
- 'musl-generic-math/lgamma.c',
- 'musl-generic-math/lgammaf.c',
- 'musl-generic-math/lgammaf_r.c',
- 'musl-generic-math/lgammal.c',
- 'musl-generic-math/lgamma_r.c',
- 'musl-generic-math/llrint.c',
- 'musl-generic-math/llrintf.c',
- 'musl-generic-math/llrintl.c',
- 'musl-generic-math/llround.c',
- 'musl-generic-math/llroundf.c',
- 'musl-generic-math/llroundl.c',
- 'musl-generic-math/log10.c',
- 'musl-generic-math/log10f.c',
- 'musl-generic-math/log10l.c',
- 'musl-generic-math/log1p.c',
- 'musl-generic-math/log1pf.c',
- 'musl-generic-math/log1pl.c',
- 'musl-generic-math/log2.c',
- 'musl-generic-math/log2f.c',
- 'musl-generic-math/log2l.c',
- 'musl-generic-math/logb.c',
- 'musl-generic-math/logbf.c',
- 'musl-generic-math/logbl.c',
- 'musl-generic-math/log.c',
- 'musl-generic-math/logf.c',
- 'musl-generic-math/logl.c',
- 'musl-generic-math/lrint.c',
- 'musl-generic-math/lrintf.c',
- 'musl-generic-math/lrintl.c',
- 'musl-generic-math/lround.c',
- 'musl-generic-math/lroundf.c',
- 'musl-generic-math/lroundl.c',
- 'musl-generic-math/modf.c',
- 'musl-generic-math/modff.c',
- 'musl-generic-math/modfl.c',
- 'musl-generic-math/nan.c',
- 'musl-generic-math/nanf.c',
- 'musl-generic-math/nanl.c',
- 'musl-generic-math/nearbyint.c',
- 'musl-generic-math/nearbyintf.c',
- 'musl-generic-math/nearbyintl.c',
- 'musl-generic-math/nextafter.c',
- 'musl-generic-math/nextafterf.c',
- 'musl-generic-math/nextafterl.c',
- 'musl-generic-math/nexttoward.c',
- 'musl-generic-math/nexttowardf.c',
- 'musl-generic-math/nexttowardl.c',
- 'musl-generic-math/__polevll.c',
- 'musl-generic-math/pow.c',
- 'musl-generic-math/powf.c',
- 'musl-generic-math/powl.c',
- 'musl-generic-math/remainder.c',
- 'musl-generic-math/remainderf.c',
- 'musl-generic-math/remainderl.c',
- 'musl-generic-math/__rem_pio2.c',
- 'musl-generic-math/__rem_pio2f.c',
- 'musl-generic-math/__rem_pio2_large.c',
- 'musl-generic-math/__rem_pio2l.c',
- 'musl-generic-math/remquo.c',
- 'musl-generic-math/remquof.c',
- 'musl-generic-math/remquol.c',
- 'musl-generic-math/rint.c',
- 'musl-generic-math/rintf.c',
- 'musl-generic-math/rintl.c',
- 'musl-generic-math/round.c',
- 'musl-generic-math/roundf.c',
- 'musl-generic-math/roundl.c',
- 'musl-generic-math/scalb.c',
- 'musl-generic-math/scalbf.c',
- 'musl-generic-math/scalbln.c',
- 'musl-generic-math/scalblnf.c',
- 'musl-generic-math/scalblnl.c',
- 'musl-generic-math/scalbn.c',
- 'musl-generic-math/scalbnf.c',
- 'musl-generic-math/scalbnl.c',
- 'musl-generic-math/__signbit.c',
- 'musl-generic-math/__signbitf.c',
- 'musl-generic-math/__signbitl.c',
- 'musl-generic-math/signgam.c',
- 'musl-generic-math/significand.c',
- 'musl-generic-math/significandf.c',
- 'musl-generic-math/__sin.c',
- 'musl-generic-math/sin.c',
- 'musl-generic-math/sincos.c',
- 'musl-generic-math/sincosf.c',
- 'musl-generic-math/sincosl.c',
- 'musl-generic-math/__sindf.c',
- 'musl-generic-math/sinf.c',
- 'musl-generic-math/sinh.c',
- 'musl-generic-math/sinhf.c',
- 'musl-generic-math/sinhl.c',
- 'musl-generic-math/__sinl.c',
- 'musl-generic-math/sinl.c',
- 'musl-generic-math/sqrt.c',
- 'musl-generic-math/sqrtf.c',
- 'musl-generic-math/sqrtl.c',
- 'musl-generic-math/__tan.c',
- 'musl-generic-math/tan.c',
- 'musl-generic-math/__tandf.c',
- 'musl-generic-math/tanf.c',
- 'musl-generic-math/tanh.c',
- 'musl-generic-math/tanhf.c',
- 'musl-generic-math/tanhl.c',
- 'musl-generic-math/__tanl.c',
- 'musl-generic-math/tanl.c',
- 'musl-generic-math/tgamma.c',
- 'musl-generic-math/tgammaf.c',
- 'musl-generic-math/tgammal.c',
- 'musl-generic-math/trunc.c',
- 'musl-generic-math/truncf.c',
- 'musl-generic-math/truncl.c',
- pic: true,
- include_directories: libc_include_dirs,
- dependencies: libc_deps,
- c_args: ['-Wno-unused', '-Wno-implicit', '-Wno-parentheses', '-Wno-sign-compare', '-Wno-attributes', '-Wno-unknown-pragmas', '-Wno-maybe-uninitialized'])
-endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__cos.c b/lib/mlibc/options/ansi/musl-generic-math/__cos.c
deleted file mode 100644
index 46cefb3..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__cos.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/k_cos.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * __cos( x, y )
- * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- *
- * Algorithm
- * 1. Since cos(-x) = cos(x), we need only to consider positive x.
- * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0.
- * 3. cos(x) is approximated by a polynomial of degree 14 on
- * [0,pi/4]
- * 4 14
- * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x
- * where the remez error is
- *
- * | 2 4 6 8 10 12 14 | -58
- * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2
- * | |
- *
- * 4 6 8 10 12 14
- * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then
- * cos(x) ~ 1 - x*x/2 + r
- * since cos(x+y) ~ cos(x) - sin(x)*y
- * ~ cos(x) - x*y,
- * a correction term is necessary in cos(x) and hence
- * cos(x+y) = 1 - (x*x/2 - (r - x*y))
- * For better accuracy, rearrange to
- * cos(x+y) ~ w + (tmp + (r-x*y))
- * where w = 1 - x*x/2 and tmp is a tiny correction term
- * (1 - x*x/2 == w + tmp exactly in infinite precision).
- * The exactness of w + tmp in infinite precision depends on w
- * and tmp having the same precision as x. If they have extra
- * precision due to compiler bugs, then the extra precision is
- * only good provided it is retained in all terms of the final
- * expression for cos(). Retention happens in all cases tested
- * under FreeBSD, so don't pessimize things by forcibly clipping
- * any extra precision in w.
- */
-
-#include "libm.h"
-
-static const double
-C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
-C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
-C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */
-C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
-C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
-C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
-
-double __cos(double x, double y)
-{
- double_t hz,z,r,w;
-
- z = x*x;
- w = z*z;
- r = z*(C1+z*(C2+z*C3)) + w*w*(C4+z*(C5+z*C6));
- hz = 0.5*z;
- w = 1.0-hz;
- return w + (((1.0-w)-hz) + (z*r-x*y));
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__cosdf.c b/lib/mlibc/options/ansi/musl-generic-math/__cosdf.c
deleted file mode 100644
index 2124989..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__cosdf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/k_cosf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Debugged and optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
-static const double
-C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
-C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
-C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
-C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
-
-float __cosdf(double x)
-{
- double_t r, w, z;
-
- /* Try to optimize for parallel evaluation as in __tandf.c. */
- z = x*x;
- w = z*z;
- r = C2+z*C3;
- return ((1.0+z*C0) + w*C1) + (w*z)*r;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__cosl.c b/lib/mlibc/options/ansi/musl-generic-math/__cosl.c
deleted file mode 100644
index fa522dd..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__cosl.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/ld80/k_cosl.c */
-/* origin: FreeBSD /usr/src/lib/msun/ld128/k_cosl.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-
-#include "libm.h"
-
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
-/*
- * ld80 version of __cos.c. See __cos.c for most comments.
- */
-/*
- * Domain [-0.7854, 0.7854], range ~[-2.43e-23, 2.425e-23]:
- * |cos(x) - c(x)| < 2**-75.1
- *
- * The coefficients of c(x) were generated by a pari-gp script using
- * a Remez algorithm that searches for the best higher coefficients
- * after rounding leading coefficients to a specified precision.
- *
- * Simpler methods like Chebyshev or basic Remez barely suffice for
- * cos() in 64-bit precision, because we want the coefficient of x^2
- * to be precisely -0.5 so that multiplying by it is exact, and plain
- * rounding of the coefficients of a good polynomial approximation only
- * gives this up to about 64-bit precision. Plain rounding also gives
- * a mediocre approximation for the coefficient of x^4, but a rounding
- * error of 0.5 ulps for this coefficient would only contribute ~0.01
- * ulps to the final error, so this is unimportant. Rounding errors in
- * higher coefficients are even less important.
- *
- * In fact, coefficients above the x^4 one only need to have 53-bit
- * precision, and this is more efficient. We get this optimization
- * almost for free from the complications needed to search for the best
- * higher coefficients.
- */
-static const long double
-C1 = 0.0416666666666666666136L; /* 0xaaaaaaaaaaaaaa9b.0p-68 */
-static const double
-C2 = -0.0013888888888888874, /* -0x16c16c16c16c10.0p-62 */
-C3 = 0.000024801587301571716, /* 0x1a01a01a018e22.0p-68 */
-C4 = -0.00000027557319215507120, /* -0x127e4fb7602f22.0p-74 */
-C5 = 0.0000000020876754400407278, /* 0x11eed8caaeccf1.0p-81 */
-C6 = -1.1470297442401303e-11, /* -0x19393412bd1529.0p-89 */
-C7 = 4.7383039476436467e-14; /* 0x1aac9d9af5c43e.0p-97 */
-#define POLY(z) (z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*C7)))))))
-#elif LDBL_MANT_DIG == 113
-/*
- * ld128 version of __cos.c. See __cos.c for most comments.
- */
-/*
- * Domain [-0.7854, 0.7854], range ~[-1.80e-37, 1.79e-37]:
- * |cos(x) - c(x))| < 2**-122.0
- *
- * 113-bit precision requires more care than 64-bit precision, since
- * simple methods give a minimax polynomial with coefficient for x^2
- * that is 1 ulp below 0.5, but we want it to be precisely 0.5. See
- * above for more details.
- */
-static const long double
-C1 = 0.04166666666666666666666666666666658424671L,
-C2 = -0.001388888888888888888888888888863490893732L,
-C3 = 0.00002480158730158730158730158600795304914210L,
-C4 = -0.2755731922398589065255474947078934284324e-6L,
-C5 = 0.2087675698786809897659225313136400793948e-8L,
-C6 = -0.1147074559772972315817149986812031204775e-10L,
-C7 = 0.4779477332386808976875457937252120293400e-13L;
-static const double
-C8 = -0.1561920696721507929516718307820958119868e-15,
-C9 = 0.4110317413744594971475941557607804508039e-18,
-C10 = -0.8896592467191938803288521958313920156409e-21,
-C11 = 0.1601061435794535138244346256065192782581e-23;
-#define POLY(z) (z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*(C7+ \
- z*(C8+z*(C9+z*(C10+z*C11)))))))))))
-#endif
-
-long double __cosl(long double x, long double y)
-{
- long double hz,z,r,w;
-
- z = x*x;
- r = POLY(z);
- hz = 0.5*z;
- w = 1.0-hz;
- return w + (((1.0-w)-hz) + (z*r-x*y));
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__expo2.c b/lib/mlibc/options/ansi/musl-generic-math/__expo2.c
deleted file mode 100644
index 740ac68..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__expo2.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "libm.h"
-
-/* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */
-static const int k = 2043;
-static const double kln2 = 0x1.62066151add8bp+10;
-
-/* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */
-double __expo2(double x)
-{
- double scale;
-
- /* note that k is odd and scale*scale overflows */
- INSERT_WORDS(scale, (uint32_t)(0x3ff + k/2) << 20, 0);
- /* exp(x - k ln2) * 2**(k-1) */
- return exp(x - kln2) * scale * scale;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__expo2f.c b/lib/mlibc/options/ansi/musl-generic-math/__expo2f.c
deleted file mode 100644
index 5163e41..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__expo2f.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "libm.h"
-
-/* k is such that k*ln2 has minimal relative error and x - kln2 > log(FLT_MIN) */
-static const int k = 235;
-static const float kln2 = 0x1.45c778p+7f;
-
-/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */
-float __expo2f(float x)
-{
- float scale;
-
- /* note that k is odd and scale*scale overflows */
- SET_FLOAT_WORD(scale, (uint32_t)(0x7f + k/2) << 23);
- /* exp(x - k ln2) * 2**(k-1) */
- return expf(x - kln2) * scale * scale;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__fpclassify.c b/lib/mlibc/options/ansi/musl-generic-math/__fpclassify.c
deleted file mode 100644
index f7c0e2d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__fpclassify.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-int __fpclassify(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i>>52 & 0x7ff;
- if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
- if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE;
- return FP_NORMAL;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__fpclassifyf.c b/lib/mlibc/options/ansi/musl-generic-math/__fpclassifyf.c
deleted file mode 100644
index fd00eb1..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__fpclassifyf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-int __fpclassifyf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = u.i>>23 & 0xff;
- if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
- if (e==0xff) return u.i<<9 ? FP_NAN : FP_INFINITE;
- return FP_NORMAL;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__fpclassifyl.c b/lib/mlibc/options/ansi/musl-generic-math/__fpclassifyl.c
deleted file mode 100644
index 481c0b9..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__fpclassifyl.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-int __fpclassifyl(long double x)
-{
- return __fpclassify(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-int __fpclassifyl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- int msb = u.i.m>>63;
- if (!e && !msb)
- return u.i.m ? FP_SUBNORMAL : FP_ZERO;
- if (!msb)
- return FP_NAN;
- if (e == 0x7fff)
- return u.i.m << 1 ? FP_NAN : FP_INFINITE;
- return FP_NORMAL;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-int __fpclassifyl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- u.i.se = 0;
- if (!e)
- return u.i2.lo | u.i2.hi ? FP_SUBNORMAL : FP_ZERO;
- if (e == 0x7fff)
- return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE;
- return FP_NORMAL;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__invtrigl.c b/lib/mlibc/options/ansi/musl-generic-math/__invtrigl.c
deleted file mode 100644
index 48f83aa..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__invtrigl.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <float.h>
-#include "__invtrigl.h"
-
-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-static const long double
-pS0 = 1.66666666666666666631e-01L,
-pS1 = -4.16313987993683104320e-01L,
-pS2 = 3.69068046323246813704e-01L,
-pS3 = -1.36213932016738603108e-01L,
-pS4 = 1.78324189708471965733e-02L,
-pS5 = -2.19216428382605211588e-04L,
-pS6 = -7.10526623669075243183e-06L,
-qS1 = -2.94788392796209867269e+00L,
-qS2 = 3.27309890266528636716e+00L,
-qS3 = -1.68285799854822427013e+00L,
-qS4 = 3.90699412641738801874e-01L,
-qS5 = -3.14365703596053263322e-02L;
-
-const long double pio2_hi = 1.57079632679489661926L;
-const long double pio2_lo = -2.50827880633416601173e-20L;
-
-/* used in asinl() and acosl() */
-/* R(x^2) is a rational approximation of (asin(x)-x)/x^3 with Remez algorithm */
-long double __invtrigl_R(long double z)
-{
- long double p, q;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*(pS5+z*pS6))))));
- q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*(qS4+z*qS5))));
- return p/q;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-static const long double
-pS0 = 1.66666666666666666666666666666700314e-01L,
-pS1 = -7.32816946414566252574527475428622708e-01L,
-pS2 = 1.34215708714992334609030036562143589e+00L,
-pS3 = -1.32483151677116409805070261790752040e+00L,
-pS4 = 7.61206183613632558824485341162121989e-01L,
-pS5 = -2.56165783329023486777386833928147375e-01L,
-pS6 = 4.80718586374448793411019434585413855e-02L,
-pS7 = -4.42523267167024279410230886239774718e-03L,
-pS8 = 1.44551535183911458253205638280410064e-04L,
-pS9 = -2.10558957916600254061591040482706179e-07L,
-qS1 = -4.84690167848739751544716485245697428e+00L,
-qS2 = 9.96619113536172610135016921140206980e+00L,
-qS3 = -1.13177895428973036660836798461641458e+01L,
-qS4 = 7.74004374389488266169304117714658761e+00L,
-qS5 = -3.25871986053534084709023539900339905e+00L,
-qS6 = 8.27830318881232209752469022352928864e-01L,
-qS7 = -1.18768052702942805423330715206348004e-01L,
-qS8 = 8.32600764660522313269101537926539470e-03L,
-qS9 = -1.99407384882605586705979504567947007e-04L;
-
-const long double pio2_hi = 1.57079632679489661923132169163975140L;
-const long double pio2_lo = 4.33590506506189051239852201302167613e-35L;
-
-long double __invtrigl_R(long double z)
-{
- long double p, q;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*(pS5+z*(pS6+z*(pS7+z*(pS8+z*pS9)))))))));
- q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*(qS4+z*(qS5+z*(qS6+z*(qS7+z*(qS8+z*qS9))))))));
- return p/q;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__invtrigl.h b/lib/mlibc/options/ansi/musl-generic-math/__invtrigl.h
deleted file mode 100644
index 6dedac3..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__invtrigl.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* shared by acosl, asinl and atan2l */
-#define pio2_hi __pio2_hi
-#define pio2_lo __pio2_lo
-
-#ifndef __MLIBC_ABI_ONLY
-
-extern const long double pio2_hi, pio2_lo;
-
-long double __invtrigl_R(long double z);
-
-#endif /* !__MLIBC_ABI_ONLY */
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__polevll.c b/lib/mlibc/options/ansi/musl-generic-math/__polevll.c
deleted file mode 100644
index ce1a840..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__polevll.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/polevll.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Evaluate polynomial
- *
- *
- * SYNOPSIS:
- *
- * int N;
- * long double x, y, coef[N+1], polevl[];
- *
- * y = polevll( x, coef, N );
- *
- *
- * DESCRIPTION:
- *
- * Evaluates polynomial of degree N:
- *
- * 2 N
- * y = C + C x + C x +...+ C x
- * 0 1 2 N
- *
- * Coefficients are stored in reverse order:
- *
- * coef[0] = C , ..., coef[N] = C .
- * N 0
- *
- * The function p1evll() assumes that coef[N] = 1.0 and is
- * omitted from the array. Its calling arguments are
- * otherwise the same as polevll().
- *
- *
- * SPEED:
- *
- * In the interest of speed, there are no checks for out
- * of bounds arithmetic. This routine is used by most of
- * the functions in the library. Depending on available
- * equipment features, the user may wish to rewrite the
- * program in microcode or assembly language.
- *
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-#else
-/*
- * Polynomial evaluator:
- * P[0] x^n + P[1] x^(n-1) + ... + P[n]
- */
-long double __polevll(long double x, const long double *P, int n)
-{
- long double y;
-
- y = *P++;
- do {
- y = y * x + *P++;
- } while (--n);
-
- return y;
-}
-
-/*
- * Polynomial evaluator:
- * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n]
- */
-long double __p1evll(long double x, const long double *P, int n)
-{
- long double y;
-
- n -= 1;
- y = x + *P++;
- do {
- y = y * x + *P++;
- } while (--n);
-
- return y;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2.c b/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2.c
deleted file mode 100644
index d403f81..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * Optimized by Bruce D. Evans.
- */
-/* __rem_pio2(x,y)
- *
- * return the remainder of x rem pi/2 in y[0]+y[1]
- * use __rem_pio2_large() for large x
- */
-
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-
-/*
- * invpio2: 53 bits of 2/pi
- * pio2_1: first 33 bit of pi/2
- * pio2_1t: pi/2 - pio2_1
- * pio2_2: second 33 bit of pi/2
- * pio2_2t: pi/2 - (pio2_1+pio2_2)
- * pio2_3: third 33 bit of pi/2
- * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
- */
-static const double
-toint = 1.5/EPS,
-invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
-pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
-pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */
-pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
-pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
-pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
-pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
-
-/* caller must handle the case when reduction is not needed: |x| ~<= pi/4 */
-int __rem_pio2(double x, double *y)
-{
- union {double f; uint64_t i;} u = {x};
- double_t z,w,t,r,fn;
- double tx[3],ty[2];
- uint32_t ix;
- int sign, n, ex, ey, i;
-
- sign = u.i>>63;
- ix = u.i>>32 & 0x7fffffff;
- if (ix <= 0x400f6a7a) { /* |x| ~<= 5pi/4 */
- if ((ix & 0xfffff) == 0x921fb) /* |x| ~= pi/2 or 2pi/2 */
- goto medium; /* cancellation -- use medium case */
- if (ix <= 0x4002d97c) { /* |x| ~<= 3pi/4 */
- if (!sign) {
- z = x - pio2_1; /* one round good to 85 bits */
- y[0] = z - pio2_1t;
- y[1] = (z-y[0]) - pio2_1t;
- return 1;
- } else {
- z = x + pio2_1;
- y[0] = z + pio2_1t;
- y[1] = (z-y[0]) + pio2_1t;
- return -1;
- }
- } else {
- if (!sign) {
- z = x - 2*pio2_1;
- y[0] = z - 2*pio2_1t;
- y[1] = (z-y[0]) - 2*pio2_1t;
- return 2;
- } else {
- z = x + 2*pio2_1;
- y[0] = z + 2*pio2_1t;
- y[1] = (z-y[0]) + 2*pio2_1t;
- return -2;
- }
- }
- }
- if (ix <= 0x401c463b) { /* |x| ~<= 9pi/4 */
- if (ix <= 0x4015fdbc) { /* |x| ~<= 7pi/4 */
- if (ix == 0x4012d97c) /* |x| ~= 3pi/2 */
- goto medium;
- if (!sign) {
- z = x - 3*pio2_1;
- y[0] = z - 3*pio2_1t;
- y[1] = (z-y[0]) - 3*pio2_1t;
- return 3;
- } else {
- z = x + 3*pio2_1;
- y[0] = z + 3*pio2_1t;
- y[1] = (z-y[0]) + 3*pio2_1t;
- return -3;
- }
- } else {
- if (ix == 0x401921fb) /* |x| ~= 4pi/2 */
- goto medium;
- if (!sign) {
- z = x - 4*pio2_1;
- y[0] = z - 4*pio2_1t;
- y[1] = (z-y[0]) - 4*pio2_1t;
- return 4;
- } else {
- z = x + 4*pio2_1;
- y[0] = z + 4*pio2_1t;
- y[1] = (z-y[0]) + 4*pio2_1t;
- return -4;
- }
- }
- }
- if (ix < 0x413921fb) { /* |x| ~< 2^20*(pi/2), medium size */
-medium:
- /* rint(x/(pi/2)), Assume round-to-nearest. */
- fn = (double_t)x*invpio2 + toint - toint;
- n = (int32_t)fn;
- r = x - fn*pio2_1;
- w = fn*pio2_1t; /* 1st round, good to 85 bits */
- y[0] = r - w;
- u.f = y[0];
- ey = u.i>>52 & 0x7ff;
- ex = ix>>20;
- if (ex - ey > 16) { /* 2nd round, good to 118 bits */
- t = r;
- w = fn*pio2_2;
- r = t - w;
- w = fn*pio2_2t - ((t-r)-w);
- y[0] = r - w;
- u.f = y[0];
- ey = u.i>>52 & 0x7ff;
- if (ex - ey > 49) { /* 3rd round, good to 151 bits, covers all cases */
- t = r;
- w = fn*pio2_3;
- r = t - w;
- w = fn*pio2_3t - ((t-r)-w);
- y[0] = r - w;
- }
- }
- y[1] = (r - y[0]) - w;
- return n;
- }
- /*
- * all other (large) arguments
- */
- if (ix >= 0x7ff00000) { /* x is inf or NaN */
- y[0] = y[1] = x - x;
- return 0;
- }
- /* set z = scalbn(|x|,-ilogb(x)+23) */
- u.f = x;
- u.i &= (uint64_t)-1>>12;
- u.i |= (uint64_t)(0x3ff + 23)<<52;
- z = u.f;
- for (i=0; i < 2; i++) {
- tx[i] = (double)(int32_t)z;
- z = (z-tx[i])*0x1p24;
- }
- tx[i] = z;
- /* skip zero terms, first term is non-zero */
- while (tx[i] == 0.0)
- i--;
- n = __rem_pio2_large(tx,ty,(int)(ix>>20)-(0x3ff+23),i+1,1);
- if (sign) {
- y[0] = -ty[0];
- y[1] = -ty[1];
- return -n;
- }
- y[0] = ty[0];
- y[1] = ty[1];
- return n;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2_large.c b/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2_large.c
deleted file mode 100644
index 958f28c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2_large.c
+++ /dev/null
@@ -1,442 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/k_rem_pio2.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * __rem_pio2_large(x,y,e0,nx,prec)
- * double x[],y[]; int e0,nx,prec;
- *
- * __rem_pio2_large return the last three digits of N with
- * y = x - N*pi/2
- * so that |y| < pi/2.
- *
- * The method is to compute the integer (mod 8) and fraction parts of
- * (2/pi)*x without doing the full multiplication. In general we
- * skip the part of the product that are known to be a huge integer (
- * more accurately, = 0 mod 8 ). Thus the number of operations are
- * independent of the exponent of the input.
- *
- * (2/pi) is represented by an array of 24-bit integers in ipio2[].
- *
- * Input parameters:
- * x[] The input value (must be positive) is broken into nx
- * pieces of 24-bit integers in double precision format.
- * x[i] will be the i-th 24 bit of x. The scaled exponent
- * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0
- * match x's up to 24 bits.
- *
- * Example of breaking a double positive z into x[0]+x[1]+x[2]:
- * e0 = ilogb(z)-23
- * z = scalbn(z,-e0)
- * for i = 0,1,2
- * x[i] = floor(z)
- * z = (z-x[i])*2**24
- *
- *
- * y[] ouput result in an array of double precision numbers.
- * The dimension of y[] is:
- * 24-bit precision 1
- * 53-bit precision 2
- * 64-bit precision 2
- * 113-bit precision 3
- * The actual value is the sum of them. Thus for 113-bit
- * precison, one may have to do something like:
- *
- * long double t,w,r_head, r_tail;
- * t = (long double)y[2] + (long double)y[1];
- * w = (long double)y[0];
- * r_head = t+w;
- * r_tail = w - (r_head - t);
- *
- * e0 The exponent of x[0]. Must be <= 16360 or you need to
- * expand the ipio2 table.
- *
- * nx dimension of x[]
- *
- * prec an integer indicating the precision:
- * 0 24 bits (single)
- * 1 53 bits (double)
- * 2 64 bits (extended)
- * 3 113 bits (quad)
- *
- * External function:
- * double scalbn(), floor();
- *
- *
- * Here is the description of some local variables:
- *
- * jk jk+1 is the initial number of terms of ipio2[] needed
- * in the computation. The minimum and recommended value
- * for jk is 3,4,4,6 for single, double, extended, and quad.
- * jk+1 must be 2 larger than you might expect so that our
- * recomputation test works. (Up to 24 bits in the integer
- * part (the 24 bits of it that we compute) and 23 bits in
- * the fraction part may be lost to cancelation before we
- * recompute.)
- *
- * jz local integer variable indicating the number of
- * terms of ipio2[] used.
- *
- * jx nx - 1
- *
- * jv index for pointing to the suitable ipio2[] for the
- * computation. In general, we want
- * ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8
- * is an integer. Thus
- * e0-3-24*jv >= 0 or (e0-3)/24 >= jv
- * Hence jv = max(0,(e0-3)/24).
- *
- * jp jp+1 is the number of terms in PIo2[] needed, jp = jk.
- *
- * q[] double array with integral value, representing the
- * 24-bits chunk of the product of x and 2/pi.
- *
- * q0 the corresponding exponent of q[0]. Note that the
- * exponent for q[i] would be q0-24*i.
- *
- * PIo2[] double precision array, obtained by cutting pi/2
- * into 24 bits chunks.
- *
- * f[] ipio2[] in floating point
- *
- * iq[] integer array by breaking up q[] in 24-bits chunk.
- *
- * fq[] final product of x*(2/pi) in fq[0],..,fq[jk]
- *
- * ih integer. If >0 it indicates q[] is >= 0.5, hence
- * it also indicates the *sign* of the result.
- *
- */
-/*
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "libm.h"
-
-static const int init_jk[] = {3,4,4,6}; /* initial value for jk */
-
-/*
- * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
- *
- * integer array, contains the (24*i)-th to (24*i+23)-th
- * bit of 2/pi after binary point. The corresponding
- * floating value is
- *
- * ipio2[i] * 2^(-24(i+1)).
- *
- * NB: This table must have at least (e0-3)/24 + jk terms.
- * For quad precision (e0 <= 16360, jk = 6), this is 686.
- */
-static const int32_t ipio2[] = {
-0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
-0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
-0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
-0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
-0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8,
-0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF,
-0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5,
-0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
-0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3,
-0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880,
-0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
-
-#if LDBL_MAX_EXP > 1024
-0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6,
-0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2,
-0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35,
-0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30,
-0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C,
-0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4,
-0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770,
-0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7,
-0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19,
-0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522,
-0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16,
-0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6,
-0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E,
-0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48,
-0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3,
-0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF,
-0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55,
-0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612,
-0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929,
-0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC,
-0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B,
-0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C,
-0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4,
-0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB,
-0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC,
-0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C,
-0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F,
-0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5,
-0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437,
-0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B,
-0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA,
-0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD,
-0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3,
-0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3,
-0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717,
-0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F,
-0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61,
-0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB,
-0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51,
-0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0,
-0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C,
-0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6,
-0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC,
-0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED,
-0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328,
-0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D,
-0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0,
-0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B,
-0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4,
-0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3,
-0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F,
-0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD,
-0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B,
-0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4,
-0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761,
-0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31,
-0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30,
-0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262,
-0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E,
-0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1,
-0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C,
-0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4,
-0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08,
-0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196,
-0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9,
-0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4,
-0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC,
-0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C,
-0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0,
-0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C,
-0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0,
-0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC,
-0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22,
-0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893,
-0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7,
-0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5,
-0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F,
-0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4,
-0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF,
-0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B,
-0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2,
-0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138,
-0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E,
-0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569,
-0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34,
-0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9,
-0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D,
-0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F,
-0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855,
-0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569,
-0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B,
-0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE,
-0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41,
-0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49,
-0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F,
-0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110,
-0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8,
-0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365,
-0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A,
-0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270,
-0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5,
-0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616,
-0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B,
-0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0,
-#endif
-};
-
-static const double PIo2[] = {
- 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
- 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
- 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
- 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
- 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
- 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
- 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
- 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
-};
-
-int __rem_pio2_large(double *x, double *y, int e0, int nx, int prec)
-{
- int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
- double z,fw,f[20],fq[20],q[20];
-
- /* initialize jk*/
- jk = init_jk[prec];
- jp = jk;
-
- /* determine jx,jv,q0, note that 3>q0 */
- jx = nx-1;
- jv = (e0-3)/24; if(jv<0) jv=0;
- q0 = e0-24*(jv+1);
-
- /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
- j = jv-jx; m = jx+jk;
- for (i=0; i<=m; i++,j++)
- f[i] = j<0 ? 0.0 : (double)ipio2[j];
-
- /* compute q[0],q[1],...q[jk] */
- for (i=0; i<=jk; i++) {
- for (j=0,fw=0.0; j<=jx; j++)
- fw += x[j]*f[jx+i-j];
- q[i] = fw;
- }
-
- jz = jk;
-recompute:
- /* distill q[] into iq[] reversingly */
- for (i=0,j=jz,z=q[jz]; j>0; i++,j--) {
- fw = (double)(int32_t)(0x1p-24*z);
- iq[i] = (int32_t)(z - 0x1p24*fw);
- z = q[j-1]+fw;
- }
-
- /* compute n */
- z = scalbn(z,q0); /* actual value of z */
- z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */
- n = (int32_t)z;
- z -= (double)n;
- ih = 0;
- if (q0 > 0) { /* need iq[jz-1] to determine n */
- i = iq[jz-1]>>(24-q0); n += i;
- iq[jz-1] -= i<<(24-q0);
- ih = iq[jz-1]>>(23-q0);
- }
- else if (q0 == 0) ih = iq[jz-1]>>23;
- else if (z >= 0.5) ih = 2;
-
- if (ih > 0) { /* q > 0.5 */
- n += 1; carry = 0;
- for (i=0; i<jz; i++) { /* compute 1-q */
- j = iq[i];
- if (carry == 0) {
- if (j != 0) {
- carry = 1;
- iq[i] = 0x1000000 - j;
- }
- } else
- iq[i] = 0xffffff - j;
- }
- if (q0 > 0) { /* rare case: chance is 1 in 12 */
- switch(q0) {
- case 1:
- iq[jz-1] &= 0x7fffff; break;
- case 2:
- iq[jz-1] &= 0x3fffff; break;
- }
- }
- if (ih == 2) {
- z = 1.0 - z;
- if (carry != 0)
- z -= scalbn(1.0,q0);
- }
- }
-
- /* check if recomputation is needed */
- if (z == 0.0) {
- j = 0;
- for (i=jz-1; i>=jk; i--) j |= iq[i];
- if (j == 0) { /* need recomputation */
- for (k=1; iq[jk-k]==0; k++); /* k = no. of terms needed */
-
- for (i=jz+1; i<=jz+k; i++) { /* add q[jz+1] to q[jz+k] */
- f[jx+i] = (double)ipio2[jv+i];
- for (j=0,fw=0.0; j<=jx; j++)
- fw += x[j]*f[jx+i-j];
- q[i] = fw;
- }
- jz += k;
- goto recompute;
- }
- }
-
- /* chop off zero terms */
- if (z == 0.0) {
- jz -= 1;
- q0 -= 24;
- while (iq[jz] == 0) {
- jz--;
- q0 -= 24;
- }
- } else { /* break z into 24-bit if necessary */
- z = scalbn(z,-q0);
- if (z >= 0x1p24) {
- fw = (double)(int32_t)(0x1p-24*z);
- iq[jz] = (int32_t)(z - 0x1p24*fw);
- jz += 1;
- q0 += 24;
- iq[jz] = (int32_t)fw;
- } else
- iq[jz] = (int32_t)z;
- }
-
- /* convert integer "bit" chunk to floating-point value */
- fw = scalbn(1.0,q0);
- for (i=jz; i>=0; i--) {
- q[i] = fw*(double)iq[i];
- fw *= 0x1p-24;
- }
-
- /* compute PIo2[0,...,jp]*q[jz,...,0] */
- for(i=jz; i>=0; i--) {
- for (fw=0.0,k=0; k<=jp && k<=jz-i; k++)
- fw += PIo2[k]*q[i+k];
- fq[jz-i] = fw;
- }
-
- /* compress fq[] into y[] */
- switch(prec) {
- case 0:
- fw = 0.0;
- for (i=jz; i>=0; i--)
- fw += fq[i];
- y[0] = ih==0 ? fw : -fw;
- break;
- case 1:
- case 2:
- fw = 0.0;
- for (i=jz; i>=0; i--)
- fw += fq[i];
- // TODO: drop excess precision here once double_t is used
- fw = (double)fw;
- y[0] = ih==0 ? fw : -fw;
- fw = fq[0]-fw;
- for (i=1; i<=jz; i++)
- fw += fq[i];
- y[1] = ih==0 ? fw : -fw;
- break;
- case 3: /* painful */
- for (i=jz; i>0; i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (i=jz; i>1; i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (fw=0.0,i=jz; i>=2; i--)
- fw += fq[i];
- if (ih==0) {
- y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
- } else {
- y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
- }
- }
- return n&7;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2f.c b/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2f.c
deleted file mode 100644
index 4473c1c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2f.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2f.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Debugged and optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* __rem_pio2f(x,y)
- *
- * return the remainder of x rem pi/2 in *y
- * use double precision for everything except passing x
- * use __rem_pio2_large() for large x
- */
-
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-
-/*
- * invpio2: 53 bits of 2/pi
- * pio2_1: first 25 bits of pi/2
- * pio2_1t: pi/2 - pio2_1
- */
-static const double
-toint = 1.5/EPS,
-invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
-pio2_1 = 1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
-pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
-
-int __rem_pio2f(float x, double *y)
-{
- union {float f; uint32_t i;} u = {x};
- double tx[1],ty[1];
- double_t fn;
- uint32_t ix;
- int n, sign, e0;
-
- ix = u.i & 0x7fffffff;
- /* 25+53 bit pi is good enough for medium size */
- if (ix < 0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */
- /* Use a specialized rint() to get fn. Assume round-to-nearest. */
- fn = (double_t)x*invpio2 + toint - toint;
- n = (int32_t)fn;
- *y = x - fn*pio2_1 - fn*pio2_1t;
- return n;
- }
- if(ix>=0x7f800000) { /* x is inf or NaN */
- *y = x-x;
- return 0;
- }
- /* scale x into [2^23, 2^24-1] */
- sign = u.i>>31;
- e0 = (ix>>23) - (0x7f+23); /* e0 = ilogb(|x|)-23, positive */
- u.i = ix - (e0<<23);
- tx[0] = u.f;
- n = __rem_pio2_large(tx,ty,e0,1,0);
- if (sign) {
- *y = -ty[0];
- return -n;
- }
- *y = ty[0];
- return n;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2l.c b/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2l.c
deleted file mode 100644
index 77255bd..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__rem_pio2l.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/ld80/e_rem_pio2.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * Optimized by Bruce D. Evans.
- */
-#include "libm.h"
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-/* ld80 and ld128 version of __rem_pio2(x,y)
- *
- * return the remainder of x rem pi/2 in y[0]+y[1]
- * use __rem_pio2_large() for large x
- */
-
-static const long double toint = 1.5/LDBL_EPSILON;
-
-#if LDBL_MANT_DIG == 64
-/* u ~< 0x1p25*pi/2 */
-#define SMALL(u) (((u.i.se & 0x7fffU)<<16 | u.i.m>>48) < ((0x3fff + 25)<<16 | 0x921f>>1 | 0x8000))
-#define QUOBITS(x) ((uint32_t)(int32_t)x & 0x7fffffff)
-#define ROUND1 22
-#define ROUND2 61
-#define NX 3
-#define NY 2
-/*
- * invpio2: 64 bits of 2/pi
- * pio2_1: first 39 bits of pi/2
- * pio2_1t: pi/2 - pio2_1
- * pio2_2: second 39 bits of pi/2
- * pio2_2t: pi/2 - (pio2_1+pio2_2)
- * pio2_3: third 39 bits of pi/2
- * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
- */
-static const double
-pio2_1 = 1.57079632679597125389e+00, /* 0x3FF921FB, 0x54444000 */
-pio2_2 = -1.07463465549783099519e-12, /* -0x12e7b967674000.0p-92 */
-pio2_3 = 6.36831716351370313614e-25; /* 0x18a2e037074000.0p-133 */
-static const long double
-invpio2 = 6.36619772367581343076e-01L, /* 0xa2f9836e4e44152a.0p-64 */
-pio2_1t = -1.07463465549719416346e-12L, /* -0x973dcb3b399d747f.0p-103 */
-pio2_2t = 6.36831716351095013979e-25L, /* 0xc51701b839a25205.0p-144 */
-pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */
-#elif LDBL_MANT_DIG == 113
-/* u ~< 0x1p45*pi/2 */
-#define SMALL(u) (((u.i.se & 0x7fffU)<<16 | u.i.top) < ((0x3fff + 45)<<16 | 0x921f))
-#define QUOBITS(x) ((uint32_t)(int64_t)x & 0x7fffffff)
-#define ROUND1 51
-#define ROUND2 119
-#define NX 5
-#define NY 3
-static const long double
-invpio2 = 6.3661977236758134307553505349005747e-01L, /* 0x145f306dc9c882a53f84eafa3ea6a.0p-113 */
-pio2_1 = 1.5707963267948966192292994253909555e+00L, /* 0x1921fb54442d18469800000000000.0p-112 */
-pio2_1t = 2.0222662487959507323996846200947577e-21L, /* 0x13198a2e03707344a4093822299f3.0p-181 */
-pio2_2 = 2.0222662487959507323994779168837751e-21L, /* 0x13198a2e03707344a400000000000.0p-181 */
-pio2_2t = 2.0670321098263988236496903051604844e-43L, /* 0x127044533e63a0105df531d89cd91.0p-254 */
-pio2_3 = 2.0670321098263988236499468110329591e-43L, /* 0x127044533e63a0105e00000000000.0p-254 */
-pio2_3t = -2.5650587247459238361625433492959285e-65L; /* -0x159c4ec64ddaeb5f78671cbfb2210.0p-327 */
-#endif
-
-int __rem_pio2l(long double x, long double *y)
-{
- union ldshape u,uz;
- long double z,w,t,r,fn;
- double tx[NX],ty[NY];
- int ex,ey,n,i;
-
- u.f = x;
- ex = u.i.se & 0x7fff;
- if (SMALL(u)) {
- /* rint(x/(pi/2)), Assume round-to-nearest. */
- fn = x*invpio2 + toint - toint;
- n = QUOBITS(fn);
- r = x-fn*pio2_1;
- w = fn*pio2_1t; /* 1st round good to 102/180 bits (ld80/ld128) */
- y[0] = r-w;
- u.f = y[0];
- ey = u.i.se & 0x7fff;
- if (ex - ey > ROUND1) { /* 2nd iteration needed, good to 141/248 (ld80/ld128) */
- t = r;
- w = fn*pio2_2;
- r = t-w;
- w = fn*pio2_2t-((t-r)-w);
- y[0] = r-w;
- u.f = y[0];
- ey = u.i.se & 0x7fff;
- if (ex - ey > ROUND2) { /* 3rd iteration, good to 180/316 bits */
- t = r; /* will cover all possible cases (not verified for ld128) */
- w = fn*pio2_3;
- r = t-w;
- w = fn*pio2_3t-((t-r)-w);
- y[0] = r-w;
- }
- }
- y[1] = (r - y[0]) - w;
- return n;
- }
- /*
- * all other (large) arguments
- */
- if (ex == 0x7fff) { /* x is inf or NaN */
- y[0] = y[1] = x - x;
- return 0;
- }
- /* set z = scalbn(|x|,-ilogb(x)+23) */
- uz.f = x;
- uz.i.se = 0x3fff + 23;
- z = uz.f;
- for (i=0; i < NX - 1; i++) {
- tx[i] = (double)(int32_t)z;
- z = (z-tx[i])*0x1p24;
- }
- tx[i] = z;
- while (tx[i] == 0)
- i--;
- n = __rem_pio2_large(tx, ty, ex-0x3fff-23, i+1, NY);
- w = ty[1];
- if (NY == 3)
- w += ty[2];
- r = ty[0] + w;
- /* TODO: for ld128 this does not follow the recommendation of the
- comments of __rem_pio2_large which seem wrong if |ty[0]| > |ty[1]+ty[2]| */
- w -= r - ty[0];
- if (u.i.se >> 15) {
- y[0] = -r;
- y[1] = -w;
- return -n;
- }
- y[0] = r;
- y[1] = w;
- return n;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__signbit.c b/lib/mlibc/options/ansi/musl-generic-math/__signbit.c
deleted file mode 100644
index e700b6b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__signbit.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "libm.h"
-
-// FIXME: macro in math.h
-int __signbit(double x)
-{
- union {
- double d;
- uint64_t i;
- } y = { x };
- return y.i>>63;
-}
-
-
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__signbitf.c b/lib/mlibc/options/ansi/musl-generic-math/__signbitf.c
deleted file mode 100644
index 40ad3cf..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__signbitf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "libm.h"
-
-// FIXME: macro in math.h
-int __signbitf(float x)
-{
- union {
- float f;
- uint32_t i;
- } y = { x };
- return y.i>>31;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__signbitl.c b/lib/mlibc/options/ansi/musl-generic-math/__signbitl.c
deleted file mode 100644
index 63b3dc5..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__signbitl.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "libm.h"
-
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-int __signbitl(long double x)
-{
- union ldshape u = {x};
- return u.i.se >> 15;
-}
-#elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-int __signbitl(long double x)
-{
- return __signbit(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__sin.c b/lib/mlibc/options/ansi/musl-generic-math/__sin.c
deleted file mode 100644
index 4030949..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__sin.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/k_sin.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* __sin( x, y, iy)
- * kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- * Input iy indicates whether y is 0. (if iy=0, y assume to be 0).
- *
- * Algorithm
- * 1. Since sin(-x) = -sin(x), we need only to consider positive x.
- * 2. Callers must return sin(-0) = -0 without calling here since our
- * odd polynomial is not evaluated in a way that preserves -0.
- * Callers may do the optimization sin(x) ~ x for tiny x.
- * 3. sin(x) is approximated by a polynomial of degree 13 on
- * [0,pi/4]
- * 3 13
- * sin(x) ~ x + S1*x + ... + S6*x
- * where
- *
- * |sin(x) 2 4 6 8 10 12 | -58
- * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2
- * | x |
- *
- * 4. sin(x+y) = sin(x) + sin'(x')*y
- * ~ sin(x) + (1-x*x/2)*y
- * For better accuracy, let
- * 3 2 2 2 2
- * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
- * then 3 2
- * sin(x) = x + (S1*x + (x *(r-y/2)+y))
- */
-
-#include "libm.h"
-
-static const double
-S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
-S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
-S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
-S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
-S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
-S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
-
-double __sin(double x, double y, int iy)
-{
- double_t z,r,v,w;
-
- z = x*x;
- w = z*z;
- r = S2 + z*(S3 + z*S4) + z*w*(S5 + z*S6);
- v = z*x;
- if (iy == 0)
- return x + v*(S1 + z*r);
- else
- return x - ((z*(0.5*y - v*r) - y) - v*S1);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__sindf.c b/lib/mlibc/options/ansi/musl-generic-math/__sindf.c
deleted file mode 100644
index 8fec2a3..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__sindf.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/k_sinf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
-static const double
-S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
-S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */
-S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
-S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */
-
-float __sindf(double x)
-{
- double_t r, s, w, z;
-
- /* Try to optimize for parallel evaluation as in __tandf.c. */
- z = x*x;
- w = z*z;
- r = S3 + z*S4;
- s = z*x;
- return (x + s*(S1 + z*S2)) + s*w*r;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__sinl.c b/lib/mlibc/options/ansi/musl-generic-math/__sinl.c
deleted file mode 100644
index 2525bbe..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__sinl.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/ld80/k_sinl.c */
-/* origin: FreeBSD /usr/src/lib/msun/ld128/k_sinl.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
-/*
- * ld80 version of __sin.c. See __sin.c for most comments.
- */
-/*
- * Domain [-0.7854, 0.7854], range ~[-1.89e-22, 1.915e-22]
- * |sin(x)/x - s(x)| < 2**-72.1
- *
- * See __cosl.c for more details about the polynomial.
- */
-static const long double
-S1 = -0.166666666666666666671L; /* -0xaaaaaaaaaaaaaaab.0p-66 */
-static const double
-S2 = 0.0083333333333333332, /* 0x11111111111111.0p-59 */
-S3 = -0.00019841269841269427, /* -0x1a01a01a019f81.0p-65 */
-S4 = 0.0000027557319223597490, /* 0x171de3a55560f7.0p-71 */
-S5 = -0.000000025052108218074604, /* -0x1ae64564f16cad.0p-78 */
-S6 = 1.6059006598854211e-10, /* 0x161242b90243b5.0p-85 */
-S7 = -7.6429779983024564e-13, /* -0x1ae42ebd1b2e00.0p-93 */
-S8 = 2.6174587166648325e-15; /* 0x179372ea0b3f64.0p-101 */
-#define POLY(z) (S2+z*(S3+z*(S4+z*(S5+z*(S6+z*(S7+z*S8))))))
-#elif LDBL_MANT_DIG == 113
-/*
- * ld128 version of __sin.c. See __sin.c for most comments.
- */
-/*
- * Domain [-0.7854, 0.7854], range ~[-1.53e-37, 1.659e-37]
- * |sin(x)/x - s(x)| < 2**-122.1
- *
- * See __cosl.c for more details about the polynomial.
- */
-static const long double
-S1 = -0.16666666666666666666666666666666666606732416116558L,
-S2 = 0.0083333333333333333333333333333331135404851288270047L,
-S3 = -0.00019841269841269841269841269839935785325638310428717L,
-S4 = 0.27557319223985890652557316053039946268333231205686e-5L,
-S5 = -0.25052108385441718775048214826384312253862930064745e-7L,
-S6 = 0.16059043836821614596571832194524392581082444805729e-9L,
-S7 = -0.76471637318198151807063387954939213287488216303768e-12L,
-S8 = 0.28114572543451292625024967174638477283187397621303e-14L;
-static const double
-S9 = -0.82206352458348947812512122163446202498005154296863e-17,
-S10 = 0.19572940011906109418080609928334380560135358385256e-19,
-S11 = -0.38680813379701966970673724299207480965452616911420e-22,
-S12 = 0.64038150078671872796678569586315881020659912139412e-25;
-#define POLY(z) (S2+z*(S3+z*(S4+z*(S5+z*(S6+z*(S7+z*(S8+ \
- z*(S9+z*(S10+z*(S11+z*S12))))))))))
-#endif
-
-long double __sinl(long double x, long double y, int iy)
-{
- long double z,r,v;
-
- z = x*x;
- v = z*x;
- r = POLY(z);
- if (iy == 0)
- return x+v*(S1+z*r);
- return x-((z*(0.5*y-v*r)-y)-v*S1);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__tan.c b/lib/mlibc/options/ansi/musl-generic-math/__tan.c
deleted file mode 100644
index 8019844..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__tan.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/k_tan.c */
-/*
- * ====================================================
- * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* __tan( x, y, k )
- * kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- * Input odd indicates whether tan (if odd = 0) or -1/tan (if odd = 1) is returned.
- *
- * Algorithm
- * 1. Since tan(-x) = -tan(x), we need only to consider positive x.
- * 2. Callers must return tan(-0) = -0 without calling here since our
- * odd polynomial is not evaluated in a way that preserves -0.
- * Callers may do the optimization tan(x) ~ x for tiny x.
- * 3. tan(x) is approximated by a odd polynomial of degree 27 on
- * [0,0.67434]
- * 3 27
- * tan(x) ~ x + T1*x + ... + T13*x
- * where
- *
- * |tan(x) 2 4 26 | -59.2
- * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2
- * | x |
- *
- * Note: tan(x+y) = tan(x) + tan'(x)*y
- * ~ tan(x) + (1+x*x)*y
- * Therefore, for better accuracy in computing tan(x+y), let
- * 3 2 2 2 2
- * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13))))
- * then
- * 3 2
- * tan(x+y) = x + (T1*x + (x *(r+y)+y))
- *
- * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then
- * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y))
- * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
- */
-
-#include "libm.h"
-
-static const double T[] = {
- 3.33333333333334091986e-01, /* 3FD55555, 55555563 */
- 1.33333333333201242699e-01, /* 3FC11111, 1110FE7A */
- 5.39682539762260521377e-02, /* 3FABA1BA, 1BB341FE */
- 2.18694882948595424599e-02, /* 3F9664F4, 8406D637 */
- 8.86323982359930005737e-03, /* 3F8226E3, E96E8493 */
- 3.59207910759131235356e-03, /* 3F6D6D22, C9560328 */
- 1.45620945432529025516e-03, /* 3F57DBC8, FEE08315 */
- 5.88041240820264096874e-04, /* 3F4344D8, F2F26501 */
- 2.46463134818469906812e-04, /* 3F3026F7, 1A8D1068 */
- 7.81794442939557092300e-05, /* 3F147E88, A03792A6 */
- 7.14072491382608190305e-05, /* 3F12B80F, 32F0A7E9 */
- -1.85586374855275456654e-05, /* BEF375CB, DB605373 */
- 2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */
-},
-pio4 = 7.85398163397448278999e-01, /* 3FE921FB, 54442D18 */
-pio4lo = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */
-
-double __tan(double x, double y, int odd)
-{
- double_t z, r, v, w, s, a;
- double w0, a0;
- uint32_t hx;
- int big, sign;
-
- GET_HIGH_WORD(hx,x);
- big = (hx&0x7fffffff) >= 0x3FE59428; /* |x| >= 0.6744 */
- if (big) {
- sign = hx>>31;
- if (sign) {
- x = -x;
- y = -y;
- }
- x = (pio4 - x) + (pio4lo - y);
- y = 0.0;
- }
- z = x * x;
- w = z * z;
- /*
- * Break x^5*(T[1]+x^2*T[2]+...) into
- * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
- * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
- */
- r = T[1] + w*(T[3] + w*(T[5] + w*(T[7] + w*(T[9] + w*T[11]))));
- v = z*(T[2] + w*(T[4] + w*(T[6] + w*(T[8] + w*(T[10] + w*T[12])))));
- s = z * x;
- r = y + z*(s*(r + v) + y) + s*T[0];
- w = x + r;
- if (big) {
- s = 1 - 2*odd;
- v = s - 2.0 * (x + (r - w*w/(w + s)));
- return sign ? -v : v;
- }
- if (!odd)
- return w;
- /* -1.0/(x+r) has up to 2ulp error, so compute it accurately */
- w0 = w;
- SET_LOW_WORD(w0, 0);
- v = r - (w0 - x); /* w0+v = r+x */
- a0 = a = -1.0 / w;
- SET_LOW_WORD(a0, 0);
- return a0 + a*(1.0 + a0*w0 + a0*v);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__tandf.c b/lib/mlibc/options/ansi/musl-generic-math/__tandf.c
deleted file mode 100644
index 25047ee..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__tandf.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/k_tanf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
-static const double T[] = {
- 0x15554d3418c99f.0p-54, /* 0.333331395030791399758 */
- 0x1112fd38999f72.0p-55, /* 0.133392002712976742718 */
- 0x1b54c91d865afe.0p-57, /* 0.0533812378445670393523 */
- 0x191df3908c33ce.0p-58, /* 0.0245283181166547278873 */
- 0x185dadfcecf44e.0p-61, /* 0.00297435743359967304927 */
- 0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */
-};
-
-float __tandf(double x, int odd)
-{
- double_t z,r,w,s,t,u;
-
- z = x*x;
- /*
- * Split up the polynomial into small independent terms to give
- * opportunities for parallel evaluation. The chosen splitting is
- * micro-optimized for Athlons (XP, X64). It costs 2 multiplications
- * relative to Horner's method on sequential machines.
- *
- * We add the small terms from lowest degree up for efficiency on
- * non-sequential machines (the lowest degree terms tend to be ready
- * earlier). Apart from this, we don't care about order of
- * operations, and don't need to to care since we have precision to
- * spare. However, the chosen splitting is good for accuracy too,
- * and would give results as accurate as Horner's method if the
- * small terms were added from highest degree down.
- */
- r = T[4] + z*T[5];
- t = T[2] + z*T[3];
- w = z*z;
- s = z*x;
- u = T[0] + z*T[1];
- r = (x + s*u) + (s*w)*(t + w*r);
- return odd ? -1.0/r : r;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/__tanl.c b/lib/mlibc/options/ansi/musl-generic-math/__tanl.c
deleted file mode 100644
index 54abc3d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/__tanl.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/ld80/k_tanl.c */
-/* origin: FreeBSD /usr/src/lib/msun/ld128/k_tanl.c */
-/*
- * ====================================================
- * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
-/*
- * ld80 version of __tan.c. See __tan.c for most comments.
- */
-/*
- * Domain [-0.67434, 0.67434], range ~[-2.25e-22, 1.921e-22]
- * |tan(x)/x - t(x)| < 2**-71.9
- *
- * See __cosl.c for more details about the polynomial.
- */
-static const long double
-T3 = 0.333333333333333333180L, /* 0xaaaaaaaaaaaaaaa5.0p-65 */
-T5 = 0.133333333333333372290L, /* 0x88888888888893c3.0p-66 */
-T7 = 0.0539682539682504975744L, /* 0xdd0dd0dd0dc13ba2.0p-68 */
-pio4 = 0.785398163397448309628L, /* 0xc90fdaa22168c235.0p-64 */
-pio4lo = -1.25413940316708300586e-20L; /* -0xece675d1fc8f8cbb.0p-130 */
-static const double
-T9 = 0.021869488536312216, /* 0x1664f4882cc1c2.0p-58 */
-T11 = 0.0088632355256619590, /* 0x1226e355c17612.0p-59 */
-T13 = 0.0035921281113786528, /* 0x1d6d3d185d7ff8.0p-61 */
-T15 = 0.0014558334756312418, /* 0x17da354aa3f96b.0p-62 */
-T17 = 0.00059003538700862256, /* 0x13559358685b83.0p-63 */
-T19 = 0.00023907843576635544, /* 0x1f56242026b5be.0p-65 */
-T21 = 0.000097154625656538905, /* 0x1977efc26806f4.0p-66 */
-T23 = 0.000038440165747303162, /* 0x14275a09b3ceac.0p-67 */
-T25 = 0.000018082171885432524, /* 0x12f5e563e5487e.0p-68 */
-T27 = 0.0000024196006108814377, /* 0x144c0d80cc6896.0p-71 */
-T29 = 0.0000078293456938132840, /* 0x106b59141a6cb3.0p-69 */
-T31 = -0.0000032609076735050182, /* -0x1b5abef3ba4b59.0p-71 */
-T33 = 0.0000023261313142559411; /* 0x13835436c0c87f.0p-71 */
-#define RPOLY(w) (T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 + \
- w * (T25 + w * (T29 + w * T33)))))))
-#define VPOLY(w) (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 + \
- w * (T27 + w * T31))))))
-#elif LDBL_MANT_DIG == 113
-/*
- * ld128 version of __tan.c. See __tan.c for most comments.
- */
-/*
- * Domain [-0.67434, 0.67434], range ~[-3.37e-36, 1.982e-37]
- * |tan(x)/x - t(x)| < 2**-117.8 (XXX should be ~1e-37)
- *
- * See __cosl.c for more details about the polynomial.
- */
-static const long double
-T3 = 0x1.5555555555555555555555555553p-2L,
-T5 = 0x1.1111111111111111111111111eb5p-3L,
-T7 = 0x1.ba1ba1ba1ba1ba1ba1ba1b694cd6p-5L,
-T9 = 0x1.664f4882c10f9f32d6bbe09d8bcdp-6L,
-T11 = 0x1.226e355e6c23c8f5b4f5762322eep-7L,
-T13 = 0x1.d6d3d0e157ddfb5fed8e84e27b37p-9L,
-T15 = 0x1.7da36452b75e2b5fce9ee7c2c92ep-10L,
-T17 = 0x1.355824803674477dfcf726649efep-11L,
-T19 = 0x1.f57d7734d1656e0aceb716f614c2p-13L,
-T21 = 0x1.967e18afcb180ed942dfdc518d6cp-14L,
-T23 = 0x1.497d8eea21e95bc7e2aa79b9f2cdp-15L,
-T25 = 0x1.0b132d39f055c81be49eff7afd50p-16L,
-T27 = 0x1.b0f72d33eff7bfa2fbc1059d90b6p-18L,
-T29 = 0x1.5ef2daf21d1113df38d0fbc00267p-19L,
-T31 = 0x1.1c77d6eac0234988cdaa04c96626p-20L,
-T33 = 0x1.cd2a5a292b180e0bdd701057dfe3p-22L,
-T35 = 0x1.75c7357d0298c01a31d0a6f7d518p-23L,
-T37 = 0x1.2f3190f4718a9a520f98f50081fcp-24L,
-pio4 = 0x1.921fb54442d18469898cc51701b8p-1L,
-pio4lo = 0x1.cd129024e088a67cc74020bbea60p-116L;
-static const double
-T39 = 0.000000028443389121318352, /* 0x1e8a7592977938.0p-78 */
-T41 = 0.000000011981013102001973, /* 0x19baa1b1223219.0p-79 */
-T43 = 0.0000000038303578044958070, /* 0x107385dfb24529.0p-80 */
-T45 = 0.0000000034664378216909893, /* 0x1dc6c702a05262.0p-81 */
-T47 = -0.0000000015090641701997785, /* -0x19ecef3569ebb6.0p-82 */
-T49 = 0.0000000029449552300483952, /* 0x194c0668da786a.0p-81 */
-T51 = -0.0000000022006995706097711, /* -0x12e763b8845268.0p-81 */
-T53 = 0.0000000015468200913196612, /* 0x1a92fc98c29554.0p-82 */
-T55 = -0.00000000061311613386849674, /* -0x151106cbc779a9.0p-83 */
-T57 = 1.4912469681508012e-10; /* 0x147edbdba6f43a.0p-85 */
-#define RPOLY(w) (T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 + \
- w * (T25 + w * (T29 + w * (T33 + w * (T37 + w * (T41 + \
- w * (T45 + w * (T49 + w * (T53 + w * T57)))))))))))))
-#define VPOLY(w) (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 + \
- w * (T27 + w * (T31 + w * (T35 + w * (T39 + w * (T43 + \
- w * (T47 + w * (T51 + w * T55))))))))))))
-#endif
-
-long double __tanl(long double x, long double y, int odd) {
- long double z, r, v, w, s, a, t;
- int big, sign;
-
- big = fabsl(x) >= 0.67434;
- if (big) {
- sign = 0;
- if (x < 0) {
- sign = 1;
- x = -x;
- y = -y;
- }
- x = (pio4 - x) + (pio4lo - y);
- y = 0.0;
- }
- z = x * x;
- w = z * z;
- r = RPOLY(w);
- v = z * VPOLY(w);
- s = z * x;
- r = y + z * (s * (r + v) + y) + T3 * s;
- w = x + r;
- if (big) {
- s = 1 - 2*odd;
- v = s - 2.0 * (x + (r - w * w / (w + s)));
- return sign ? -v : v;
- }
- if (!odd)
- return w;
- /*
- * if allow error up to 2 ulp, simply return
- * -1.0 / (x+r) here
- */
- /* compute -1.0 / (x+r) accurately */
- z = w;
- z = z + 0x1p32 - 0x1p32;
- v = r - (z - x); /* z+v = r+x */
- t = a = -1.0 / w; /* a = -1.0/w */
- t = t + 0x1p32 - 0x1p32;
- s = 1.0 + t * z;
- return t + a * (s + t * v);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/acos.c b/lib/mlibc/options/ansi/musl-generic-math/acos.c
deleted file mode 100644
index ea9c87b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/acos.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_acos.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* acos(x)
- * Method :
- * acos(x) = pi/2 - asin(x)
- * acos(-x) = pi/2 + asin(x)
- * For |x|<=0.5
- * acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c)
- * For x>0.5
- * acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
- * = 2asin(sqrt((1-x)/2))
- * = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z)
- * = 2f + (2c + 2s*z*R(z))
- * where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
- * for f so that f+c ~ sqrt(z).
- * For x<-0.5
- * acos(x) = pi - 2asin(sqrt((1-|x|)/2))
- * = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
- *
- * Special cases:
- * if x is NaN, return x itself;
- * if |x|>1, return NaN with invalid signal.
- *
- * Function needed: sqrt
- */
-
-#include "libm.h"
-
-static const double
-pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
-pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
-pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
-pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
-pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
-pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
-pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
-pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
-qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
-qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
-qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
-qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-
-static double R(double z)
-{
- double_t p, q;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- return p/q;
-}
-
-double acos(double x)
-{
- double z,w,s,c,df;
- uint32_t hx,ix;
-
- GET_HIGH_WORD(hx, x);
- ix = hx & 0x7fffffff;
- /* |x| >= 1 or nan */
- if (ix >= 0x3ff00000) {
- uint32_t lx;
-
- GET_LOW_WORD(lx,x);
- if ((ix-0x3ff00000 | lx) == 0) {
- /* acos(1)=0, acos(-1)=pi */
- if (hx >> 31)
- return 2*pio2_hi + 0x1p-120f;
- return 0;
- }
- return 0/(x-x);
- }
- /* |x| < 0.5 */
- if (ix < 0x3fe00000) {
- if (ix <= 0x3c600000) /* |x| < 2**-57 */
- return pio2_hi + 0x1p-120f;
- return pio2_hi - (x - (pio2_lo-x*R(x*x)));
- }
- /* x < -0.5 */
- if (hx >> 31) {
- z = (1.0+x)*0.5;
- s = sqrt(z);
- w = R(z)*s-pio2_lo;
- return 2*(pio2_hi - (s+w));
- }
- /* x > 0.5 */
- z = (1.0-x)*0.5;
- s = sqrt(z);
- df = s;
- SET_LOW_WORD(df,0);
- c = (z-df*df)/(s+df);
- w = R(z)*s+c;
- return 2*(df+w);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/acosf.c b/lib/mlibc/options/ansi/musl-generic-math/acosf.c
deleted file mode 100644
index 8ee1a71..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/acosf.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_acosf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float
-pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
-pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
-pS0 = 1.6666586697e-01,
-pS1 = -4.2743422091e-02,
-pS2 = -8.6563630030e-03,
-qS1 = -7.0662963390e-01;
-
-static float R(float z)
-{
- float_t p, q;
- p = z*(pS0+z*(pS1+z*pS2));
- q = 1.0f+z*qS1;
- return p/q;
-}
-
-float acosf(float x)
-{
- float z,w,s,c,df;
- uint32_t hx,ix;
-
- GET_FLOAT_WORD(hx, x);
- ix = hx & 0x7fffffff;
- /* |x| >= 1 or nan */
- if (ix >= 0x3f800000) {
- if (ix == 0x3f800000) {
- if (hx >> 31)
- return 2*pio2_hi + 0x1p-120f;
- return 0;
- }
- return 0/(x-x);
- }
- /* |x| < 0.5 */
- if (ix < 0x3f000000) {
- if (ix <= 0x32800000) /* |x| < 2**-26 */
- return pio2_hi + 0x1p-120f;
- return pio2_hi - (x - (pio2_lo-x*R(x*x)));
- }
- /* x < -0.5 */
- if (hx >> 31) {
- z = (1+x)*0.5f;
- s = sqrtf(z);
- w = R(z)*s-pio2_lo;
- return 2*(pio2_hi - (s+w));
- }
- /* x > 0.5 */
- z = (1-x)*0.5f;
- s = sqrtf(z);
- GET_FLOAT_WORD(hx,s);
- SET_FLOAT_WORD(df,hx&0xfffff000);
- c = (z-df*df)/(s+df);
- w = R(z)*s+c;
- return 2*(df+w);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/acosh.c b/lib/mlibc/options/ansi/musl-generic-math/acosh.c
deleted file mode 100644
index badbf90..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/acosh.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==2
-#undef sqrt
-#define sqrt sqrtl
-#endif
-
-/* acosh(x) = log(x + sqrt(x*x-1)) */
-double acosh(double x)
-{
- union {double f; uint64_t i;} u = {.f = x};
- unsigned e = u.i >> 52 & 0x7ff;
-
- /* x < 1 domain error is handled in the called functions */
-
- if (e < 0x3ff + 1)
- /* |x| < 2, up to 2ulp error in [1,1.125] */
- return log1p(x-1 + sqrt((x-1)*(x-1)+2*(x-1)));
- if (e < 0x3ff + 26)
- /* |x| < 0x1p26 */
- return log(2*x - 1/(x+sqrt(x*x-1)));
- /* |x| >= 0x1p26 or nan */
- return log(x) + 0.693147180559945309417232121458176568;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/acoshf.c b/lib/mlibc/options/ansi/musl-generic-math/acoshf.c
deleted file mode 100644
index 8a4ec4d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/acoshf.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==2
-#undef sqrtf
-#define sqrtf sqrtl
-#elif FLT_EVAL_METHOD==1
-#undef sqrtf
-#define sqrtf sqrt
-#endif
-
-/* acosh(x) = log(x + sqrt(x*x-1)) */
-float acoshf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- uint32_t a = u.i & 0x7fffffff;
-
- if (a < 0x3f800000+(1<<23))
- /* |x| < 2, invalid if x < 1 or nan */
- /* up to 2ulp error in [1,1.125] */
- return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1)));
- if (a < 0x3f800000+(12<<23))
- /* |x| < 0x1p12 */
- return logf(2*x - 1/(x+sqrtf(x*x-1)));
- /* x >= 0x1p12 */
- return logf(x) + 0.693147180559945309417232121458176568f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/acoshl.c b/lib/mlibc/options/ansi/musl-generic-math/acoshl.c
deleted file mode 100644
index 8d4b43f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/acoshl.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double acoshl(long double x)
-{
- return acosh(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-/* acosh(x) = log(x + sqrt(x*x-1)) */
-long double acoshl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
-
- if (e < 0x3fff + 1)
- /* |x| < 2, invalid if x < 1 or nan */
- return log1pl(x-1 + sqrtl((x-1)*(x-1)+2*(x-1)));
- if (e < 0x3fff + 32)
- /* |x| < 0x1p32 */
- return logl(2*x - 1/(x+sqrtl(x*x-1)));
- return logl(x) + 0.693147180559945309417232121458176568L;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double acoshl(long double x)
-{
- return acosh(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/acosl.c b/lib/mlibc/options/ansi/musl-generic-math/acosl.c
deleted file mode 100644
index c03bdf0..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/acosl.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_acosl.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * See comments in acos.c.
- * Converted to long double by David Schultz <das@FreeBSD.ORG>.
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double acosl(long double x)
-{
- return acos(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include "__invtrigl.h"
-#if LDBL_MANT_DIG == 64
-#define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
-#elif LDBL_MANT_DIG == 113
-#define CLEARBOTTOM(u) (u.i.lo = 0)
-#endif
-
-long double acosl(long double x)
-{
- union ldshape u = {x};
- long double z, s, c, f;
- uint16_t e = u.i.se & 0x7fff;
-
- /* |x| >= 1 or nan */
- if (e >= 0x3fff) {
- if (x == 1)
- return 0;
- if (x == -1)
- return 2*pio2_hi + 0x1p-120f;
- return 0/(x-x);
- }
- /* |x| < 0.5 */
- if (e < 0x3fff - 1) {
- if (e < 0x3fff - LDBL_MANT_DIG - 1)
- return pio2_hi + 0x1p-120f;
- return pio2_hi - (__invtrigl_R(x*x)*x - pio2_lo + x);
- }
- /* x < -0.5 */
- if (u.i.se >> 15) {
- z = (1 + x)*0.5;
- s = sqrtl(z);
- return 2*(pio2_hi - (__invtrigl_R(z)*s - pio2_lo + s));
- }
- /* x > 0.5 */
- z = (1 - x)*0.5;
- s = sqrtl(z);
- u.f = s;
- CLEARBOTTOM(u);
- f = u.f;
- c = (z - f*f)/(s + f);
- return 2*(__invtrigl_R(z)*s + c + f);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/asin.c b/lib/mlibc/options/ansi/musl-generic-math/asin.c
deleted file mode 100644
index c926b18..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/asin.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_asin.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* asin(x)
- * Method :
- * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
- * we approximate asin(x) on [0,0.5] by
- * asin(x) = x + x*x^2*R(x^2)
- * where
- * R(x^2) is a rational approximation of (asin(x)-x)/x^3
- * and its remez error is bounded by
- * |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75)
- *
- * For x in [0.5,1]
- * asin(x) = pi/2-2*asin(sqrt((1-x)/2))
- * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2;
- * then for x>0.98
- * asin(x) = pi/2 - 2*(s+s*z*R(z))
- * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo)
- * For x<=0.98, let pio4_hi = pio2_hi/2, then
- * f = hi part of s;
- * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z)
- * and
- * asin(x) = pi/2 - 2*(s+s*z*R(z))
- * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo)
- * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c))
- *
- * Special cases:
- * if x is NaN, return x itself;
- * if |x|>1, return NaN with invalid signal.
- *
- */
-
-#include "libm.h"
-
-static const double
-pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
-pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
-/* coefficients for R(x^2) */
-pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
-pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
-pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
-pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
-pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
-pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
-qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
-qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
-qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
-qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-
-static double R(double z)
-{
- double_t p, q;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- return p/q;
-}
-
-double asin(double x)
-{
- double z,r,s;
- uint32_t hx,ix;
-
- GET_HIGH_WORD(hx, x);
- ix = hx & 0x7fffffff;
- /* |x| >= 1 or nan */
- if (ix >= 0x3ff00000) {
- uint32_t lx;
- GET_LOW_WORD(lx, x);
- if ((ix-0x3ff00000 | lx) == 0)
- /* asin(1) = +-pi/2 with inexact */
- return x*pio2_hi + 0x1p-120f;
- return 0/(x-x);
- }
- /* |x| < 0.5 */
- if (ix < 0x3fe00000) {
- /* if 0x1p-1022 <= |x| < 0x1p-26, avoid raising underflow */
- if (ix < 0x3e500000 && ix >= 0x00100000)
- return x;
- return x + x*R(x*x);
- }
- /* 1 > |x| >= 0.5 */
- z = (1 - fabs(x))*0.5;
- s = sqrt(z);
- r = R(z);
- if (ix >= 0x3fef3333) { /* if |x| > 0.975 */
- x = pio2_hi-(2*(s+s*r)-pio2_lo);
- } else {
- double f,c;
- /* f+c = sqrt(z) */
- f = s;
- SET_LOW_WORD(f,0);
- c = (z-f*f)/(s+f);
- x = 0.5*pio2_hi - (2*s*r - (pio2_lo-2*c) - (0.5*pio2_hi-2*f));
- }
- if (hx >> 31)
- return -x;
- return x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/asinf.c b/lib/mlibc/options/ansi/musl-generic-math/asinf.c
deleted file mode 100644
index bcd304a..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/asinf.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_asinf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-#include "libm.h"
-
-static const double
-pio2 = 1.570796326794896558e+00;
-
-static const float
-/* coefficients for R(x^2) */
-pS0 = 1.6666586697e-01,
-pS1 = -4.2743422091e-02,
-pS2 = -8.6563630030e-03,
-qS1 = -7.0662963390e-01;
-
-static float R(float z)
-{
- float_t p, q;
- p = z*(pS0+z*(pS1+z*pS2));
- q = 1.0f+z*qS1;
- return p/q;
-}
-
-float asinf(float x)
-{
- double s;
- float z;
- uint32_t hx,ix;
-
- GET_FLOAT_WORD(hx, x);
- ix = hx & 0x7fffffff;
- if (ix >= 0x3f800000) { /* |x| >= 1 */
- if (ix == 0x3f800000) /* |x| == 1 */
- return x*pio2 + 0x1p-120f; /* asin(+-1) = +-pi/2 with inexact */
- return 0/(x-x); /* asin(|x|>1) is NaN */
- }
- if (ix < 0x3f000000) { /* |x| < 0.5 */
- /* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */
- if (ix < 0x39800000 && ix >= 0x00800000)
- return x;
- return x + x*R(x*x);
- }
- /* 1 > |x| >= 0.5 */
- z = (1 - fabsf(x))*0.5f;
- s = sqrt(z);
- x = pio2 - 2*(s+s*R(z));
- if (hx >> 31)
- return -x;
- return x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/asinh.c b/lib/mlibc/options/ansi/musl-generic-math/asinh.c
deleted file mode 100644
index 0829f22..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/asinh.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "libm.h"
-
-/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */
-double asinh(double x)
-{
- union {double f; uint64_t i;} u = {.f = x};
- unsigned e = u.i >> 52 & 0x7ff;
- unsigned s = u.i >> 63;
-
- /* |x| */
- u.i &= (uint64_t)-1/2;
- x = u.f;
-
- if (e >= 0x3ff + 26) {
- /* |x| >= 0x1p26 or inf or nan */
- x = log(x) + 0.693147180559945309417232121458176568;
- } else if (e >= 0x3ff + 1) {
- /* |x| >= 2 */
- x = log(2*x + 1/(sqrt(x*x+1)+x));
- } else if (e >= 0x3ff - 26) {
- /* |x| >= 0x1p-26, up to 1.6ulp error in [0.125,0.5] */
- x = log1p(x + x*x/(sqrt(x*x+1)+1));
- } else {
- /* |x| < 0x1p-26, raise inexact if x != 0 */
- FORCE_EVAL(x + 0x1p120f);
- }
- return s ? -x : x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/asinhf.c b/lib/mlibc/options/ansi/musl-generic-math/asinhf.c
deleted file mode 100644
index fc9f091..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/asinhf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "libm.h"
-
-/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */
-float asinhf(float x)
-{
- union {float f; uint32_t i;} u = {.f = x};
- uint32_t i = u.i & 0x7fffffff;
- unsigned s = u.i >> 31;
-
- /* |x| */
- u.i = i;
- x = u.f;
-
- if (i >= 0x3f800000 + (12<<23)) {
- /* |x| >= 0x1p12 or inf or nan */
- x = logf(x) + 0.693147180559945309417232121458176568f;
- } else if (i >= 0x3f800000 + (1<<23)) {
- /* |x| >= 2 */
- x = logf(2*x + 1/(sqrtf(x*x+1)+x));
- } else if (i >= 0x3f800000 - (12<<23)) {
- /* |x| >= 0x1p-12, up to 1.6ulp error in [0.125,0.5] */
- x = log1pf(x + x*x/(sqrtf(x*x+1)+1));
- } else {
- /* |x| < 0x1p-12, raise inexact if x!=0 */
- FORCE_EVAL(x + 0x1p120f);
- }
- return s ? -x : x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/asinhl.c b/lib/mlibc/options/ansi/musl-generic-math/asinhl.c
deleted file mode 100644
index 8635f52..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/asinhl.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double asinhl(long double x)
-{
- return asinh(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */
-long double asinhl(long double x)
-{
- union ldshape u = {x};
- unsigned e = u.i.se & 0x7fff;
- unsigned s = u.i.se >> 15;
-
- /* |x| */
- u.i.se = e;
- x = u.f;
-
- if (e >= 0x3fff + 32) {
- /* |x| >= 0x1p32 or inf or nan */
- x = logl(x) + 0.693147180559945309417232121458176568L;
- } else if (e >= 0x3fff + 1) {
- /* |x| >= 2 */
- x = logl(2*x + 1/(sqrtl(x*x+1)+x));
- } else if (e >= 0x3fff - 32) {
- /* |x| >= 0x1p-32 */
- x = log1pl(x + x*x/(sqrtl(x*x+1)+1));
- } else {
- /* |x| < 0x1p-32, raise inexact if x!=0 */
- FORCE_EVAL(x + 0x1p120f);
- }
- return s ? -x : x;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double asinhl(long double x)
-{
- return asinh(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/asinl.c b/lib/mlibc/options/ansi/musl-generic-math/asinl.c
deleted file mode 100644
index 347c535..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/asinl.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_asinl.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * See comments in asin.c.
- * Converted to long double by David Schultz <das@FreeBSD.ORG>.
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double asinl(long double x)
-{
- return asin(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include "__invtrigl.h"
-#if LDBL_MANT_DIG == 64
-#define CLOSETO1(u) (u.i.m>>56 >= 0xf7)
-#define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
-#elif LDBL_MANT_DIG == 113
-#define CLOSETO1(u) (u.i.top >= 0xee00)
-#define CLEARBOTTOM(u) (u.i.lo = 0)
-#endif
-
-long double asinl(long double x)
-{
- union ldshape u = {x};
- long double z, r, s;
- uint16_t e = u.i.se & 0x7fff;
- int sign = u.i.se >> 15;
-
- if (e >= 0x3fff) { /* |x| >= 1 or nan */
- /* asin(+-1)=+-pi/2 with inexact */
- if (x == 1 || x == -1)
- return x*pio2_hi + 0x1p-120f;
- return 0/(x-x);
- }
- if (e < 0x3fff - 1) { /* |x| < 0.5 */
- if (e < 0x3fff - (LDBL_MANT_DIG+1)/2) {
- /* return x with inexact if x!=0 */
- FORCE_EVAL(x + 0x1p120f);
- return x;
- }
- return x + x*__invtrigl_R(x*x);
- }
- /* 1 > |x| >= 0.5 */
- z = (1.0 - fabsl(x))*0.5;
- s = sqrtl(z);
- r = __invtrigl_R(z);
- if (CLOSETO1(u)) {
- x = pio2_hi - (2*(s+s*r)-pio2_lo);
- } else {
- long double f, c;
- u.f = s;
- CLEARBOTTOM(u);
- f = u.f;
- c = (z - f*f)/(s + f);
- x = 0.5*pio2_hi-(2*s*r - (pio2_lo-2*c) - (0.5*pio2_hi-2*f));
- }
- return sign ? -x : x;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atan.c b/lib/mlibc/options/ansi/musl-generic-math/atan.c
deleted file mode 100644
index 63b0ab2..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atan.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_atan.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* atan(x)
- * Method
- * 1. Reduce x to positive by atan(x) = -atan(-x).
- * 2. According to the integer k=4t+0.25 chopped, t=x, the argument
- * is further reduced to one of the following intervals and the
- * arctangent of t is evaluated by the corresponding formula:
- *
- * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
- * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
- * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
- * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
- * [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-
-#include "libm.h"
-
-static const double atanhi[] = {
- 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
- 7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */
- 9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */
- 1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */
-};
-
-static const double atanlo[] = {
- 2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */
- 3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */
- 1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */
- 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */
-};
-
-static const double aT[] = {
- 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */
- -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */
- 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */
- -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */
- 9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */
- -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */
- 6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */
- -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */
- 4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */
- -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */
- 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
-};
-
-double atan(double x)
-{
- double_t w,s1,s2,z;
- uint32_t ix,sign;
- int id;
-
- GET_HIGH_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
- if (ix >= 0x44100000) { /* if |x| >= 2^66 */
- if (isnan(x))
- return x;
- z = atanhi[3] + 0x1p-120f;
- return sign ? -z : z;
- }
- if (ix < 0x3fdc0000) { /* |x| < 0.4375 */
- if (ix < 0x3e400000) { /* |x| < 2^-27 */
- if (ix < 0x00100000)
- /* raise underflow for subnormal x */
- FORCE_EVAL((float)x);
- return x;
- }
- id = -1;
- } else {
- x = fabs(x);
- if (ix < 0x3ff30000) { /* |x| < 1.1875 */
- if (ix < 0x3fe60000) { /* 7/16 <= |x| < 11/16 */
- id = 0;
- x = (2.0*x-1.0)/(2.0+x);
- } else { /* 11/16 <= |x| < 19/16 */
- id = 1;
- x = (x-1.0)/(x+1.0);
- }
- } else {
- if (ix < 0x40038000) { /* |x| < 2.4375 */
- id = 2;
- x = (x-1.5)/(1.0+1.5*x);
- } else { /* 2.4375 <= |x| < 2^66 */
- id = 3;
- x = -1.0/x;
- }
- }
- }
- /* end of argument reduction */
- z = x*x;
- w = z*z;
- /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
- s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10])))));
- s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9]))));
- if (id < 0)
- return x - x*(s1+s2);
- z = atanhi[id] - (x*(s1+s2) - atanlo[id] - x);
- return sign ? -z : z;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atan2.c b/lib/mlibc/options/ansi/musl-generic-math/atan2.c
deleted file mode 100644
index 5a1903c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atan2.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-/* atan2(y,x)
- * Method :
- * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
- * 2. Reduce x to positive by (if x and y are unexceptional):
- * ARG (x+iy) = arctan(y/x) ... if x > 0,
- * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
- *
- * Special cases:
- *
- * ATAN2((anything), NaN ) is NaN;
- * ATAN2(NAN , (anything) ) is NaN;
- * ATAN2(+-0, +(anything but NaN)) is +-0 ;
- * ATAN2(+-0, -(anything but NaN)) is +-pi ;
- * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
- * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
- * ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
- * ATAN2(+-INF,+INF ) is +-pi/4 ;
- * ATAN2(+-INF,-INF ) is +-3pi/4;
- * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "libm.h"
-
-static const double
-pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
-pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
-
-double atan2(double y, double x)
-{
- double z;
- uint32_t m,lx,ly,ix,iy;
-
- if (isnan(x) || isnan(y))
- return x+y;
- EXTRACT_WORDS(ix, lx, x);
- EXTRACT_WORDS(iy, ly, y);
- if ((ix-0x3ff00000 | lx) == 0) /* x = 1.0 */
- return atan(y);
- m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */
- ix = ix & 0x7fffffff;
- iy = iy & 0x7fffffff;
-
- /* when y = 0 */
- if ((iy|ly) == 0) {
- switch(m) {
- case 0:
- case 1: return y; /* atan(+-0,+anything)=+-0 */
- case 2: return pi; /* atan(+0,-anything) = pi */
- case 3: return -pi; /* atan(-0,-anything) =-pi */
- }
- }
- /* when x = 0 */
- if ((ix|lx) == 0)
- return m&1 ? -pi/2 : pi/2;
- /* when x is INF */
- if (ix == 0x7ff00000) {
- if (iy == 0x7ff00000) {
- switch(m) {
- case 0: return pi/4; /* atan(+INF,+INF) */
- case 1: return -pi/4; /* atan(-INF,+INF) */
- case 2: return 3*pi/4; /* atan(+INF,-INF) */
- case 3: return -3*pi/4; /* atan(-INF,-INF) */
- }
- } else {
- switch(m) {
- case 0: return 0.0; /* atan(+...,+INF) */
- case 1: return -0.0; /* atan(-...,+INF) */
- case 2: return pi; /* atan(+...,-INF) */
- case 3: return -pi; /* atan(-...,-INF) */
- }
- }
- }
- /* |y/x| > 0x1p64 */
- if (ix+(64<<20) < iy || iy == 0x7ff00000)
- return m&1 ? -pi/2 : pi/2;
-
- /* z = atan(|y/x|) without spurious underflow */
- if ((m&2) && iy+(64<<20) < ix) /* |y/x| < 0x1p-64, x<0 */
- z = 0;
- else
- z = atan(fabs(y/x));
- switch (m) {
- case 0: return z; /* atan(+,+) */
- case 1: return -z; /* atan(-,+) */
- case 2: return pi - (z-pi_lo); /* atan(+,-) */
- default: /* case 3 */
- return (z-pi_lo) - pi; /* atan(-,-) */
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atan2f.c b/lib/mlibc/options/ansi/musl-generic-math/atan2f.c
deleted file mode 100644
index c634d00..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atan2f.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2f.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float
-pi = 3.1415927410e+00, /* 0x40490fdb */
-pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */
-
-float atan2f(float y, float x)
-{
- float z;
- uint32_t m,ix,iy;
-
- if (isnan(x) || isnan(y))
- return x+y;
- GET_FLOAT_WORD(ix, x);
- GET_FLOAT_WORD(iy, y);
- if (ix == 0x3f800000) /* x=1.0 */
- return atanf(y);
- m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */
- ix &= 0x7fffffff;
- iy &= 0x7fffffff;
-
- /* when y = 0 */
- if (iy == 0) {
- switch (m) {
- case 0:
- case 1: return y; /* atan(+-0,+anything)=+-0 */
- case 2: return pi; /* atan(+0,-anything) = pi */
- case 3: return -pi; /* atan(-0,-anything) =-pi */
- }
- }
- /* when x = 0 */
- if (ix == 0)
- return m&1 ? -pi/2 : pi/2;
- /* when x is INF */
- if (ix == 0x7f800000) {
- if (iy == 0x7f800000) {
- switch (m) {
- case 0: return pi/4; /* atan(+INF,+INF) */
- case 1: return -pi/4; /* atan(-INF,+INF) */
- case 2: return 3*pi/4; /*atan(+INF,-INF)*/
- case 3: return -3*pi/4; /*atan(-INF,-INF)*/
- }
- } else {
- switch (m) {
- case 0: return 0.0f; /* atan(+...,+INF) */
- case 1: return -0.0f; /* atan(-...,+INF) */
- case 2: return pi; /* atan(+...,-INF) */
- case 3: return -pi; /* atan(-...,-INF) */
- }
- }
- }
- /* |y/x| > 0x1p26 */
- if (ix+(26<<23) < iy || iy == 0x7f800000)
- return m&1 ? -pi/2 : pi/2;
-
- /* z = atan(|y/x|) with correct underflow */
- if ((m&2) && iy+(26<<23) < ix) /*|y/x| < 0x1p-26, x < 0 */
- z = 0.0;
- else
- z = atanf(fabsf(y/x));
- switch (m) {
- case 0: return z; /* atan(+,+) */
- case 1: return -z; /* atan(-,+) */
- case 2: return pi - (z-pi_lo); /* atan(+,-) */
- default: /* case 3 */
- return (z-pi_lo) - pi; /* atan(-,-) */
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atan2l.c b/lib/mlibc/options/ansi/musl-generic-math/atan2l.c
deleted file mode 100644
index f0937a9..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atan2l.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2l.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-/*
- * See comments in atan2.c.
- * Converted to long double by David Schultz <das@FreeBSD.ORG>.
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double atan2l(long double y, long double x)
-{
- return atan2(y, x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include "__invtrigl.h"
-
-long double atan2l(long double y, long double x)
-{
- union ldshape ux, uy;
- long double z;
- int m, ex, ey;
-
- if (isnan(x) || isnan(y))
- return x+y;
- if (x == 1)
- return atanl(y);
- ux.f = x;
- uy.f = y;
- ex = ux.i.se & 0x7fff;
- ey = uy.i.se & 0x7fff;
- m = 2*(ux.i.se>>15) | uy.i.se>>15;
- if (y == 0) {
- switch(m) {
- case 0:
- case 1: return y; /* atan(+-0,+anything)=+-0 */
- case 2: return 2*pio2_hi; /* atan(+0,-anything) = pi */
- case 3: return -2*pio2_hi; /* atan(-0,-anything) =-pi */
- }
- }
- if (x == 0)
- return m&1 ? -pio2_hi : pio2_hi;
- if (ex == 0x7fff) {
- if (ey == 0x7fff) {
- switch(m) {
- case 0: return pio2_hi/2; /* atan(+INF,+INF) */
- case 1: return -pio2_hi/2; /* atan(-INF,+INF) */
- case 2: return 1.5*pio2_hi; /* atan(+INF,-INF) */
- case 3: return -1.5*pio2_hi; /* atan(-INF,-INF) */
- }
- } else {
- switch(m) {
- case 0: return 0.0; /* atan(+...,+INF) */
- case 1: return -0.0; /* atan(-...,+INF) */
- case 2: return 2*pio2_hi; /* atan(+...,-INF) */
- case 3: return -2*pio2_hi; /* atan(-...,-INF) */
- }
- }
- }
- if (ex+120 < ey || ey == 0x7fff)
- return m&1 ? -pio2_hi : pio2_hi;
- /* z = atan(|y/x|) without spurious underflow */
- if ((m&2) && ey+120 < ex) /* |y/x| < 0x1p-120, x<0 */
- z = 0.0;
- else
- z = atanl(fabsl(y/x));
- switch (m) {
- case 0: return z; /* atan(+,+) */
- case 1: return -z; /* atan(-,+) */
- case 2: return 2*pio2_hi-(z-2*pio2_lo); /* atan(+,-) */
- default: /* case 3 */
- return (z-2*pio2_lo)-2*pio2_hi; /* atan(-,-) */
- }
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atanf.c b/lib/mlibc/options/ansi/musl-generic-math/atanf.c
deleted file mode 100644
index 178341b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atanf.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_atanf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-
-#include "libm.h"
-
-static const float atanhi[] = {
- 4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
- 7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
- 9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
- 1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */
-};
-
-static const float atanlo[] = {
- 5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */
- 3.7748947079e-08, /* atan(1.0)lo 0x33222168 */
- 3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */
- 7.5497894159e-08, /* atan(inf)lo 0x33a22168 */
-};
-
-static const float aT[] = {
- 3.3333328366e-01,
- -1.9999158382e-01,
- 1.4253635705e-01,
- -1.0648017377e-01,
- 6.1687607318e-02,
-};
-
-float atanf(float x)
-{
- float_t w,s1,s2,z;
- uint32_t ix,sign;
- int id;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix >= 0x4c800000) { /* if |x| >= 2**26 */
- if (isnan(x))
- return x;
- z = atanhi[3] + 0x1p-120f;
- return sign ? -z : z;
- }
- if (ix < 0x3ee00000) { /* |x| < 0.4375 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- if (ix < 0x00800000)
- /* raise underflow for subnormal x */
- FORCE_EVAL(x*x);
- return x;
- }
- id = -1;
- } else {
- x = fabsf(x);
- if (ix < 0x3f980000) { /* |x| < 1.1875 */
- if (ix < 0x3f300000) { /* 7/16 <= |x| < 11/16 */
- id = 0;
- x = (2.0f*x - 1.0f)/(2.0f + x);
- } else { /* 11/16 <= |x| < 19/16 */
- id = 1;
- x = (x - 1.0f)/(x + 1.0f);
- }
- } else {
- if (ix < 0x401c0000) { /* |x| < 2.4375 */
- id = 2;
- x = (x - 1.5f)/(1.0f + 1.5f*x);
- } else { /* 2.4375 <= |x| < 2**26 */
- id = 3;
- x = -1.0f/x;
- }
- }
- }
- /* end of argument reduction */
- z = x*x;
- w = z*z;
- /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
- s1 = z*(aT[0]+w*(aT[2]+w*aT[4]));
- s2 = w*(aT[1]+w*aT[3]);
- if (id < 0)
- return x - x*(s1+s2);
- z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
- return sign ? -z : z;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atanh.c b/lib/mlibc/options/ansi/musl-generic-math/atanh.c
deleted file mode 100644
index 63a035d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atanh.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "libm.h"
-
-/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */
-double atanh(double x)
-{
- union {double f; uint64_t i;} u = {.f = x};
- unsigned e = u.i >> 52 & 0x7ff;
- unsigned s = u.i >> 63;
- double_t y;
-
- /* |x| */
- u.i &= (uint64_t)-1/2;
- y = u.f;
-
- if (e < 0x3ff - 1) {
- if (e < 0x3ff - 32) {
- /* handle underflow */
- if (e == 0)
- FORCE_EVAL((float)y);
- } else {
- /* |x| < 0.5, up to 1.7ulp error */
- y = 0.5*log1p(2*y + 2*y*y/(1-y));
- }
- } else {
- /* avoid overflow */
- y = 0.5*log1p(2*(y/(1-y)));
- }
- return s ? -y : y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atanhf.c b/lib/mlibc/options/ansi/musl-generic-math/atanhf.c
deleted file mode 100644
index 65f07c0..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atanhf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "libm.h"
-
-/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */
-float atanhf(float x)
-{
- union {float f; uint32_t i;} u = {.f = x};
- unsigned s = u.i >> 31;
- float_t y;
-
- /* |x| */
- u.i &= 0x7fffffff;
- y = u.f;
-
- if (u.i < 0x3f800000 - (1<<23)) {
- if (u.i < 0x3f800000 - (32<<23)) {
- /* handle underflow */
- if (u.i < (1<<23))
- FORCE_EVAL((float)(y*y));
- } else {
- /* |x| < 0.5, up to 1.7ulp error */
- y = 0.5f*log1pf(2*y + 2*y*y/(1-y));
- }
- } else {
- /* avoid overflow */
- y = 0.5f*log1pf(2*(y/(1-y)));
- }
- return s ? -y : y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atanhl.c b/lib/mlibc/options/ansi/musl-generic-math/atanhl.c
deleted file mode 100644
index 87cd1cd..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atanhl.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double atanhl(long double x)
-{
- return atanh(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */
-long double atanhl(long double x)
-{
- union ldshape u = {x};
- unsigned e = u.i.se & 0x7fff;
- unsigned s = u.i.se >> 15;
-
- /* |x| */
- u.i.se = e;
- x = u.f;
-
- if (e < 0x3ff - 1) {
- if (e < 0x3ff - LDBL_MANT_DIG/2) {
- /* handle underflow */
- if (e == 0)
- FORCE_EVAL((float)x);
- } else {
- /* |x| < 0.5, up to 1.7ulp error */
- x = 0.5*log1pl(2*x + 2*x*x/(1-x));
- }
- } else {
- /* avoid overflow */
- x = 0.5*log1pl(2*(x/(1-x)));
- }
- return s ? -x : x;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/atanl.c b/lib/mlibc/options/ansi/musl-generic-math/atanl.c
deleted file mode 100644
index 79a3edb..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/atanl.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_atanl.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * See comments in atan.c.
- * Converted to long double by David Schultz <das@FreeBSD.ORG>.
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double atanl(long double x)
-{
- return atan(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-#if LDBL_MANT_DIG == 64
-#define EXPMAN(u) ((u.i.se & 0x7fff)<<8 | (u.i.m>>55 & 0xff))
-
-static const long double atanhi[] = {
- 4.63647609000806116202e-01L,
- 7.85398163397448309628e-01L,
- 9.82793723247329067960e-01L,
- 1.57079632679489661926e+00L,
-};
-
-static const long double atanlo[] = {
- 1.18469937025062860669e-20L,
- -1.25413940316708300586e-20L,
- 2.55232234165405176172e-20L,
- -2.50827880633416601173e-20L,
-};
-
-static const long double aT[] = {
- 3.33333333333333333017e-01L,
- -1.99999999999999632011e-01L,
- 1.42857142857046531280e-01L,
- -1.11111111100562372733e-01L,
- 9.09090902935647302252e-02L,
- -7.69230552476207730353e-02L,
- 6.66661718042406260546e-02L,
- -5.88158892835030888692e-02L,
- 5.25499891539726639379e-02L,
- -4.70119845393155721494e-02L,
- 4.03539201366454414072e-02L,
- -2.91303858419364158725e-02L,
- 1.24822046299269234080e-02L,
-};
-
-static long double T_even(long double x)
-{
- return aT[0] + x * (aT[2] + x * (aT[4] + x * (aT[6] +
- x * (aT[8] + x * (aT[10] + x * aT[12])))));
-}
-
-static long double T_odd(long double x)
-{
- return aT[1] + x * (aT[3] + x * (aT[5] + x * (aT[7] +
- x * (aT[9] + x * aT[11]))));
-}
-#elif LDBL_MANT_DIG == 113
-#define EXPMAN(u) ((u.i.se & 0x7fff)<<8 | u.i.top>>8)
-
-const long double atanhi[] = {
- 4.63647609000806116214256231461214397e-01L,
- 7.85398163397448309615660845819875699e-01L,
- 9.82793723247329067985710611014666038e-01L,
- 1.57079632679489661923132169163975140e+00L,
-};
-
-const long double atanlo[] = {
- 4.89509642257333492668618435220297706e-36L,
- 2.16795253253094525619926100651083806e-35L,
- -2.31288434538183565909319952098066272e-35L,
- 4.33590506506189051239852201302167613e-35L,
-};
-
-const long double aT[] = {
- 3.33333333333333333333333333333333125e-01L,
- -1.99999999999999999999999999999180430e-01L,
- 1.42857142857142857142857142125269827e-01L,
- -1.11111111111111111111110834490810169e-01L,
- 9.09090909090909090908522355708623681e-02L,
- -7.69230769230769230696553844935357021e-02L,
- 6.66666666666666660390096773046256096e-02L,
- -5.88235294117646671706582985209643694e-02L,
- 5.26315789473666478515847092020327506e-02L,
- -4.76190476189855517021024424991436144e-02L,
- 4.34782608678695085948531993458097026e-02L,
- -3.99999999632663469330634215991142368e-02L,
- 3.70370363987423702891250829918659723e-02L,
- -3.44827496515048090726669907612335954e-02L,
- 3.22579620681420149871973710852268528e-02L,
- -3.03020767654269261041647570626778067e-02L,
- 2.85641979882534783223403715930946138e-02L,
- -2.69824879726738568189929461383741323e-02L,
- 2.54194698498808542954187110873675769e-02L,
- -2.35083879708189059926183138130183215e-02L,
- 2.04832358998165364349957325067131428e-02L,
- -1.54489555488544397858507248612362957e-02L,
- 8.64492360989278761493037861575248038e-03L,
- -2.58521121597609872727919154569765469e-03L,
-};
-
-static long double T_even(long double x)
-{
- return (aT[0] + x * (aT[2] + x * (aT[4] + x * (aT[6] + x * (aT[8] +
- x * (aT[10] + x * (aT[12] + x * (aT[14] + x * (aT[16] +
- x * (aT[18] + x * (aT[20] + x * aT[22])))))))))));
-}
-
-static long double T_odd(long double x)
-{
- return (aT[1] + x * (aT[3] + x * (aT[5] + x * (aT[7] + x * (aT[9] +
- x * (aT[11] + x * (aT[13] + x * (aT[15] + x * (aT[17] +
- x * (aT[19] + x * (aT[21] + x * aT[23])))))))))));
-}
-#endif
-
-long double atanl(long double x)
-{
- union ldshape u = {x};
- long double w, s1, s2, z;
- int id;
- unsigned e = u.i.se & 0x7fff;
- unsigned sign = u.i.se >> 15;
- unsigned expman;
-
- if (e >= 0x3fff + LDBL_MANT_DIG + 1) { /* if |x| is large, atan(x)~=pi/2 */
- if (isnan(x))
- return x;
- return sign ? -atanhi[3] : atanhi[3];
- }
- /* Extract the exponent and the first few bits of the mantissa. */
- expman = EXPMAN(u);
- if (expman < ((0x3fff - 2) << 8) + 0xc0) { /* |x| < 0.4375 */
- if (e < 0x3fff - (LDBL_MANT_DIG+1)/2) { /* if |x| is small, atanl(x)~=x */
- /* raise underflow if subnormal */
- if (e == 0)
- FORCE_EVAL((float)x);
- return x;
- }
- id = -1;
- } else {
- x = fabsl(x);
- if (expman < (0x3fff << 8) + 0x30) { /* |x| < 1.1875 */
- if (expman < ((0x3fff - 1) << 8) + 0x60) { /* 7/16 <= |x| < 11/16 */
- id = 0;
- x = (2.0*x-1.0)/(2.0+x);
- } else { /* 11/16 <= |x| < 19/16 */
- id = 1;
- x = (x-1.0)/(x+1.0);
- }
- } else {
- if (expman < ((0x3fff + 1) << 8) + 0x38) { /* |x| < 2.4375 */
- id = 2;
- x = (x-1.5)/(1.0+1.5*x);
- } else { /* 2.4375 <= |x| */
- id = 3;
- x = -1.0/x;
- }
- }
- }
- /* end of argument reduction */
- z = x*x;
- w = z*z;
- /* break sum aT[i]z**(i+1) into odd and even poly */
- s1 = z*T_even(w);
- s2 = w*T_odd(w);
- if (id < 0)
- return x - x*(s1+s2);
- z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
- return sign ? -z : z;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/cbrt.c b/lib/mlibc/options/ansi/musl-generic-math/cbrt.c
deleted file mode 100644
index 7599d3e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/cbrt.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_cbrt.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * Optimized by Bruce D. Evans.
- */
-/* cbrt(x)
- * Return cube root of x
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const uint32_t
-B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20 */
-B2 = 696219795; /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */
-
-/* |1/cbrt(x) - p(x)| < 2**-23.5 (~[-7.93e-8, 7.929e-8]). */
-static const double
-P0 = 1.87595182427177009643, /* 0x3ffe03e6, 0x0f61e692 */
-P1 = -1.88497979543377169875, /* 0xbffe28e0, 0x92f02420 */
-P2 = 1.621429720105354466140, /* 0x3ff9f160, 0x4a49d6c2 */
-P3 = -0.758397934778766047437, /* 0xbfe844cb, 0xbee751d9 */
-P4 = 0.145996192886612446982; /* 0x3fc2b000, 0xd4e4edd7 */
-
-double cbrt(double x)
-{
- union {double f; uint64_t i;} u = {x};
- double_t r,s,t,w;
- uint32_t hx = u.i>>32 & 0x7fffffff;
-
- if (hx >= 0x7ff00000) /* cbrt(NaN,INF) is itself */
- return x+x;
-
- /*
- * Rough cbrt to 5 bits:
- * cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3)
- * where e is integral and >= 0, m is real and in [0, 1), and "/" and
- * "%" are integer division and modulus with rounding towards minus
- * infinity. The RHS is always >= the LHS and has a maximum relative
- * error of about 1 in 16. Adding a bias of -0.03306235651 to the
- * (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE
- * floating point representation, for finite positive normal values,
- * ordinary integer divison of the value in bits magically gives
- * almost exactly the RHS of the above provided we first subtract the
- * exponent bias (1023 for doubles) and later add it back. We do the
- * subtraction virtually to keep e >= 0 so that ordinary integer
- * division rounds towards minus infinity; this is also efficient.
- */
- if (hx < 0x00100000) { /* zero or subnormal? */
- u.f = x*0x1p54;
- hx = u.i>>32 & 0x7fffffff;
- if (hx == 0)
- return x; /* cbrt(0) is itself */
- hx = hx/3 + B2;
- } else
- hx = hx/3 + B1;
- u.i &= 1ULL<<63;
- u.i |= (uint64_t)hx << 32;
- t = u.f;
-
- /*
- * New cbrt to 23 bits:
- * cbrt(x) = t*cbrt(x/t**3) ~= t*P(t**3/x)
- * where P(r) is a polynomial of degree 4 that approximates 1/cbrt(r)
- * to within 2**-23.5 when |r - 1| < 1/10. The rough approximation
- * has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this
- * gives us bounds for r = t**3/x.
- *
- * Try to optimize for parallel evaluation as in __tanf.c.
- */
- r = (t*t)*(t/x);
- t = t*((P0+r*(P1+r*P2))+((r*r)*r)*(P3+r*P4));
-
- /*
- * Round t away from zero to 23 bits (sloppily except for ensuring that
- * the result is larger in magnitude than cbrt(x) but not much more than
- * 2 23-bit ulps larger). With rounding towards zero, the error bound
- * would be ~5/6 instead of ~4/6. With a maximum error of 2 23-bit ulps
- * in the rounded t, the infinite-precision error in the Newton
- * approximation barely affects third digit in the final error
- * 0.667; the error in the rounded t can be up to about 3 23-bit ulps
- * before the final error is larger than 0.667 ulps.
- */
- u.f = t;
- u.i = (u.i + 0x80000000) & 0xffffffffc0000000ULL;
- t = u.f;
-
- /* one step Newton iteration to 53 bits with error < 0.667 ulps */
- s = t*t; /* t*t is exact */
- r = x/s; /* error <= 0.5 ulps; |r| < |t| */
- w = t+t; /* t+t is exact */
- r = (r-t)/(w+r); /* r-t is exact; w+r ~= 3*t */
- t = t+t*r; /* error <= 0.5 + 0.5/3 + epsilon */
- return t;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/cbrtf.c b/lib/mlibc/options/ansi/musl-generic-math/cbrtf.c
deleted file mode 100644
index 89c2c86..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/cbrtf.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_cbrtf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Debugged and optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* cbrtf(x)
- * Return cube root of x
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const unsigned
-B1 = 709958130, /* B1 = (127-127.0/3-0.03306235651)*2**23 */
-B2 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */
-
-float cbrtf(float x)
-{
- double_t r,T;
- union {float f; uint32_t i;} u = {x};
- uint32_t hx = u.i & 0x7fffffff;
-
- if (hx >= 0x7f800000) /* cbrt(NaN,INF) is itself */
- return x + x;
-
- /* rough cbrt to 5 bits */
- if (hx < 0x00800000) { /* zero or subnormal? */
- if (hx == 0)
- return x; /* cbrt(+-0) is itself */
- u.f = x*0x1p24f;
- hx = u.i & 0x7fffffff;
- hx = hx/3 + B2;
- } else
- hx = hx/3 + B1;
- u.i &= 0x80000000;
- u.i |= hx;
-
- /*
- * First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In
- * double precision so that its terms can be arranged for efficiency
- * without causing overflow or underflow.
- */
- T = u.f;
- r = T*T*T;
- T = T*((double_t)x+x+r)/(x+r+r);
-
- /*
- * Second step Newton iteration to 47 bits. In double precision for
- * efficiency and accuracy.
- */
- r = T*T*T;
- T = T*((double_t)x+x+r)/(x+r+r);
-
- /* rounding to 24 bits is perfect in round-to-nearest mode */
- return T;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/cbrtl.c b/lib/mlibc/options/ansi/musl-generic-math/cbrtl.c
deleted file mode 100644
index ceff913..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/cbrtl.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_cbrtl.c */
-/*-
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2009-2011, Bruce D. Evans, Steven G. Kargl, David Schultz.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- * The argument reduction and testing for exceptional cases was
- * written by Steven G. Kargl with input from Bruce D. Evans
- * and David A. Schultz.
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double cbrtl(long double x)
-{
- return cbrt(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-static const unsigned B1 = 709958130; /* B1 = (127-127.0/3-0.03306235651)*2**23 */
-
-long double cbrtl(long double x)
-{
- union ldshape u = {x}, v;
- union {float f; uint32_t i;} uft;
- long double r, s, t, w;
- double_t dr, dt, dx;
- float_t ft;
- int e = u.i.se & 0x7fff;
- int sign = u.i.se & 0x8000;
-
- /*
- * If x = +-Inf, then cbrt(x) = +-Inf.
- * If x = NaN, then cbrt(x) = NaN.
- */
- if (e == 0x7fff)
- return x + x;
- if (e == 0) {
- /* Adjust subnormal numbers. */
- u.f *= 0x1p120;
- e = u.i.se & 0x7fff;
- /* If x = +-0, then cbrt(x) = +-0. */
- if (e == 0)
- return x;
- e -= 120;
- }
- e -= 0x3fff;
- u.i.se = 0x3fff;
- x = u.f;
- switch (e % 3) {
- case 1:
- case -2:
- x *= 2;
- e--;
- break;
- case 2:
- case -1:
- x *= 4;
- e -= 2;
- break;
- }
- v.f = 1.0;
- v.i.se = sign | (0x3fff + e/3);
-
- /*
- * The following is the guts of s_cbrtf, with the handling of
- * special values removed and extra care for accuracy not taken,
- * but with most of the extra accuracy not discarded.
- */
-
- /* ~5-bit estimate: */
- uft.f = x;
- uft.i = (uft.i & 0x7fffffff)/3 + B1;
- ft = uft.f;
-
- /* ~16-bit estimate: */
- dx = x;
- dt = ft;
- dr = dt * dt * dt;
- dt = dt * (dx + dx + dr) / (dx + dr + dr);
-
- /* ~47-bit estimate: */
- dr = dt * dt * dt;
- dt = dt * (dx + dx + dr) / (dx + dr + dr);
-
-#if LDBL_MANT_DIG == 64
- /*
- * dt is cbrtl(x) to ~47 bits (after x has been reduced to 1 <= x < 8).
- * Round it away from zero to 32 bits (32 so that t*t is exact, and
- * away from zero for technical reasons).
- */
- t = dt + (0x1.0p32L + 0x1.0p-31L) - 0x1.0p32;
-#elif LDBL_MANT_DIG == 113
- /*
- * Round dt away from zero to 47 bits. Since we don't trust the 47,
- * add 2 47-bit ulps instead of 1 to round up. Rounding is slow and
- * might be avoidable in this case, since on most machines dt will
- * have been evaluated in 53-bit precision and the technical reasons
- * for rounding up might not apply to either case in cbrtl() since
- * dt is much more accurate than needed.
- */
- t = dt + 0x2.0p-46 + 0x1.0p60L - 0x1.0p60;
-#endif
-
- /*
- * Final step Newton iteration to 64 or 113 bits with
- * error < 0.667 ulps
- */
- s = t*t; /* t*t is exact */
- r = x/s; /* error <= 0.5 ulps; |r| < |t| */
- w = t+t; /* t+t is exact */
- r = (r-t)/(w+r); /* r-t is exact; w+r ~= 3*t */
- t = t+t*r; /* error <= 0.5 + 0.5/3 + epsilon */
-
- t *= v.f;
- return t;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ceil.c b/lib/mlibc/options/ansi/musl-generic-math/ceil.c
deleted file mode 100644
index b13e6f2..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ceil.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double ceil(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i >> 52 & 0x7ff;
- double_t y;
-
- if (e >= 0x3ff+52 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i >> 63)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3ff-1) {
- FORCE_EVAL(y);
- return u.i >> 63 ? -0.0 : 1;
- }
- if (y < 0)
- return x + y + 1;
- return x + y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ceilf.c b/lib/mlibc/options/ansi/musl-generic-math/ceilf.c
deleted file mode 100644
index 869835f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ceilf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "libm.h"
-
-float ceilf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = (int)(u.i >> 23 & 0xff) - 0x7f;
- uint32_t m;
-
- if (e >= 23)
- return x;
- if (e >= 0) {
- m = 0x007fffff >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31 == 0)
- u.i += m;
- u.i &= ~m;
- } else {
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31)
- u.f = -0.0;
- else if (u.i << 1)
- u.f = 1.0;
- }
- return u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ceill.c b/lib/mlibc/options/ansi/musl-generic-math/ceill.c
deleted file mode 100644
index 60a8302..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ceill.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double ceill(long double x)
-{
- return ceil(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-static const long double toint = 1/LDBL_EPSILON;
-
-long double ceill(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- long double y;
-
- if (e >= 0x3fff+LDBL_MANT_DIG-1 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i.se >> 15)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3fff-1) {
- FORCE_EVAL(y);
- return u.i.se >> 15 ? -0.0 : 1;
- }
- if (y < 0)
- return x + y + 1;
- return x + y;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/copysign.c b/lib/mlibc/options/ansi/musl-generic-math/copysign.c
deleted file mode 100644
index b09331b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/copysign.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "libm.h"
-
-double copysign(double x, double y) {
- union {double f; uint64_t i;} ux={x}, uy={y};
- ux.i &= -1ULL/2;
- ux.i |= uy.i & 1ULL<<63;
- return ux.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/copysignf.c b/lib/mlibc/options/ansi/musl-generic-math/copysignf.c
deleted file mode 100644
index 0af6ae9..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/copysignf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float copysignf(float x, float y)
-{
- union {float f; uint32_t i;} ux={x}, uy={y};
- ux.i &= 0x7fffffff;
- ux.i |= uy.i & 0x80000000;
- return ux.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/copysignl.c b/lib/mlibc/options/ansi/musl-generic-math/copysignl.c
deleted file mode 100644
index 9dd933c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/copysignl.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double copysignl(long double x, long double y)
-{
- return copysign(x, y);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double copysignl(long double x, long double y)
-{
- union ldshape ux = {x}, uy = {y};
- ux.i.se &= 0x7fff;
- ux.i.se |= uy.i.se & 0x8000;
- return ux.f;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/cos.c b/lib/mlibc/options/ansi/musl-generic-math/cos.c
deleted file mode 100644
index ee97f68..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/cos.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* cos(x)
- * Return cosine function of x.
- *
- * kernel function:
- * __sin ... sine function on [-pi/4,pi/4]
- * __cos ... cosine function on [-pi/4,pi/4]
- * __rem_pio2 ... argument reduction routine
- *
- * Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- * in [-pi/4 , +pi/4], and let n = k mod 4.
- * We have
- *
- * n sin(x) cos(x) tan(x)
- * ----------------------------------------------------------
- * 0 S C T
- * 1 C -S -1/T
- * 2 -S -C T
- * 3 -C S -1/T
- * ----------------------------------------------------------
- *
- * Special cases:
- * Let trig be any of sin, cos, or tan.
- * trig(+-INF) is NaN, with signals;
- * trig(NaN) is that NaN;
- *
- * Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "libm.h"
-
-double cos(double x)
-{
- double y[2];
- uint32_t ix;
- unsigned n;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
-
- /* |x| ~< pi/4 */
- if (ix <= 0x3fe921fb) {
- if (ix < 0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */
- /* raise inexact if x!=0 */
- FORCE_EVAL(x + 0x1p120f);
- return 1.0;
- }
- return __cos(x, 0);
- }
-
- /* cos(Inf or NaN) is NaN */
- if (ix >= 0x7ff00000)
- return x-x;
-
- /* argument reduction */
- n = __rem_pio2(x, y);
- switch (n&3) {
- case 0: return __cos(y[0], y[1]);
- case 1: return -__sin(y[0], y[1], 1);
- case 2: return -__cos(y[0], y[1]);
- default:
- return __sin(y[0], y[1], 1);
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/cosf.c b/lib/mlibc/options/ansi/musl-generic-math/cosf.c
deleted file mode 100644
index 23f3e5b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/cosf.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_cosf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
-c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
-c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
-c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
-float cosf(float x)
-{
- double y;
- uint32_t ix;
- unsigned n, sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
-
- if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- /* raise inexact if x != 0 */
- FORCE_EVAL(x + 0x1p120f);
- return 1.0f;
- }
- return __cosdf(x);
- }
- if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */
- return -__cosdf(sign ? x+c2pio2 : x-c2pio2);
- else {
- if (sign)
- return __sindf(x + c1pio2);
- else
- return __sindf(c1pio2 - x);
- }
- }
- if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */
- return __cosdf(sign ? x+c4pio2 : x-c4pio2);
- else {
- if (sign)
- return __sindf(-x - c3pio2);
- else
- return __sindf(x - c3pio2);
- }
- }
-
- /* cos(Inf or NaN) is NaN */
- if (ix >= 0x7f800000)
- return x-x;
-
- /* general argument reduction needed */
- n = __rem_pio2f(x,&y);
- switch (n&3) {
- case 0: return __cosdf(y);
- case 1: return __sindf(-y);
- case 2: return -__cosdf(y);
- default:
- return __sindf(y);
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/cosh.c b/lib/mlibc/options/ansi/musl-generic-math/cosh.c
deleted file mode 100644
index 100f823..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/cosh.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "libm.h"
-
-/* cosh(x) = (exp(x) + 1/exp(x))/2
- * = 1 + 0.5*(exp(x)-1)*(exp(x)-1)/exp(x)
- * = 1 + x*x/2 + o(x^4)
- */
-double cosh(double x)
-{
- union {double f; uint64_t i;} u = {.f = x};
- uint32_t w;
- double t;
-
- /* |x| */
- u.i &= (uint64_t)-1/2;
- x = u.f;
- w = u.i >> 32;
-
- /* |x| < log(2) */
- if (w < 0x3fe62e42) {
- if (w < 0x3ff00000 - (26<<20)) {
- /* raise inexact if x!=0 */
- FORCE_EVAL(x + 0x1p120f);
- return 1;
- }
- t = expm1(x);
- return 1 + t*t/(2*(1+t));
- }
-
- /* |x| < log(DBL_MAX) */
- if (w < 0x40862e42) {
- t = exp(x);
- /* note: if x>log(0x1p26) then the 1/t is not needed */
- return 0.5*(t + 1/t);
- }
-
- /* |x| > log(DBL_MAX) or nan */
- /* note: the result is stored to handle overflow */
- t = __expo2(x);
- return t;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/coshf.c b/lib/mlibc/options/ansi/musl-generic-math/coshf.c
deleted file mode 100644
index b09f2ee..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/coshf.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "libm.h"
-
-float coshf(float x)
-{
- union {float f; uint32_t i;} u = {.f = x};
- uint32_t w;
- float t;
-
- /* |x| */
- u.i &= 0x7fffffff;
- x = u.f;
- w = u.i;
-
- /* |x| < log(2) */
- if (w < 0x3f317217) {
- if (w < 0x3f800000 - (12<<23)) {
- FORCE_EVAL(x + 0x1p120f);
- return 1;
- }
- t = expm1f(x);
- return 1 + t*t/(2*(1+t));
- }
-
- /* |x| < log(FLT_MAX) */
- if (w < 0x42b17217) {
- t = expf(x);
- return 0.5f*(t + 1/t);
- }
-
- /* |x| > log(FLT_MAX) or nan */
- t = __expo2f(x);
- return t;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/coshl.c b/lib/mlibc/options/ansi/musl-generic-math/coshl.c
deleted file mode 100644
index 06a56fe..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/coshl.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double coshl(long double x)
-{
- return cosh(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-long double coshl(long double x)
-{
- union ldshape u = {x};
- unsigned ex = u.i.se & 0x7fff;
- uint32_t w;
- long double t;
-
- /* |x| */
- u.i.se = ex;
- x = u.f;
- w = u.i.m >> 32;
-
- /* |x| < log(2) */
- if (ex < 0x3fff-1 || (ex == 0x3fff-1 && w < 0xb17217f7)) {
- if (ex < 0x3fff-32) {
- FORCE_EVAL(x + 0x1p120f);
- return 1;
- }
- t = expm1l(x);
- return 1 + t*t/(2*(1+t));
- }
-
- /* |x| < log(LDBL_MAX) */
- if (ex < 0x3fff+13 || (ex == 0x3fff+13 && w < 0xb17217f7)) {
- t = expl(x);
- return 0.5*(t + 1/t);
- }
-
- /* |x| > log(LDBL_MAX) or nan */
- t = expl(0.5*x);
- return 0.5*t*t;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double coshl(long double x)
-{
- return cosh(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/cosl.c b/lib/mlibc/options/ansi/musl-generic-math/cosl.c
deleted file mode 100644
index 79c41c7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/cosl.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double cosl(long double x) {
- return cos(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double cosl(long double x)
-{
- union ldshape u = {x};
- unsigned n;
- long double y[2], hi, lo;
-
- u.i.se &= 0x7fff;
- if (u.i.se == 0x7fff)
- return x - x;
- x = u.f;
- if (x < M_PI_4) {
- if (u.i.se < 0x3fff - LDBL_MANT_DIG)
- /* raise inexact if x!=0 */
- return 1.0 + x;
- return __cosl(x, 0);
- }
- n = __rem_pio2l(x, y);
- hi = y[0];
- lo = y[1];
- switch (n & 3) {
- case 0:
- return __cosl(hi, lo);
- case 1:
- return -__sinl(hi, lo, 1);
- case 2:
- return -__cosl(hi, lo);
- case 3:
- default:
- return __sinl(hi, lo, 1);
- }
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/erf.c b/lib/mlibc/options/ansi/musl-generic-math/erf.c
deleted file mode 100644
index 2f30a29..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/erf.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_erf.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* double erf(double x)
- * double erfc(double x)
- * x
- * 2 |\
- * erf(x) = --------- | exp(-t*t)dt
- * sqrt(pi) \|
- * 0
- *
- * erfc(x) = 1-erf(x)
- * Note that
- * erf(-x) = -erf(x)
- * erfc(-x) = 2 - erfc(x)
- *
- * Method:
- * 1. For |x| in [0, 0.84375]
- * erf(x) = x + x*R(x^2)
- * erfc(x) = 1 - erf(x) if x in [-.84375,0.25]
- * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375]
- * where R = P/Q where P is an odd poly of degree 8 and
- * Q is an odd poly of degree 10.
- * -57.90
- * | R - (erf(x)-x)/x | <= 2
- *
- *
- * Remark. The formula is derived by noting
- * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
- * and that
- * 2/sqrt(pi) = 1.128379167095512573896158903121545171688
- * is close to one. The interval is chosen because the fix
- * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
- * near 0.6174), and by some experiment, 0.84375 is chosen to
- * guarantee the error is less than one ulp for erf.
- *
- * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and
- * c = 0.84506291151 rounded to single (24 bits)
- * erf(x) = sign(x) * (c + P1(s)/Q1(s))
- * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0
- * 1+(c+P1(s)/Q1(s)) if x < 0
- * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06
- * Remark: here we use the taylor series expansion at x=1.
- * erf(1+s) = erf(1) + s*Poly(s)
- * = 0.845.. + P1(s)/Q1(s)
- * That is, we use rational approximation to approximate
- * erf(1+s) - (c = (single)0.84506291151)
- * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
- * where
- * P1(s) = degree 6 poly in s
- * Q1(s) = degree 6 poly in s
- *
- * 3. For x in [1.25,1/0.35(~2.857143)],
- * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1)
- * erf(x) = 1 - erfc(x)
- * where
- * R1(z) = degree 7 poly in z, (z=1/x^2)
- * S1(z) = degree 8 poly in z
- *
- * 4. For x in [1/0.35,28]
- * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0
- * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6<x<0
- * = 2.0 - tiny (if x <= -6)
- * erf(x) = sign(x)*(1.0 - erfc(x)) if x < 6, else
- * erf(x) = sign(x)*(1.0 - tiny)
- * where
- * R2(z) = degree 6 poly in z, (z=1/x^2)
- * S2(z) = degree 7 poly in z
- *
- * Note1:
- * To compute exp(-x*x-0.5625+R/S), let s be a single
- * precision number and s := x; then
- * -x*x = -s*s + (s-x)*(s+x)
- * exp(-x*x-0.5626+R/S) =
- * exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S);
- * Note2:
- * Here 4 and 5 make use of the asymptotic series
- * exp(-x*x)
- * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) )
- * x*sqrt(pi)
- * We use rational approximation to approximate
- * g(s)=f(1/x^2) = log(erfc(x)*x) - x*x + 0.5625
- * Here is the error bound for R1/S1 and R2/S2
- * |R1/S1 - f(x)| < 2**(-62.57)
- * |R2/S2 - f(x)| < 2**(-61.52)
- *
- * 5. For inf > x >= 28
- * erf(x) = sign(x) *(1 - tiny) (raise inexact)
- * erfc(x) = tiny*tiny (raise underflow) if x > 0
- * = 2 - tiny if x<0
- *
- * 7. Special case:
- * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1,
- * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
- * erfc/erf(NaN) is NaN
- */
-
-#include "libm.h"
-
-static const double
-erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */
-/*
- * Coefficients for approximation to erf on [0,0.84375]
- */
-efx8 = 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */
-pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */
-pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */
-pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */
-pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */
-pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */
-qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */
-qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */
-qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */
-qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */
-qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */
-/*
- * Coefficients for approximation to erf in [0.84375,1.25]
- */
-pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */
-pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */
-pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */
-pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */
-pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */
-pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */
-pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */
-qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */
-qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */
-qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */
-qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */
-qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */
-qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */
-/*
- * Coefficients for approximation to erfc in [1.25,1/0.35]
- */
-ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */
-ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */
-ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */
-ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */
-ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */
-ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */
-ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */
-ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */
-sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */
-sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */
-sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */
-sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */
-sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */
-sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */
-sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */
-sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */
-/*
- * Coefficients for approximation to erfc in [1/.35,28]
- */
-rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */
-rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */
-rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */
-rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */
-rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */
-rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */
-rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */
-sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */
-sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */
-sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */
-sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */
-sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */
-sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */
-sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
-
-static double erfc1(double x)
-{
- double_t s,P,Q;
-
- s = fabs(x) - 1;
- P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
- Q = 1+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
- return 1 - erx - P/Q;
-}
-
-static double erfc2(uint32_t ix, double x)
-{
- double_t s,R,S;
- double z;
-
- if (ix < 0x3ff40000) /* |x| < 1.25 */
- return erfc1(x);
-
- x = fabs(x);
- s = 1/(x*x);
- if (ix < 0x4006db6d) { /* |x| < 1/.35 ~ 2.85714 */
- R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S = 1.0+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
- } else { /* |x| > 1/.35 */
- R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S = 1.0+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
- }
- z = x;
- SET_LOW_WORD(z,0);
- return exp(-z*z-0.5625)*exp((z-x)*(z+x)+R/S)/x;
-}
-
-double erf(double x)
-{
- double r,s,z,y;
- uint32_t ix;
- int sign;
-
- GET_HIGH_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix >= 0x7ff00000) {
- /* erf(nan)=nan, erf(+-inf)=+-1 */
- return 1-2*sign + 1/x;
- }
- if (ix < 0x3feb0000) { /* |x| < 0.84375 */
- if (ix < 0x3e300000) { /* |x| < 2**-28 */
- /* avoid underflow */
- return 0.125*(8*x + efx8*x);
- }
- z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = 1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
- y = r/s;
- return x + x*y;
- }
- if (ix < 0x40180000) /* 0.84375 <= |x| < 6 */
- y = 1 - erfc2(ix,x);
- else
- y = 1 - 0x1p-1022;
- return sign ? -y : y;
-}
-
-double erfc(double x)
-{
- double r,s,z,y;
- uint32_t ix;
- int sign;
-
- GET_HIGH_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix >= 0x7ff00000) {
- /* erfc(nan)=nan, erfc(+-inf)=0,2 */
- return 2*sign + 1/x;
- }
- if (ix < 0x3feb0000) { /* |x| < 0.84375 */
- if (ix < 0x3c700000) /* |x| < 2**-56 */
- return 1.0 - x;
- z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = 1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
- y = r/s;
- if (sign || ix < 0x3fd00000) { /* x < 1/4 */
- return 1.0 - (x+x*y);
- }
- return 0.5 - (x - 0.5 + x*y);
- }
- if (ix < 0x403c0000) { /* 0.84375 <= |x| < 28 */
- return sign ? 2 - erfc2(ix,x) : erfc2(ix,x);
- }
- return sign ? 2 - 0x1p-1022 : 0x1p-1022*0x1p-1022;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/erff.c b/lib/mlibc/options/ansi/musl-generic-math/erff.c
deleted file mode 100644
index ed5f397..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/erff.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_erff.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float
-erx = 8.4506291151e-01, /* 0x3f58560b */
-/*
- * Coefficients for approximation to erf on [0,0.84375]
- */
-efx8 = 1.0270333290e+00, /* 0x3f8375d4 */
-pp0 = 1.2837916613e-01, /* 0x3e0375d4 */
-pp1 = -3.2504209876e-01, /* 0xbea66beb */
-pp2 = -2.8481749818e-02, /* 0xbce9528f */
-pp3 = -5.7702702470e-03, /* 0xbbbd1489 */
-pp4 = -2.3763017452e-05, /* 0xb7c756b1 */
-qq1 = 3.9791721106e-01, /* 0x3ecbbbce */
-qq2 = 6.5022252500e-02, /* 0x3d852a63 */
-qq3 = 5.0813062117e-03, /* 0x3ba68116 */
-qq4 = 1.3249473704e-04, /* 0x390aee49 */
-qq5 = -3.9602282413e-06, /* 0xb684e21a */
-/*
- * Coefficients for approximation to erf in [0.84375,1.25]
- */
-pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */
-pa1 = 4.1485610604e-01, /* 0x3ed46805 */
-pa2 = -3.7220788002e-01, /* 0xbebe9208 */
-pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */
-pa4 = -1.1089469492e-01, /* 0xbde31cc2 */
-pa5 = 3.5478305072e-02, /* 0x3d1151b3 */
-pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */
-qa1 = 1.0642088205e-01, /* 0x3dd9f331 */
-qa2 = 5.4039794207e-01, /* 0x3f0a5785 */
-qa3 = 7.1828655899e-02, /* 0x3d931ae7 */
-qa4 = 1.2617121637e-01, /* 0x3e013307 */
-qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */
-qa6 = 1.1984500103e-02, /* 0x3c445aa3 */
-/*
- * Coefficients for approximation to erfc in [1.25,1/0.35]
- */
-ra0 = -9.8649440333e-03, /* 0xbc21a093 */
-ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */
-ra2 = -1.0558626175e+01, /* 0xc128f022 */
-ra3 = -6.2375331879e+01, /* 0xc2798057 */
-ra4 = -1.6239666748e+02, /* 0xc322658c */
-ra5 = -1.8460508728e+02, /* 0xc3389ae7 */
-ra6 = -8.1287437439e+01, /* 0xc2a2932b */
-ra7 = -9.8143291473e+00, /* 0xc11d077e */
-sa1 = 1.9651271820e+01, /* 0x419d35ce */
-sa2 = 1.3765776062e+02, /* 0x4309a863 */
-sa3 = 4.3456588745e+02, /* 0x43d9486f */
-sa4 = 6.4538726807e+02, /* 0x442158c9 */
-sa5 = 4.2900814819e+02, /* 0x43d6810b */
-sa6 = 1.0863500214e+02, /* 0x42d9451f */
-sa7 = 6.5702495575e+00, /* 0x40d23f7c */
-sa8 = -6.0424413532e-02, /* 0xbd777f97 */
-/*
- * Coefficients for approximation to erfc in [1/.35,28]
- */
-rb0 = -9.8649431020e-03, /* 0xbc21a092 */
-rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */
-rb2 = -1.7757955551e+01, /* 0xc18e104b */
-rb3 = -1.6063638306e+02, /* 0xc320a2ea */
-rb4 = -6.3756646729e+02, /* 0xc41f6441 */
-rb5 = -1.0250950928e+03, /* 0xc480230b */
-rb6 = -4.8351919556e+02, /* 0xc3f1c275 */
-sb1 = 3.0338060379e+01, /* 0x41f2b459 */
-sb2 = 3.2579251099e+02, /* 0x43a2e571 */
-sb3 = 1.5367296143e+03, /* 0x44c01759 */
-sb4 = 3.1998581543e+03, /* 0x4547fdbb */
-sb5 = 2.5530502930e+03, /* 0x451f90ce */
-sb6 = 4.7452853394e+02, /* 0x43ed43a7 */
-sb7 = -2.2440952301e+01; /* 0xc1b38712 */
-
-static float erfc1(float x)
-{
- float_t s,P,Q;
-
- s = fabsf(x) - 1;
- P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
- Q = 1+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
- return 1 - erx - P/Q;
-}
-
-static float erfc2(uint32_t ix, float x)
-{
- float_t s,R,S;
- float z;
-
- if (ix < 0x3fa00000) /* |x| < 1.25 */
- return erfc1(x);
-
- x = fabsf(x);
- s = 1/(x*x);
- if (ix < 0x4036db6d) { /* |x| < 1/0.35 */
- R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S = 1.0f+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
- } else { /* |x| >= 1/0.35 */
- R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S = 1.0f+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
- }
- GET_FLOAT_WORD(ix, x);
- SET_FLOAT_WORD(z, ix&0xffffe000);
- return expf(-z*z - 0.5625f) * expf((z-x)*(z+x) + R/S)/x;
-}
-
-float erff(float x)
-{
- float r,s,z,y;
- uint32_t ix;
- int sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix >= 0x7f800000) {
- /* erf(nan)=nan, erf(+-inf)=+-1 */
- return 1-2*sign + 1/x;
- }
- if (ix < 0x3f580000) { /* |x| < 0.84375 */
- if (ix < 0x31800000) { /* |x| < 2**-28 */
- /*avoid underflow */
- return 0.125f*(8*x + efx8*x);
- }
- z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = 1+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
- y = r/s;
- return x + x*y;
- }
- if (ix < 0x40c00000) /* |x| < 6 */
- y = 1 - erfc2(ix,x);
- else
- y = 1 - 0x1p-120f;
- return sign ? -y : y;
-}
-
-float erfcf(float x)
-{
- float r,s,z,y;
- uint32_t ix;
- int sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix >= 0x7f800000) {
- /* erfc(nan)=nan, erfc(+-inf)=0,2 */
- return 2*sign + 1/x;
- }
-
- if (ix < 0x3f580000) { /* |x| < 0.84375 */
- if (ix < 0x23800000) /* |x| < 2**-56 */
- return 1.0f - x;
- z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = 1.0f+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
- y = r/s;
- if (sign || ix < 0x3e800000) /* x < 1/4 */
- return 1.0f - (x+x*y);
- return 0.5f - (x - 0.5f + x*y);
- }
- if (ix < 0x41e00000) { /* |x| < 28 */
- return sign ? 2 - erfc2(ix,x) : erfc2(ix,x);
- }
- return sign ? 2 - 0x1p-120f : 0x1p-120f*0x1p-120f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/erfl.c b/lib/mlibc/options/ansi/musl-generic-math/erfl.c
deleted file mode 100644
index e267c23..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/erfl.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_erfl.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* double erf(double x)
- * double erfc(double x)
- * x
- * 2 |\
- * erf(x) = --------- | exp(-t*t)dt
- * sqrt(pi) \|
- * 0
- *
- * erfc(x) = 1-erf(x)
- * Note that
- * erf(-x) = -erf(x)
- * erfc(-x) = 2 - erfc(x)
- *
- * Method:
- * 1. For |x| in [0, 0.84375]
- * erf(x) = x + x*R(x^2)
- * erfc(x) = 1 - erf(x) if x in [-.84375,0.25]
- * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375]
- * Remark. The formula is derived by noting
- * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
- * and that
- * 2/sqrt(pi) = 1.128379167095512573896158903121545171688
- * is close to one. The interval is chosen because the fix
- * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
- * near 0.6174), and by some experiment, 0.84375 is chosen to
- * guarantee the error is less than one ulp for erf.
- *
- * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and
- * c = 0.84506291151 rounded to single (24 bits)
- * erf(x) = sign(x) * (c + P1(s)/Q1(s))
- * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0
- * 1+(c+P1(s)/Q1(s)) if x < 0
- * Remark: here we use the taylor series expansion at x=1.
- * erf(1+s) = erf(1) + s*Poly(s)
- * = 0.845.. + P1(s)/Q1(s)
- * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
- *
- * 3. For x in [1.25,1/0.35(~2.857143)],
- * erfc(x) = (1/x)*exp(-x*x-0.5625+R1(z)/S1(z))
- * z=1/x^2
- * erf(x) = 1 - erfc(x)
- *
- * 4. For x in [1/0.35,107]
- * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0
- * = 2.0 - (1/x)*exp(-x*x-0.5625+R2(z)/S2(z))
- * if -6.666<x<0
- * = 2.0 - tiny (if x <= -6.666)
- * z=1/x^2
- * erf(x) = sign(x)*(1.0 - erfc(x)) if x < 6.666, else
- * erf(x) = sign(x)*(1.0 - tiny)
- * Note1:
- * To compute exp(-x*x-0.5625+R/S), let s be a single
- * precision number and s := x; then
- * -x*x = -s*s + (s-x)*(s+x)
- * exp(-x*x-0.5626+R/S) =
- * exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S);
- * Note2:
- * Here 4 and 5 make use of the asymptotic series
- * exp(-x*x)
- * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) )
- * x*sqrt(pi)
- *
- * 5. For inf > x >= 107
- * erf(x) = sign(x) *(1 - tiny) (raise inexact)
- * erfc(x) = tiny*tiny (raise underflow) if x > 0
- * = 2 - tiny if x<0
- *
- * 7. Special case:
- * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1,
- * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
- * erfc/erf(NaN) is NaN
- */
-
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double erfl(long double x)
-{
- return erf(x);
-}
-long double erfcl(long double x)
-{
- return erfc(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-static const long double
-erx = 0.845062911510467529296875L,
-
-/*
- * Coefficients for approximation to erf on [0,0.84375]
- */
-/* 8 * (2/sqrt(pi) - 1) */
-efx8 = 1.0270333367641005911692712249723613735048E0L,
-pp[6] = {
- 1.122751350964552113068262337278335028553E6L,
- -2.808533301997696164408397079650699163276E6L,
- -3.314325479115357458197119660818768924100E5L,
- -6.848684465326256109712135497895525446398E4L,
- -2.657817695110739185591505062971929859314E3L,
- -1.655310302737837556654146291646499062882E2L,
-},
-qq[6] = {
- 8.745588372054466262548908189000448124232E6L,
- 3.746038264792471129367533128637019611485E6L,
- 7.066358783162407559861156173539693900031E5L,
- 7.448928604824620999413120955705448117056E4L,
- 4.511583986730994111992253980546131408924E3L,
- 1.368902937933296323345610240009071254014E2L,
- /* 1.000000000000000000000000000000000000000E0 */
-},
-
-/*
- * Coefficients for approximation to erf in [0.84375,1.25]
- */
-/* erf(x+1) = 0.845062911510467529296875 + pa(x)/qa(x)
- -0.15625 <= x <= +.25
- Peak relative error 8.5e-22 */
-pa[8] = {
- -1.076952146179812072156734957705102256059E0L,
- 1.884814957770385593365179835059971587220E2L,
- -5.339153975012804282890066622962070115606E1L,
- 4.435910679869176625928504532109635632618E1L,
- 1.683219516032328828278557309642929135179E1L,
- -2.360236618396952560064259585299045804293E0L,
- 1.852230047861891953244413872297940938041E0L,
- 9.394994446747752308256773044667843200719E-2L,
-},
-qa[7] = {
- 4.559263722294508998149925774781887811255E2L,
- 3.289248982200800575749795055149780689738E2L,
- 2.846070965875643009598627918383314457912E2L,
- 1.398715859064535039433275722017479994465E2L,
- 6.060190733759793706299079050985358190726E1L,
- 2.078695677795422351040502569964299664233E1L,
- 4.641271134150895940966798357442234498546E0L,
- /* 1.000000000000000000000000000000000000000E0 */
-},
-
-/*
- * Coefficients for approximation to erfc in [1.25,1/0.35]
- */
-/* erfc(1/x) = x exp (-1/x^2 - 0.5625 + ra(x^2)/sa(x^2))
- 1/2.85711669921875 < 1/x < 1/1.25
- Peak relative error 3.1e-21 */
-ra[] = {
- 1.363566591833846324191000679620738857234E-1L,
- 1.018203167219873573808450274314658434507E1L,
- 1.862359362334248675526472871224778045594E2L,
- 1.411622588180721285284945138667933330348E3L,
- 5.088538459741511988784440103218342840478E3L,
- 8.928251553922176506858267311750789273656E3L,
- 7.264436000148052545243018622742770549982E3L,
- 2.387492459664548651671894725748959751119E3L,
- 2.220916652813908085449221282808458466556E2L,
-},
-sa[] = {
- -1.382234625202480685182526402169222331847E1L,
- -3.315638835627950255832519203687435946482E2L,
- -2.949124863912936259747237164260785326692E3L,
- -1.246622099070875940506391433635999693661E4L,
- -2.673079795851665428695842853070996219632E4L,
- -2.880269786660559337358397106518918220991E4L,
- -1.450600228493968044773354186390390823713E4L,
- -2.874539731125893533960680525192064277816E3L,
- -1.402241261419067750237395034116942296027E2L,
- /* 1.000000000000000000000000000000000000000E0 */
-},
-
-/*
- * Coefficients for approximation to erfc in [1/.35,107]
- */
-/* erfc(1/x) = x exp (-1/x^2 - 0.5625 + rb(x^2)/sb(x^2))
- 1/6.6666259765625 < 1/x < 1/2.85711669921875
- Peak relative error 4.2e-22 */
-rb[] = {
- -4.869587348270494309550558460786501252369E-5L,
- -4.030199390527997378549161722412466959403E-3L,
- -9.434425866377037610206443566288917589122E-2L,
- -9.319032754357658601200655161585539404155E-1L,
- -4.273788174307459947350256581445442062291E0L,
- -8.842289940696150508373541814064198259278E0L,
- -7.069215249419887403187988144752613025255E0L,
- -1.401228723639514787920274427443330704764E0L,
-},
-sb[] = {
- 4.936254964107175160157544545879293019085E-3L,
- 1.583457624037795744377163924895349412015E-1L,
- 1.850647991850328356622940552450636420484E0L,
- 9.927611557279019463768050710008450625415E0L,
- 2.531667257649436709617165336779212114570E1L,
- 2.869752886406743386458304052862814690045E1L,
- 1.182059497870819562441683560749192539345E1L,
- /* 1.000000000000000000000000000000000000000E0 */
-},
-/* erfc(1/x) = x exp (-1/x^2 - 0.5625 + rc(x^2)/sc(x^2))
- 1/107 <= 1/x <= 1/6.6666259765625
- Peak relative error 1.1e-21 */
-rc[] = {
- -8.299617545269701963973537248996670806850E-5L,
- -6.243845685115818513578933902532056244108E-3L,
- -1.141667210620380223113693474478394397230E-1L,
- -7.521343797212024245375240432734425789409E-1L,
- -1.765321928311155824664963633786967602934E0L,
- -1.029403473103215800456761180695263439188E0L,
-},
-sc[] = {
- 8.413244363014929493035952542677768808601E-3L,
- 2.065114333816877479753334599639158060979E-1L,
- 1.639064941530797583766364412782135680148E0L,
- 4.936788463787115555582319302981666347450E0L,
- 5.005177727208955487404729933261347679090E0L,
- /* 1.000000000000000000000000000000000000000E0 */
-};
-
-static long double erfc1(long double x)
-{
- long double s,P,Q;
-
- s = fabsl(x) - 1;
- P = pa[0] + s * (pa[1] + s * (pa[2] +
- s * (pa[3] + s * (pa[4] + s * (pa[5] + s * (pa[6] + s * pa[7]))))));
- Q = qa[0] + s * (qa[1] + s * (qa[2] +
- s * (qa[3] + s * (qa[4] + s * (qa[5] + s * (qa[6] + s))))));
- return 1 - erx - P / Q;
-}
-
-static long double erfc2(uint32_t ix, long double x)
-{
- union ldshape u;
- long double s,z,R,S;
-
- if (ix < 0x3fffa000) /* 0.84375 <= |x| < 1.25 */
- return erfc1(x);
-
- x = fabsl(x);
- s = 1 / (x * x);
- if (ix < 0x4000b6db) { /* 1.25 <= |x| < 2.857 ~ 1/.35 */
- R = ra[0] + s * (ra[1] + s * (ra[2] + s * (ra[3] + s * (ra[4] +
- s * (ra[5] + s * (ra[6] + s * (ra[7] + s * ra[8])))))));
- S = sa[0] + s * (sa[1] + s * (sa[2] + s * (sa[3] + s * (sa[4] +
- s * (sa[5] + s * (sa[6] + s * (sa[7] + s * (sa[8] + s))))))));
- } else if (ix < 0x4001d555) { /* 2.857 <= |x| < 6.6666259765625 */
- R = rb[0] + s * (rb[1] + s * (rb[2] + s * (rb[3] + s * (rb[4] +
- s * (rb[5] + s * (rb[6] + s * rb[7]))))));
- S = sb[0] + s * (sb[1] + s * (sb[2] + s * (sb[3] + s * (sb[4] +
- s * (sb[5] + s * (sb[6] + s))))));
- } else { /* 6.666 <= |x| < 107 (erfc only) */
- R = rc[0] + s * (rc[1] + s * (rc[2] + s * (rc[3] +
- s * (rc[4] + s * rc[5]))));
- S = sc[0] + s * (sc[1] + s * (sc[2] + s * (sc[3] +
- s * (sc[4] + s))));
- }
- u.f = x;
- u.i.m &= -1ULL << 40;
- z = u.f;
- return expl(-z*z - 0.5625) * expl((z - x) * (z + x) + R / S) / x;
-}
-
-long double erfl(long double x)
-{
- long double r, s, z, y;
- union ldshape u = {x};
- uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
- int sign = u.i.se >> 15;
-
- if (ix >= 0x7fff0000)
- /* erf(nan)=nan, erf(+-inf)=+-1 */
- return 1 - 2*sign + 1/x;
- if (ix < 0x3ffed800) { /* |x| < 0.84375 */
- if (ix < 0x3fde8000) { /* |x| < 2**-33 */
- return 0.125 * (8 * x + efx8 * x); /* avoid underflow */
- }
- z = x * x;
- r = pp[0] + z * (pp[1] +
- z * (pp[2] + z * (pp[3] + z * (pp[4] + z * pp[5]))));
- s = qq[0] + z * (qq[1] +
- z * (qq[2] + z * (qq[3] + z * (qq[4] + z * (qq[5] + z)))));
- y = r / s;
- return x + x * y;
- }
- if (ix < 0x4001d555) /* |x| < 6.6666259765625 */
- y = 1 - erfc2(ix,x);
- else
- y = 1 - 0x1p-16382L;
- return sign ? -y : y;
-}
-
-long double erfcl(long double x)
-{
- long double r, s, z, y;
- union ldshape u = {x};
- uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
- int sign = u.i.se >> 15;
-
- if (ix >= 0x7fff0000)
- /* erfc(nan) = nan, erfc(+-inf) = 0,2 */
- return 2*sign + 1/x;
- if (ix < 0x3ffed800) { /* |x| < 0.84375 */
- if (ix < 0x3fbe0000) /* |x| < 2**-65 */
- return 1.0 - x;
- z = x * x;
- r = pp[0] + z * (pp[1] +
- z * (pp[2] + z * (pp[3] + z * (pp[4] + z * pp[5]))));
- s = qq[0] + z * (qq[1] +
- z * (qq[2] + z * (qq[3] + z * (qq[4] + z * (qq[5] + z)))));
- y = r / s;
- if (ix < 0x3ffd8000) /* x < 1/4 */
- return 1.0 - (x + x * y);
- return 0.5 - (x - 0.5 + x * y);
- }
- if (ix < 0x4005d600) /* |x| < 107 */
- return sign ? 2 - erfc2(ix,x) : erfc2(ix,x);
- y = 0x1p-16382L;
- return sign ? 2 - y : y*y;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double erfl(long double x)
-{
- return erf(x);
-}
-long double erfcl(long double x)
-{
- return erfc(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/exp.c b/lib/mlibc/options/ansi/musl-generic-math/exp.c
deleted file mode 100644
index 9ea672f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/exp.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_exp.c */
-/*
- * ====================================================
- * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* exp(x)
- * Returns the exponential of x.
- *
- * Method
- * 1. Argument reduction:
- * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
- * Given x, find r and integer k such that
- *
- * x = k*ln2 + r, |r| <= 0.5*ln2.
- *
- * Here r will be represented as r = hi-lo for better
- * accuracy.
- *
- * 2. Approximation of exp(r) by a special rational function on
- * the interval [0,0.34658]:
- * Write
- * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
- * We use a special Remez algorithm on [0,0.34658] to generate
- * a polynomial of degree 5 to approximate R. The maximum error
- * of this polynomial approximation is bounded by 2**-59. In
- * other words,
- * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
- * (where z=r*r, and the values of P1 to P5 are listed below)
- * and
- * | 5 | -59
- * | 2.0+P1*z+...+P5*z - R(z) | <= 2
- * | |
- * The computation of exp(r) thus becomes
- * 2*r
- * exp(r) = 1 + ----------
- * R(r) - r
- * r*c(r)
- * = 1 + r + ----------- (for better accuracy)
- * 2 - c(r)
- * where
- * 2 4 10
- * c(r) = r - (P1*r + P2*r + ... + P5*r ).
- *
- * 3. Scale back to obtain exp(x):
- * From step 1, we have
- * exp(x) = 2^k * exp(r)
- *
- * Special cases:
- * exp(INF) is INF, exp(NaN) is NaN;
- * exp(-INF) is 0, and
- * for finite argument, only exp(0)=1 is exact.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Misc. info.
- * For IEEE double
- * if x > 709.782712893383973096 then exp(x) overflows
- * if x < -745.133219101941108420 then exp(x) underflows
- */
-
-#include "libm.h"
-
-static const double
-half[2] = {0.5,-0.5},
-ln2hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
-ln2lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */
-invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
-P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
-
-double exp(double x)
-{
- double_t hi, lo, c, xx, y;
- int k, sign;
- uint32_t hx;
-
- GET_HIGH_WORD(hx, x);
- sign = hx>>31;
- hx &= 0x7fffffff; /* high word of |x| */
-
- /* special cases */
- if (hx >= 0x4086232b) { /* if |x| >= 708.39... */
- if (isnan(x))
- return x;
- if (x > 709.782712893383973096) {
- /* overflow if x!=inf */
- x *= 0x1p1023;
- return x;
- }
- if (x < -708.39641853226410622) {
- /* underflow if x!=-inf */
- FORCE_EVAL((float)(-0x1p-149/x));
- if (x < -745.13321910194110842)
- return 0;
- }
- }
-
- /* argument reduction */
- if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
- if (hx >= 0x3ff0a2b2) /* if |x| >= 1.5 ln2 */
- k = (int)(invln2*x + half[sign]);
- else
- k = 1 - sign - sign;
- hi = x - k*ln2hi; /* k*ln2hi is exact here */
- lo = k*ln2lo;
- x = hi - lo;
- } else if (hx > 0x3e300000) { /* if |x| > 2**-28 */
- k = 0;
- hi = x;
- lo = 0;
- } else {
- /* inexact if x!=0 */
- FORCE_EVAL(0x1p1023 + x);
- return 1 + x;
- }
-
- /* x is now in primary range */
- xx = x*x;
- c = x - xx*(P1+xx*(P2+xx*(P3+xx*(P4+xx*P5))));
- y = 1 + (x*c/(2-c) - lo + hi);
- if (k == 0)
- return y;
- return scalbn(y, k);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/exp10.c b/lib/mlibc/options/ansi/musl-generic-math/exp10.c
deleted file mode 100644
index 47b4dc7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/exp10.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#define _GNU_SOURCE
-#include <math.h>
-#include <stdint.h>
-#include "weak_alias.h"
-//#include "libc.h"
-
-double exp10(double x)
-{
- static const double p10[] = {
- 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10,
- 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1,
- 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15
- };
- double n, y = modf(x, &n);
- union {double f; uint64_t i;} u = {n};
- /* fabs(n) < 16 without raising invalid on nan */
- if ((u.i>>52 & 0x7ff) < 0x3ff+4) {
- if (!y) return p10[(int)n+15];
- y = exp2(3.32192809488736234787031942948939 * y);
- return y * p10[(int)n+15];
- }
- return pow(10.0, x);
-}
-
-weak_alias(exp10, pow10);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/exp10f.c b/lib/mlibc/options/ansi/musl-generic-math/exp10f.c
deleted file mode 100644
index 74f8909..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/exp10f.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#define _GNU_SOURCE
-#include <math.h>
-#include <stdint.h>
-#include "weak_alias.h"
-//#include "libc.h"
-
-float exp10f(float x)
-{
- static const float p10[] = {
- 1e-7f, 1e-6f, 1e-5f, 1e-4f, 1e-3f, 1e-2f, 1e-1f,
- 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7
- };
- float n, y = modff(x, &n);
- union {float f; uint32_t i;} u = {n};
- /* fabsf(n) < 8 without raising invalid on nan */
- if ((u.i>>23 & 0xff) < 0x7f+3) {
- if (!y) return p10[(int)n+7];
- y = exp2f(3.32192809488736234787031942948939f * y);
- return y * p10[(int)n+7];
- }
- return exp2(3.32192809488736234787031942948939 * x);
-}
-
-weak_alias(exp10f, pow10f);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/exp10l.c b/lib/mlibc/options/ansi/musl-generic-math/exp10l.c
deleted file mode 100644
index f18e554..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/exp10l.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#define _GNU_SOURCE
-#include <float.h>
-#include <math.h>
-//#include "libc.h"
-#include "libm.h"
-#include "weak_alias.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double exp10l(long double x)
-{
- return exp10(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double exp10l(long double x)
-{
- static const long double p10[] = {
- 1e-15L, 1e-14L, 1e-13L, 1e-12L, 1e-11L, 1e-10L,
- 1e-9L, 1e-8L, 1e-7L, 1e-6L, 1e-5L, 1e-4L, 1e-3L, 1e-2L, 1e-1L,
- 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15
- };
- long double n, y = modfl(x, &n);
- union ldshape u = {n};
- /* fabsl(n) < 16 without raising invalid on nan */
- if ((u.i.se & 0x7fff) < 0x3fff+4) {
- if (!y) return p10[(int)n+15];
- y = exp2l(3.32192809488736234787031942948939L * y);
- return y * p10[(int)n+15];
- }
- return powl(10.0, x);
-}
-#endif
-
-weak_alias(exp10l, pow10l);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/exp2.c b/lib/mlibc/options/ansi/musl-generic-math/exp2.c
deleted file mode 100644
index e14adba..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/exp2.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_exp2.c */
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "libm.h"
-
-#define TBLSIZE 256
-
-static const double
-redux = 0x1.8p52 / TBLSIZE,
-P1 = 0x1.62e42fefa39efp-1,
-P2 = 0x1.ebfbdff82c575p-3,
-P3 = 0x1.c6b08d704a0a6p-5,
-P4 = 0x1.3b2ab88f70400p-7,
-P5 = 0x1.5d88003875c74p-10;
-
-static const double tbl[TBLSIZE * 2] = {
-/* exp2(z + eps) eps */
- 0x1.6a09e667f3d5dp-1, 0x1.9880p-44,
- 0x1.6b052fa751744p-1, 0x1.8000p-50,
- 0x1.6c012750bd9fep-1, -0x1.8780p-45,
- 0x1.6cfdcddd476bfp-1, 0x1.ec00p-46,
- 0x1.6dfb23c651a29p-1, -0x1.8000p-50,
- 0x1.6ef9298593ae3p-1, -0x1.c000p-52,
- 0x1.6ff7df9519386p-1, -0x1.fd80p-45,
- 0x1.70f7466f42da3p-1, -0x1.c880p-45,
- 0x1.71f75e8ec5fc3p-1, 0x1.3c00p-46,
- 0x1.72f8286eacf05p-1, -0x1.8300p-44,
- 0x1.73f9a48a58152p-1, -0x1.0c00p-47,
- 0x1.74fbd35d7ccfcp-1, 0x1.f880p-45,
- 0x1.75feb564267f1p-1, 0x1.3e00p-47,
- 0x1.77024b1ab6d48p-1, -0x1.7d00p-45,
- 0x1.780694fde5d38p-1, -0x1.d000p-50,
- 0x1.790b938ac1d00p-1, 0x1.3000p-49,
- 0x1.7a11473eb0178p-1, -0x1.d000p-49,
- 0x1.7b17b0976d060p-1, 0x1.0400p-45,
- 0x1.7c1ed0130c133p-1, 0x1.0000p-53,
- 0x1.7d26a62ff8636p-1, -0x1.6900p-45,
- 0x1.7e2f336cf4e3bp-1, -0x1.2e00p-47,
- 0x1.7f3878491c3e8p-1, -0x1.4580p-45,
- 0x1.80427543e1b4ep-1, 0x1.3000p-44,
- 0x1.814d2add1071ap-1, 0x1.f000p-47,
- 0x1.82589994ccd7ep-1, -0x1.1c00p-45,
- 0x1.8364c1eb942d0p-1, 0x1.9d00p-45,
- 0x1.8471a4623cab5p-1, 0x1.7100p-43,
- 0x1.857f4179f5bbcp-1, 0x1.2600p-45,
- 0x1.868d99b4491afp-1, -0x1.2c40p-44,
- 0x1.879cad931a395p-1, -0x1.3000p-45,
- 0x1.88ac7d98a65b8p-1, -0x1.a800p-45,
- 0x1.89bd0a4785800p-1, -0x1.d000p-49,
- 0x1.8ace5422aa223p-1, 0x1.3280p-44,
- 0x1.8be05bad619fap-1, 0x1.2b40p-43,
- 0x1.8cf3216b54383p-1, -0x1.ed00p-45,
- 0x1.8e06a5e08664cp-1, -0x1.0500p-45,
- 0x1.8f1ae99157807p-1, 0x1.8280p-45,
- 0x1.902fed0282c0ep-1, -0x1.cb00p-46,
- 0x1.9145b0b91ff96p-1, -0x1.5e00p-47,
- 0x1.925c353aa2ff9p-1, 0x1.5400p-48,
- 0x1.93737b0cdc64ap-1, 0x1.7200p-46,
- 0x1.948b82b5f98aep-1, -0x1.9000p-47,
- 0x1.95a44cbc852cbp-1, 0x1.5680p-45,
- 0x1.96bdd9a766f21p-1, -0x1.6d00p-44,
- 0x1.97d829fde4e2ap-1, -0x1.1000p-47,
- 0x1.98f33e47a23a3p-1, 0x1.d000p-45,
- 0x1.9a0f170ca0604p-1, -0x1.8a40p-44,
- 0x1.9b2bb4d53ff89p-1, 0x1.55c0p-44,
- 0x1.9c49182a3f15bp-1, 0x1.6b80p-45,
- 0x1.9d674194bb8c5p-1, -0x1.c000p-49,
- 0x1.9e86319e3238ep-1, 0x1.7d00p-46,
- 0x1.9fa5e8d07f302p-1, 0x1.6400p-46,
- 0x1.a0c667b5de54dp-1, -0x1.5000p-48,
- 0x1.a1e7aed8eb8f6p-1, 0x1.9e00p-47,
- 0x1.a309bec4a2e27p-1, 0x1.ad80p-45,
- 0x1.a42c980460a5dp-1, -0x1.af00p-46,
- 0x1.a5503b23e259bp-1, 0x1.b600p-47,
- 0x1.a674a8af46213p-1, 0x1.8880p-44,
- 0x1.a799e1330b3a7p-1, 0x1.1200p-46,
- 0x1.a8bfe53c12e8dp-1, 0x1.6c00p-47,
- 0x1.a9e6b5579fcd2p-1, -0x1.9b80p-45,
- 0x1.ab0e521356fb8p-1, 0x1.b700p-45,
- 0x1.ac36bbfd3f381p-1, 0x1.9000p-50,
- 0x1.ad5ff3a3c2780p-1, 0x1.4000p-49,
- 0x1.ae89f995ad2a3p-1, -0x1.c900p-45,
- 0x1.afb4ce622f367p-1, 0x1.6500p-46,
- 0x1.b0e07298db790p-1, 0x1.fd40p-45,
- 0x1.b20ce6c9a89a9p-1, 0x1.2700p-46,
- 0x1.b33a2b84f1a4bp-1, 0x1.d470p-43,
- 0x1.b468415b747e7p-1, -0x1.8380p-44,
- 0x1.b59728de5593ap-1, 0x1.8000p-54,
- 0x1.b6c6e29f1c56ap-1, 0x1.ad00p-47,
- 0x1.b7f76f2fb5e50p-1, 0x1.e800p-50,
- 0x1.b928cf22749b2p-1, -0x1.4c00p-47,
- 0x1.ba5b030a10603p-1, -0x1.d700p-47,
- 0x1.bb8e0b79a6f66p-1, 0x1.d900p-47,
- 0x1.bcc1e904bc1ffp-1, 0x1.2a00p-47,
- 0x1.bdf69c3f3a16fp-1, -0x1.f780p-46,
- 0x1.bf2c25bd71db8p-1, -0x1.0a00p-46,
- 0x1.c06286141b2e9p-1, -0x1.1400p-46,
- 0x1.c199bdd8552e0p-1, 0x1.be00p-47,
- 0x1.c2d1cd9fa64eep-1, -0x1.9400p-47,
- 0x1.c40ab5fffd02fp-1, -0x1.ed00p-47,
- 0x1.c544778fafd15p-1, 0x1.9660p-44,
- 0x1.c67f12e57d0cbp-1, -0x1.a100p-46,
- 0x1.c7ba88988c1b6p-1, -0x1.8458p-42,
- 0x1.c8f6d9406e733p-1, -0x1.a480p-46,
- 0x1.ca3405751c4dfp-1, 0x1.b000p-51,
- 0x1.cb720dcef9094p-1, 0x1.1400p-47,
- 0x1.ccb0f2e6d1689p-1, 0x1.0200p-48,
- 0x1.cdf0b555dc412p-1, 0x1.3600p-48,
- 0x1.cf3155b5bab3bp-1, -0x1.6900p-47,
- 0x1.d072d4a0789bcp-1, 0x1.9a00p-47,
- 0x1.d1b532b08c8fap-1, -0x1.5e00p-46,
- 0x1.d2f87080d8a85p-1, 0x1.d280p-46,
- 0x1.d43c8eacaa203p-1, 0x1.1a00p-47,
- 0x1.d5818dcfba491p-1, 0x1.f000p-50,
- 0x1.d6c76e862e6a1p-1, -0x1.3a00p-47,
- 0x1.d80e316c9834ep-1, -0x1.cd80p-47,
- 0x1.d955d71ff6090p-1, 0x1.4c00p-48,
- 0x1.da9e603db32aep-1, 0x1.f900p-48,
- 0x1.dbe7cd63a8325p-1, 0x1.9800p-49,
- 0x1.dd321f301b445p-1, -0x1.5200p-48,
- 0x1.de7d5641c05bfp-1, -0x1.d700p-46,
- 0x1.dfc97337b9aecp-1, -0x1.6140p-46,
- 0x1.e11676b197d5ep-1, 0x1.b480p-47,
- 0x1.e264614f5a3e7p-1, 0x1.0ce0p-43,
- 0x1.e3b333b16ee5cp-1, 0x1.c680p-47,
- 0x1.e502ee78b3fb4p-1, -0x1.9300p-47,
- 0x1.e653924676d68p-1, -0x1.5000p-49,
- 0x1.e7a51fbc74c44p-1, -0x1.7f80p-47,
- 0x1.e8f7977cdb726p-1, -0x1.3700p-48,
- 0x1.ea4afa2a490e8p-1, 0x1.5d00p-49,
- 0x1.eb9f4867ccae4p-1, 0x1.61a0p-46,
- 0x1.ecf482d8e680dp-1, 0x1.5500p-48,
- 0x1.ee4aaa2188514p-1, 0x1.6400p-51,
- 0x1.efa1bee615a13p-1, -0x1.e800p-49,
- 0x1.f0f9c1cb64106p-1, -0x1.a880p-48,
- 0x1.f252b376bb963p-1, -0x1.c900p-45,
- 0x1.f3ac948dd7275p-1, 0x1.a000p-53,
- 0x1.f50765b6e4524p-1, -0x1.4f00p-48,
- 0x1.f6632798844fdp-1, 0x1.a800p-51,
- 0x1.f7bfdad9cbe38p-1, 0x1.abc0p-48,
- 0x1.f91d802243c82p-1, -0x1.4600p-50,
- 0x1.fa7c1819e908ep-1, -0x1.b0c0p-47,
- 0x1.fbdba3692d511p-1, -0x1.0e00p-51,
- 0x1.fd3c22b8f7194p-1, -0x1.0de8p-46,
- 0x1.fe9d96b2a23eep-1, 0x1.e430p-49,
- 0x1.0000000000000p+0, 0x0.0000p+0,
- 0x1.00b1afa5abcbep+0, -0x1.3400p-52,
- 0x1.0163da9fb3303p+0, -0x1.2170p-46,
- 0x1.02168143b0282p+0, 0x1.a400p-52,
- 0x1.02c9a3e77806cp+0, 0x1.f980p-49,
- 0x1.037d42e11bbcap+0, -0x1.7400p-51,
- 0x1.04315e86e7f89p+0, 0x1.8300p-50,
- 0x1.04e5f72f65467p+0, -0x1.a3f0p-46,
- 0x1.059b0d315855ap+0, -0x1.2840p-47,
- 0x1.0650a0e3c1f95p+0, 0x1.1600p-48,
- 0x1.0706b29ddf71ap+0, 0x1.5240p-46,
- 0x1.07bd42b72a82dp+0, -0x1.9a00p-49,
- 0x1.0874518759bd0p+0, 0x1.6400p-49,
- 0x1.092bdf66607c8p+0, -0x1.0780p-47,
- 0x1.09e3ecac6f383p+0, -0x1.8000p-54,
- 0x1.0a9c79b1f3930p+0, 0x1.fa00p-48,
- 0x1.0b5586cf988fcp+0, -0x1.ac80p-48,
- 0x1.0c0f145e46c8ap+0, 0x1.9c00p-50,
- 0x1.0cc922b724816p+0, 0x1.5200p-47,
- 0x1.0d83b23395dd8p+0, -0x1.ad00p-48,
- 0x1.0e3ec32d3d1f3p+0, 0x1.bac0p-46,
- 0x1.0efa55fdfa9a6p+0, -0x1.4e80p-47,
- 0x1.0fb66affed2f0p+0, -0x1.d300p-47,
- 0x1.1073028d7234bp+0, 0x1.1500p-48,
- 0x1.11301d0125b5bp+0, 0x1.c000p-49,
- 0x1.11edbab5e2af9p+0, 0x1.6bc0p-46,
- 0x1.12abdc06c31d5p+0, 0x1.8400p-49,
- 0x1.136a814f2047dp+0, -0x1.ed00p-47,
- 0x1.1429aaea92de9p+0, 0x1.8e00p-49,
- 0x1.14e95934f3138p+0, 0x1.b400p-49,
- 0x1.15a98c8a58e71p+0, 0x1.5300p-47,
- 0x1.166a45471c3dfp+0, 0x1.3380p-47,
- 0x1.172b83c7d5211p+0, 0x1.8d40p-45,
- 0x1.17ed48695bb9fp+0, -0x1.5d00p-47,
- 0x1.18af9388c8d93p+0, -0x1.c880p-46,
- 0x1.1972658375d66p+0, 0x1.1f00p-46,
- 0x1.1a35beb6fcba7p+0, 0x1.0480p-46,
- 0x1.1af99f81387e3p+0, -0x1.7390p-43,
- 0x1.1bbe084045d54p+0, 0x1.4e40p-45,
- 0x1.1c82f95281c43p+0, -0x1.a200p-47,
- 0x1.1d4873168b9b2p+0, 0x1.3800p-49,
- 0x1.1e0e75eb44031p+0, 0x1.ac00p-49,
- 0x1.1ed5022fcd938p+0, 0x1.1900p-47,
- 0x1.1f9c18438cdf7p+0, -0x1.b780p-46,
- 0x1.2063b88628d8fp+0, 0x1.d940p-45,
- 0x1.212be3578a81ep+0, 0x1.8000p-50,
- 0x1.21f49917ddd41p+0, 0x1.b340p-45,
- 0x1.22bdda2791323p+0, 0x1.9f80p-46,
- 0x1.2387a6e7561e7p+0, -0x1.9c80p-46,
- 0x1.2451ffb821427p+0, 0x1.2300p-47,
- 0x1.251ce4fb2a602p+0, -0x1.3480p-46,
- 0x1.25e85711eceb0p+0, 0x1.2700p-46,
- 0x1.26b4565e27d16p+0, 0x1.1d00p-46,
- 0x1.2780e341de00fp+0, 0x1.1ee0p-44,
- 0x1.284dfe1f5633ep+0, -0x1.4c00p-46,
- 0x1.291ba7591bb30p+0, -0x1.3d80p-46,
- 0x1.29e9df51fdf09p+0, 0x1.8b00p-47,
- 0x1.2ab8a66d10e9bp+0, -0x1.27c0p-45,
- 0x1.2b87fd0dada3ap+0, 0x1.a340p-45,
- 0x1.2c57e39771af9p+0, -0x1.0800p-46,
- 0x1.2d285a6e402d9p+0, -0x1.ed00p-47,
- 0x1.2df961f641579p+0, -0x1.4200p-48,
- 0x1.2ecafa93e2ecfp+0, -0x1.4980p-45,
- 0x1.2f9d24abd8822p+0, -0x1.6300p-46,
- 0x1.306fe0a31b625p+0, -0x1.2360p-44,
- 0x1.31432edeea50bp+0, -0x1.0df8p-40,
- 0x1.32170fc4cd7b8p+0, -0x1.2480p-45,
- 0x1.32eb83ba8e9a2p+0, -0x1.5980p-45,
- 0x1.33c08b2641766p+0, 0x1.ed00p-46,
- 0x1.3496266e3fa27p+0, -0x1.c000p-50,
- 0x1.356c55f929f0fp+0, -0x1.0d80p-44,
- 0x1.36431a2de88b9p+0, 0x1.2c80p-45,
- 0x1.371a7373aaa39p+0, 0x1.0600p-45,
- 0x1.37f26231e74fep+0, -0x1.6600p-46,
- 0x1.38cae6d05d838p+0, -0x1.ae00p-47,
- 0x1.39a401b713ec3p+0, -0x1.4720p-43,
- 0x1.3a7db34e5a020p+0, 0x1.8200p-47,
- 0x1.3b57fbfec6e95p+0, 0x1.e800p-44,
- 0x1.3c32dc313a8f2p+0, 0x1.f800p-49,
- 0x1.3d0e544ede122p+0, -0x1.7a00p-46,
- 0x1.3dea64c1234bbp+0, 0x1.6300p-45,
- 0x1.3ec70df1c4eccp+0, -0x1.8a60p-43,
- 0x1.3fa4504ac7e8cp+0, -0x1.cdc0p-44,
- 0x1.40822c367a0bbp+0, 0x1.5b80p-45,
- 0x1.4160a21f72e95p+0, 0x1.ec00p-46,
- 0x1.423fb27094646p+0, -0x1.3600p-46,
- 0x1.431f5d950a920p+0, 0x1.3980p-45,
- 0x1.43ffa3f84b9ebp+0, 0x1.a000p-48,
- 0x1.44e0860618919p+0, -0x1.6c00p-48,
- 0x1.45c2042a7d201p+0, -0x1.bc00p-47,
- 0x1.46a41ed1d0016p+0, -0x1.2800p-46,
- 0x1.4786d668b3326p+0, 0x1.0e00p-44,
- 0x1.486a2b5c13c00p+0, -0x1.d400p-45,
- 0x1.494e1e192af04p+0, 0x1.c200p-47,
- 0x1.4a32af0d7d372p+0, -0x1.e500p-46,
- 0x1.4b17dea6db801p+0, 0x1.7800p-47,
- 0x1.4bfdad53629e1p+0, -0x1.3800p-46,
- 0x1.4ce41b817c132p+0, 0x1.0800p-47,
- 0x1.4dcb299fddddbp+0, 0x1.c700p-45,
- 0x1.4eb2d81d8ab96p+0, -0x1.ce00p-46,
- 0x1.4f9b2769d2d02p+0, 0x1.9200p-46,
- 0x1.508417f4531c1p+0, -0x1.8c00p-47,
- 0x1.516daa2cf662ap+0, -0x1.a000p-48,
- 0x1.5257de83f51eap+0, 0x1.a080p-43,
- 0x1.5342b569d4edap+0, -0x1.6d80p-45,
- 0x1.542e2f4f6ac1ap+0, -0x1.2440p-44,
- 0x1.551a4ca5d94dbp+0, 0x1.83c0p-43,
- 0x1.56070dde9116bp+0, 0x1.4b00p-45,
- 0x1.56f4736b529dep+0, 0x1.15a0p-43,
- 0x1.57e27dbe2c40ep+0, -0x1.9e00p-45,
- 0x1.58d12d497c76fp+0, -0x1.3080p-45,
- 0x1.59c0827ff0b4cp+0, 0x1.dec0p-43,
- 0x1.5ab07dd485427p+0, -0x1.4000p-51,
- 0x1.5ba11fba87af4p+0, 0x1.0080p-44,
- 0x1.5c9268a59460bp+0, -0x1.6c80p-45,
- 0x1.5d84590998e3fp+0, 0x1.69a0p-43,
- 0x1.5e76f15ad20e1p+0, -0x1.b400p-46,
- 0x1.5f6a320dcebcap+0, 0x1.7700p-46,
- 0x1.605e1b976dcb8p+0, 0x1.6f80p-45,
- 0x1.6152ae6cdf715p+0, 0x1.1000p-47,
- 0x1.6247eb03a5531p+0, -0x1.5d00p-46,
- 0x1.633dd1d1929b5p+0, -0x1.2d00p-46,
- 0x1.6434634ccc313p+0, -0x1.a800p-49,
- 0x1.652b9febc8efap+0, -0x1.8600p-45,
- 0x1.6623882553397p+0, 0x1.1fe0p-40,
- 0x1.671c1c708328ep+0, -0x1.7200p-44,
- 0x1.68155d44ca97ep+0, 0x1.6800p-49,
- 0x1.690f4b19e9471p+0, -0x1.9780p-45,
-};
-
-/*
- * exp2(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.503 ulp for normalized results.
- *
- * Method: (accurate tables)
- *
- * Reduce x:
- * x = k + y, for integer k and |y| <= 1/2.
- * Thus we have exp2(x) = 2**k * exp2(y).
- *
- * Reduce y:
- * y = i/TBLSIZE + z - eps[i] for integer i near y * TBLSIZE.
- * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z - eps[i]),
- * with |z - eps[i]| <= 2**-9 + 2**-39 for the table used.
- *
- * We compute exp2(i/TBLSIZE) via table lookup and exp2(z - eps[i]) via
- * a degree-5 minimax polynomial with maximum error under 1.3 * 2**-61.
- * The values in exp2t[] and eps[] are chosen such that
- * exp2t[i] = exp2(i/TBLSIZE + eps[i]), and eps[i] is a small offset such
- * that exp2t[i] is accurate to 2**-64.
- *
- * Note that the range of i is +-TBLSIZE/2, so we actually index the tables
- * by i0 = i + TBLSIZE/2. For cache efficiency, exp2t[] and eps[] are
- * virtual tables, interleaved in the real table tbl[].
- *
- * This method is due to Gal, with many details due to Gal and Bachelis:
- *
- * Gal, S. and Bachelis, B. An Accurate Elementary Mathematical Library
- * for the IEEE Floating Point Standard. TOMS 17(1), 26-46 (1991).
- */
-double exp2(double x)
-{
- double_t r, t, z;
- uint32_t ix, i0;
- union {double f; uint64_t i;} u = {x};
- union {uint32_t u; int32_t i;} k;
-
- /* Filter out exceptional cases. */
- ix = u.i>>32 & 0x7fffffff;
- if (ix >= 0x408ff000) { /* |x| >= 1022 or nan */
- if (ix >= 0x40900000 && u.i>>63 == 0) { /* x >= 1024 or nan */
- /* overflow */
- x *= 0x1p1023;
- return x;
- }
- if (ix >= 0x7ff00000) /* -inf or -nan */
- return -1/x;
- if (u.i>>63) { /* x <= -1022 */
- /* underflow */
- if (x <= -1075 || x - 0x1p52 + 0x1p52 != x)
- FORCE_EVAL((float)(-0x1p-149/x));
- if (x <= -1075)
- return 0;
- }
- } else if (ix < 0x3c900000) { /* |x| < 0x1p-54 */
- return 1.0 + x;
- }
-
- /* Reduce x, computing z, i0, and k. */
- u.f = x + redux;
- i0 = u.i;
- i0 += TBLSIZE / 2;
- k.u = i0 / TBLSIZE * TBLSIZE;
- k.i /= TBLSIZE;
- i0 %= TBLSIZE;
- u.f -= redux;
- z = x - u.f;
-
- /* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
- t = tbl[2*i0]; /* exp2t[i0] */
- z -= tbl[2*i0 + 1]; /* eps[i0] */
- r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
-
- return scalbn(r, k.i);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/exp2f.c b/lib/mlibc/options/ansi/musl-generic-math/exp2f.c
deleted file mode 100644
index 296b634..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/exp2f.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_exp2f.c */
-/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "libm.h"
-
-#define TBLSIZE 16
-
-static const float
-redux = 0x1.8p23f / TBLSIZE,
-P1 = 0x1.62e430p-1f,
-P2 = 0x1.ebfbe0p-3f,
-P3 = 0x1.c6b348p-5f,
-P4 = 0x1.3b2c9cp-7f;
-
-static const double exp2ft[TBLSIZE] = {
- 0x1.6a09e667f3bcdp-1,
- 0x1.7a11473eb0187p-1,
- 0x1.8ace5422aa0dbp-1,
- 0x1.9c49182a3f090p-1,
- 0x1.ae89f995ad3adp-1,
- 0x1.c199bdd85529cp-1,
- 0x1.d5818dcfba487p-1,
- 0x1.ea4afa2a490dap-1,
- 0x1.0000000000000p+0,
- 0x1.0b5586cf9890fp+0,
- 0x1.172b83c7d517bp+0,
- 0x1.2387a6e756238p+0,
- 0x1.306fe0a31b715p+0,
- 0x1.3dea64c123422p+0,
- 0x1.4bfdad5362a27p+0,
- 0x1.5ab07dd485429p+0,
-};
-
-/*
- * exp2f(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.501 ulp; location of peak: -0.030110927.
- *
- * Method: (equally-spaced tables)
- *
- * Reduce x:
- * x = k + y, for integer k and |y| <= 1/2.
- * Thus we have exp2f(x) = 2**k * exp2(y).
- *
- * Reduce y:
- * y = i/TBLSIZE + z for integer i near y * TBLSIZE.
- * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
- * with |z| <= 2**-(TBLSIZE+1).
- *
- * We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
- * degree-4 minimax polynomial with maximum error under 1.4 * 2**-33.
- * Using double precision for everything except the reduction makes
- * roundoff error insignificant and simplifies the scaling step.
- *
- * This method is due to Tang, but I do not use his suggested parameters:
- *
- * Tang, P. Table-driven Implementation of the Exponential Function
- * in IEEE Floating-Point Arithmetic. TOMS 15(2), 144-157 (1989).
- */
-float exp2f(float x)
-{
- double_t t, r, z;
- union {float f; uint32_t i;} u = {x};
- union {double f; uint64_t i;} uk;
- uint32_t ix, i0, k;
-
- /* Filter out exceptional cases. */
- ix = u.i & 0x7fffffff;
- if (ix > 0x42fc0000) { /* |x| > 126 */
- if (ix > 0x7f800000) /* NaN */
- return x;
- if (u.i >= 0x43000000 && u.i < 0x80000000) { /* x >= 128 */
- x *= 0x1p127f;
- return x;
- }
- if (u.i >= 0x80000000) { /* x < -126 */
- if (u.i >= 0xc3160000 || (u.i & 0x0000ffff))
- FORCE_EVAL(-0x1p-149f/x);
- if (u.i >= 0xc3160000) /* x <= -150 */
- return 0;
- }
- } else if (ix <= 0x33000000) { /* |x| <= 0x1p-25 */
- return 1.0f + x;
- }
-
- /* Reduce x, computing z, i0, and k. */
- u.f = x + redux;
- i0 = u.i;
- i0 += TBLSIZE / 2;
- k = i0 / TBLSIZE;
- uk.i = (uint64_t)(0x3ff + k)<<52;
- i0 &= TBLSIZE - 1;
- u.f -= redux;
- z = x - u.f;
- /* Compute r = exp2(y) = exp2ft[i0] * p(z). */
- r = exp2ft[i0];
- t = r * z;
- r = r + t * (P1 + z * P2) + t * (z * z) * (P3 + z * P4);
-
- /* Scale by 2**k */
- return r * uk.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/exp2l.c b/lib/mlibc/options/ansi/musl-generic-math/exp2l.c
deleted file mode 100644
index 3565c1e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/exp2l.c
+++ /dev/null
@@ -1,619 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/ld80/s_exp2l.c and /usr/src/lib/msun/ld128/s_exp2l.c */
-/*-
- * Copyright (c) 2005-2008 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double exp2l(long double x)
-{
- return exp2(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-#define TBLBITS 7
-#define TBLSIZE (1 << TBLBITS)
-
-static const double
-redux = 0x1.8p63 / TBLSIZE,
-P1 = 0x1.62e42fefa39efp-1,
-P2 = 0x1.ebfbdff82c58fp-3,
-P3 = 0x1.c6b08d7049fap-5,
-P4 = 0x1.3b2ab6fba4da5p-7,
-P5 = 0x1.5d8804780a736p-10,
-P6 = 0x1.430918835e33dp-13;
-
-static const double tbl[TBLSIZE * 2] = {
- 0x1.6a09e667f3bcdp-1, -0x1.bdd3413b2648p-55,
- 0x1.6c012750bdabfp-1, -0x1.2895667ff0cp-57,
- 0x1.6dfb23c651a2fp-1, -0x1.bbe3a683c88p-58,
- 0x1.6ff7df9519484p-1, -0x1.83c0f25860fp-56,
- 0x1.71f75e8ec5f74p-1, -0x1.16e4786887bp-56,
- 0x1.73f9a48a58174p-1, -0x1.0a8d96c65d5p-55,
- 0x1.75feb564267c9p-1, -0x1.0245957316ep-55,
- 0x1.780694fde5d3fp-1, 0x1.866b80a0216p-55,
- 0x1.7a11473eb0187p-1, -0x1.41577ee0499p-56,
- 0x1.7c1ed0130c132p-1, 0x1.f124cd1164ep-55,
- 0x1.7e2f336cf4e62p-1, 0x1.05d02ba157ap-57,
- 0x1.80427543e1a12p-1, -0x1.27c86626d97p-55,
- 0x1.82589994cce13p-1, -0x1.d4c1dd41533p-55,
- 0x1.8471a4623c7adp-1, -0x1.8d684a341cep-56,
- 0x1.868d99b4492edp-1, -0x1.fc6f89bd4f68p-55,
- 0x1.88ac7d98a6699p-1, 0x1.994c2f37cb5p-55,
- 0x1.8ace5422aa0dbp-1, 0x1.6e9f156864bp-55,
- 0x1.8cf3216b5448cp-1, -0x1.0d55e32e9e4p-57,
- 0x1.8f1ae99157736p-1, 0x1.5cc13a2e397p-56,
- 0x1.9145b0b91ffc6p-1, -0x1.dd6792e5825p-55,
- 0x1.93737b0cdc5e5p-1, -0x1.75fc781b58p-58,
- 0x1.95a44cbc8520fp-1, -0x1.64b7c96a5fp-57,
- 0x1.97d829fde4e5p-1, -0x1.d185b7c1b86p-55,
- 0x1.9a0f170ca07bap-1, -0x1.173bd91cee6p-55,
- 0x1.9c49182a3f09p-1, 0x1.c7c46b071f2p-57,
- 0x1.9e86319e32323p-1, 0x1.824ca78e64cp-57,
- 0x1.a0c667b5de565p-1, -0x1.359495d1cd5p-55,
- 0x1.a309bec4a2d33p-1, 0x1.6305c7ddc368p-55,
- 0x1.a5503b23e255dp-1, -0x1.d2f6edb8d42p-55,
- 0x1.a799e1330b358p-1, 0x1.bcb7ecac564p-55,
- 0x1.a9e6b5579fdbfp-1, 0x1.0fac90ef7fdp-55,
- 0x1.ac36bbfd3f37ap-1, -0x1.f9234cae76dp-56,
- 0x1.ae89f995ad3adp-1, 0x1.7a1cd345dcc8p-55,
- 0x1.b0e07298db666p-1, -0x1.bdef54c80e4p-55,
- 0x1.b33a2b84f15fbp-1, -0x1.2805e3084d8p-58,
- 0x1.b59728de5593ap-1, -0x1.c71dfbbba6ep-55,
- 0x1.b7f76f2fb5e47p-1, -0x1.5584f7e54acp-57,
- 0x1.ba5b030a1064ap-1, -0x1.efcd30e5429p-55,
- 0x1.bcc1e904bc1d2p-1, 0x1.23dd07a2d9fp-56,
- 0x1.bf2c25bd71e09p-1, -0x1.efdca3f6b9c8p-55,
- 0x1.c199bdd85529cp-1, 0x1.11065895049p-56,
- 0x1.c40ab5fffd07ap-1, 0x1.b4537e083c6p-55,
- 0x1.c67f12e57d14bp-1, 0x1.2884dff483c8p-55,
- 0x1.c8f6d9406e7b5p-1, 0x1.1acbc48805cp-57,
- 0x1.cb720dcef9069p-1, 0x1.503cbd1e94ap-57,
- 0x1.cdf0b555dc3fap-1, -0x1.dd83b53829dp-56,
- 0x1.d072d4a07897cp-1, -0x1.cbc3743797a8p-55,
- 0x1.d2f87080d89f2p-1, -0x1.d487b719d858p-55,
- 0x1.d5818dcfba487p-1, 0x1.2ed02d75b37p-56,
- 0x1.d80e316c98398p-1, -0x1.11ec18bedep-55,
- 0x1.da9e603db3285p-1, 0x1.c2300696db5p-55,
- 0x1.dd321f301b46p-1, 0x1.2da5778f019p-55,
- 0x1.dfc97337b9b5fp-1, -0x1.1a5cd4f184b8p-55,
- 0x1.e264614f5a129p-1, -0x1.7b627817a148p-55,
- 0x1.e502ee78b3ff6p-1, 0x1.39e8980a9cdp-56,
- 0x1.e7a51fbc74c83p-1, 0x1.2d522ca0c8ep-55,
- 0x1.ea4afa2a490dap-1, -0x1.e9c23179c288p-55,
- 0x1.ecf482d8e67f1p-1, -0x1.c93f3b411ad8p-55,
- 0x1.efa1bee615a27p-1, 0x1.dc7f486a4b68p-55,
- 0x1.f252b376bba97p-1, 0x1.3a1a5bf0d8e8p-55,
- 0x1.f50765b6e454p-1, 0x1.9d3e12dd8a18p-55,
- 0x1.f7bfdad9cbe14p-1, -0x1.dbb12d00635p-55,
- 0x1.fa7c1819e90d8p-1, 0x1.74853f3a593p-56,
- 0x1.fd3c22b8f71f1p-1, 0x1.2eb74966578p-58,
- 0x1p+0, 0x0p+0,
- 0x1.0163da9fb3335p+0, 0x1.b61299ab8cd8p-54,
- 0x1.02c9a3e778061p+0, -0x1.19083535b08p-56,
- 0x1.04315e86e7f85p+0, -0x1.0a31c1977c98p-54,
- 0x1.059b0d3158574p+0, 0x1.d73e2a475b4p-55,
- 0x1.0706b29ddf6dep+0, -0x1.c91dfe2b13cp-55,
- 0x1.0874518759bc8p+0, 0x1.186be4bb284p-57,
- 0x1.09e3ecac6f383p+0, 0x1.14878183161p-54,
- 0x1.0b5586cf9890fp+0, 0x1.8a62e4adc61p-54,
- 0x1.0cc922b7247f7p+0, 0x1.01edc16e24f8p-54,
- 0x1.0e3ec32d3d1a2p+0, 0x1.03a1727c58p-59,
- 0x1.0fb66affed31bp+0, -0x1.b9bedc44ebcp-57,
- 0x1.11301d0125b51p+0, -0x1.6c51039449bp-54,
- 0x1.12abdc06c31ccp+0, -0x1.1b514b36ca8p-58,
- 0x1.1429aaea92dep+0, -0x1.32fbf9af1368p-54,
- 0x1.15a98c8a58e51p+0, 0x1.2406ab9eeabp-55,
- 0x1.172b83c7d517bp+0, -0x1.19041b9d78ap-55,
- 0x1.18af9388c8deap+0, -0x1.11023d1970f8p-54,
- 0x1.1a35beb6fcb75p+0, 0x1.e5b4c7b4969p-55,
- 0x1.1bbe084045cd4p+0, -0x1.95386352ef6p-54,
- 0x1.1d4873168b9aap+0, 0x1.e016e00a264p-54,
- 0x1.1ed5022fcd91dp+0, -0x1.1df98027bb78p-54,
- 0x1.2063b88628cd6p+0, 0x1.dc775814a85p-55,
- 0x1.21f49917ddc96p+0, 0x1.2a97e9494a6p-55,
- 0x1.2387a6e756238p+0, 0x1.9b07eb6c7058p-54,
- 0x1.251ce4fb2a63fp+0, 0x1.ac155bef4f5p-55,
- 0x1.26b4565e27cddp+0, 0x1.2bd339940eap-55,
- 0x1.284dfe1f56381p+0, -0x1.a4c3a8c3f0d8p-54,
- 0x1.29e9df51fdee1p+0, 0x1.612e8afad12p-55,
- 0x1.2b87fd0dad99p+0, -0x1.10adcd6382p-59,
- 0x1.2d285a6e4030bp+0, 0x1.0024754db42p-54,
- 0x1.2ecafa93e2f56p+0, 0x1.1ca0f45d524p-56,
- 0x1.306fe0a31b715p+0, 0x1.6f46ad23183p-55,
- 0x1.32170fc4cd831p+0, 0x1.a9ce78e1804p-55,
- 0x1.33c08b26416ffp+0, 0x1.327218436598p-54,
- 0x1.356c55f929ff1p+0, -0x1.b5cee5c4e46p-55,
- 0x1.371a7373aa9cbp+0, -0x1.63aeabf42ebp-54,
- 0x1.38cae6d05d866p+0, -0x1.e958d3c99048p-54,
- 0x1.3a7db34e59ff7p+0, -0x1.5e436d661f6p-56,
- 0x1.3c32dc313a8e5p+0, -0x1.efff8375d2ap-54,
- 0x1.3dea64c123422p+0, 0x1.ada0911f09fp-55,
- 0x1.3fa4504ac801cp+0, -0x1.7d023f956fap-54,
- 0x1.4160a21f72e2ap+0, -0x1.ef3691c309p-58,
- 0x1.431f5d950a897p+0, -0x1.1c7dde35f7ap-55,
- 0x1.44e086061892dp+0, 0x1.89b7a04ef8p-59,
- 0x1.46a41ed1d0057p+0, 0x1.c944bd1648a8p-54,
- 0x1.486a2b5c13cdp+0, 0x1.3c1a3b69062p-56,
- 0x1.4a32af0d7d3dep+0, 0x1.9cb62f3d1be8p-54,
- 0x1.4bfdad5362a27p+0, 0x1.d4397afec42p-56,
- 0x1.4dcb299fddd0dp+0, 0x1.8ecdbbc6a78p-54,
- 0x1.4f9b2769d2ca7p+0, -0x1.4b309d25958p-54,
- 0x1.516daa2cf6642p+0, -0x1.f768569bd94p-55,
- 0x1.5342b569d4f82p+0, -0x1.07abe1db13dp-55,
- 0x1.551a4ca5d920fp+0, -0x1.d689cefede6p-55,
- 0x1.56f4736b527dap+0, 0x1.9bb2c011d938p-54,
- 0x1.58d12d497c7fdp+0, 0x1.295e15b9a1ep-55,
- 0x1.5ab07dd485429p+0, 0x1.6324c0546478p-54,
- 0x1.5c9268a5946b7p+0, 0x1.c4b1b81698p-60,
- 0x1.5e76f15ad2148p+0, 0x1.ba6f93080e68p-54,
- 0x1.605e1b976dc09p+0, -0x1.3e2429b56de8p-54,
- 0x1.6247eb03a5585p+0, -0x1.383c17e40b48p-54,
- 0x1.6434634ccc32p+0, -0x1.c483c759d89p-55,
- 0x1.6623882552225p+0, -0x1.bb60987591cp-54,
- 0x1.68155d44ca973p+0, 0x1.038ae44f74p-57,
-};
-
-/*
- * exp2l(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.511 ulp.
- *
- * Method: (equally-spaced tables)
- *
- * Reduce x:
- * x = 2**k + y, for integer k and |y| <= 1/2.
- * Thus we have exp2l(x) = 2**k * exp2(y).
- *
- * Reduce y:
- * y = i/TBLSIZE + z for integer i near y * TBLSIZE.
- * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
- * with |z| <= 2**-(TBLBITS+1).
- *
- * We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
- * degree-6 minimax polynomial with maximum error under 2**-69.
- * The table entries each have 104 bits of accuracy, encoded as
- * a pair of double precision values.
- */
-long double exp2l(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- long double r, z;
- uint32_t i0;
- union {uint32_t u; int32_t i;} k;
-
- /* Filter out exceptional cases. */
- if (e >= 0x3fff + 13) { /* |x| >= 8192 or x is NaN */
- if (u.i.se >= 0x3fff + 14 && u.i.se >> 15 == 0)
- /* overflow */
- return x * 0x1p16383L;
- if (e == 0x7fff) /* -inf or -nan */
- return -1/x;
- if (x < -16382) {
- if (x <= -16446 || x - 0x1p63 + 0x1p63 != x)
- /* underflow */
- FORCE_EVAL((float)(-0x1p-149/x));
- if (x <= -16446)
- return 0;
- }
- } else if (e < 0x3fff - 64) {
- return 1 + x;
- }
-
- /*
- * Reduce x, computing z, i0, and k. The low bits of x + redux
- * contain the 16-bit integer part of the exponent (k) followed by
- * TBLBITS fractional bits (i0). We use bit tricks to extract these
- * as integers, then set z to the remainder.
- *
- * Example: Suppose x is 0xabc.123456p0 and TBLBITS is 8.
- * Then the low-order word of x + redux is 0x000abc12,
- * We split this into k = 0xabc and i0 = 0x12 (adjusted to
- * index into the table), then we compute z = 0x0.003456p0.
- */
- u.f = x + redux;
- i0 = u.i.m + TBLSIZE / 2;
- k.u = i0 / TBLSIZE * TBLSIZE;
- k.i /= TBLSIZE;
- i0 %= TBLSIZE;
- u.f -= redux;
- z = x - u.f;
-
- /* Compute r = exp2l(y) = exp2lt[i0] * p(z). */
- long double t_hi = tbl[2*i0];
- long double t_lo = tbl[2*i0 + 1];
- /* XXX This gives > 1 ulp errors outside of FE_TONEAREST mode */
- r = t_lo + (t_hi + t_lo) * z * (P1 + z * (P2 + z * (P3 + z * (P4
- + z * (P5 + z * P6))))) + t_hi;
-
- return scalbnl(r, k.i);
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-#define TBLBITS 7
-#define TBLSIZE (1 << TBLBITS)
-
-static const long double
- P1 = 0x1.62e42fefa39ef35793c7673007e6p-1L,
- P2 = 0x1.ebfbdff82c58ea86f16b06ec9736p-3L,
- P3 = 0x1.c6b08d704a0bf8b33a762bad3459p-5L,
- P4 = 0x1.3b2ab6fba4e7729ccbbe0b4f3fc2p-7L,
- P5 = 0x1.5d87fe78a67311071dee13fd11d9p-10L,
- P6 = 0x1.430912f86c7876f4b663b23c5fe5p-13L;
-
-static const double
- P7 = 0x1.ffcbfc588b041p-17,
- P8 = 0x1.62c0223a5c7c7p-20,
- P9 = 0x1.b52541ff59713p-24,
- P10 = 0x1.e4cf56a391e22p-28,
- redux = 0x1.8p112 / TBLSIZE;
-
-static const long double tbl[TBLSIZE] = {
- 0x1.6a09e667f3bcc908b2fb1366dfeap-1L,
- 0x1.6c012750bdabeed76a99800f4edep-1L,
- 0x1.6dfb23c651a2ef220e2cbe1bc0d4p-1L,
- 0x1.6ff7df9519483cf87e1b4f3e1e98p-1L,
- 0x1.71f75e8ec5f73dd2370f2ef0b148p-1L,
- 0x1.73f9a48a58173bd5c9a4e68ab074p-1L,
- 0x1.75feb564267c8bf6e9aa33a489a8p-1L,
- 0x1.780694fde5d3f619ae02808592a4p-1L,
- 0x1.7a11473eb0186d7d51023f6ccb1ap-1L,
- 0x1.7c1ed0130c1327c49334459378dep-1L,
- 0x1.7e2f336cf4e62105d02ba1579756p-1L,
- 0x1.80427543e1a11b60de67649a3842p-1L,
- 0x1.82589994cce128acf88afab34928p-1L,
- 0x1.8471a4623c7acce52f6b97c6444cp-1L,
- 0x1.868d99b4492ec80e41d90ac2556ap-1L,
- 0x1.88ac7d98a669966530bcdf2d4cc0p-1L,
- 0x1.8ace5422aa0db5ba7c55a192c648p-1L,
- 0x1.8cf3216b5448bef2aa1cd161c57ap-1L,
- 0x1.8f1ae991577362b982745c72eddap-1L,
- 0x1.9145b0b91ffc588a61b469f6b6a0p-1L,
- 0x1.93737b0cdc5e4f4501c3f2540ae8p-1L,
- 0x1.95a44cbc8520ee9b483695a0e7fep-1L,
- 0x1.97d829fde4e4f8b9e920f91e8eb6p-1L,
- 0x1.9a0f170ca07b9ba3109b8c467844p-1L,
- 0x1.9c49182a3f0901c7c46b071f28dep-1L,
- 0x1.9e86319e323231824ca78e64c462p-1L,
- 0x1.a0c667b5de564b29ada8b8cabbacp-1L,
- 0x1.a309bec4a2d3358c171f770db1f4p-1L,
- 0x1.a5503b23e255c8b424491caf88ccp-1L,
- 0x1.a799e1330b3586f2dfb2b158f31ep-1L,
- 0x1.a9e6b5579fdbf43eb243bdff53a2p-1L,
- 0x1.ac36bbfd3f379c0db966a3126988p-1L,
- 0x1.ae89f995ad3ad5e8734d17731c80p-1L,
- 0x1.b0e07298db66590842acdfc6fb4ep-1L,
- 0x1.b33a2b84f15faf6bfd0e7bd941b0p-1L,
- 0x1.b59728de559398e3881111648738p-1L,
- 0x1.b7f76f2fb5e46eaa7b081ab53ff6p-1L,
- 0x1.ba5b030a10649840cb3c6af5b74cp-1L,
- 0x1.bcc1e904bc1d2247ba0f45b3d06cp-1L,
- 0x1.bf2c25bd71e088408d7025190cd0p-1L,
- 0x1.c199bdd85529c2220cb12a0916bap-1L,
- 0x1.c40ab5fffd07a6d14df820f17deap-1L,
- 0x1.c67f12e57d14b4a2137fd20f2a26p-1L,
- 0x1.c8f6d9406e7b511acbc48805c3f6p-1L,
- 0x1.cb720dcef90691503cbd1e949d0ap-1L,
- 0x1.cdf0b555dc3f9c44f8958fac4f12p-1L,
- 0x1.d072d4a07897b8d0f22f21a13792p-1L,
- 0x1.d2f87080d89f18ade123989ea50ep-1L,
- 0x1.d5818dcfba48725da05aeb66dff8p-1L,
- 0x1.d80e316c98397bb84f9d048807a0p-1L,
- 0x1.da9e603db3285708c01a5b6d480cp-1L,
- 0x1.dd321f301b4604b695de3c0630c0p-1L,
- 0x1.dfc97337b9b5eb968cac39ed284cp-1L,
- 0x1.e264614f5a128a12761fa17adc74p-1L,
- 0x1.e502ee78b3ff6273d130153992d0p-1L,
- 0x1.e7a51fbc74c834b548b2832378a4p-1L,
- 0x1.ea4afa2a490d9858f73a18f5dab4p-1L,
- 0x1.ecf482d8e67f08db0312fb949d50p-1L,
- 0x1.efa1bee615a27771fd21a92dabb6p-1L,
- 0x1.f252b376bba974e8696fc3638f24p-1L,
- 0x1.f50765b6e4540674f84b762861a6p-1L,
- 0x1.f7bfdad9cbe138913b4bfe72bd78p-1L,
- 0x1.fa7c1819e90d82e90a7e74b26360p-1L,
- 0x1.fd3c22b8f71f10975ba4b32bd006p-1L,
- 0x1.0000000000000000000000000000p+0L,
- 0x1.0163da9fb33356d84a66ae336e98p+0L,
- 0x1.02c9a3e778060ee6f7caca4f7a18p+0L,
- 0x1.04315e86e7f84bd738f9a20da442p+0L,
- 0x1.059b0d31585743ae7c548eb68c6ap+0L,
- 0x1.0706b29ddf6ddc6dc403a9d87b1ep+0L,
- 0x1.0874518759bc808c35f25d942856p+0L,
- 0x1.09e3ecac6f3834521e060c584d5cp+0L,
- 0x1.0b5586cf9890f6298b92b7184200p+0L,
- 0x1.0cc922b7247f7407b705b893dbdep+0L,
- 0x1.0e3ec32d3d1a2020742e4f8af794p+0L,
- 0x1.0fb66affed31af232091dd8a169ep+0L,
- 0x1.11301d0125b50a4ebbf1aed9321cp+0L,
- 0x1.12abdc06c31cbfb92bad324d6f84p+0L,
- 0x1.1429aaea92ddfb34101943b2588ep+0L,
- 0x1.15a98c8a58e512480d573dd562aep+0L,
- 0x1.172b83c7d517adcdf7c8c50eb162p+0L,
- 0x1.18af9388c8de9bbbf70b9a3c269cp+0L,
- 0x1.1a35beb6fcb753cb698f692d2038p+0L,
- 0x1.1bbe084045cd39ab1e72b442810ep+0L,
- 0x1.1d4873168b9aa7805b8028990be8p+0L,
- 0x1.1ed5022fcd91cb8819ff61121fbep+0L,
- 0x1.2063b88628cd63b8eeb0295093f6p+0L,
- 0x1.21f49917ddc962552fd29294bc20p+0L,
- 0x1.2387a6e75623866c1fadb1c159c0p+0L,
- 0x1.251ce4fb2a63f3582ab7de9e9562p+0L,
- 0x1.26b4565e27cdd257a673281d3068p+0L,
- 0x1.284dfe1f5638096cf15cf03c9fa0p+0L,
- 0x1.29e9df51fdee12c25d15f5a25022p+0L,
- 0x1.2b87fd0dad98ffddea46538fca24p+0L,
- 0x1.2d285a6e4030b40091d536d0733ep+0L,
- 0x1.2ecafa93e2f5611ca0f45d5239a4p+0L,
- 0x1.306fe0a31b7152de8d5a463063bep+0L,
- 0x1.32170fc4cd8313539cf1c3009330p+0L,
- 0x1.33c08b26416ff4c9c8610d96680ep+0L,
- 0x1.356c55f929ff0c94623476373be4p+0L,
- 0x1.371a7373aa9caa7145502f45452ap+0L,
- 0x1.38cae6d05d86585a9cb0d9bed530p+0L,
- 0x1.3a7db34e59ff6ea1bc9299e0a1fep+0L,
- 0x1.3c32dc313a8e484001f228b58cf0p+0L,
- 0x1.3dea64c12342235b41223e13d7eep+0L,
- 0x1.3fa4504ac801ba0bf701aa417b9cp+0L,
- 0x1.4160a21f72e29f84325b8f3dbacap+0L,
- 0x1.431f5d950a896dc704439410b628p+0L,
- 0x1.44e086061892d03136f409df0724p+0L,
- 0x1.46a41ed1d005772512f459229f0ap+0L,
- 0x1.486a2b5c13cd013c1a3b69062f26p+0L,
- 0x1.4a32af0d7d3de672d8bcf46f99b4p+0L,
- 0x1.4bfdad5362a271d4397afec42e36p+0L,
- 0x1.4dcb299fddd0d63b36ef1a9e19dep+0L,
- 0x1.4f9b2769d2ca6ad33d8b69aa0b8cp+0L,
- 0x1.516daa2cf6641c112f52c84d6066p+0L,
- 0x1.5342b569d4f81df0a83c49d86bf4p+0L,
- 0x1.551a4ca5d920ec52ec620243540cp+0L,
- 0x1.56f4736b527da66ecb004764e61ep+0L,
- 0x1.58d12d497c7fd252bc2b7343d554p+0L,
- 0x1.5ab07dd48542958c93015191e9a8p+0L,
- 0x1.5c9268a5946b701c4b1b81697ed4p+0L,
- 0x1.5e76f15ad21486e9be4c20399d12p+0L,
- 0x1.605e1b976dc08b076f592a487066p+0L,
- 0x1.6247eb03a5584b1f0fa06fd2d9eap+0L,
- 0x1.6434634ccc31fc76f8714c4ee122p+0L,
- 0x1.66238825522249127d9e29b92ea2p+0L,
- 0x1.68155d44ca973081c57227b9f69ep+0L,
-};
-
-static const float eps[TBLSIZE] = {
- -0x1.5c50p-101,
- -0x1.5d00p-106,
- 0x1.8e90p-102,
- -0x1.5340p-103,
- 0x1.1bd0p-102,
- -0x1.4600p-105,
- -0x1.7a40p-104,
- 0x1.d590p-102,
- -0x1.d590p-101,
- 0x1.b100p-103,
- -0x1.0d80p-105,
- 0x1.6b00p-103,
- -0x1.9f00p-105,
- 0x1.c400p-103,
- 0x1.e120p-103,
- -0x1.c100p-104,
- -0x1.9d20p-103,
- 0x1.a800p-108,
- 0x1.4c00p-106,
- -0x1.9500p-106,
- 0x1.6900p-105,
- -0x1.29d0p-100,
- 0x1.4c60p-103,
- 0x1.13a0p-102,
- -0x1.5b60p-103,
- -0x1.1c40p-103,
- 0x1.db80p-102,
- 0x1.91a0p-102,
- 0x1.dc00p-105,
- 0x1.44c0p-104,
- 0x1.9710p-102,
- 0x1.8760p-103,
- -0x1.a720p-103,
- 0x1.ed20p-103,
- -0x1.49c0p-102,
- -0x1.e000p-111,
- 0x1.86a0p-103,
- 0x1.2b40p-103,
- -0x1.b400p-108,
- 0x1.1280p-99,
- -0x1.02d8p-102,
- -0x1.e3d0p-103,
- -0x1.b080p-105,
- -0x1.f100p-107,
- -0x1.16c0p-105,
- -0x1.1190p-103,
- -0x1.a7d2p-100,
- 0x1.3450p-103,
- -0x1.67c0p-105,
- 0x1.4b80p-104,
- -0x1.c4e0p-103,
- 0x1.6000p-108,
- -0x1.3f60p-105,
- 0x1.93f0p-104,
- 0x1.5fe0p-105,
- 0x1.6f80p-107,
- -0x1.7600p-106,
- 0x1.21e0p-106,
- -0x1.3a40p-106,
- -0x1.40c0p-104,
- -0x1.9860p-105,
- -0x1.5d40p-108,
- -0x1.1d70p-106,
- 0x1.2760p-105,
- 0x0.0000p+0,
- 0x1.21e2p-104,
- -0x1.9520p-108,
- -0x1.5720p-106,
- -0x1.4810p-106,
- -0x1.be00p-109,
- 0x1.0080p-105,
- -0x1.5780p-108,
- -0x1.d460p-105,
- -0x1.6140p-105,
- 0x1.4630p-104,
- 0x1.ad50p-103,
- 0x1.82e0p-105,
- 0x1.1d3cp-101,
- 0x1.6100p-107,
- 0x1.ec30p-104,
- 0x1.f200p-108,
- 0x1.0b40p-103,
- 0x1.3660p-102,
- 0x1.d9d0p-103,
- -0x1.02d0p-102,
- 0x1.b070p-103,
- 0x1.b9c0p-104,
- -0x1.01c0p-103,
- -0x1.dfe0p-103,
- 0x1.1b60p-104,
- -0x1.ae94p-101,
- -0x1.3340p-104,
- 0x1.b3d8p-102,
- -0x1.6e40p-105,
- -0x1.3670p-103,
- 0x1.c140p-104,
- 0x1.1840p-101,
- 0x1.1ab0p-102,
- -0x1.a400p-104,
- 0x1.1f00p-104,
- -0x1.7180p-103,
- 0x1.4ce0p-102,
- 0x1.9200p-107,
- -0x1.54c0p-103,
- 0x1.1b80p-105,
- -0x1.1828p-101,
- 0x1.5720p-102,
- -0x1.a060p-100,
- 0x1.9160p-102,
- 0x1.a280p-104,
- 0x1.3400p-107,
- 0x1.2b20p-102,
- 0x1.7800p-108,
- 0x1.cfd0p-101,
- 0x1.2ef0p-102,
- -0x1.2760p-99,
- 0x1.b380p-104,
- 0x1.0048p-101,
- -0x1.60b0p-102,
- 0x1.a1ccp-100,
- -0x1.a640p-104,
- -0x1.08a0p-101,
- 0x1.7e60p-102,
- 0x1.22c0p-103,
- -0x1.7200p-106,
- 0x1.f0f0p-102,
- 0x1.eb4ep-99,
- 0x1.c6e0p-103,
-};
-
-/*
- * exp2l(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.502 ulp.
- *
- * Method: (accurate tables)
- *
- * Reduce x:
- * x = 2**k + y, for integer k and |y| <= 1/2.
- * Thus we have exp2(x) = 2**k * exp2(y).
- *
- * Reduce y:
- * y = i/TBLSIZE + z - eps[i] for integer i near y * TBLSIZE.
- * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z - eps[i]),
- * with |z - eps[i]| <= 2**-8 + 2**-98 for the table used.
- *
- * We compute exp2(i/TBLSIZE) via table lookup and exp2(z - eps[i]) via
- * a degree-10 minimax polynomial with maximum error under 2**-120.
- * The values in exp2t[] and eps[] are chosen such that
- * exp2t[i] = exp2(i/TBLSIZE + eps[i]), and eps[i] is a small offset such
- * that exp2t[i] is accurate to 2**-122.
- *
- * Note that the range of i is +-TBLSIZE/2, so we actually index the tables
- * by i0 = i + TBLSIZE/2.
- *
- * This method is due to Gal, with many details due to Gal and Bachelis:
- *
- * Gal, S. and Bachelis, B. An Accurate Elementary Mathematical Library
- * for the IEEE Floating Point Standard. TOMS 17(1), 26-46 (1991).
- */
-long double
-exp2l(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- long double r, z, t;
- uint32_t i0;
- union {uint32_t u; int32_t i;} k;
-
- /* Filter out exceptional cases. */
- if (e >= 0x3fff + 14) { /* |x| >= 16384 or x is NaN */
- if (u.i.se >= 0x3fff + 15 && u.i.se >> 15 == 0)
- /* overflow */
- return x * 0x1p16383L;
- if (e == 0x7fff) /* -inf or -nan */
- return -1/x;
- if (x < -16382) {
- if (x <= -16495 || x - 0x1p112 + 0x1p112 != x)
- /* underflow */
- FORCE_EVAL((float)(-0x1p-149/x));
- if (x <= -16446)
- return 0;
- }
- } else if (e < 0x3fff - 114) {
- return 1 + x;
- }
-
- /*
- * Reduce x, computing z, i0, and k. The low bits of x + redux
- * contain the 16-bit integer part of the exponent (k) followed by
- * TBLBITS fractional bits (i0). We use bit tricks to extract these
- * as integers, then set z to the remainder.
- *
- * Example: Suppose x is 0xabc.123456p0 and TBLBITS is 8.
- * Then the low-order word of x + redux is 0x000abc12,
- * We split this into k = 0xabc and i0 = 0x12 (adjusted to
- * index into the table), then we compute z = 0x0.003456p0.
- */
- u.f = x + redux;
- i0 = u.i2.lo + TBLSIZE / 2;
- k.u = i0 / TBLSIZE * TBLSIZE;
- k.i /= TBLSIZE;
- i0 %= TBLSIZE;
- u.f -= redux;
- z = x - u.f;
-
- /* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
- t = tbl[i0];
- z -= eps[i0];
- r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * (P5 + z * (P6
- + z * (P7 + z * (P8 + z * (P9 + z * P10)))))))));
-
- return scalbnl(r, k.i);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/expf.c b/lib/mlibc/options/ansi/musl-generic-math/expf.c
deleted file mode 100644
index feee2b0..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/expf.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_expf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float
-half[2] = {0.5,-0.5},
-ln2hi = 6.9314575195e-1f, /* 0x3f317200 */
-ln2lo = 1.4286067653e-6f, /* 0x35bfbe8e */
-invln2 = 1.4426950216e+0f, /* 0x3fb8aa3b */
-/*
- * Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]:
- * |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74
- */
-P1 = 1.6666625440e-1f, /* 0xaaaa8f.0p-26 */
-P2 = -2.7667332906e-3f; /* -0xb55215.0p-32 */
-
-float expf(float x)
-{
- float_t hi, lo, c, xx, y;
- int k, sign;
- uint32_t hx;
-
- GET_FLOAT_WORD(hx, x);
- sign = hx >> 31; /* sign bit of x */
- hx &= 0x7fffffff; /* high word of |x| */
-
- /* special cases */
- if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */
- if (hx > 0x7f800000) /* NaN */
- return x;
- if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */
- /* overflow */
- x *= 0x1p127f;
- return x;
- }
- if (sign) {
- /* underflow */
- FORCE_EVAL(-0x1p-149f/x);
- if (hx >= 0x42cff1b5) /* x <= -103.972084f */
- return 0;
- }
- }
-
- /* argument reduction */
- if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */
- if (hx > 0x3f851592) /* if |x| > 1.5 ln2 */
- k = invln2*x + half[sign];
- else
- k = 1 - sign - sign;
- hi = x - k*ln2hi; /* k*ln2hi is exact here */
- lo = k*ln2lo;
- x = hi - lo;
- } else if (hx > 0x39000000) { /* |x| > 2**-14 */
- k = 0;
- hi = x;
- lo = 0;
- } else {
- /* raise inexact */
- FORCE_EVAL(0x1p127f + x);
- return 1 + x;
- }
-
- /* x is now in primary range */
- xx = x*x;
- c = x - xx*(P1+xx*P2);
- y = 1 + (x*c/(2-c) - lo + hi);
- if (k == 0)
- return y;
- return scalbnf(y, k);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/expl.c b/lib/mlibc/options/ansi/musl-generic-math/expl.c
deleted file mode 100644
index 0a7f44f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/expl.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_expl.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Exponential function, long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, expl();
- *
- * y = expl( x );
- *
- *
- * DESCRIPTION:
- *
- * Returns e (2.71828...) raised to the x power.
- *
- * Range reduction is accomplished by separating the argument
- * into an integer k and fraction f such that
- *
- * x k f
- * e = 2 e.
- *
- * A Pade' form of degree 5/6 is used to approximate exp(f) - 1
- * in the basic range [-0.5 ln 2, 0.5 ln 2].
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- * IEEE +-10000 50000 1.12e-19 2.81e-20
- *
- *
- * Error amplification in the exponential function can be
- * a serious matter. The error propagation involves
- * exp( X(1+delta) ) = exp(X) ( 1 + X*delta + ... ),
- * which shows that a 1 lsb error in representing X produces
- * a relative error of X times 1 lsb in the function.
- * While the routine gives an accurate result for arguments
- * that are exactly represented by a long double precision
- * computer number, the result contains amplified roundoff
- * error for large arguments not exactly represented.
- *
- *
- * ERROR MESSAGES:
- *
- * message condition value returned
- * exp underflow x < MINLOG 0.0
- * exp overflow x > MAXLOG MAXNUM
- *
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double expl(long double x)
-{
- return exp(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-
-static const long double P[3] = {
- 1.2617719307481059087798E-4L,
- 3.0299440770744196129956E-2L,
- 9.9999999999999999991025E-1L,
-};
-static const long double Q[4] = {
- 3.0019850513866445504159E-6L,
- 2.5244834034968410419224E-3L,
- 2.2726554820815502876593E-1L,
- 2.0000000000000000000897E0L,
-};
-static const long double
-LN2HI = 6.9314575195312500000000E-1L,
-LN2LO = 1.4286068203094172321215E-6L,
-LOG2E = 1.4426950408889634073599E0L;
-
-long double expl(long double x)
-{
- long double px, xx;
- int k;
-
- if (isnan(x))
- return x;
- if (x > 11356.5234062941439488L) /* x > ln(2^16384 - 0.5) */
- return x * 0x1p16383L;
- if (x < -11399.4985314888605581L) /* x < ln(2^-16446) */
- return -0x1p-16445L/x;
-
- /* Express e**x = e**f 2**k
- * = e**(f + k ln(2))
- */
- px = floorl(LOG2E * x + 0.5);
- k = px;
- x -= px * LN2HI;
- x -= px * LN2LO;
-
- /* rational approximation of the fractional part:
- * e**x = 1 + 2x P(x**2)/(Q(x**2) - x P(x**2))
- */
- xx = x * x;
- px = x * __polevll(xx, P, 2);
- x = px/(__polevll(xx, Q, 3) - px);
- x = 1.0 + 2.0 * x;
- return scalbnl(x, k);
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double expl(long double x)
-{
- return exp(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/expm1.c b/lib/mlibc/options/ansi/musl-generic-math/expm1.c
deleted file mode 100644
index ac1e61e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/expm1.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_expm1.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* expm1(x)
- * Returns exp(x)-1, the exponential of x minus 1.
- *
- * Method
- * 1. Argument reduction:
- * Given x, find r and integer k such that
- *
- * x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658
- *
- * Here a correction term c will be computed to compensate
- * the error in r when rounded to a floating-point number.
- *
- * 2. Approximating expm1(r) by a special rational function on
- * the interval [0,0.34658]:
- * Since
- * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ...
- * we define R1(r*r) by
- * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r)
- * That is,
- * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
- * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
- * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
- * We use a special Remez algorithm on [0,0.347] to generate
- * a polynomial of degree 5 in r*r to approximate R1. The
- * maximum error of this polynomial approximation is bounded
- * by 2**-61. In other words,
- * R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
- * where Q1 = -1.6666666666666567384E-2,
- * Q2 = 3.9682539681370365873E-4,
- * Q3 = -9.9206344733435987357E-6,
- * Q4 = 2.5051361420808517002E-7,
- * Q5 = -6.2843505682382617102E-9;
- * z = r*r,
- * with error bounded by
- * | 5 | -61
- * | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2
- * | |
- *
- * expm1(r) = exp(r)-1 is then computed by the following
- * specific way which minimize the accumulation rounding error:
- * 2 3
- * r r [ 3 - (R1 + R1*r/2) ]
- * expm1(r) = r + --- + --- * [--------------------]
- * 2 2 [ 6 - r*(3 - R1*r/2) ]
- *
- * To compensate the error in the argument reduction, we use
- * expm1(r+c) = expm1(r) + c + expm1(r)*c
- * ~ expm1(r) + c + r*c
- * Thus c+r*c will be added in as the correction terms for
- * expm1(r+c). Now rearrange the term to avoid optimization
- * screw up:
- * ( 2 2 )
- * ({ ( r [ R1 - (3 - R1*r/2) ] ) } r )
- * expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
- * ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 )
- * ( )
- *
- * = r - E
- * 3. Scale back to obtain expm1(x):
- * From step 1, we have
- * expm1(x) = either 2^k*[expm1(r)+1] - 1
- * = or 2^k*[expm1(r) + (1-2^-k)]
- * 4. Implementation notes:
- * (A). To save one multiplication, we scale the coefficient Qi
- * to Qi*2^i, and replace z by (x^2)/2.
- * (B). To achieve maximum accuracy, we compute expm1(x) by
- * (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
- * (ii) if k=0, return r-E
- * (iii) if k=-1, return 0.5*(r-E)-0.5
- * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E)
- * else return 1.0+2.0*(r-E);
- * (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
- * (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else
- * (vii) return 2^k(1-((E+2^-k)-r))
- *
- * Special cases:
- * expm1(INF) is INF, expm1(NaN) is NaN;
- * expm1(-INF) is -1, and
- * for finite argument, only expm1(0)=0 is exact.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Misc. info.
- * For IEEE double
- * if x > 7.09782712893383973096e+02 then expm1(x) overflow
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "libm.h"
-
-static const double
-o_threshold = 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
-ln2_hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
-ln2_lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */
-invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
-/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */
-Q1 = -3.33333333333331316428e-02, /* BFA11111 111110F4 */
-Q2 = 1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */
-Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
-Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
-Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
-
-double expm1(double x)
-{
- double_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
- union {double f; uint64_t i;} u = {x};
- uint32_t hx = u.i>>32 & 0x7fffffff;
- int k, sign = u.i>>63;
-
- /* filter out huge and non-finite argument */
- if (hx >= 0x4043687A) { /* if |x|>=56*ln2 */
- if (isnan(x))
- return x;
- if (sign)
- return -1;
- if (x > o_threshold) {
- x *= 0x1p1023;
- return x;
- }
- }
-
- /* argument reduction */
- if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
- if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
- if (!sign) {
- hi = x - ln2_hi;
- lo = ln2_lo;
- k = 1;
- } else {
- hi = x + ln2_hi;
- lo = -ln2_lo;
- k = -1;
- }
- } else {
- k = invln2*x + (sign ? -0.5 : 0.5);
- t = k;
- hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
- lo = t*ln2_lo;
- }
- x = hi-lo;
- c = (hi-x)-lo;
- } else if (hx < 0x3c900000) { /* |x| < 2**-54, return x */
- if (hx < 0x00100000)
- FORCE_EVAL((float)x);
- return x;
- } else
- k = 0;
-
- /* x is now in primary range */
- hfx = 0.5*x;
- hxs = x*hfx;
- r1 = 1.0+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
- t = 3.0-r1*hfx;
- e = hxs*((r1-t)/(6.0 - x*t));
- if (k == 0) /* c is 0 */
- return x - (x*e-hxs);
- e = x*(e-c) - c;
- e -= hxs;
- /* exp(x) ~ 2^k (x_reduced - e + 1) */
- if (k == -1)
- return 0.5*(x-e) - 0.5;
- if (k == 1) {
- if (x < -0.25)
- return -2.0*(e-(x+0.5));
- return 1.0+2.0*(x-e);
- }
- u.i = (uint64_t)(0x3ff + k)<<52; /* 2^k */
- twopk = u.f;
- if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */
- y = x - e + 1.0;
- if (k == 1024)
- y = y*2.0*0x1p1023;
- else
- y = y*twopk;
- return y - 1.0;
- }
- u.i = (uint64_t)(0x3ff - k)<<52; /* 2^-k */
- if (k < 20)
- y = (x-e+(1-u.f))*twopk;
- else
- y = (x-(e+u.f)+1)*twopk;
- return y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/expm1f.c b/lib/mlibc/options/ansi/musl-generic-math/expm1f.c
deleted file mode 100644
index 297e0b4..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/expm1f.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_expm1f.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float
-o_threshold = 8.8721679688e+01, /* 0x42b17180 */
-ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
-ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
-invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
-/*
- * Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]:
- * |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04
- * Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c):
- */
-Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */
-Q2 = 1.5807170421e-3; /* 0xcf3010.0p-33 */
-
-float expm1f(float x)
-{
- float_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
- union {float f; uint32_t i;} u = {x};
- uint32_t hx = u.i & 0x7fffffff;
- int k, sign = u.i >> 31;
-
- /* filter out huge and non-finite argument */
- if (hx >= 0x4195b844) { /* if |x|>=27*ln2 */
- if (hx > 0x7f800000) /* NaN */
- return x;
- if (sign)
- return -1;
- if (x > o_threshold) {
- x *= 0x1p127f;
- return x;
- }
- }
-
- /* argument reduction */
- if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */
- if (hx < 0x3F851592) { /* and |x| < 1.5 ln2 */
- if (!sign) {
- hi = x - ln2_hi;
- lo = ln2_lo;
- k = 1;
- } else {
- hi = x + ln2_hi;
- lo = -ln2_lo;
- k = -1;
- }
- } else {
- k = invln2*x + (sign ? -0.5f : 0.5f);
- t = k;
- hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
- lo = t*ln2_lo;
- }
- x = hi-lo;
- c = (hi-x)-lo;
- } else if (hx < 0x33000000) { /* when |x|<2**-25, return x */
- if (hx < 0x00800000)
- FORCE_EVAL(x*x);
- return x;
- } else
- k = 0;
-
- /* x is now in primary range */
- hfx = 0.5f*x;
- hxs = x*hfx;
- r1 = 1.0f+hxs*(Q1+hxs*Q2);
- t = 3.0f - r1*hfx;
- e = hxs*((r1-t)/(6.0f - x*t));
- if (k == 0) /* c is 0 */
- return x - (x*e-hxs);
- e = x*(e-c) - c;
- e -= hxs;
- /* exp(x) ~ 2^k (x_reduced - e + 1) */
- if (k == -1)
- return 0.5f*(x-e) - 0.5f;
- if (k == 1) {
- if (x < -0.25f)
- return -2.0f*(e-(x+0.5f));
- return 1.0f + 2.0f*(x-e);
- }
- u.i = (0x7f+k)<<23; /* 2^k */
- twopk = u.f;
- if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */
- y = x - e + 1.0f;
- if (k == 128)
- y = y*2.0f*0x1p127f;
- else
- y = y*twopk;
- return y - 1.0f;
- }
- u.i = (0x7f-k)<<23; /* 2^-k */
- if (k < 23)
- y = (x-e+(1-u.f))*twopk;
- else
- y = (x-(e+u.f)+1)*twopk;
- return y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/expm1l.c b/lib/mlibc/options/ansi/musl-generic-math/expm1l.c
deleted file mode 100644
index d171507..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/expm1l.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_expm1l.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Exponential function, minus 1
- * Long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, expm1l();
- *
- * y = expm1l( x );
- *
- *
- * DESCRIPTION:
- *
- * Returns e (2.71828...) raised to the x power, minus 1.
- *
- * Range reduction is accomplished by separating the argument
- * into an integer k and fraction f such that
- *
- * x k f
- * e = 2 e.
- *
- * An expansion x + .5 x^2 + x^3 R(x) approximates exp(f) - 1
- * in the basic range [-0.5 ln 2, 0.5 ln 2].
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- * IEEE -45,+maxarg 200,000 1.2e-19 2.5e-20
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double expm1l(long double x)
-{
- return expm1(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-
-/* exp(x) - 1 = x + 0.5 x^2 + x^3 P(x)/Q(x)
- -.5 ln 2 < x < .5 ln 2
- Theoretical peak relative error = 3.4e-22 */
-static const long double
-P0 = -1.586135578666346600772998894928250240826E4L,
-P1 = 2.642771505685952966904660652518429479531E3L,
-P2 = -3.423199068835684263987132888286791620673E2L,
-P3 = 1.800826371455042224581246202420972737840E1L,
-P4 = -5.238523121205561042771939008061958820811E-1L,
-Q0 = -9.516813471998079611319047060563358064497E4L,
-Q1 = 3.964866271411091674556850458227710004570E4L,
-Q2 = -7.207678383830091850230366618190187434796E3L,
-Q3 = 7.206038318724600171970199625081491823079E2L,
-Q4 = -4.002027679107076077238836622982900945173E1L,
-/* Q5 = 1.000000000000000000000000000000000000000E0 */
-/* C1 + C2 = ln 2 */
-C1 = 6.93145751953125E-1L,
-C2 = 1.428606820309417232121458176568075500134E-6L,
-/* ln 2^-65 */
-minarg = -4.5054566736396445112120088E1L,
-/* ln 2^16384 */
-maxarg = 1.1356523406294143949492E4L;
-
-long double expm1l(long double x)
-{
- long double px, qx, xx;
- int k;
-
- if (isnan(x))
- return x;
- if (x > maxarg)
- return x*0x1p16383L; /* overflow, unless x==inf */
- if (x == 0.0)
- return x;
- if (x < minarg)
- return -1.0;
-
- xx = C1 + C2;
- /* Express x = ln 2 (k + remainder), remainder not exceeding 1/2. */
- px = floorl(0.5 + x / xx);
- k = px;
- /* remainder times ln 2 */
- x -= px * C1;
- x -= px * C2;
-
- /* Approximate exp(remainder ln 2).*/
- px = (((( P4 * x + P3) * x + P2) * x + P1) * x + P0) * x;
- qx = (((( x + Q4) * x + Q3) * x + Q2) * x + Q1) * x + Q0;
- xx = x * x;
- qx = x + (0.5 * xx + xx * px / qx);
-
- /* exp(x) = exp(k ln 2) exp(remainder ln 2) = 2^k exp(remainder ln 2).
- We have qx = exp(remainder ln 2) - 1, so
- exp(x) - 1 = 2^k (qx + 1) - 1 = 2^k qx + 2^k - 1. */
- px = scalbnl(1.0, k);
- x = px * qx + (px - 1.0);
- return x;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double expm1l(long double x)
-{
- return expm1(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fabs.c b/lib/mlibc/options/ansi/musl-generic-math/fabs.c
deleted file mode 100644
index e8258cf..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fabs.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-double fabs(double x)
-{
- union {double f; uint64_t i;} u = {x};
- u.i &= -1ULL/2;
- return u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fabsf.c b/lib/mlibc/options/ansi/musl-generic-math/fabsf.c
deleted file mode 100644
index 4efc8d6..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fabsf.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float fabsf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- u.i &= 0x7fffffff;
- return u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fabsl.c b/lib/mlibc/options/ansi/musl-generic-math/fabsl.c
deleted file mode 100644
index c4f36ec..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fabsl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "libm.h"
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double fabsl(long double x)
-{
- return fabs(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double fabsl(long double x)
-{
- union ldshape u = {x};
-
- u.i.se &= 0x7fff;
- return u.f;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fdim.c b/lib/mlibc/options/ansi/musl-generic-math/fdim.c
deleted file mode 100644
index 9585460..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fdim.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-double fdim(double x, double y)
-{
- if (isnan(x))
- return x;
- if (isnan(y))
- return y;
- return x > y ? x - y : 0;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fdimf.c b/lib/mlibc/options/ansi/musl-generic-math/fdimf.c
deleted file mode 100644
index 543c364..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fdimf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-float fdimf(float x, float y)
-{
- if (isnan(x))
- return x;
- if (isnan(y))
- return y;
- return x > y ? x - y : 0;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fdiml.c b/lib/mlibc/options/ansi/musl-generic-math/fdiml.c
deleted file mode 100644
index 62e29b7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fdiml.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <math.h>
-#include <float.h>
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double fdiml(long double x, long double y)
-{
- return fdim(x, y);
-}
-#else
-long double fdiml(long double x, long double y)
-{
- if (isnan(x))
- return x;
- if (isnan(y))
- return y;
- return x > y ? x - y : 0;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/finite.c b/lib/mlibc/options/ansi/musl-generic-math/finite.c
deleted file mode 100644
index 25a0575..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/finite.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#define _GNU_SOURCE
-#include <math.h>
-
-int finite(double x)
-{
- return isfinite(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/finitef.c b/lib/mlibc/options/ansi/musl-generic-math/finitef.c
deleted file mode 100644
index 2c4c771..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/finitef.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#define _GNU_SOURCE
-#include <math.h>
-
-int finitef(float x)
-{
- return isfinite(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/floor.c b/lib/mlibc/options/ansi/musl-generic-math/floor.c
deleted file mode 100644
index 14a31cd..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/floor.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double floor(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i >> 52 & 0x7ff;
- double_t y;
-
- if (e >= 0x3ff+52 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i >> 63)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3ff-1) {
- FORCE_EVAL(y);
- return u.i >> 63 ? -1 : 0;
- }
- if (y > 0)
- return x + y - 1;
- return x + y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/floorf.c b/lib/mlibc/options/ansi/musl-generic-math/floorf.c
deleted file mode 100644
index dceec73..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/floorf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "libm.h"
-
-float floorf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = (int)(u.i >> 23 & 0xff) - 0x7f;
- uint32_t m;
-
- if (e >= 23)
- return x;
- if (e >= 0) {
- m = 0x007fffff >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31)
- u.i += m;
- u.i &= ~m;
- } else {
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31 == 0)
- u.i = 0;
- else if (u.i << 1)
- u.f = -1.0;
- }
- return u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/floorl.c b/lib/mlibc/options/ansi/musl-generic-math/floorl.c
deleted file mode 100644
index 16aaec4..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/floorl.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double floorl(long double x)
-{
- return floor(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-static const long double toint = 1/LDBL_EPSILON;
-
-long double floorl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- long double y;
-
- if (e >= 0x3fff+LDBL_MANT_DIG-1 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i.se >> 15)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3fff-1) {
- FORCE_EVAL(y);
- return u.i.se >> 15 ? -1 : 0;
- }
- if (y > 0)
- return x + y - 1;
- return x + y;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fma.c b/lib/mlibc/options/ansi/musl-generic-math/fma.c
deleted file mode 100644
index f65eab7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fma.c
+++ /dev/null
@@ -1,194 +0,0 @@
-#include <stdint.h>
-#include <float.h>
-#include <math.h>
-
-static inline int a_clz_64(uint64_t x)
-{
- uint32_t y;
- int r;
- if (x>>32) y=x>>32, r=0; else y=x, r=32;
- if (y>>16) y>>=16; else r |= 16;
- if (y>>8) y>>=8; else r |= 8;
- if (y>>4) y>>=4; else r |= 4;
- if (y>>2) y>>=2; else r |= 2;
- return r | !(y>>1);
-}
-
-#define ASUINT64(x) ((union {double f; uint64_t i;}){x}).i
-#define ZEROINFNAN (0x7ff-0x3ff-52-1)
-
-struct num { uint64_t m; int e; int sign; };
-
-static struct num normalize(double x)
-{
- uint64_t ix = ASUINT64(x);
- int e = ix>>52;
- int sign = e & 0x800;
- e &= 0x7ff;
- if (!e) {
- ix = ASUINT64(x*0x1p63);
- e = ix>>52 & 0x7ff;
- e = e ? e-63 : 0x800;
- }
- ix &= (1ull<<52)-1;
- ix |= 1ull<<52;
- ix <<= 1;
- e -= 0x3ff + 52 + 1;
- return (struct num){ix,e,sign};
-}
-
-static void mul(uint64_t *hi, uint64_t *lo, uint64_t x, uint64_t y)
-{
- uint64_t t1,t2,t3;
- uint64_t xlo = (uint32_t)x, xhi = x>>32;
- uint64_t ylo = (uint32_t)y, yhi = y>>32;
-
- t1 = xlo*ylo;
- t2 = xlo*yhi + xhi*ylo;
- t3 = xhi*yhi;
- *lo = t1 + (t2<<32);
- *hi = t3 + (t2>>32) + (t1 > *lo);
-}
-
-double fma(double x, double y, double z)
-{
- #pragma STDC FENV_ACCESS ON
-
- /* normalize so top 10bits and last bit are 0 */
- struct num nx, ny, nz;
- nx = normalize(x);
- ny = normalize(y);
- nz = normalize(z);
-
- if (nx.e >= ZEROINFNAN || ny.e >= ZEROINFNAN)
- return x*y + z;
- if (nz.e >= ZEROINFNAN) {
- if (nz.e > ZEROINFNAN) /* z==0 */
- return x*y + z;
- return z;
- }
-
- /* mul: r = x*y */
- uint64_t rhi, rlo, zhi, zlo;
- mul(&rhi, &rlo, nx.m, ny.m);
- /* either top 20 or 21 bits of rhi and last 2 bits of rlo are 0 */
-
- /* align exponents */
- int e = nx.e + ny.e;
- int d = nz.e - e;
- /* shift bits z<<=kz, r>>=kr, so kz+kr == d, set e = e+kr (== ez-kz) */
- if (d > 0) {
- if (d < 64) {
- zlo = nz.m<<d;
- zhi = nz.m>>64-d;
- } else {
- zlo = 0;
- zhi = nz.m;
- e = nz.e - 64;
- d -= 64;
- if (d == 0) {
- } else if (d < 64) {
- rlo = rhi<<64-d | rlo>>d | !!(rlo<<64-d);
- rhi = rhi>>d;
- } else {
- rlo = 1;
- rhi = 0;
- }
- }
- } else {
- zhi = 0;
- d = -d;
- if (d == 0) {
- zlo = nz.m;
- } else if (d < 64) {
- zlo = nz.m>>d | !!(nz.m<<64-d);
- } else {
- zlo = 1;
- }
- }
-
- /* add */
- int sign = nx.sign^ny.sign;
- int samesign = !(sign^nz.sign);
- int nonzero = 1;
- if (samesign) {
- /* r += z */
- rlo += zlo;
- rhi += zhi + (rlo < zlo);
- } else {
- /* r -= z */
- uint64_t t = rlo;
- rlo -= zlo;
- rhi = rhi - zhi - (t < rlo);
- if (rhi>>63) {
- rlo = -rlo;
- rhi = -rhi-!!rlo;
- sign = !sign;
- }
- nonzero = !!rhi;
- }
-
- /* set rhi to top 63bit of the result (last bit is sticky) */
- if (nonzero) {
- e += 64;
- d = a_clz_64(rhi)-1;
- /* note: d > 0 */
- rhi = rhi<<d | rlo>>64-d | !!(rlo<<d);
- } else if (rlo) {
- d = a_clz_64(rlo)-1;
- if (d < 0)
- rhi = rlo>>1 | (rlo&1);
- else
- rhi = rlo<<d;
- } else {
- /* exact +-0 */
- return x*y + z;
- }
- e -= d;
-
- /* convert to double */
- int64_t i = rhi; /* i is in [1<<62,(1<<63)-1] */
- if (sign)
- i = -i;
- double r = i; /* |r| is in [0x1p62,0x1p63] */
-
- if (e < -1022-62) {
- /* result is subnormal before rounding */
- if (e == -1022-63) {
- double c = 0x1p63;
- if (sign)
- c = -c;
- if (r == c) {
- /* min normal after rounding, underflow depends
- on arch behaviour which can be imitated by
- a double to float conversion */
- float fltmin = 0x0.ffffff8p-63*FLT_MIN * r;
- return DBL_MIN/FLT_MIN * fltmin;
- }
- /* one bit is lost when scaled, add another top bit to
- only round once at conversion if it is inexact */
- if (rhi << 53) {
- i = rhi>>1 | (rhi&1) | 1ull<<62;
- if (sign)
- i = -i;
- r = i;
- r = 2*r - c; /* remove top bit */
-
- /* raise underflow portably, such that it
- cannot be optimized away */
- {
- double_t tiny = DBL_MIN/FLT_MIN * r;
- r += (double)(tiny*tiny) * (r-r);
- }
- }
- } else {
- /* only round once when scaled */
- d = 10;
- i = ( rhi>>d | !!(rhi<<64-d) ) << d;
- if (sign)
- i = -i;
- r = i;
- }
- }
- return scalbn(r, e);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmaf.c b/lib/mlibc/options/ansi/musl-generic-math/fmaf.c
deleted file mode 100644
index aa57feb..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmaf.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_fmaf.c */
-/*-
- * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <fenv.h>
-#include <math.h>
-#include <stdint.h>
-
-/*
- * Fused multiply-add: Compute x * y + z with a single rounding error.
- *
- * A double has more than twice as much precision than a float, so
- * direct double-precision arithmetic suffices, except where double
- * rounding occurs.
- */
-float fmaf(float x, float y, float z)
-{
- #pragma STDC FENV_ACCESS ON
- double xy, result;
- union {double f; uint64_t i;} u;
- int e;
-
- xy = (double)x * y;
- result = xy + z;
- u.f = result;
- e = u.i>>52 & 0x7ff;
- /* Common case: The double precision result is fine. */
- if ((u.i & 0x1fffffff) != 0x10000000 || /* not a halfway case */
- e == 0x7ff || /* NaN */
- result - xy == z || /* exact */
- fegetround() != FE_TONEAREST) /* not round-to-nearest */
- {
- /*
- underflow may not be raised correctly, example:
- fmaf(0x1p-120f, 0x1p-120f, 0x1p-149f)
- */
-#if defined(FE_INEXACT) && defined(FE_UNDERFLOW)
- if (e < 0x3ff-126 && e >= 0x3ff-149 && fetestexcept(FE_INEXACT)) {
- feclearexcept(FE_INEXACT);
- /* TODO: gcc and clang bug workaround */
- volatile float vz = z;
- result = xy + vz;
- if (fetestexcept(FE_INEXACT))
- feraiseexcept(FE_UNDERFLOW);
- else
- feraiseexcept(FE_INEXACT);
- }
-#endif
- z = result;
- return z;
- }
-
- /*
- * If result is inexact, and exactly halfway between two float values,
- * we need to adjust the low-order bit in the direction of the error.
- */
-#ifdef FE_TOWARDZERO
- fesetround(FE_TOWARDZERO);
-#endif
- volatile double vxy = xy; /* XXX work around gcc CSE bug */
- double adjusted_result = vxy + z;
- fesetround(FE_TONEAREST);
- if (result == adjusted_result) {
- u.f = adjusted_result;
- u.i++;
- adjusted_result = u.f;
- }
- z = adjusted_result;
- return z;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmal.c b/lib/mlibc/options/ansi/musl-generic-math/fmal.c
deleted file mode 100644
index 4506aac..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmal.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_fmal.c */
-/*-
- * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-#include "libm.h"
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double fmal(long double x, long double y, long double z)
-{
- return fma(x, y, z);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include <fenv.h>
-#if LDBL_MANT_DIG == 64
-#define LASTBIT(u) (u.i.m & 1)
-#define SPLIT (0x1p32L + 1)
-#elif LDBL_MANT_DIG == 113
-#define LASTBIT(u) (u.i.lo & 1)
-#define SPLIT (0x1p57L + 1)
-#endif
-
-/*
- * A struct dd represents a floating-point number with twice the precision
- * of a long double. We maintain the invariant that "hi" stores the high-order
- * bits of the result.
- */
-struct dd {
- long double hi;
- long double lo;
-};
-
-/*
- * Compute a+b exactly, returning the exact result in a struct dd. We assume
- * that both a and b are finite, but make no assumptions about their relative
- * magnitudes.
- */
-static inline struct dd dd_add(long double a, long double b)
-{
- struct dd ret;
- long double s;
-
- ret.hi = a + b;
- s = ret.hi - a;
- ret.lo = (a - (ret.hi - s)) + (b - s);
- return (ret);
-}
-
-/*
- * Compute a+b, with a small tweak: The least significant bit of the
- * result is adjusted into a sticky bit summarizing all the bits that
- * were lost to rounding. This adjustment negates the effects of double
- * rounding when the result is added to another number with a higher
- * exponent. For an explanation of round and sticky bits, see any reference
- * on FPU design, e.g.,
- *
- * J. Coonen. An Implementation Guide to a Proposed Standard for
- * Floating-Point Arithmetic. Computer, vol. 13, no. 1, Jan 1980.
- */
-static inline long double add_adjusted(long double a, long double b)
-{
- struct dd sum;
- union ldshape u;
-
- sum = dd_add(a, b);
- if (sum.lo != 0) {
- u.f = sum.hi;
- if (!LASTBIT(u))
- sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
- }
- return (sum.hi);
-}
-
-/*
- * Compute ldexp(a+b, scale) with a single rounding error. It is assumed
- * that the result will be subnormal, and care is taken to ensure that
- * double rounding does not occur.
- */
-static inline long double add_and_denormalize(long double a, long double b, int scale)
-{
- struct dd sum;
- int bits_lost;
- union ldshape u;
-
- sum = dd_add(a, b);
-
- /*
- * If we are losing at least two bits of accuracy to denormalization,
- * then the first lost bit becomes a round bit, and we adjust the
- * lowest bit of sum.hi to make it a sticky bit summarizing all the
- * bits in sum.lo. With the sticky bit adjusted, the hardware will
- * break any ties in the correct direction.
- *
- * If we are losing only one bit to denormalization, however, we must
- * break the ties manually.
- */
- if (sum.lo != 0) {
- u.f = sum.hi;
- bits_lost = -u.i.se - scale + 1;
- if ((bits_lost != 1) ^ LASTBIT(u))
- sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
- }
- return scalbnl(sum.hi, scale);
-}
-
-/*
- * Compute a*b exactly, returning the exact result in a struct dd. We assume
- * that both a and b are normalized, so no underflow or overflow will occur.
- * The current rounding mode must be round-to-nearest.
- */
-static inline struct dd dd_mul(long double a, long double b)
-{
- struct dd ret;
- long double ha, hb, la, lb, p, q;
-
- p = a * SPLIT;
- ha = a - p;
- ha += p;
- la = a - ha;
-
- p = b * SPLIT;
- hb = b - p;
- hb += p;
- lb = b - hb;
-
- p = ha * hb;
- q = ha * lb + la * hb;
-
- ret.hi = p + q;
- ret.lo = p - ret.hi + q + la * lb;
- return (ret);
-}
-
-/*
- * Fused multiply-add: Compute x * y + z with a single rounding error.
- *
- * We use scaling to avoid overflow/underflow, along with the
- * canonical precision-doubling technique adapted from:
- *
- * Dekker, T. A Floating-Point Technique for Extending the
- * Available Precision. Numer. Math. 18, 224-242 (1971).
- */
-long double fmal(long double x, long double y, long double z)
-{
- #pragma STDC FENV_ACCESS ON
- long double xs, ys, zs, adj;
- struct dd xy, r;
- int oround;
- int ex, ey, ez;
- int spread;
-
- /*
- * Handle special cases. The order of operations and the particular
- * return values here are crucial in handling special cases involving
- * infinities, NaNs, overflows, and signed zeroes correctly.
- */
- if (!isfinite(x) || !isfinite(y))
- return (x * y + z);
- if (!isfinite(z))
- return (z);
- if (x == 0.0 || y == 0.0)
- return (x * y + z);
- if (z == 0.0)
- return (x * y);
-
- xs = frexpl(x, &ex);
- ys = frexpl(y, &ey);
- zs = frexpl(z, &ez);
- oround = fegetround();
- spread = ex + ey - ez;
-
- /*
- * If x * y and z are many orders of magnitude apart, the scaling
- * will overflow, so we handle these cases specially. Rounding
- * modes other than FE_TONEAREST are painful.
- */
- if (spread < -LDBL_MANT_DIG) {
-#ifdef FE_INEXACT
- feraiseexcept(FE_INEXACT);
-#endif
-#ifdef FE_UNDERFLOW
- if (!isnormal(z))
- feraiseexcept(FE_UNDERFLOW);
-#endif
- switch (oround) {
- default: /* FE_TONEAREST */
- return (z);
-#ifdef FE_TOWARDZERO
- case FE_TOWARDZERO:
- if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
- return (z);
- else
- return (nextafterl(z, 0));
-#endif
-#ifdef FE_DOWNWARD
- case FE_DOWNWARD:
- if (x > 0.0 ^ y < 0.0)
- return (z);
- else
- return (nextafterl(z, -INFINITY));
-#endif
-#ifdef FE_UPWARD
- case FE_UPWARD:
- if (x > 0.0 ^ y < 0.0)
- return (nextafterl(z, INFINITY));
- else
- return (z);
-#endif
- }
- }
- if (spread <= LDBL_MANT_DIG * 2)
- zs = scalbnl(zs, -spread);
- else
- zs = copysignl(LDBL_MIN, zs);
-
- fesetround(FE_TONEAREST);
-
- /*
- * Basic approach for round-to-nearest:
- *
- * (xy.hi, xy.lo) = x * y (exact)
- * (r.hi, r.lo) = xy.hi + z (exact)
- * adj = xy.lo + r.lo (inexact; low bit is sticky)
- * result = r.hi + adj (correctly rounded)
- */
- xy = dd_mul(xs, ys);
- r = dd_add(xy.hi, zs);
-
- spread = ex + ey;
-
- if (r.hi == 0.0) {
- /*
- * When the addends cancel to 0, ensure that the result has
- * the correct sign.
- */
- fesetround(oround);
- volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
- return xy.hi + vzs + scalbnl(xy.lo, spread);
- }
-
- if (oround != FE_TONEAREST) {
- /*
- * There is no need to worry about double rounding in directed
- * rounding modes.
- * But underflow may not be raised correctly, example in downward rounding:
- * fmal(0x1.0000000001p-16000L, 0x1.0000000001p-400L, -0x1p-16440L)
- */
- long double ret;
-#if defined(FE_INEXACT) && defined(FE_UNDERFLOW)
- int e = fetestexcept(FE_INEXACT);
- feclearexcept(FE_INEXACT);
-#endif
- fesetround(oround);
- adj = r.lo + xy.lo;
- ret = scalbnl(r.hi + adj, spread);
-#if defined(FE_INEXACT) && defined(FE_UNDERFLOW)
- if (ilogbl(ret) < -16382 && fetestexcept(FE_INEXACT))
- feraiseexcept(FE_UNDERFLOW);
- else if (e)
- feraiseexcept(FE_INEXACT);
-#endif
- return ret;
- }
-
- adj = add_adjusted(r.lo, xy.lo);
- if (spread + ilogbl(r.hi) > -16383)
- return scalbnl(r.hi + adj, spread);
- else
- return add_and_denormalize(r.hi, adj, spread);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmax.c b/lib/mlibc/options/ansi/musl-generic-math/fmax.c
deleted file mode 100644
index 94f0caa..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmax.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-double fmax(double x, double y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? y : x;
- return x < y ? y : x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmaxf.c b/lib/mlibc/options/ansi/musl-generic-math/fmaxf.c
deleted file mode 100644
index 695d817..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmaxf.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-float fmaxf(float x, float y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeroes, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? y : x;
- return x < y ? y : x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmaxl.c b/lib/mlibc/options/ansi/musl-generic-math/fmaxl.c
deleted file mode 100644
index 4b03158..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmaxl.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <math.h>
-#include <float.h>
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double fmaxl(long double x, long double y)
-{
- return fmax(x, y);
-}
-#else
-long double fmaxl(long double x, long double y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? y : x;
- return x < y ? y : x;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmin.c b/lib/mlibc/options/ansi/musl-generic-math/fmin.c
deleted file mode 100644
index 08a8fd1..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmin.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-double fmin(double x, double y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? x : y;
- return x < y ? x : y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fminf.c b/lib/mlibc/options/ansi/musl-generic-math/fminf.c
deleted file mode 100644
index 3573c7d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fminf.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-float fminf(float x, float y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? x : y;
- return x < y ? x : y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fminl.c b/lib/mlibc/options/ansi/musl-generic-math/fminl.c
deleted file mode 100644
index 69bc24a..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fminl.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <math.h>
-#include <float.h>
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double fminl(long double x, long double y)
-{
- return fmin(x, y);
-}
-#else
-long double fminl(long double x, long double y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? x : y;
- return x < y ? x : y;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmod.c b/lib/mlibc/options/ansi/musl-generic-math/fmod.c
deleted file mode 100644
index 6849722..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmod.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-double fmod(double x, double y)
-{
- union {double f; uint64_t i;} ux = {x}, uy = {y};
- int ex = ux.i>>52 & 0x7ff;
- int ey = uy.i>>52 & 0x7ff;
- int sx = ux.i>>63;
- uint64_t i;
-
- /* in the followings uxi should be ux.i, but then gcc wrongly adds */
- /* float load/store to inner loops ruining performance and code size */
- uint64_t uxi = ux.i;
-
- if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff)
- return (x*y)/(x*y);
- if (uxi<<1 <= uy.i<<1) {
- if (uxi<<1 == uy.i<<1)
- return 0*x;
- return x;
- }
-
- /* normalize x and y */
- if (!ex) {
- for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1);
- uxi <<= -ex + 1;
- } else {
- uxi &= -1ULL >> 12;
- uxi |= 1ULL << 52;
- }
- if (!ey) {
- for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1);
- uy.i <<= -ey + 1;
- } else {
- uy.i &= -1ULL >> 12;
- uy.i |= 1ULL << 52;
- }
-
- /* x mod y */
- for (; ex > ey; ex--) {
- i = uxi - uy.i;
- if (i >> 63 == 0) {
- if (i == 0)
- return 0*x;
- uxi = i;
- }
- uxi <<= 1;
- }
- i = uxi - uy.i;
- if (i >> 63 == 0) {
- if (i == 0)
- return 0*x;
- uxi = i;
- }
- for (; uxi>>52 == 0; uxi <<= 1, ex--);
-
- /* scale result */
- if (ex > 0) {
- uxi -= 1ULL << 52;
- uxi |= (uint64_t)ex << 52;
- } else {
- uxi >>= -ex + 1;
- }
- uxi |= (uint64_t)sx << 63;
- ux.i = uxi;
- return ux.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmodf.c b/lib/mlibc/options/ansi/musl-generic-math/fmodf.c
deleted file mode 100644
index ff58f93..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmodf.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float fmodf(float x, float y)
-{
- union {float f; uint32_t i;} ux = {x}, uy = {y};
- int ex = ux.i>>23 & 0xff;
- int ey = uy.i>>23 & 0xff;
- uint32_t sx = ux.i & 0x80000000;
- uint32_t i;
- uint32_t uxi = ux.i;
-
- if (uy.i<<1 == 0 || isnan(y) || ex == 0xff)
- return (x*y)/(x*y);
- if (uxi<<1 <= uy.i<<1) {
- if (uxi<<1 == uy.i<<1)
- return 0*x;
- return x;
- }
-
- /* normalize x and y */
- if (!ex) {
- for (i = uxi<<9; i>>31 == 0; ex--, i <<= 1);
- uxi <<= -ex + 1;
- } else {
- uxi &= -1U >> 9;
- uxi |= 1U << 23;
- }
- if (!ey) {
- for (i = uy.i<<9; i>>31 == 0; ey--, i <<= 1);
- uy.i <<= -ey + 1;
- } else {
- uy.i &= -1U >> 9;
- uy.i |= 1U << 23;
- }
-
- /* x mod y */
- for (; ex > ey; ex--) {
- i = uxi - uy.i;
- if (i >> 31 == 0) {
- if (i == 0)
- return 0*x;
- uxi = i;
- }
- uxi <<= 1;
- }
- i = uxi - uy.i;
- if (i >> 31 == 0) {
- if (i == 0)
- return 0*x;
- uxi = i;
- }
- for (; uxi>>23 == 0; uxi <<= 1, ex--);
-
- /* scale result up */
- if (ex > 0) {
- uxi -= 1U << 23;
- uxi |= (uint32_t)ex << 23;
- } else {
- uxi >>= -ex + 1;
- }
- uxi |= sx;
- ux.i = uxi;
- return ux.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/fmodl.c b/lib/mlibc/options/ansi/musl-generic-math/fmodl.c
deleted file mode 100644
index 9f5b873..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/fmodl.c
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double fmodl(long double x, long double y)
-{
- return fmod(x, y);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double fmodl(long double x, long double y)
-{
- union ldshape ux = {x}, uy = {y};
- int ex = ux.i.se & 0x7fff;
- int ey = uy.i.se & 0x7fff;
- int sx = ux.i.se & 0x8000;
-
- if (y == 0 || isnan(y) || ex == 0x7fff)
- return (x*y)/(x*y);
- ux.i.se = ex;
- uy.i.se = ey;
- if (ux.f <= uy.f) {
- if (ux.f == uy.f)
- return 0*x;
- return x;
- }
-
- /* normalize x and y */
- if (!ex) {
- ux.f *= 0x1p120f;
- ex = ux.i.se - 120;
- }
- if (!ey) {
- uy.f *= 0x1p120f;
- ey = uy.i.se - 120;
- }
-
- /* x mod y */
-#if LDBL_MANT_DIG == 64
- uint64_t i, mx, my;
- mx = ux.i.m;
- my = uy.i.m;
- for (; ex > ey; ex--) {
- i = mx - my;
- if (mx >= my) {
- if (i == 0)
- return 0*x;
- mx = 2*i;
- } else if (2*mx < mx) {
- mx = 2*mx - my;
- } else {
- mx = 2*mx;
- }
- }
- i = mx - my;
- if (mx >= my) {
- if (i == 0)
- return 0*x;
- mx = i;
- }
- for (; mx >> 63 == 0; mx *= 2, ex--);
- ux.i.m = mx;
-#elif LDBL_MANT_DIG == 113
- uint64_t hi, lo, xhi, xlo, yhi, ylo;
- xhi = (ux.i2.hi & -1ULL>>16) | 1ULL<<48;
- yhi = (uy.i2.hi & -1ULL>>16) | 1ULL<<48;
- xlo = ux.i2.lo;
- ylo = uy.i2.lo;
- for (; ex > ey; ex--) {
- hi = xhi - yhi;
- lo = xlo - ylo;
- if (xlo < ylo)
- hi -= 1;
- if (hi >> 63 == 0) {
- if ((hi|lo) == 0)
- return 0*x;
- xhi = 2*hi + (lo>>63);
- xlo = 2*lo;
- } else {
- xhi = 2*xhi + (xlo>>63);
- xlo = 2*xlo;
- }
- }
- hi = xhi - yhi;
- lo = xlo - ylo;
- if (xlo < ylo)
- hi -= 1;
- if (hi >> 63 == 0) {
- if ((hi|lo) == 0)
- return 0*x;
- xhi = hi;
- xlo = lo;
- }
- for (; xhi >> 48 == 0; xhi = 2*xhi + (xlo>>63), xlo = 2*xlo, ex--);
- ux.i2.hi = xhi;
- ux.i2.lo = xlo;
-#endif
-
- /* scale result */
- if (ex <= 0) {
- ux.i.se = (ex+120)|sx;
- ux.f *= 0x1p-120f;
- } else
- ux.i.se = ex|sx;
- return ux.f;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/frexp.c b/lib/mlibc/options/ansi/musl-generic-math/frexp.c
deleted file mode 100644
index 27b6266..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/frexp.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-double frexp(double x, int *e)
-{
- union { double d; uint64_t i; } y = { x };
- int ee = y.i>>52 & 0x7ff;
-
- if (!ee) {
- if (x) {
- x = frexp(x*0x1p64, e);
- *e -= 64;
- } else *e = 0;
- return x;
- } else if (ee == 0x7ff) {
- return x;
- }
-
- *e = ee - 0x3fe;
- y.i &= 0x800fffffffffffffull;
- y.i |= 0x3fe0000000000000ull;
- return y.d;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/frexpf.c b/lib/mlibc/options/ansi/musl-generic-math/frexpf.c
deleted file mode 100644
index 0787097..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/frexpf.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float frexpf(float x, int *e)
-{
- union { float f; uint32_t i; } y = { x };
- int ee = y.i>>23 & 0xff;
-
- if (!ee) {
- if (x) {
- x = frexpf(x*0x1p64, e);
- *e -= 64;
- } else *e = 0;
- return x;
- } else if (ee == 0xff) {
- return x;
- }
-
- *e = ee - 0x7e;
- y.i &= 0x807ffffful;
- y.i |= 0x3f000000ul;
- return y.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/frexpl.c b/lib/mlibc/options/ansi/musl-generic-math/frexpl.c
deleted file mode 100644
index 3c1b553..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/frexpl.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double frexpl(long double x, int *e)
-{
- return frexp(x, e);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double frexpl(long double x, int *e)
-{
- union ldshape u = {x};
- int ee = u.i.se & 0x7fff;
-
- if (!ee) {
- if (x) {
- x = frexpl(x*0x1p120, e);
- *e -= 120;
- } else *e = 0;
- return x;
- } else if (ee == 0x7fff) {
- return x;
- }
-
- *e = ee - 0x3ffe;
- u.i.se &= 0x8000;
- u.i.se |= 0x3ffe;
- return u.f;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/hypot.c b/lib/mlibc/options/ansi/musl-generic-math/hypot.c
deleted file mode 100644
index 6071bf1..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/hypot.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-#include <float.h>
-
-#if FLT_EVAL_METHOD > 1U && LDBL_MANT_DIG == 64
-#define SPLIT (0x1p32 + 1)
-#else
-#define SPLIT (0x1p27 + 1)
-#endif
-
-static void sq(double_t *hi, double_t *lo, double x)
-{
- double_t xh, xl, xc;
-
- xc = (double_t)x*SPLIT;
- xh = x - xc + xc;
- xl = x - xh;
- *hi = (double_t)x*x;
- *lo = xh*xh - *hi + 2*xh*xl + xl*xl;
-}
-
-double hypot(double x, double y)
-{
- union {double f; uint64_t i;} ux = {x}, uy = {y}, ut;
- int ex, ey;
- double_t hx, lx, hy, ly, z;
-
- /* arrange |x| >= |y| */
- ux.i &= -1ULL>>1;
- uy.i &= -1ULL>>1;
- if (ux.i < uy.i) {
- ut = ux;
- ux = uy;
- uy = ut;
- }
-
- /* special cases */
- ex = ux.i>>52;
- ey = uy.i>>52;
- x = ux.f;
- y = uy.f;
- /* note: hypot(inf,nan) == inf */
- if (ey == 0x7ff)
- return y;
- if (ex == 0x7ff || uy.i == 0)
- return x;
- /* note: hypot(x,y) ~= x + y*y/x/2 with inexact for small y/x */
- /* 64 difference is enough for ld80 double_t */
- if (ex - ey > 64)
- return x + y;
-
- /* precise sqrt argument in nearest rounding mode without overflow */
- /* xh*xh must not overflow and xl*xl must not underflow in sq */
- z = 1;
- if (ex > 0x3ff+510) {
- z = 0x1p700;
- x *= 0x1p-700;
- y *= 0x1p-700;
- } else if (ey < 0x3ff-450) {
- z = 0x1p-700;
- x *= 0x1p700;
- y *= 0x1p700;
- }
- sq(&hx, &lx, x);
- sq(&hy, &ly, y);
- return z*sqrt(ly+lx+hy+hx);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/hypotf.c b/lib/mlibc/options/ansi/musl-generic-math/hypotf.c
deleted file mode 100644
index 2fc214b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/hypotf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float hypotf(float x, float y)
-{
- union {float f; uint32_t i;} ux = {x}, uy = {y}, ut;
- float_t z;
-
- ux.i &= -1U>>1;
- uy.i &= -1U>>1;
- if (ux.i < uy.i) {
- ut = ux;
- ux = uy;
- uy = ut;
- }
-
- x = ux.f;
- y = uy.f;
- if (uy.i == 0xff<<23)
- return y;
- if (ux.i >= 0xff<<23 || uy.i == 0 || ux.i - uy.i >= 25<<23)
- return x + y;
-
- z = 1;
- if (ux.i >= (0x7f+60)<<23) {
- z = 0x1p90f;
- x *= 0x1p-90f;
- y *= 0x1p-90f;
- } else if (uy.i < (0x7f-60)<<23) {
- z = 0x1p-90f;
- x *= 0x1p90f;
- y *= 0x1p90f;
- }
- return z*sqrtf((double)x*x + (double)y*y);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/hypotl.c b/lib/mlibc/options/ansi/musl-generic-math/hypotl.c
deleted file mode 100644
index 479aa92..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/hypotl.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double hypotl(long double x, long double y)
-{
- return hypot(x, y);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
-#define SPLIT (0x1p32L+1)
-#elif LDBL_MANT_DIG == 113
-#define SPLIT (0x1p57L+1)
-#endif
-
-static void sq(long double *hi, long double *lo, long double x)
-{
- long double xh, xl, xc;
- xc = x*SPLIT;
- xh = x - xc + xc;
- xl = x - xh;
- *hi = x*x;
- *lo = xh*xh - *hi + 2*xh*xl + xl*xl;
-}
-
-long double hypotl(long double x, long double y)
-{
- union ldshape ux = {x}, uy = {y};
- int ex, ey;
- long double hx, lx, hy, ly, z;
-
- ux.i.se &= 0x7fff;
- uy.i.se &= 0x7fff;
- if (ux.i.se < uy.i.se) {
- ex = uy.i.se;
- ey = ux.i.se;
- x = uy.f;
- y = ux.f;
- } else {
- ex = ux.i.se;
- ey = uy.i.se;
- x = ux.f;
- y = uy.f;
- }
-
- if (ex == 0x7fff && isinf(y))
- return y;
- if (ex == 0x7fff || y == 0)
- return x;
- if (ex - ey > LDBL_MANT_DIG)
- return x + y;
-
- z = 1;
- if (ex > 0x3fff+8000) {
- z = 0x1p10000L;
- x *= 0x1p-10000L;
- y *= 0x1p-10000L;
- } else if (ey < 0x3fff-8000) {
- z = 0x1p-10000L;
- x *= 0x1p10000L;
- y *= 0x1p10000L;
- }
- sq(&hx, &lx, x);
- sq(&hy, &ly, y);
- return z*sqrtl(ly+lx+hy+hx);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ilogb.c b/lib/mlibc/options/ansi/musl-generic-math/ilogb.c
deleted file mode 100644
index 64d4015..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ilogb.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <limits.h>
-#include "libm.h"
-
-int ilogb(double x)
-{
- #pragma STDC FENV_ACCESS ON
- union {double f; uint64_t i;} u = {x};
- uint64_t i = u.i;
- int e = i>>52 & 0x7ff;
-
- if (!e) {
- i <<= 12;
- if (i == 0) {
- FORCE_EVAL(0/0.0f);
- return FP_ILOGB0;
- }
- /* subnormal x */
- for (e = -0x3ff; i>>63 == 0; e--, i<<=1);
- return e;
- }
- if (e == 0x7ff) {
- FORCE_EVAL(0/0.0f);
- return i<<12 ? FP_ILOGBNAN : INT_MAX;
- }
- return e - 0x3ff;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ilogbf.c b/lib/mlibc/options/ansi/musl-generic-math/ilogbf.c
deleted file mode 100644
index e23ba20..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ilogbf.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <limits.h>
-#include "libm.h"
-
-int ilogbf(float x)
-{
- #pragma STDC FENV_ACCESS ON
- union {float f; uint32_t i;} u = {x};
- uint32_t i = u.i;
- int e = i>>23 & 0xff;
-
- if (!e) {
- i <<= 9;
- if (i == 0) {
- FORCE_EVAL(0/0.0f);
- return FP_ILOGB0;
- }
- /* subnormal x */
- for (e = -0x7f; i>>31 == 0; e--, i<<=1);
- return e;
- }
- if (e == 0xff) {
- FORCE_EVAL(0/0.0f);
- return i<<9 ? FP_ILOGBNAN : INT_MAX;
- }
- return e - 0x7f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ilogbl.c b/lib/mlibc/options/ansi/musl-generic-math/ilogbl.c
deleted file mode 100644
index 7b1a9cf..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ilogbl.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <limits.h>
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-int ilogbl(long double x)
-{
- return ilogb(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-int ilogbl(long double x)
-{
- #pragma STDC FENV_ACCESS ON
- union ldshape u = {x};
- uint64_t m = u.i.m;
- int e = u.i.se & 0x7fff;
-
- if (!e) {
- if (m == 0) {
- FORCE_EVAL(0/0.0f);
- return FP_ILOGB0;
- }
- /* subnormal x */
- for (e = -0x3fff+1; m>>63 == 0; e--, m<<=1);
- return e;
- }
- if (e == 0x7fff) {
- FORCE_EVAL(0/0.0f);
- return m<<1 ? FP_ILOGBNAN : INT_MAX;
- }
- return e - 0x3fff;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-int ilogbl(long double x)
-{
- #pragma STDC FENV_ACCESS ON
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
-
- if (!e) {
- if (x == 0) {
- FORCE_EVAL(0/0.0f);
- return FP_ILOGB0;
- }
- /* subnormal x */
- x *= 0x1p120;
- return ilogbl(x) - 120;
- }
- if (e == 0x7fff) {
- FORCE_EVAL(0/0.0f);
- u.i.se = 0;
- return u.f ? FP_ILOGBNAN : INT_MAX;
- }
- return e - 0x3fff;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/j0.c b/lib/mlibc/options/ansi/musl-generic-math/j0.c
deleted file mode 100644
index d722d94..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/j0.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_j0.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* j0(x), y0(x)
- * Bessel function of the first and second kinds of order zero.
- * Method -- j0(x):
- * 1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ...
- * 2. Reduce x to |x| since j0(x)=j0(-x), and
- * for x in (0,2)
- * j0(x) = 1-z/4+ z^2*R0/S0, where z = x*x;
- * (precision: |j0-1+z/4-z^2R0/S0 |<2**-63.67 )
- * for x in (2,inf)
- * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0))
- * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
- * as follow:
- * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
- * = 1/sqrt(2) * (cos(x) + sin(x))
- * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4)
- * = 1/sqrt(2) * (sin(x) - cos(x))
- * (To avoid cancellation, use
- * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
- * to compute the worse one.)
- *
- * 3 Special cases
- * j0(nan)= nan
- * j0(0) = 1
- * j0(inf) = 0
- *
- * Method -- y0(x):
- * 1. For x<2.
- * Since
- * y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...)
- * therefore y0(x)-2/pi*j0(x)*ln(x) is an even function.
- * We use the following function to approximate y0,
- * y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2
- * where
- * U(z) = u00 + u01*z + ... + u06*z^6
- * V(z) = 1 + v01*z + ... + v04*z^4
- * with absolute approximation error bounded by 2**-72.
- * Note: For tiny x, U/V = u0 and j0(x)~1, hence
- * y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27)
- * 2. For x>=2.
- * y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0))
- * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
- * by the method mentioned above.
- * 3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0.
- */
-
-#include "libm.h"
-
-static double pzero(double), qzero(double);
-
-static const double
-invsqrtpi = 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
-tpi = 6.36619772367581382433e-01; /* 0x3FE45F30, 0x6DC9C883 */
-
-/* common method when |x|>=2 */
-static double common(uint32_t ix, double x, int y0)
-{
- double s,c,ss,cc,z;
-
- /*
- * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x-pi/4)-q0(x)*sin(x-pi/4))
- * y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x-pi/4)+q0(x)*cos(x-pi/4))
- *
- * sin(x-pi/4) = (sin(x) - cos(x))/sqrt(2)
- * cos(x-pi/4) = (sin(x) + cos(x))/sqrt(2)
- * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
- */
- s = sin(x);
- c = cos(x);
- if (y0)
- c = -c;
- cc = s+c;
- /* avoid overflow in 2*x, big ulp error when x>=0x1p1023 */
- if (ix < 0x7fe00000) {
- ss = s-c;
- z = -cos(2*x);
- if (s*c < 0)
- cc = z/ss;
- else
- ss = z/cc;
- if (ix < 0x48000000) {
- if (y0)
- ss = -ss;
- cc = pzero(x)*cc-qzero(x)*ss;
- }
- }
- return invsqrtpi*cc/sqrt(x);
-}
-
-/* R0/S0 on [0, 2.00] */
-static const double
-R02 = 1.56249999999999947958e-02, /* 0x3F8FFFFF, 0xFFFFFFFD */
-R03 = -1.89979294238854721751e-04, /* 0xBF28E6A5, 0xB61AC6E9 */
-R04 = 1.82954049532700665670e-06, /* 0x3EBEB1D1, 0x0C503919 */
-R05 = -4.61832688532103189199e-09, /* 0xBE33D5E7, 0x73D63FCE */
-S01 = 1.56191029464890010492e-02, /* 0x3F8FFCE8, 0x82C8C2A4 */
-S02 = 1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */
-S03 = 5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */
-S04 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
-
-double j0(double x)
-{
- double z,r,s;
- uint32_t ix;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
-
- /* j0(+-inf)=0, j0(nan)=nan */
- if (ix >= 0x7ff00000)
- return 1/(x*x);
- x = fabs(x);
-
- if (ix >= 0x40000000) { /* |x| >= 2 */
- /* large ulp error near zeros: 2.4, 5.52, 8.6537,.. */
- return common(ix,x,0);
- }
-
- /* 1 - x*x/4 + x*x*R(x^2)/S(x^2) */
- if (ix >= 0x3f200000) { /* |x| >= 2**-13 */
- /* up to 4ulp error close to 2 */
- z = x*x;
- r = z*(R02+z*(R03+z*(R04+z*R05)));
- s = 1+z*(S01+z*(S02+z*(S03+z*S04)));
- return (1+x/2)*(1-x/2) + z*(r/s);
- }
-
- /* 1 - x*x/4 */
- /* prevent underflow */
- /* inexact should be raised when x!=0, this is not done correctly */
- if (ix >= 0x38000000) /* |x| >= 2**-127 */
- x = 0.25*x*x;
- return 1 - x;
-}
-
-static const double
-u00 = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */
-u01 = 1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */
-u02 = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */
-u03 = 3.47453432093683650238e-04, /* 0x3F36C54D, 0x20B29B6B */
-u04 = -3.81407053724364161125e-06, /* 0xBECFFEA7, 0x73D25CAD */
-u05 = 1.95590137035022920206e-08, /* 0x3E550057, 0x3B4EABD4 */
-u06 = -3.98205194132103398453e-11, /* 0xBDC5E43D, 0x693FB3C8 */
-v01 = 1.27304834834123699328e-02, /* 0x3F8A1270, 0x91C9C71A */
-v02 = 7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */
-v03 = 2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */
-v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
-
-double y0(double x)
-{
- double z,u,v;
- uint32_t ix,lx;
-
- EXTRACT_WORDS(ix, lx, x);
-
- /* y0(nan)=nan, y0(<0)=nan, y0(0)=-inf, y0(inf)=0 */
- if ((ix<<1 | lx) == 0)
- return -1/0.0;
- if (ix>>31)
- return 0/0.0;
- if (ix >= 0x7ff00000)
- return 1/x;
-
- if (ix >= 0x40000000) { /* x >= 2 */
- /* large ulp errors near zeros: 3.958, 7.086,.. */
- return common(ix,x,1);
- }
-
- /* U(x^2)/V(x^2) + (2/pi)*j0(x)*log(x) */
- if (ix >= 0x3e400000) { /* x >= 2**-27 */
- /* large ulp error near the first zero, x ~= 0.89 */
- z = x*x;
- u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
- v = 1.0+z*(v01+z*(v02+z*(v03+z*v04)));
- return u/v + tpi*(j0(x)*log(x));
- }
- return u00 + tpi*log(x);
-}
-
-/* The asymptotic expansions of pzero is
- * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x.
- * For x >= 2, We approximate pzero by
- * pzero(x) = 1 + (R/S)
- * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
- * S = 1 + pS0*s^2 + ... + pS4*s^10
- * and
- * | pzero(x)-1-R/S | <= 2 ** ( -60.26)
- */
-static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
- -7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */
- -8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */
- -2.57063105679704847262e+02, /* 0xC0701102, 0x7B19E863 */
- -2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */
- -5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */
-};
-static const double pS8[5] = {
- 1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */
- 3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */
- 4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */
- 1.16752972564375915681e+05, /* 0x40FC810F, 0x8F9FA9BD */
- 4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */
-};
-
-static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */
- -7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */
- -4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */
- -6.76747652265167261021e+01, /* 0xC050EB2F, 0x5A7D1783 */
- -3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */
- -3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */
-};
-static const double pS5[5] = {
- 6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */
- 1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */
- 5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */
- 9.62544514357774460223e+03, /* 0x40C2CCB8, 0xFA76FA38 */
- 2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */
-};
-
-static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
- -2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */
- -7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */
- -2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */
- -2.19659774734883086467e+01, /* 0xC035F74A, 0x4CB94E14 */
- -5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */
- -3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */
-};
-static const double pS3[5] = {
- 3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */
- 3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */
- 1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */
- 1.12799679856907414432e+03, /* 0x40919FFC, 0xB8C39B7E */
- 1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */
-};
-
-static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */
- -7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */
- -1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */
- -7.63569613823527770791e+00, /* 0xC01E8AF3, 0xEDAFA7F3 */
- -1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */
- -3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */
-};
-static const double pS2[5] = {
- 2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */
- 1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */
- 2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */
- 1.53875394208320329881e+02, /* 0x40633C03, 0x3AB6FAFF */
- 1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
-};
-
-static double pzero(double x)
-{
- const double *p,*q;
- double_t z,r,s;
- uint32_t ix;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x40200000){p = pR8; q = pS8;}
- else if (ix >= 0x40122E8B){p = pR5; q = pS5;}
- else if (ix >= 0x4006DB6D){p = pR3; q = pS3;}
- else /*ix >= 0x40000000*/ {p = pR2; q = pS2;}
- z = 1.0/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
- return 1.0 + r/s;
-}
-
-
-/* For x >= 8, the asymptotic expansions of qzero is
- * -1/8 s + 75/1024 s^3 - ..., where s = 1/x.
- * We approximate pzero by
- * qzero(x) = s*(-1.25 + (R/S))
- * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
- * S = 1 + qS0*s^2 + ... + qS5*s^12
- * and
- * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22)
- */
-static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
- 7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */
- 1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */
- 5.57673380256401856059e+02, /* 0x40816D63, 0x15301825 */
- 8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */
- 3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */
-};
-static const double qS8[6] = {
- 1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */
- 8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */
- 1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */
- 8.03309257119514397345e+05, /* 0x412883DA, 0x83A52B43 */
- 8.40501579819060512818e+05, /* 0x4129A66B, 0x28DE0B3D */
- -3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */
-};
-
-static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- 1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */
- 7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */
- 5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */
- 1.35111577286449829671e+02, /* 0x4060E392, 0x0A8788E9 */
- 1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */
- 1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */
-};
-static const double qS5[6] = {
- 8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */
- 2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */
- 1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */
- 5.67511122894947329769e+04, /* 0x40EBB5E3, 0x97E02372 */
- 3.59767538425114471465e+04, /* 0x40E19118, 0x1F7A54A0 */
- -5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */
-};
-
-static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
- 4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */
- 7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */
- 3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */
- 4.26218440745412650017e+01, /* 0x40454F98, 0x962DAEDD */
- 1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */
- 1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */
-};
-static const double qS3[6] = {
- 4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */
- 7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */
- 3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */
- 6.46042516752568917582e+03, /* 0x40B93C6C, 0xD7C76A28 */
- 2.51633368920368957333e+03, /* 0x40A3A8AA, 0xD94FB1C0 */
- -1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */
-};
-
-static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- 1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */
- 7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */
- 1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */
- 1.44956029347885735348e+01, /* 0x402CFDBF, 0xAAF96FE5 */
- 3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */
- 1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */
-};
-static const double qS2[6] = {
- 3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */
- 2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */
- 8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */
- 8.82935845112488550512e+02, /* 0x408B977C, 0x9C5CC214 */
- 2.12666388511798828631e+02, /* 0x406A9553, 0x0E001365 */
- -5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
-};
-
-static double qzero(double x)
-{
- const double *p,*q;
- double_t s,r,z;
- uint32_t ix;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x40200000){p = qR8; q = qS8;}
- else if (ix >= 0x40122E8B){p = qR5; q = qS5;}
- else if (ix >= 0x4006DB6D){p = qR3; q = qS3;}
- else /*ix >= 0x40000000*/ {p = qR2; q = qS2;}
- z = 1.0/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
- return (-.125 + r/s)/x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/j0f.c b/lib/mlibc/options/ansi/musl-generic-math/j0f.c
deleted file mode 100644
index fab554a..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/j0f.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_j0f.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#define _GNU_SOURCE
-#include "libm.h"
-
-static float pzerof(float), qzerof(float);
-
-static const float
-invsqrtpi = 5.6418961287e-01, /* 0x3f106ebb */
-tpi = 6.3661974669e-01; /* 0x3f22f983 */
-
-static float common(uint32_t ix, float x, int y0)
-{
- float z,s,c,ss,cc;
- /*
- * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
- * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
- */
- s = sinf(x);
- c = cosf(x);
- if (y0)
- c = -c;
- cc = s+c;
- if (ix < 0x7f000000) {
- ss = s-c;
- z = -cosf(2*x);
- if (s*c < 0)
- cc = z/ss;
- else
- ss = z/cc;
- if (ix < 0x58800000) {
- if (y0)
- ss = -ss;
- cc = pzerof(x)*cc-qzerof(x)*ss;
- }
- }
- return invsqrtpi*cc/sqrtf(x);
-}
-
-/* R0/S0 on [0, 2.00] */
-static const float
-R02 = 1.5625000000e-02, /* 0x3c800000 */
-R03 = -1.8997929874e-04, /* 0xb947352e */
-R04 = 1.8295404516e-06, /* 0x35f58e88 */
-R05 = -4.6183270541e-09, /* 0xb19eaf3c */
-S01 = 1.5619102865e-02, /* 0x3c7fe744 */
-S02 = 1.1692678527e-04, /* 0x38f53697 */
-S03 = 5.1354652442e-07, /* 0x3509daa6 */
-S04 = 1.1661400734e-09; /* 0x30a045e8 */
-
-float j0f(float x)
-{
- float z,r,s;
- uint32_t ix;
-
- GET_FLOAT_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x7f800000)
- return 1/(x*x);
- x = fabsf(x);
-
- if (ix >= 0x40000000) { /* |x| >= 2 */
- /* large ulp error near zeros */
- return common(ix, x, 0);
- }
- if (ix >= 0x3a000000) { /* |x| >= 2**-11 */
- /* up to 4ulp error near 2 */
- z = x*x;
- r = z*(R02+z*(R03+z*(R04+z*R05)));
- s = 1+z*(S01+z*(S02+z*(S03+z*S04)));
- return (1+x/2)*(1-x/2) + z*(r/s);
- }
- if (ix >= 0x21800000) /* |x| >= 2**-60 */
- x = 0.25f*x*x;
- return 1 - x;
-}
-
-static const float
-u00 = -7.3804296553e-02, /* 0xbd9726b5 */
-u01 = 1.7666645348e-01, /* 0x3e34e80d */
-u02 = -1.3818567619e-02, /* 0xbc626746 */
-u03 = 3.4745343146e-04, /* 0x39b62a69 */
-u04 = -3.8140706238e-06, /* 0xb67ff53c */
-u05 = 1.9559013964e-08, /* 0x32a802ba */
-u06 = -3.9820518410e-11, /* 0xae2f21eb */
-v01 = 1.2730483897e-02, /* 0x3c509385 */
-v02 = 7.6006865129e-05, /* 0x389f65e0 */
-v03 = 2.5915085189e-07, /* 0x348b216c */
-v04 = 4.4111031494e-10; /* 0x2ff280c2 */
-
-float y0f(float x)
-{
- float z,u,v;
- uint32_t ix;
-
- GET_FLOAT_WORD(ix, x);
- if ((ix & 0x7fffffff) == 0)
- return -1/0.0f;
- if (ix>>31)
- return 0/0.0f;
- if (ix >= 0x7f800000)
- return 1/x;
- if (ix >= 0x40000000) { /* |x| >= 2.0 */
- /* large ulp error near zeros */
- return common(ix,x,1);
- }
- if (ix >= 0x39000000) { /* x >= 2**-13 */
- /* large ulp error at x ~= 0.89 */
- z = x*x;
- u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
- v = 1+z*(v01+z*(v02+z*(v03+z*v04)));
- return u/v + tpi*(j0f(x)*logf(x));
- }
- return u00 + tpi*logf(x);
-}
-
-/* The asymptotic expansions of pzero is
- * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x.
- * For x >= 2, We approximate pzero by
- * pzero(x) = 1 + (R/S)
- * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
- * S = 1 + pS0*s^2 + ... + pS4*s^10
- * and
- * | pzero(x)-1-R/S | <= 2 ** ( -60.26)
- */
-static const float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.0000000000e+00, /* 0x00000000 */
- -7.0312500000e-02, /* 0xbd900000 */
- -8.0816707611e+00, /* 0xc1014e86 */
- -2.5706311035e+02, /* 0xc3808814 */
- -2.4852163086e+03, /* 0xc51b5376 */
- -5.2530439453e+03, /* 0xc5a4285a */
-};
-static const float pS8[5] = {
- 1.1653436279e+02, /* 0x42e91198 */
- 3.8337448730e+03, /* 0x456f9beb */
- 4.0597855469e+04, /* 0x471e95db */
- 1.1675296875e+05, /* 0x47e4087c */
- 4.7627726562e+04, /* 0x473a0bba */
-};
-static const float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -1.1412546255e-11, /* 0xad48c58a */
- -7.0312492549e-02, /* 0xbd8fffff */
- -4.1596107483e+00, /* 0xc0851b88 */
- -6.7674766541e+01, /* 0xc287597b */
- -3.3123129272e+02, /* 0xc3a59d9b */
- -3.4643338013e+02, /* 0xc3ad3779 */
-};
-static const float pS5[5] = {
- 6.0753936768e+01, /* 0x42730408 */
- 1.0512523193e+03, /* 0x44836813 */
- 5.9789707031e+03, /* 0x45bad7c4 */
- 9.6254453125e+03, /* 0x461665c8 */
- 2.4060581055e+03, /* 0x451660ee */
-};
-
-static const float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
- -2.5470459075e-09, /* 0xb12f081b */
- -7.0311963558e-02, /* 0xbd8fffb8 */
- -2.4090321064e+00, /* 0xc01a2d95 */
- -2.1965976715e+01, /* 0xc1afba52 */
- -5.8079170227e+01, /* 0xc2685112 */
- -3.1447946548e+01, /* 0xc1fb9565 */
-};
-static const float pS3[5] = {
- 3.5856033325e+01, /* 0x420f6c94 */
- 3.6151397705e+02, /* 0x43b4c1ca */
- 1.1936077881e+03, /* 0x44953373 */
- 1.1279968262e+03, /* 0x448cffe6 */
- 1.7358093262e+02, /* 0x432d94b8 */
-};
-
-static const float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -8.8753431271e-08, /* 0xb3be98b7 */
- -7.0303097367e-02, /* 0xbd8ffb12 */
- -1.4507384300e+00, /* 0xbfb9b1cc */
- -7.6356959343e+00, /* 0xc0f4579f */
- -1.1193166733e+01, /* 0xc1331736 */
- -3.2336456776e+00, /* 0xc04ef40d */
-};
-static const float pS2[5] = {
- 2.2220300674e+01, /* 0x41b1c32d */
- 1.3620678711e+02, /* 0x430834f0 */
- 2.7047027588e+02, /* 0x43873c32 */
- 1.5387539673e+02, /* 0x4319e01a */
- 1.4657617569e+01, /* 0x416a859a */
-};
-
-static float pzerof(float x)
-{
- const float *p,*q;
- float_t z,r,s;
- uint32_t ix;
-
- GET_FLOAT_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x41000000){p = pR8; q = pS8;}
- else if (ix >= 0x409173eb){p = pR5; q = pS5;}
- else if (ix >= 0x4036d917){p = pR3; q = pS3;}
- else /*ix >= 0x40000000*/ {p = pR2; q = pS2;}
- z = 1.0f/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0f+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
- return 1.0f + r/s;
-}
-
-
-/* For x >= 8, the asymptotic expansions of qzero is
- * -1/8 s + 75/1024 s^3 - ..., where s = 1/x.
- * We approximate pzero by
- * qzero(x) = s*(-1.25 + (R/S))
- * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
- * S = 1 + qS0*s^2 + ... + qS5*s^12
- * and
- * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22)
- */
-static const float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.0000000000e+00, /* 0x00000000 */
- 7.3242187500e-02, /* 0x3d960000 */
- 1.1768206596e+01, /* 0x413c4a93 */
- 5.5767340088e+02, /* 0x440b6b19 */
- 8.8591972656e+03, /* 0x460a6cca */
- 3.7014625000e+04, /* 0x471096a0 */
-};
-static const float qS8[6] = {
- 1.6377603149e+02, /* 0x4323c6aa */
- 8.0983447266e+03, /* 0x45fd12c2 */
- 1.4253829688e+05, /* 0x480b3293 */
- 8.0330925000e+05, /* 0x49441ed4 */
- 8.4050156250e+05, /* 0x494d3359 */
- -3.4389928125e+05, /* 0xc8a7eb69 */
-};
-
-static const float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- 1.8408595828e-11, /* 0x2da1ec79 */
- 7.3242180049e-02, /* 0x3d95ffff */
- 5.8356351852e+00, /* 0x40babd86 */
- 1.3511157227e+02, /* 0x43071c90 */
- 1.0272437744e+03, /* 0x448067cd */
- 1.9899779053e+03, /* 0x44f8bf4b */
-};
-static const float qS5[6] = {
- 8.2776611328e+01, /* 0x42a58da0 */
- 2.0778142090e+03, /* 0x4501dd07 */
- 1.8847289062e+04, /* 0x46933e94 */
- 5.6751113281e+04, /* 0x475daf1d */
- 3.5976753906e+04, /* 0x470c88c1 */
- -5.3543427734e+03, /* 0xc5a752be */
-};
-
-static const float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
- 4.3774099900e-09, /* 0x3196681b */
- 7.3241114616e-02, /* 0x3d95ff70 */
- 3.3442313671e+00, /* 0x405607e3 */
- 4.2621845245e+01, /* 0x422a7cc5 */
- 1.7080809021e+02, /* 0x432acedf */
- 1.6673394775e+02, /* 0x4326bbe4 */
-};
-static const float qS3[6] = {
- 4.8758872986e+01, /* 0x42430916 */
- 7.0968920898e+02, /* 0x44316c1c */
- 3.7041481934e+03, /* 0x4567825f */
- 6.4604252930e+03, /* 0x45c9e367 */
- 2.5163337402e+03, /* 0x451d4557 */
- -1.4924745178e+02, /* 0xc3153f59 */
-};
-
-static const float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- 1.5044444979e-07, /* 0x342189db */
- 7.3223426938e-02, /* 0x3d95f62a */
- 1.9981917143e+00, /* 0x3fffc4bf */
- 1.4495602608e+01, /* 0x4167edfd */
- 3.1666231155e+01, /* 0x41fd5471 */
- 1.6252708435e+01, /* 0x4182058c */
-};
-static const float qS2[6] = {
- 3.0365585327e+01, /* 0x41f2ecb8 */
- 2.6934811401e+02, /* 0x4386ac8f */
- 8.4478375244e+02, /* 0x44533229 */
- 8.8293585205e+02, /* 0x445cbbe5 */
- 2.1266638184e+02, /* 0x4354aa98 */
- -5.3109550476e+00, /* 0xc0a9f358 */
-};
-
-static float qzerof(float x)
-{
- const float *p,*q;
- float_t s,r,z;
- uint32_t ix;
-
- GET_FLOAT_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x41000000){p = qR8; q = qS8;}
- else if (ix >= 0x409173eb){p = qR5; q = qS5;}
- else if (ix >= 0x4036d917){p = qR3; q = qS3;}
- else /*ix >= 0x40000000*/ {p = qR2; q = qS2;}
- z = 1.0f/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0f+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
- return (-.125f + r/s)/x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/j1.c b/lib/mlibc/options/ansi/musl-generic-math/j1.c
deleted file mode 100644
index df724d1..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/j1.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_j1.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* j1(x), y1(x)
- * Bessel function of the first and second kinds of order zero.
- * Method -- j1(x):
- * 1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ...
- * 2. Reduce x to |x| since j1(x)=-j1(-x), and
- * for x in (0,2)
- * j1(x) = x/2 + x*z*R0/S0, where z = x*x;
- * (precision: |j1/x - 1/2 - R0/S0 |<2**-61.51 )
- * for x in (2,inf)
- * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
- * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
- * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
- * as follow:
- * cos(x1) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
- * = 1/sqrt(2) * (sin(x) - cos(x))
- * sin(x1) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
- * = -1/sqrt(2) * (sin(x) + cos(x))
- * (To avoid cancellation, use
- * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
- * to compute the worse one.)
- *
- * 3 Special cases
- * j1(nan)= nan
- * j1(0) = 0
- * j1(inf) = 0
- *
- * Method -- y1(x):
- * 1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN
- * 2. For x<2.
- * Since
- * y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...)
- * therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function.
- * We use the following function to approximate y1,
- * y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2
- * where for x in [0,2] (abs err less than 2**-65.89)
- * U(z) = U0[0] + U0[1]*z + ... + U0[4]*z^4
- * V(z) = 1 + v0[0]*z + ... + v0[4]*z^5
- * Note: For tiny x, 1/x dominate y1 and hence
- * y1(tiny) = -2/pi/tiny, (choose tiny<2**-54)
- * 3. For x>=2.
- * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
- * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
- * by method mentioned above.
- */
-
-#include "libm.h"
-
-static double pone(double), qone(double);
-
-static const double
-invsqrtpi = 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
-tpi = 6.36619772367581382433e-01; /* 0x3FE45F30, 0x6DC9C883 */
-
-static double common(uint32_t ix, double x, int y1, int sign)
-{
- double z,s,c,ss,cc;
-
- /*
- * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x-3pi/4)-q1(x)*sin(x-3pi/4))
- * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x-3pi/4)+q1(x)*cos(x-3pi/4))
- *
- * sin(x-3pi/4) = -(sin(x) + cos(x))/sqrt(2)
- * cos(x-3pi/4) = (sin(x) - cos(x))/sqrt(2)
- * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
- */
- s = sin(x);
- if (y1)
- s = -s;
- c = cos(x);
- cc = s-c;
- if (ix < 0x7fe00000) {
- /* avoid overflow in 2*x */
- ss = -s-c;
- z = cos(2*x);
- if (s*c > 0)
- cc = z/ss;
- else
- ss = z/cc;
- if (ix < 0x48000000) {
- if (y1)
- ss = -ss;
- cc = pone(x)*cc-qone(x)*ss;
- }
- }
- if (sign)
- cc = -cc;
- return invsqrtpi*cc/sqrt(x);
-}
-
-/* R0/S0 on [0,2] */
-static const double
-r00 = -6.25000000000000000000e-02, /* 0xBFB00000, 0x00000000 */
-r01 = 1.40705666955189706048e-03, /* 0x3F570D9F, 0x98472C61 */
-r02 = -1.59955631084035597520e-05, /* 0xBEF0C5C6, 0xBA169668 */
-r03 = 4.96727999609584448412e-08, /* 0x3E6AAAFA, 0x46CA0BD9 */
-s01 = 1.91537599538363460805e-02, /* 0x3F939D0B, 0x12637E53 */
-s02 = 1.85946785588630915560e-04, /* 0x3F285F56, 0xB9CDF664 */
-s03 = 1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */
-s04 = 5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */
-s05 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */
-
-double j1(double x)
-{
- double z,r,s;
- uint32_t ix;
- int sign;
-
- GET_HIGH_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix >= 0x7ff00000)
- return 1/(x*x);
- if (ix >= 0x40000000) /* |x| >= 2 */
- return common(ix, fabs(x), 0, sign);
- if (ix >= 0x38000000) { /* |x| >= 2**-127 */
- z = x*x;
- r = z*(r00+z*(r01+z*(r02+z*r03)));
- s = 1+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
- z = r/s;
- } else
- /* avoid underflow, raise inexact if x!=0 */
- z = x;
- return (0.5 + z)*x;
-}
-
-static const double U0[5] = {
- -1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */
- 5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */
- -1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */
- 2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */
- -9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */
-};
-static const double V0[5] = {
- 1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */
- 2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */
- 1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */
- 6.22741452364621501295e-09, /* 0x3E3ABF1D, 0x5BA69A86 */
- 1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
-};
-
-double y1(double x)
-{
- double z,u,v;
- uint32_t ix,lx;
-
- EXTRACT_WORDS(ix, lx, x);
- /* y1(nan)=nan, y1(<0)=nan, y1(0)=-inf, y1(inf)=0 */
- if ((ix<<1 | lx) == 0)
- return -1/0.0;
- if (ix>>31)
- return 0/0.0;
- if (ix >= 0x7ff00000)
- return 1/x;
-
- if (ix >= 0x40000000) /* x >= 2 */
- return common(ix, x, 1, 0);
- if (ix < 0x3c900000) /* x < 2**-54 */
- return -tpi/x;
- z = x*x;
- u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
- v = 1+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
- return x*(u/v) + tpi*(j1(x)*log(x)-1/x);
-}
-
-/* For x >= 8, the asymptotic expansions of pone is
- * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x.
- * We approximate pone by
- * pone(x) = 1 + (R/S)
- * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
- * S = 1 + ps0*s^2 + ... + ps4*s^10
- * and
- * | pone(x)-1-R/S | <= 2 ** ( -60.06)
- */
-
-static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
- 1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */
- 1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */
- 4.12051854307378562225e+02, /* 0x4079C0D4, 0x652EA590 */
- 3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */
- 7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */
-};
-static const double ps8[5] = {
- 1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */
- 3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */
- 3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */
- 9.76027935934950801311e+04, /* 0x40F7D42C, 0xB28F17BB */
- 3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */
-};
-
-static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- 1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */
- 1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */
- 6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */
- 1.08308182990189109773e+02, /* 0x405B13B9, 0x452602ED */
- 5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */
- 5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */
-};
-static const double ps5[5] = {
- 5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */
- 9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */
- 5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */
- 7.84469031749551231769e+03, /* 0x40BEA4B0, 0xB8A5BB15 */
- 1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */
-};
-
-static const double pr3[6] = {
- 3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */
- 1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */
- 3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */
- 3.51194035591636932736e+01, /* 0x40418F48, 0x9DA6D129 */
- 9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */
- 4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */
-};
-static const double ps3[5] = {
- 3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */
- 3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */
- 1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */
- 8.90811346398256432622e+02, /* 0x408BD67D, 0xA32E31E9 */
- 1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */
-};
-
-static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- 1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */
- 1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */
- 2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */
- 1.22426109148261232917e+01, /* 0x40287C37, 0x7F71A964 */
- 1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */
- 5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */
-};
-static const double ps2[5] = {
- 2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */
- 1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */
- 2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */
- 1.17679373287147100768e+02, /* 0x405D6B7A, 0xDA1884A9 */
- 8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
-};
-
-static double pone(double x)
-{
- const double *p,*q;
- double_t z,r,s;
- uint32_t ix;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x40200000){p = pr8; q = ps8;}
- else if (ix >= 0x40122E8B){p = pr5; q = ps5;}
- else if (ix >= 0x4006DB6D){p = pr3; q = ps3;}
- else /*ix >= 0x40000000*/ {p = pr2; q = ps2;}
- z = 1.0/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
- return 1.0+ r/s;
-}
-
-/* For x >= 8, the asymptotic expansions of qone is
- * 3/8 s - 105/1024 s^3 - ..., where s = 1/x.
- * We approximate pone by
- * qone(x) = s*(0.375 + (R/S))
- * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
- * S = 1 + qs1*s^2 + ... + qs6*s^12
- * and
- * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13)
- */
-
-static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
- -1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */
- -1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */
- -7.59601722513950107896e+02, /* 0xC087BCD0, 0x53E4B576 */
- -1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */
- -4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */
-};
-static const double qs8[6] = {
- 1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */
- 7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */
- 1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */
- 7.19657723683240939863e+05, /* 0x4125F653, 0x72869C19 */
- 6.66601232617776375264e+05, /* 0x412457D2, 0x7719AD5C */
- -2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */
-};
-
-static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */
- -1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */
- -8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */
- -1.83669607474888380239e+02, /* 0xC066F56D, 0x6CA7B9B0 */
- -1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */
- -2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */
-};
-static const double qs5[6] = {
- 8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */
- 1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */
- 1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */
- 4.98514270910352279316e+04, /* 0x40E8576D, 0xAABAD197 */
- 2.79480751638918118260e+04, /* 0x40DB4B04, 0xCF7C364B */
- -4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */
-};
-
-static const double qr3[6] = {
- -5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */
- -1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */
- -4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */
- -5.78472216562783643212e+01, /* 0xC04CEC71, 0xC25D16DA */
- -2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */
- -2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */
-};
-static const double qs3[6] = {
- 4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */
- 6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */
- 3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */
- 5.54772909720722782367e+03, /* 0x40B5ABBA, 0xA61D54A6 */
- 1.90311919338810798763e+03, /* 0x409DBC7A, 0x0DD4DF4B */
- -1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */
-};
-
-static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */
- -1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */
- -2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */
- -1.96636162643703720221e+01, /* 0xC033A9E2, 0xC168907F */
- -4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */
- -2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */
-};
-static const double qs2[6] = {
- 2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */
- 2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */
- 7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */
- 7.39393205320467245656e+02, /* 0x40871B25, 0x48D4C029 */
- 1.55949003336666123687e+02, /* 0x40637E5E, 0x3C3ED8D4 */
- -4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
-};
-
-static double qone(double x)
-{
- const double *p,*q;
- double_t s,r,z;
- uint32_t ix;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x40200000){p = qr8; q = qs8;}
- else if (ix >= 0x40122E8B){p = qr5; q = qs5;}
- else if (ix >= 0x4006DB6D){p = qr3; q = qs3;}
- else /*ix >= 0x40000000*/ {p = qr2; q = qs2;}
- z = 1.0/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
- return (.375 + r/s)/x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/j1f.c b/lib/mlibc/options/ansi/musl-generic-math/j1f.c
deleted file mode 100644
index 3434c53..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/j1f.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_j1f.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#define _GNU_SOURCE
-#include "libm.h"
-
-static float ponef(float), qonef(float);
-
-static const float
-invsqrtpi = 5.6418961287e-01, /* 0x3f106ebb */
-tpi = 6.3661974669e-01; /* 0x3f22f983 */
-
-static float common(uint32_t ix, float x, int y1, int sign)
-{
- double z,s,c,ss,cc;
-
- s = sinf(x);
- if (y1)
- s = -s;
- c = cosf(x);
- cc = s-c;
- if (ix < 0x7f000000) {
- ss = -s-c;
- z = cosf(2*x);
- if (s*c > 0)
- cc = z/ss;
- else
- ss = z/cc;
- if (ix < 0x58800000) {
- if (y1)
- ss = -ss;
- cc = ponef(x)*cc-qonef(x)*ss;
- }
- }
- if (sign)
- cc = -cc;
- return invsqrtpi*cc/sqrtf(x);
-}
-
-/* R0/S0 on [0,2] */
-static const float
-r00 = -6.2500000000e-02, /* 0xbd800000 */
-r01 = 1.4070566976e-03, /* 0x3ab86cfd */
-r02 = -1.5995563444e-05, /* 0xb7862e36 */
-r03 = 4.9672799207e-08, /* 0x335557d2 */
-s01 = 1.9153760746e-02, /* 0x3c9ce859 */
-s02 = 1.8594678841e-04, /* 0x3942fab6 */
-s03 = 1.1771846857e-06, /* 0x359dffc2 */
-s04 = 5.0463624390e-09, /* 0x31ad6446 */
-s05 = 1.2354227016e-11; /* 0x2d59567e */
-
-float j1f(float x)
-{
- float z,r,s;
- uint32_t ix;
- int sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix >= 0x7f800000)
- return 1/(x*x);
- if (ix >= 0x40000000) /* |x| >= 2 */
- return common(ix, fabsf(x), 0, sign);
- if (ix >= 0x39000000) { /* |x| >= 2**-13 */
- z = x*x;
- r = z*(r00+z*(r01+z*(r02+z*r03)));
- s = 1+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
- z = 0.5f + r/s;
- } else
- z = 0.5f;
- return z*x;
-}
-
-static const float U0[5] = {
- -1.9605709612e-01, /* 0xbe48c331 */
- 5.0443872809e-02, /* 0x3d4e9e3c */
- -1.9125689287e-03, /* 0xbafaaf2a */
- 2.3525259166e-05, /* 0x37c5581c */
- -9.1909917899e-08, /* 0xb3c56003 */
-};
-static const float V0[5] = {
- 1.9916731864e-02, /* 0x3ca3286a */
- 2.0255257550e-04, /* 0x3954644b */
- 1.3560879779e-06, /* 0x35b602d4 */
- 6.2274145840e-09, /* 0x31d5f8eb */
- 1.6655924903e-11, /* 0x2d9281cf */
-};
-
-float y1f(float x)
-{
- float z,u,v;
- uint32_t ix;
-
- GET_FLOAT_WORD(ix, x);
- if ((ix & 0x7fffffff) == 0)
- return -1/0.0f;
- if (ix>>31)
- return 0/0.0f;
- if (ix >= 0x7f800000)
- return 1/x;
- if (ix >= 0x40000000) /* |x| >= 2.0 */
- return common(ix,x,1,0);
- if (ix < 0x33000000) /* x < 2**-25 */
- return -tpi/x;
- z = x*x;
- u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
- v = 1.0f+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
- return x*(u/v) + tpi*(j1f(x)*logf(x)-1.0f/x);
-}
-
-/* For x >= 8, the asymptotic expansions of pone is
- * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x.
- * We approximate pone by
- * pone(x) = 1 + (R/S)
- * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
- * S = 1 + ps0*s^2 + ... + ps4*s^10
- * and
- * | pone(x)-1-R/S | <= 2 ** ( -60.06)
- */
-
-static const float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.0000000000e+00, /* 0x00000000 */
- 1.1718750000e-01, /* 0x3df00000 */
- 1.3239480972e+01, /* 0x4153d4ea */
- 4.1205184937e+02, /* 0x43ce06a3 */
- 3.8747453613e+03, /* 0x45722bed */
- 7.9144794922e+03, /* 0x45f753d6 */
-};
-static const float ps8[5] = {
- 1.1420736694e+02, /* 0x42e46a2c */
- 3.6509309082e+03, /* 0x45642ee5 */
- 3.6956207031e+04, /* 0x47105c35 */
- 9.7602796875e+04, /* 0x47bea166 */
- 3.0804271484e+04, /* 0x46f0a88b */
-};
-
-static const float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- 1.3199052094e-11, /* 0x2d68333f */
- 1.1718749255e-01, /* 0x3defffff */
- 6.8027510643e+00, /* 0x40d9b023 */
- 1.0830818176e+02, /* 0x42d89dca */
- 5.1763616943e+02, /* 0x440168b7 */
- 5.2871520996e+02, /* 0x44042dc6 */
-};
-static const float ps5[5] = {
- 5.9280597687e+01, /* 0x426d1f55 */
- 9.9140142822e+02, /* 0x4477d9b1 */
- 5.3532670898e+03, /* 0x45a74a23 */
- 7.8446904297e+03, /* 0x45f52586 */
- 1.5040468750e+03, /* 0x44bc0180 */
-};
-
-static const float pr3[6] = {
- 3.0250391081e-09, /* 0x314fe10d */
- 1.1718686670e-01, /* 0x3defffab */
- 3.9329774380e+00, /* 0x407bb5e7 */
- 3.5119403839e+01, /* 0x420c7a45 */
- 9.1055007935e+01, /* 0x42b61c2a */
- 4.8559066772e+01, /* 0x42423c7c */
-};
-static const float ps3[5] = {
- 3.4791309357e+01, /* 0x420b2a4d */
- 3.3676245117e+02, /* 0x43a86198 */
- 1.0468714600e+03, /* 0x4482dbe3 */
- 8.9081134033e+02, /* 0x445eb3ed */
- 1.0378793335e+02, /* 0x42cf936c */
-};
-
-static const float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- 1.0771083225e-07, /* 0x33e74ea8 */
- 1.1717621982e-01, /* 0x3deffa16 */
- 2.3685150146e+00, /* 0x401795c0 */
- 1.2242610931e+01, /* 0x4143e1bc */
- 1.7693971634e+01, /* 0x418d8d41 */
- 5.0735230446e+00, /* 0x40a25a4d */
-};
-static const float ps2[5] = {
- 2.1436485291e+01, /* 0x41ab7dec */
- 1.2529022980e+02, /* 0x42fa9499 */
- 2.3227647400e+02, /* 0x436846c7 */
- 1.1767937469e+02, /* 0x42eb5bd7 */
- 8.3646392822e+00, /* 0x4105d590 */
-};
-
-static float ponef(float x)
-{
- const float *p,*q;
- float_t z,r,s;
- uint32_t ix;
-
- GET_FLOAT_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x41000000){p = pr8; q = ps8;}
- else if (ix >= 0x409173eb){p = pr5; q = ps5;}
- else if (ix >= 0x4036d917){p = pr3; q = ps3;}
- else /*ix >= 0x40000000*/ {p = pr2; q = ps2;}
- z = 1.0f/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0f+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
- return 1.0f + r/s;
-}
-
-/* For x >= 8, the asymptotic expansions of qone is
- * 3/8 s - 105/1024 s^3 - ..., where s = 1/x.
- * We approximate pone by
- * qone(x) = s*(0.375 + (R/S))
- * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
- * S = 1 + qs1*s^2 + ... + qs6*s^12
- * and
- * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13)
- */
-
-static const float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
- 0.0000000000e+00, /* 0x00000000 */
- -1.0253906250e-01, /* 0xbdd20000 */
- -1.6271753311e+01, /* 0xc1822c8d */
- -7.5960174561e+02, /* 0xc43de683 */
- -1.1849806641e+04, /* 0xc639273a */
- -4.8438511719e+04, /* 0xc73d3683 */
-};
-static const float qs8[6] = {
- 1.6139537048e+02, /* 0x43216537 */
- 7.8253862305e+03, /* 0x45f48b17 */
- 1.3387534375e+05, /* 0x4802bcd6 */
- 7.1965775000e+05, /* 0x492fb29c */
- 6.6660125000e+05, /* 0x4922be94 */
- -2.9449025000e+05, /* 0xc88fcb48 */
-};
-
-static const float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
- -2.0897993405e-11, /* 0xadb7d219 */
- -1.0253904760e-01, /* 0xbdd1fffe */
- -8.0564479828e+00, /* 0xc100e736 */
- -1.8366960144e+02, /* 0xc337ab6b */
- -1.3731937256e+03, /* 0xc4aba633 */
- -2.6124443359e+03, /* 0xc523471c */
-};
-static const float qs5[6] = {
- 8.1276550293e+01, /* 0x42a28d98 */
- 1.9917987061e+03, /* 0x44f8f98f */
- 1.7468484375e+04, /* 0x468878f8 */
- 4.9851425781e+04, /* 0x4742bb6d */
- 2.7948074219e+04, /* 0x46da5826 */
- -4.7191835938e+03, /* 0xc5937978 */
-};
-
-static const float qr3[6] = {
- -5.0783124372e-09, /* 0xb1ae7d4f */
- -1.0253783315e-01, /* 0xbdd1ff5b */
- -4.6101160049e+00, /* 0xc0938612 */
- -5.7847221375e+01, /* 0xc267638e */
- -2.2824453735e+02, /* 0xc3643e9a */
- -2.1921012878e+02, /* 0xc35b35cb */
-};
-static const float qs3[6] = {
- 4.7665153503e+01, /* 0x423ea91e */
- 6.7386511230e+02, /* 0x4428775e */
- 3.3801528320e+03, /* 0x45534272 */
- 5.5477290039e+03, /* 0x45ad5dd5 */
- 1.9031191406e+03, /* 0x44ede3d0 */
- -1.3520118713e+02, /* 0xc3073381 */
-};
-
-static const float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
- -1.7838172539e-07, /* 0xb43f8932 */
- -1.0251704603e-01, /* 0xbdd1f475 */
- -2.7522056103e+00, /* 0xc0302423 */
- -1.9663616180e+01, /* 0xc19d4f16 */
- -4.2325313568e+01, /* 0xc2294d1f */
- -2.1371921539e+01, /* 0xc1aaf9b2 */
-};
-static const float qs2[6] = {
- 2.9533363342e+01, /* 0x41ec4454 */
- 2.5298155212e+02, /* 0x437cfb47 */
- 7.5750280762e+02, /* 0x443d602e */
- 7.3939318848e+02, /* 0x4438d92a */
- 1.5594900513e+02, /* 0x431bf2f2 */
- -4.9594988823e+00, /* 0xc09eb437 */
-};
-
-static float qonef(float x)
-{
- const float *p,*q;
- float_t s,r,z;
- uint32_t ix;
-
- GET_FLOAT_WORD(ix, x);
- ix &= 0x7fffffff;
- if (ix >= 0x41000000){p = qr8; q = qs8;}
- else if (ix >= 0x409173eb){p = qr5; q = qs5;}
- else if (ix >= 0x4036d917){p = qr3; q = qs3;}
- else /*ix >= 0x40000000*/ {p = qr2; q = qs2;}
- z = 1.0f/(x*x);
- r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
- s = 1.0f+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
- return (.375f + r/s)/x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/jn.c b/lib/mlibc/options/ansi/musl-generic-math/jn.c
deleted file mode 100644
index 4878a54..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/jn.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_jn.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * jn(n, x), yn(n, x)
- * floating point Bessel's function of the 1st and 2nd kind
- * of order n
- *
- * Special cases:
- * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
- * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
- * Note 2. About jn(n,x), yn(n,x)
- * For n=0, j0(x) is called,
- * for n=1, j1(x) is called,
- * for n<=x, forward recursion is used starting
- * from values of j0(x) and j1(x).
- * for n>x, a continued fraction approximation to
- * j(n,x)/j(n-1,x) is evaluated and then backward
- * recursion is used starting from a supposed value
- * for j(n,x). The resulting value of j(0,x) is
- * compared with the actual value to correct the
- * supposed value of j(n,x).
- *
- * yn(n,x) is similar in all respects, except
- * that forward recursion is used for all
- * values of n>1.
- */
-
-#include "libm.h"
-
-static const double invsqrtpi = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */
-
-double jn(int n, double x)
-{
- uint32_t ix, lx;
- int nm1, i, sign;
- double a, b, temp;
-
- EXTRACT_WORDS(ix, lx, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
-
- if ((ix | (lx|-lx)>>31) > 0x7ff00000) /* nan */
- return x;
-
- /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x)
- * Thus, J(-n,x) = J(n,-x)
- */
- /* nm1 = |n|-1 is used instead of |n| to handle n==INT_MIN */
- if (n == 0)
- return j0(x);
- if (n < 0) {
- nm1 = -(n+1);
- x = -x;
- sign ^= 1;
- } else
- nm1 = n-1;
- if (nm1 == 0)
- return j1(x);
-
- sign &= n; /* even n: 0, odd n: signbit(x) */
- x = fabs(x);
- if ((ix|lx) == 0 || ix == 0x7ff00000) /* if x is 0 or inf */
- b = 0.0;
- else if (nm1 < x) {
- /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
- if (ix >= 0x52d00000) { /* x > 2**302 */
- /* (x >> n**2)
- * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
- * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
- * Let s=sin(x), c=cos(x),
- * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
- *
- * n sin(xn)*sqt2 cos(xn)*sqt2
- * ----------------------------------
- * 0 s-c c+s
- * 1 -s-c -c+s
- * 2 -s+c -c-s
- * 3 s+c c-s
- */
- switch(nm1&3) {
- case 0: temp = -cos(x)+sin(x); break;
- case 1: temp = -cos(x)-sin(x); break;
- case 2: temp = cos(x)-sin(x); break;
- default:
- case 3: temp = cos(x)+sin(x); break;
- }
- b = invsqrtpi*temp/sqrt(x);
- } else {
- a = j0(x);
- b = j1(x);
- for (i=0; i<nm1; ) {
- i++;
- temp = b;
- b = b*(2.0*i/x) - a; /* avoid underflow */
- a = temp;
- }
- }
- } else {
- if (ix < 0x3e100000) { /* x < 2**-29 */
- /* x is tiny, return the first Taylor expansion of J(n,x)
- * J(n,x) = 1/n!*(x/2)^n - ...
- */
- if (nm1 > 32) /* underflow */
- b = 0.0;
- else {
- temp = x*0.5;
- b = temp;
- a = 1.0;
- for (i=2; i<=nm1+1; i++) {
- a *= (double)i; /* a = n! */
- b *= temp; /* b = (x/2)^n */
- }
- b = b/a;
- }
- } else {
- /* use backward recurrence */
- /* x x^2 x^2
- * J(n,x)/J(n-1,x) = ---- ------ ------ .....
- * 2n - 2(n+1) - 2(n+2)
- *
- * 1 1 1
- * (for large x) = ---- ------ ------ .....
- * 2n 2(n+1) 2(n+2)
- * -- - ------ - ------ -
- * x x x
- *
- * Let w = 2n/x and h=2/x, then the above quotient
- * is equal to the continued fraction:
- * 1
- * = -----------------------
- * 1
- * w - -----------------
- * 1
- * w+h - ---------
- * w+2h - ...
- *
- * To determine how many terms needed, let
- * Q(0) = w, Q(1) = w(w+h) - 1,
- * Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
- * When Q(k) > 1e4 good for single
- * When Q(k) > 1e9 good for double
- * When Q(k) > 1e17 good for quadruple
- */
- /* determine k */
- double t,q0,q1,w,h,z,tmp,nf;
- int k;
-
- nf = nm1 + 1.0;
- w = 2*nf/x;
- h = 2/x;
- z = w+h;
- q0 = w;
- q1 = w*z - 1.0;
- k = 1;
- while (q1 < 1.0e9) {
- k += 1;
- z += h;
- tmp = z*q1 - q0;
- q0 = q1;
- q1 = tmp;
- }
- for (t=0.0, i=k; i>=0; i--)
- t = 1/(2*(i+nf)/x - t);
- a = t;
- b = 1.0;
- /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
- * Hence, if n*(log(2n/x)) > ...
- * single 8.8722839355e+01
- * double 7.09782712893383973096e+02
- * long double 1.1356523406294143949491931077970765006170e+04
- * then recurrent value may overflow and the result is
- * likely underflow to zero
- */
- tmp = nf*log(fabs(w));
- if (tmp < 7.09782712893383973096e+02) {
- for (i=nm1; i>0; i--) {
- temp = b;
- b = b*(2.0*i)/x - a;
- a = temp;
- }
- } else {
- for (i=nm1; i>0; i--) {
- temp = b;
- b = b*(2.0*i)/x - a;
- a = temp;
- /* scale b to avoid spurious overflow */
- if (b > 0x1p500) {
- a /= b;
- t /= b;
- b = 1.0;
- }
- }
- }
- z = j0(x);
- w = j1(x);
- if (fabs(z) >= fabs(w))
- b = t*z/b;
- else
- b = t*w/a;
- }
- }
- return sign ? -b : b;
-}
-
-
-double yn(int n, double x)
-{
- uint32_t ix, lx, ib;
- int nm1, sign, i;
- double a, b, temp;
-
- EXTRACT_WORDS(ix, lx, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
-
- if ((ix | (lx|-lx)>>31) > 0x7ff00000) /* nan */
- return x;
- if (sign && (ix|lx)!=0) /* x < 0 */
- return 0/0.0;
- if (ix == 0x7ff00000)
- return 0.0;
-
- if (n == 0)
- return y0(x);
- if (n < 0) {
- nm1 = -(n+1);
- sign = n&1;
- } else {
- nm1 = n-1;
- sign = 0;
- }
- if (nm1 == 0)
- return sign ? -y1(x) : y1(x);
-
- if (ix >= 0x52d00000) { /* x > 2**302 */
- /* (x >> n**2)
- * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
- * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
- * Let s=sin(x), c=cos(x),
- * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
- *
- * n sin(xn)*sqt2 cos(xn)*sqt2
- * ----------------------------------
- * 0 s-c c+s
- * 1 -s-c -c+s
- * 2 -s+c -c-s
- * 3 s+c c-s
- */
- switch(nm1&3) {
- case 0: temp = -sin(x)-cos(x); break;
- case 1: temp = -sin(x)+cos(x); break;
- case 2: temp = sin(x)+cos(x); break;
- default:
- case 3: temp = sin(x)-cos(x); break;
- }
- b = invsqrtpi*temp/sqrt(x);
- } else {
- a = y0(x);
- b = y1(x);
- /* quit if b is -inf */
- GET_HIGH_WORD(ib, b);
- for (i=0; i<nm1 && ib!=0xfff00000; ){
- i++;
- temp = b;
- b = (2.0*i/x)*b - a;
- GET_HIGH_WORD(ib, b);
- a = temp;
- }
- }
- return sign ? -b : b;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/jnf.c b/lib/mlibc/options/ansi/musl-generic-math/jnf.c
deleted file mode 100644
index f63c062..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/jnf.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_jnf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#define _GNU_SOURCE
-#include "libm.h"
-
-float jnf(int n, float x)
-{
- uint32_t ix;
- int nm1, sign, i;
- float a, b, temp;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix > 0x7f800000) /* nan */
- return x;
-
- /* J(-n,x) = J(n,-x), use |n|-1 to avoid overflow in -n */
- if (n == 0)
- return j0f(x);
- if (n < 0) {
- nm1 = -(n+1);
- x = -x;
- sign ^= 1;
- } else
- nm1 = n-1;
- if (nm1 == 0)
- return j1f(x);
-
- sign &= n; /* even n: 0, odd n: signbit(x) */
- x = fabsf(x);
- if (ix == 0 || ix == 0x7f800000) /* if x is 0 or inf */
- b = 0.0f;
- else if (nm1 < x) {
- /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
- a = j0f(x);
- b = j1f(x);
- for (i=0; i<nm1; ){
- i++;
- temp = b;
- b = b*(2.0f*i/x) - a;
- a = temp;
- }
- } else {
- if (ix < 0x35800000) { /* x < 2**-20 */
- /* x is tiny, return the first Taylor expansion of J(n,x)
- * J(n,x) = 1/n!*(x/2)^n - ...
- */
- if (nm1 > 8) /* underflow */
- nm1 = 8;
- temp = 0.5f * x;
- b = temp;
- a = 1.0f;
- for (i=2; i<=nm1+1; i++) {
- a *= (float)i; /* a = n! */
- b *= temp; /* b = (x/2)^n */
- }
- b = b/a;
- } else {
- /* use backward recurrence */
- /* x x^2 x^2
- * J(n,x)/J(n-1,x) = ---- ------ ------ .....
- * 2n - 2(n+1) - 2(n+2)
- *
- * 1 1 1
- * (for large x) = ---- ------ ------ .....
- * 2n 2(n+1) 2(n+2)
- * -- - ------ - ------ -
- * x x x
- *
- * Let w = 2n/x and h=2/x, then the above quotient
- * is equal to the continued fraction:
- * 1
- * = -----------------------
- * 1
- * w - -----------------
- * 1
- * w+h - ---------
- * w+2h - ...
- *
- * To determine how many terms needed, let
- * Q(0) = w, Q(1) = w(w+h) - 1,
- * Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
- * When Q(k) > 1e4 good for single
- * When Q(k) > 1e9 good for double
- * When Q(k) > 1e17 good for quadruple
- */
- /* determine k */
- float t,q0,q1,w,h,z,tmp,nf;
- int k;
-
- nf = nm1+1.0f;
- w = 2*nf/x;
- h = 2/x;
- z = w+h;
- q0 = w;
- q1 = w*z - 1.0f;
- k = 1;
- while (q1 < 1.0e4f) {
- k += 1;
- z += h;
- tmp = z*q1 - q0;
- q0 = q1;
- q1 = tmp;
- }
- for (t=0.0f, i=k; i>=0; i--)
- t = 1.0f/(2*(i+nf)/x-t);
- a = t;
- b = 1.0f;
- /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
- * Hence, if n*(log(2n/x)) > ...
- * single 8.8722839355e+01
- * double 7.09782712893383973096e+02
- * long double 1.1356523406294143949491931077970765006170e+04
- * then recurrent value may overflow and the result is
- * likely underflow to zero
- */
- tmp = nf*logf(fabsf(w));
- if (tmp < 88.721679688f) {
- for (i=nm1; i>0; i--) {
- temp = b;
- b = 2.0f*i*b/x - a;
- a = temp;
- }
- } else {
- for (i=nm1; i>0; i--){
- temp = b;
- b = 2.0f*i*b/x - a;
- a = temp;
- /* scale b to avoid spurious overflow */
- if (b > 0x1p60f) {
- a /= b;
- t /= b;
- b = 1.0f;
- }
- }
- }
- z = j0f(x);
- w = j1f(x);
- if (fabsf(z) >= fabsf(w))
- b = t*z/b;
- else
- b = t*w/a;
- }
- }
- return sign ? -b : b;
-}
-
-float ynf(int n, float x)
-{
- uint32_t ix, ib;
- int nm1, sign, i;
- float a, b, temp;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix>>31;
- ix &= 0x7fffffff;
- if (ix > 0x7f800000) /* nan */
- return x;
- if (sign && ix != 0) /* x < 0 */
- return 0/0.0f;
- if (ix == 0x7f800000)
- return 0.0f;
-
- if (n == 0)
- return y0f(x);
- if (n < 0) {
- nm1 = -(n+1);
- sign = n&1;
- } else {
- nm1 = n-1;
- sign = 0;
- }
- if (nm1 == 0)
- return sign ? -y1f(x) : y1f(x);
-
- a = y0f(x);
- b = y1f(x);
- /* quit if b is -inf */
- GET_FLOAT_WORD(ib,b);
- for (i = 0; i < nm1 && ib != 0xff800000; ) {
- i++;
- temp = b;
- b = (2.0f*i/x)*b - a;
- GET_FLOAT_WORD(ib, b);
- a = temp;
- }
- return sign ? -b : b;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ldexp.c b/lib/mlibc/options/ansi/musl-generic-math/ldexp.c
deleted file mode 100644
index f4d1cd6..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ldexp.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-double ldexp(double x, int n)
-{
- return scalbn(x, n);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ldexpf.c b/lib/mlibc/options/ansi/musl-generic-math/ldexpf.c
deleted file mode 100644
index 3bad5f3..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ldexpf.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-float ldexpf(float x, int n)
-{
- return scalbnf(x, n);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/ldexpl.c b/lib/mlibc/options/ansi/musl-generic-math/ldexpl.c
deleted file mode 100644
index fd145cc..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/ldexpl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long double ldexpl(long double x, int n)
-{
- return scalbnl(x, n);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lgamma.c b/lib/mlibc/options/ansi/musl-generic-math/lgamma.c
deleted file mode 100644
index e25ec8e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lgamma.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-
-extern int __signgam;
-double __lgamma_r(double, int *);
-
-double lgamma(double x)
-{
- return __lgamma_r(x, &__signgam);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lgamma_r.c b/lib/mlibc/options/ansi/musl-generic-math/lgamma_r.c
deleted file mode 100644
index 84596a3..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lgamma_r.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_lgamma_r.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-/* lgamma_r(x, signgamp)
- * Reentrant version of the logarithm of the Gamma function
- * with user provide pointer for the sign of Gamma(x).
- *
- * Method:
- * 1. Argument Reduction for 0 < x <= 8
- * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
- * reduce x to a number in [1.5,2.5] by
- * lgamma(1+s) = log(s) + lgamma(s)
- * for example,
- * lgamma(7.3) = log(6.3) + lgamma(6.3)
- * = log(6.3*5.3) + lgamma(5.3)
- * = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)
- * 2. Polynomial approximation of lgamma around its
- * minimun ymin=1.461632144968362245 to maintain monotonicity.
- * On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
- * Let z = x-ymin;
- * lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
- * where
- * poly(z) is a 14 degree polynomial.
- * 2. Rational approximation in the primary interval [2,3]
- * We use the following approximation:
- * s = x-2.0;
- * lgamma(x) = 0.5*s + s*P(s)/Q(s)
- * with accuracy
- * |P/Q - (lgamma(x)-0.5s)| < 2**-61.71
- * Our algorithms are based on the following observation
- *
- * zeta(2)-1 2 zeta(3)-1 3
- * lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ...
- * 2 3
- *
- * where Euler = 0.5771... is the Euler constant, which is very
- * close to 0.5.
- *
- * 3. For x>=8, we have
- * lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
- * (better formula:
- * lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
- * Let z = 1/x, then we approximation
- * f(z) = lgamma(x) - (x-0.5)(log(x)-1)
- * by
- * 3 5 11
- * w = w0 + w1*z + w2*z + w3*z + ... + w6*z
- * where
- * |w - f(z)| < 2**-58.74
- *
- * 4. For negative x, since (G is gamma function)
- * -x*G(-x)*G(x) = pi/sin(pi*x),
- * we have
- * G(x) = pi/(sin(pi*x)*(-x)*G(-x))
- * since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
- * Hence, for x<0, signgam = sign(sin(pi*x)) and
- * lgamma(x) = log(|Gamma(x)|)
- * = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
- * Note: one should avoid compute pi*(-x) directly in the
- * computation of sin(pi*(-x)).
- *
- * 5. Special Cases
- * lgamma(2+s) ~ s*(1-Euler) for tiny s
- * lgamma(1) = lgamma(2) = 0
- * lgamma(x) ~ -log(|x|) for tiny x
- * lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero
- * lgamma(inf) = inf
- * lgamma(-inf) = inf (bug for bug compatible with C99!?)
- *
- */
-
-#include "libm.h"
-#include "weak_alias.h"
-//#include "libc.h"
-
-static const double
-pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
-a0 = 7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */
-a1 = 3.22467033424113591611e-01, /* 0x3FD4A34C, 0xC4A60FAD */
-a2 = 6.73523010531292681824e-02, /* 0x3FB13E00, 0x1A5562A7 */
-a3 = 2.05808084325167332806e-02, /* 0x3F951322, 0xAC92547B */
-a4 = 7.38555086081402883957e-03, /* 0x3F7E404F, 0xB68FEFE8 */
-a5 = 2.89051383673415629091e-03, /* 0x3F67ADD8, 0xCCB7926B */
-a6 = 1.19270763183362067845e-03, /* 0x3F538A94, 0x116F3F5D */
-a7 = 5.10069792153511336608e-04, /* 0x3F40B6C6, 0x89B99C00 */
-a8 = 2.20862790713908385557e-04, /* 0x3F2CF2EC, 0xED10E54D */
-a9 = 1.08011567247583939954e-04, /* 0x3F1C5088, 0x987DFB07 */
-a10 = 2.52144565451257326939e-05, /* 0x3EFA7074, 0x428CFA52 */
-a11 = 4.48640949618915160150e-05, /* 0x3F07858E, 0x90A45837 */
-tc = 1.46163214496836224576e+00, /* 0x3FF762D8, 0x6356BE3F */
-tf = -1.21486290535849611461e-01, /* 0xBFBF19B9, 0xBCC38A42 */
-/* tt = -(tail of tf) */
-tt = -3.63867699703950536541e-18, /* 0xBC50C7CA, 0xA48A971F */
-t0 = 4.83836122723810047042e-01, /* 0x3FDEF72B, 0xC8EE38A2 */
-t1 = -1.47587722994593911752e-01, /* 0xBFC2E427, 0x8DC6C509 */
-t2 = 6.46249402391333854778e-02, /* 0x3FB08B42, 0x94D5419B */
-t3 = -3.27885410759859649565e-02, /* 0xBFA0C9A8, 0xDF35B713 */
-t4 = 1.79706750811820387126e-02, /* 0x3F9266E7, 0x970AF9EC */
-t5 = -1.03142241298341437450e-02, /* 0xBF851F9F, 0xBA91EC6A */
-t6 = 6.10053870246291332635e-03, /* 0x3F78FCE0, 0xE370E344 */
-t7 = -3.68452016781138256760e-03, /* 0xBF6E2EFF, 0xB3E914D7 */
-t8 = 2.25964780900612472250e-03, /* 0x3F6282D3, 0x2E15C915 */
-t9 = -1.40346469989232843813e-03, /* 0xBF56FE8E, 0xBF2D1AF1 */
-t10 = 8.81081882437654011382e-04, /* 0x3F4CDF0C, 0xEF61A8E9 */
-t11 = -5.38595305356740546715e-04, /* 0xBF41A610, 0x9C73E0EC */
-t12 = 3.15632070903625950361e-04, /* 0x3F34AF6D, 0x6C0EBBF7 */
-t13 = -3.12754168375120860518e-04, /* 0xBF347F24, 0xECC38C38 */
-t14 = 3.35529192635519073543e-04, /* 0x3F35FD3E, 0xE8C2D3F4 */
-u0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
-u1 = 6.32827064025093366517e-01, /* 0x3FE4401E, 0x8B005DFF */
-u2 = 1.45492250137234768737e+00, /* 0x3FF7475C, 0xD119BD6F */
-u3 = 9.77717527963372745603e-01, /* 0x3FEF4976, 0x44EA8450 */
-u4 = 2.28963728064692451092e-01, /* 0x3FCD4EAE, 0xF6010924 */
-u5 = 1.33810918536787660377e-02, /* 0x3F8B678B, 0xBF2BAB09 */
-v1 = 2.45597793713041134822e+00, /* 0x4003A5D7, 0xC2BD619C */
-v2 = 2.12848976379893395361e+00, /* 0x40010725, 0xA42B18F5 */
-v3 = 7.69285150456672783825e-01, /* 0x3FE89DFB, 0xE45050AF */
-v4 = 1.04222645593369134254e-01, /* 0x3FBAAE55, 0xD6537C88 */
-v5 = 3.21709242282423911810e-03, /* 0x3F6A5ABB, 0x57D0CF61 */
-s0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
-s1 = 2.14982415960608852501e-01, /* 0x3FCB848B, 0x36E20878 */
-s2 = 3.25778796408930981787e-01, /* 0x3FD4D98F, 0x4F139F59 */
-s3 = 1.46350472652464452805e-01, /* 0x3FC2BB9C, 0xBEE5F2F7 */
-s4 = 2.66422703033638609560e-02, /* 0x3F9B481C, 0x7E939961 */
-s5 = 1.84028451407337715652e-03, /* 0x3F5E26B6, 0x7368F239 */
-s6 = 3.19475326584100867617e-05, /* 0x3F00BFEC, 0xDD17E945 */
-r1 = 1.39200533467621045958e+00, /* 0x3FF645A7, 0x62C4AB74 */
-r2 = 7.21935547567138069525e-01, /* 0x3FE71A18, 0x93D3DCDC */
-r3 = 1.71933865632803078993e-01, /* 0x3FC601ED, 0xCCFBDF27 */
-r4 = 1.86459191715652901344e-02, /* 0x3F9317EA, 0x742ED475 */
-r5 = 7.77942496381893596434e-04, /* 0x3F497DDA, 0xCA41A95B */
-r6 = 7.32668430744625636189e-06, /* 0x3EDEBAF7, 0xA5B38140 */
-w0 = 4.18938533204672725052e-01, /* 0x3FDACFE3, 0x90C97D69 */
-w1 = 8.33333333333329678849e-02, /* 0x3FB55555, 0x5555553B */
-w2 = -2.77777777728775536470e-03, /* 0xBF66C16C, 0x16B02E5C */
-w3 = 7.93650558643019558500e-04, /* 0x3F4A019F, 0x98CF38B6 */
-w4 = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */
-w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */
-w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
-
-/* sin(pi*x) assuming x > 2^-100, if sin(pi*x)==0 the sign is arbitrary */
-static double sin_pi(double x)
-{
- int n;
-
- /* spurious inexact if odd int */
- x = 2.0*(x*0.5 - floor(x*0.5)); /* x mod 2.0 */
-
- n = (int)(x*4.0);
- n = (n+1)/2;
- x -= n*0.5f;
- x *= pi;
-
- switch (n) {
- default: /* case 4: */
- case 0: return __sin(x, 0.0, 0);
- case 1: return __cos(x, 0.0);
- case 2: return __sin(-x, 0.0, 0);
- case 3: return -__cos(x, 0.0);
- }
-}
-
-double __lgamma_r(double x, int *signgamp)
-{
- union {double f; uint64_t i;} u = {x};
- double_t t,y,z,nadj,p,p1,p2,p3,q,r,w;
- uint32_t ix;
- int sign,i;
-
- /* purge off +-inf, NaN, +-0, tiny and negative arguments */
- *signgamp = 1;
- sign = u.i>>63;
- ix = u.i>>32 & 0x7fffffff;
- if (ix >= 0x7ff00000)
- return x*x;
- if (ix < (0x3ff-70)<<20) { /* |x|<2**-70, return -log(|x|) */
- if(sign) {
- x = -x;
- *signgamp = -1;
- }
- return -log(x);
- }
- if (sign) {
- x = -x;
- t = sin_pi(x);
- if (t == 0.0) /* -integer */
- return 1.0/(x-x);
- if (t > 0.0)
- *signgamp = -1;
- else
- t = -t;
- nadj = log(pi/(t*x));
- }
-
- /* purge off 1 and 2 */
- if ((ix == 0x3ff00000 || ix == 0x40000000) && (uint32_t)u.i == 0)
- r = 0;
- /* for x < 2.0 */
- else if (ix < 0x40000000) {
- if (ix <= 0x3feccccc) { /* lgamma(x) = lgamma(x+1)-log(x) */
- r = -log(x);
- if (ix >= 0x3FE76944) {
- y = 1.0 - x;
- i = 0;
- } else if (ix >= 0x3FCDA661) {
- y = x - (tc-1.0);
- i = 1;
- } else {
- y = x;
- i = 2;
- }
- } else {
- r = 0.0;
- if (ix >= 0x3FFBB4C3) { /* [1.7316,2] */
- y = 2.0 - x;
- i = 0;
- } else if(ix >= 0x3FF3B4C4) { /* [1.23,1.73] */
- y = x - tc;
- i = 1;
- } else {
- y = x - 1.0;
- i = 2;
- }
- }
- switch (i) {
- case 0:
- z = y*y;
- p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
- p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
- p = y*p1+p2;
- r += (p-0.5*y);
- break;
- case 1:
- z = y*y;
- w = z*y;
- p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */
- p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
- p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
- p = z*p1-(tt-w*(p2+y*p3));
- r += tf + p;
- break;
- case 2:
- p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
- p2 = 1.0+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
- r += -0.5*y + p1/p2;
- }
- } else if (ix < 0x40200000) { /* x < 8.0 */
- i = (int)x;
- y = x - (double)i;
- p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
- q = 1.0+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
- r = 0.5*y+p/q;
- z = 1.0; /* lgamma(1+s) = log(s) + lgamma(s) */
- switch (i) {
- case 7: z *= y + 6.0; /* FALLTHRU */
- case 6: z *= y + 5.0; /* FALLTHRU */
- case 5: z *= y + 4.0; /* FALLTHRU */
- case 4: z *= y + 3.0; /* FALLTHRU */
- case 3: z *= y + 2.0; /* FALLTHRU */
- r += log(z);
- break;
- }
- } else if (ix < 0x43900000) { /* 8.0 <= x < 2**58 */
- t = log(x);
- z = 1.0/x;
- y = z*z;
- w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
- r = (x-0.5)*(t-1.0)+w;
- } else /* 2**58 <= x <= inf */
- r = x*(log(x)-1.0);
- if (sign)
- r = nadj - r;
- return r;
-}
-
-weak_alias(__lgamma_r, lgamma_r);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lgammaf.c b/lib/mlibc/options/ansi/musl-generic-math/lgammaf.c
deleted file mode 100644
index badb6df..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lgammaf.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-
-extern int __signgam;
-float __lgammaf_r(float, int *);
-
-float lgammaf(float x)
-{
- return __lgammaf_r(x, &__signgam);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lgammaf_r.c b/lib/mlibc/options/ansi/musl-generic-math/lgammaf_r.c
deleted file mode 100644
index f73e89d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lgammaf_r.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_lgammaf_r.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-#include "weak_alias.h"
-//#include "libc.h"
-
-static const float
-pi = 3.1415927410e+00, /* 0x40490fdb */
-a0 = 7.7215664089e-02, /* 0x3d9e233f */
-a1 = 3.2246702909e-01, /* 0x3ea51a66 */
-a2 = 6.7352302372e-02, /* 0x3d89f001 */
-a3 = 2.0580807701e-02, /* 0x3ca89915 */
-a4 = 7.3855509982e-03, /* 0x3bf2027e */
-a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */
-a6 = 1.1927076848e-03, /* 0x3a9c54a1 */
-a7 = 5.1006977446e-04, /* 0x3a05b634 */
-a8 = 2.2086278477e-04, /* 0x39679767 */
-a9 = 1.0801156895e-04, /* 0x38e28445 */
-a10 = 2.5214456400e-05, /* 0x37d383a2 */
-a11 = 4.4864096708e-05, /* 0x383c2c75 */
-tc = 1.4616321325e+00, /* 0x3fbb16c3 */
-tf = -1.2148628384e-01, /* 0xbdf8cdcd */
-/* tt = -(tail of tf) */
-tt = 6.6971006518e-09, /* 0x31e61c52 */
-t0 = 4.8383611441e-01, /* 0x3ef7b95e */
-t1 = -1.4758771658e-01, /* 0xbe17213c */
-t2 = 6.4624942839e-02, /* 0x3d845a15 */
-t3 = -3.2788541168e-02, /* 0xbd064d47 */
-t4 = 1.7970675603e-02, /* 0x3c93373d */
-t5 = -1.0314224288e-02, /* 0xbc28fcfe */
-t6 = 6.1005386524e-03, /* 0x3bc7e707 */
-t7 = -3.6845202558e-03, /* 0xbb7177fe */
-t8 = 2.2596477065e-03, /* 0x3b141699 */
-t9 = -1.4034647029e-03, /* 0xbab7f476 */
-t10 = 8.8108185446e-04, /* 0x3a66f867 */
-t11 = -5.3859531181e-04, /* 0xba0d3085 */
-t12 = 3.1563205994e-04, /* 0x39a57b6b */
-t13 = -3.1275415677e-04, /* 0xb9a3f927 */
-t14 = 3.3552918467e-04, /* 0x39afe9f7 */
-u0 = -7.7215664089e-02, /* 0xbd9e233f */
-u1 = 6.3282704353e-01, /* 0x3f2200f4 */
-u2 = 1.4549225569e+00, /* 0x3fba3ae7 */
-u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */
-u4 = 2.2896373272e-01, /* 0x3e6a7578 */
-u5 = 1.3381091878e-02, /* 0x3c5b3c5e */
-v1 = 2.4559779167e+00, /* 0x401d2ebe */
-v2 = 2.1284897327e+00, /* 0x4008392d */
-v3 = 7.6928514242e-01, /* 0x3f44efdf */
-v4 = 1.0422264785e-01, /* 0x3dd572af */
-v5 = 3.2170924824e-03, /* 0x3b52d5db */
-s0 = -7.7215664089e-02, /* 0xbd9e233f */
-s1 = 2.1498242021e-01, /* 0x3e5c245a */
-s2 = 3.2577878237e-01, /* 0x3ea6cc7a */
-s3 = 1.4635047317e-01, /* 0x3e15dce6 */
-s4 = 2.6642270386e-02, /* 0x3cda40e4 */
-s5 = 1.8402845599e-03, /* 0x3af135b4 */
-s6 = 3.1947532989e-05, /* 0x3805ff67 */
-r1 = 1.3920053244e+00, /* 0x3fb22d3b */
-r2 = 7.2193557024e-01, /* 0x3f38d0c5 */
-r3 = 1.7193385959e-01, /* 0x3e300f6e */
-r4 = 1.8645919859e-02, /* 0x3c98bf54 */
-r5 = 7.7794247773e-04, /* 0x3a4beed6 */
-r6 = 7.3266842264e-06, /* 0x36f5d7bd */
-w0 = 4.1893854737e-01, /* 0x3ed67f1d */
-w1 = 8.3333335817e-02, /* 0x3daaaaab */
-w2 = -2.7777778450e-03, /* 0xbb360b61 */
-w3 = 7.9365057172e-04, /* 0x3a500cfd */
-w4 = -5.9518753551e-04, /* 0xba1c065c */
-w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */
-w6 = -1.6309292987e-03; /* 0xbad5c4e8 */
-
-/* sin(pi*x) assuming x > 2^-100, if sin(pi*x)==0 the sign is arbitrary */
-static float sin_pi(float x)
-{
- double_t y;
- int n;
-
- /* spurious inexact if odd int */
- x = 2*(x*0.5f - floorf(x*0.5f)); /* x mod 2.0 */
-
- n = (int)(x*4);
- n = (n+1)/2;
- y = x - n*0.5f;
- y *= 3.14159265358979323846;
- switch (n) {
- default: /* case 4: */
- case 0: return __sindf(y);
- case 1: return __cosdf(y);
- case 2: return __sindf(-y);
- case 3: return -__cosdf(y);
- }
-}
-
-float __lgammaf_r(float x, int *signgamp)
-{
- union {float f; uint32_t i;} u = {x};
- float t,y,z,nadj,p,p1,p2,p3,q,r,w;
- uint32_t ix;
- int i,sign;
-
- /* purge off +-inf, NaN, +-0, tiny and negative arguments */
- *signgamp = 1;
- sign = u.i>>31;
- ix = u.i & 0x7fffffff;
- if (ix >= 0x7f800000)
- return x*x;
- if (ix < 0x35000000) { /* |x| < 2**-21, return -log(|x|) */
- if (sign) {
- *signgamp = -1;
- x = -x;
- }
- return -logf(x);
- }
- if (sign) {
- x = -x;
- t = sin_pi(x);
- if (t == 0.0f) /* -integer */
- return 1.0f/(x-x);
- if (t > 0.0f)
- *signgamp = -1;
- else
- t = -t;
- nadj = logf(pi/(t*x));
- }
-
- /* purge off 1 and 2 */
- if (ix == 0x3f800000 || ix == 0x40000000)
- r = 0;
- /* for x < 2.0 */
- else if (ix < 0x40000000) {
- if (ix <= 0x3f666666) { /* lgamma(x) = lgamma(x+1)-log(x) */
- r = -logf(x);
- if (ix >= 0x3f3b4a20) {
- y = 1.0f - x;
- i = 0;
- } else if (ix >= 0x3e6d3308) {
- y = x - (tc-1.0f);
- i = 1;
- } else {
- y = x;
- i = 2;
- }
- } else {
- r = 0.0f;
- if (ix >= 0x3fdda618) { /* [1.7316,2] */
- y = 2.0f - x;
- i = 0;
- } else if (ix >= 0x3F9da620) { /* [1.23,1.73] */
- y = x - tc;
- i = 1;
- } else {
- y = x - 1.0f;
- i = 2;
- }
- }
- switch(i) {
- case 0:
- z = y*y;
- p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
- p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
- p = y*p1+p2;
- r += p - 0.5f*y;
- break;
- case 1:
- z = y*y;
- w = z*y;
- p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */
- p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
- p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
- p = z*p1-(tt-w*(p2+y*p3));
- r += (tf + p);
- break;
- case 2:
- p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
- p2 = 1.0f+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
- r += -0.5f*y + p1/p2;
- }
- } else if (ix < 0x41000000) { /* x < 8.0 */
- i = (int)x;
- y = x - (float)i;
- p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
- q = 1.0f+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
- r = 0.5f*y+p/q;
- z = 1.0f; /* lgamma(1+s) = log(s) + lgamma(s) */
- switch (i) {
- case 7: z *= y + 6.0f; /* FALLTHRU */
- case 6: z *= y + 5.0f; /* FALLTHRU */
- case 5: z *= y + 4.0f; /* FALLTHRU */
- case 4: z *= y + 3.0f; /* FALLTHRU */
- case 3: z *= y + 2.0f; /* FALLTHRU */
- r += logf(z);
- break;
- }
- } else if (ix < 0x5c800000) { /* 8.0 <= x < 2**58 */
- t = logf(x);
- z = 1.0f/x;
- y = z*z;
- w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
- r = (x-0.5f)*(t-1.0f)+w;
- } else /* 2**58 <= x <= inf */
- r = x*(logf(x)-1.0f);
- if (sign)
- r = nadj - r;
- return r;
-}
-
-weak_alias(__lgammaf_r, lgammaf_r);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lgammal.c b/lib/mlibc/options/ansi/musl-generic-math/lgammal.c
deleted file mode 100644
index f0bea36..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lgammal.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_lgammal.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* lgammal(x)
- * Reentrant version of the logarithm of the Gamma function
- * with user provide pointer for the sign of Gamma(x).
- *
- * Method:
- * 1. Argument Reduction for 0 < x <= 8
- * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
- * reduce x to a number in [1.5,2.5] by
- * lgamma(1+s) = log(s) + lgamma(s)
- * for example,
- * lgamma(7.3) = log(6.3) + lgamma(6.3)
- * = log(6.3*5.3) + lgamma(5.3)
- * = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)
- * 2. Polynomial approximation of lgamma around its
- * minimun ymin=1.461632144968362245 to maintain monotonicity.
- * On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
- * Let z = x-ymin;
- * lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
- * 2. Rational approximation in the primary interval [2,3]
- * We use the following approximation:
- * s = x-2.0;
- * lgamma(x) = 0.5*s + s*P(s)/Q(s)
- * Our algorithms are based on the following observation
- *
- * zeta(2)-1 2 zeta(3)-1 3
- * lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ...
- * 2 3
- *
- * where Euler = 0.5771... is the Euler constant, which is very
- * close to 0.5.
- *
- * 3. For x>=8, we have
- * lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
- * (better formula:
- * lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
- * Let z = 1/x, then we approximation
- * f(z) = lgamma(x) - (x-0.5)(log(x)-1)
- * by
- * 3 5 11
- * w = w0 + w1*z + w2*z + w3*z + ... + w6*z
- *
- * 4. For negative x, since (G is gamma function)
- * -x*G(-x)*G(x) = pi/sin(pi*x),
- * we have
- * G(x) = pi/(sin(pi*x)*(-x)*G(-x))
- * since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
- * Hence, for x<0, signgam = sign(sin(pi*x)) and
- * lgamma(x) = log(|Gamma(x)|)
- * = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
- * Note: one should avoid compute pi*(-x) directly in the
- * computation of sin(pi*(-x)).
- *
- * 5. Special Cases
- * lgamma(2+s) ~ s*(1-Euler) for tiny s
- * lgamma(1)=lgamma(2)=0
- * lgamma(x) ~ -log(x) for tiny x
- * lgamma(0) = lgamma(inf) = inf
- * lgamma(-integer) = +-inf
- *
- */
-
-#define _GNU_SOURCE
-#include "libm.h"
-#include "weak_alias.h"
-//#include "libc.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-double __lgamma_r(double x, int *sg);
-
-long double __lgammal_r(long double x, int *sg)
-{
- return __lgamma_r(x, sg);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-static const long double
-pi = 3.14159265358979323846264L,
-
-/* lgam(1+x) = 0.5 x + x a(x)/b(x)
- -0.268402099609375 <= x <= 0
- peak relative error 6.6e-22 */
-a0 = -6.343246574721079391729402781192128239938E2L,
-a1 = 1.856560238672465796768677717168371401378E3L,
-a2 = 2.404733102163746263689288466865843408429E3L,
-a3 = 8.804188795790383497379532868917517596322E2L,
-a4 = 1.135361354097447729740103745999661157426E2L,
-a5 = 3.766956539107615557608581581190400021285E0L,
-
-b0 = 8.214973713960928795704317259806842490498E3L,
-b1 = 1.026343508841367384879065363925870888012E4L,
-b2 = 4.553337477045763320522762343132210919277E3L,
-b3 = 8.506975785032585797446253359230031874803E2L,
-b4 = 6.042447899703295436820744186992189445813E1L,
-/* b5 = 1.000000000000000000000000000000000000000E0 */
-
-
-tc = 1.4616321449683623412626595423257213284682E0L,
-tf = -1.2148629053584961146050602565082954242826E-1, /* double precision */
-/* tt = (tail of tf), i.e. tf + tt has extended precision. */
-tt = 3.3649914684731379602768989080467587736363E-18L,
-/* lgam ( 1.4616321449683623412626595423257213284682E0 ) =
--1.2148629053584960809551455717769158215135617312999903886372437313313530E-1 */
-
-/* lgam (x + tc) = tf + tt + x g(x)/h(x)
- -0.230003726999612341262659542325721328468 <= x
- <= 0.2699962730003876587373404576742786715318
- peak relative error 2.1e-21 */
-g0 = 3.645529916721223331888305293534095553827E-18L,
-g1 = 5.126654642791082497002594216163574795690E3L,
-g2 = 8.828603575854624811911631336122070070327E3L,
-g3 = 5.464186426932117031234820886525701595203E3L,
-g4 = 1.455427403530884193180776558102868592293E3L,
-g5 = 1.541735456969245924860307497029155838446E2L,
-g6 = 4.335498275274822298341872707453445815118E0L,
-
-h0 = 1.059584930106085509696730443974495979641E4L,
-h1 = 2.147921653490043010629481226937850618860E4L,
-h2 = 1.643014770044524804175197151958100656728E4L,
-h3 = 5.869021995186925517228323497501767586078E3L,
-h4 = 9.764244777714344488787381271643502742293E2L,
-h5 = 6.442485441570592541741092969581997002349E1L,
-/* h6 = 1.000000000000000000000000000000000000000E0 */
-
-
-/* lgam (x+1) = -0.5 x + x u(x)/v(x)
- -0.100006103515625 <= x <= 0.231639862060546875
- peak relative error 1.3e-21 */
-u0 = -8.886217500092090678492242071879342025627E1L,
-u1 = 6.840109978129177639438792958320783599310E2L,
-u2 = 2.042626104514127267855588786511809932433E3L,
-u3 = 1.911723903442667422201651063009856064275E3L,
-u4 = 7.447065275665887457628865263491667767695E2L,
-u5 = 1.132256494121790736268471016493103952637E2L,
-u6 = 4.484398885516614191003094714505960972894E0L,
-
-v0 = 1.150830924194461522996462401210374632929E3L,
-v1 = 3.399692260848747447377972081399737098610E3L,
-v2 = 3.786631705644460255229513563657226008015E3L,
-v3 = 1.966450123004478374557778781564114347876E3L,
-v4 = 4.741359068914069299837355438370682773122E2L,
-v5 = 4.508989649747184050907206782117647852364E1L,
-/* v6 = 1.000000000000000000000000000000000000000E0 */
-
-
-/* lgam (x+2) = .5 x + x s(x)/r(x)
- 0 <= x <= 1
- peak relative error 7.2e-22 */
-s0 = 1.454726263410661942989109455292824853344E6L,
-s1 = -3.901428390086348447890408306153378922752E6L,
-s2 = -6.573568698209374121847873064292963089438E6L,
-s3 = -3.319055881485044417245964508099095984643E6L,
-s4 = -7.094891568758439227560184618114707107977E5L,
-s5 = -6.263426646464505837422314539808112478303E4L,
-s6 = -1.684926520999477529949915657519454051529E3L,
-
-r0 = -1.883978160734303518163008696712983134698E7L,
-r1 = -2.815206082812062064902202753264922306830E7L,
-r2 = -1.600245495251915899081846093343626358398E7L,
-r3 = -4.310526301881305003489257052083370058799E6L,
-r4 = -5.563807682263923279438235987186184968542E5L,
-r5 = -3.027734654434169996032905158145259713083E4L,
-r6 = -4.501995652861105629217250715790764371267E2L,
-/* r6 = 1.000000000000000000000000000000000000000E0 */
-
-
-/* lgam(x) = ( x - 0.5 ) * log(x) - x + LS2PI + 1/x w(1/x^2)
- x >= 8
- Peak relative error 1.51e-21
-w0 = LS2PI - 0.5 */
-w0 = 4.189385332046727417803e-1L,
-w1 = 8.333333333333331447505E-2L,
-w2 = -2.777777777750349603440E-3L,
-w3 = 7.936507795855070755671E-4L,
-w4 = -5.952345851765688514613E-4L,
-w5 = 8.412723297322498080632E-4L,
-w6 = -1.880801938119376907179E-3L,
-w7 = 4.885026142432270781165E-3L;
-
-/* sin(pi*x) assuming x > 2^-1000, if sin(pi*x)==0 the sign is arbitrary */
-static long double sin_pi(long double x)
-{
- int n;
-
- /* spurious inexact if odd int */
- x *= 0.5;
- x = 2.0*(x - floorl(x)); /* x mod 2.0 */
-
- n = (int)(x*4.0);
- n = (n+1)/2;
- x -= n*0.5f;
- x *= pi;
-
- switch (n) {
- default: /* case 4: */
- case 0: return __sinl(x, 0.0, 0);
- case 1: return __cosl(x, 0.0);
- case 2: return __sinl(-x, 0.0, 0);
- case 3: return -__cosl(x, 0.0);
- }
-}
-
-long double __lgammal_r(long double x, int *sg) {
- long double t, y, z, nadj, p, p1, p2, q, r, w;
- union ldshape u = {x};
- uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
- int sign = u.i.se >> 15;
- int i;
-
- *sg = 1;
-
- /* purge off +-inf, NaN, +-0, tiny and negative arguments */
- if (ix >= 0x7fff0000)
- return x * x;
- if (ix < 0x3fc08000) { /* |x|<2**-63, return -log(|x|) */
- if (sign) {
- *sg = -1;
- x = -x;
- }
- return -logl(x);
- }
- if (sign) {
- x = -x;
- t = sin_pi(x);
- if (t == 0.0)
- return 1.0 / (x-x); /* -integer */
- if (t > 0.0)
- *sg = -1;
- else
- t = -t;
- nadj = logl(pi / (t * x));
- }
-
- /* purge off 1 and 2 (so the sign is ok with downward rounding) */
- if ((ix == 0x3fff8000 || ix == 0x40008000) && u.i.m == 0) {
- r = 0;
- } else if (ix < 0x40008000) { /* x < 2.0 */
- if (ix <= 0x3ffee666) { /* 8.99993896484375e-1 */
- /* lgamma(x) = lgamma(x+1) - log(x) */
- r = -logl(x);
- if (ix >= 0x3ffebb4a) { /* 7.31597900390625e-1 */
- y = x - 1.0;
- i = 0;
- } else if (ix >= 0x3ffced33) { /* 2.31639862060546875e-1 */
- y = x - (tc - 1.0);
- i = 1;
- } else { /* x < 0.23 */
- y = x;
- i = 2;
- }
- } else {
- r = 0.0;
- if (ix >= 0x3fffdda6) { /* 1.73162841796875 */
- /* [1.7316,2] */
- y = x - 2.0;
- i = 0;
- } else if (ix >= 0x3fff9da6) { /* 1.23162841796875 */
- /* [1.23,1.73] */
- y = x - tc;
- i = 1;
- } else {
- /* [0.9, 1.23] */
- y = x - 1.0;
- i = 2;
- }
- }
- switch (i) {
- case 0:
- p1 = a0 + y * (a1 + y * (a2 + y * (a3 + y * (a4 + y * a5))));
- p2 = b0 + y * (b1 + y * (b2 + y * (b3 + y * (b4 + y))));
- r += 0.5 * y + y * p1/p2;
- break;
- case 1:
- p1 = g0 + y * (g1 + y * (g2 + y * (g3 + y * (g4 + y * (g5 + y * g6)))));
- p2 = h0 + y * (h1 + y * (h2 + y * (h3 + y * (h4 + y * (h5 + y)))));
- p = tt + y * p1/p2;
- r += (tf + p);
- break;
- case 2:
- p1 = y * (u0 + y * (u1 + y * (u2 + y * (u3 + y * (u4 + y * (u5 + y * u6))))));
- p2 = v0 + y * (v1 + y * (v2 + y * (v3 + y * (v4 + y * (v5 + y)))));
- r += (-0.5 * y + p1 / p2);
- }
- } else if (ix < 0x40028000) { /* 8.0 */
- /* x < 8.0 */
- i = (int)x;
- y = x - (double)i;
- p = y * (s0 + y * (s1 + y * (s2 + y * (s3 + y * (s4 + y * (s5 + y * s6))))));
- q = r0 + y * (r1 + y * (r2 + y * (r3 + y * (r4 + y * (r5 + y * (r6 + y))))));
- r = 0.5 * y + p / q;
- z = 1.0;
- /* lgamma(1+s) = log(s) + lgamma(s) */
- switch (i) {
- case 7:
- z *= (y + 6.0); /* FALLTHRU */
- case 6:
- z *= (y + 5.0); /* FALLTHRU */
- case 5:
- z *= (y + 4.0); /* FALLTHRU */
- case 4:
- z *= (y + 3.0); /* FALLTHRU */
- case 3:
- z *= (y + 2.0); /* FALLTHRU */
- r += logl(z);
- break;
- }
- } else if (ix < 0x40418000) { /* 2^66 */
- /* 8.0 <= x < 2**66 */
- t = logl(x);
- z = 1.0 / x;
- y = z * z;
- w = w0 + z * (w1 + y * (w2 + y * (w3 + y * (w4 + y * (w5 + y * (w6 + y * w7))))));
- r = (x - 0.5) * (t - 1.0) + w;
- } else /* 2**66 <= x <= inf */
- r = x * (logl(x) - 1.0);
- if (sign)
- r = nadj - r;
- return r;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-double __lgamma_r(double x, int *sg);
-
-long double __lgammal_r(long double x, int *sg)
-{
- return __lgamma_r(x, sg);
-}
-#endif
-
-extern int __signgam;
-
-long double lgammal(long double x)
-{
- return __lgammal_r(x, &__signgam);
-}
-
-weak_alias(__lgammal_r, lgammal_r);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/libm.h b/lib/mlibc/options/ansi/musl-generic-math/libm.h
deleted file mode 100644
index 8120292..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/libm.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#ifndef _LIBM_H
-#define _LIBM_H
-
-#include <stdint.h>
-#include <float.h>
-#include <math.h>
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
-union ldshape {
- long double f;
- struct {
- uint64_t m;
- uint16_t se;
- } i;
-};
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
-union ldshape {
- long double f;
- struct {
- uint64_t lo;
- uint32_t mid;
- uint16_t top;
- uint16_t se;
- } i;
- struct {
- uint64_t lo;
- uint64_t hi;
- } i2;
-};
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
-union ldshape {
- long double f;
- struct {
- uint16_t se;
- uint16_t top;
- uint32_t mid;
- uint64_t lo;
- } i;
- struct {
- uint64_t hi;
- uint64_t lo;
- } i2;
-};
-#else
-#error Unsupported long double representation
-#endif
-
-#define FORCE_EVAL(x) do { \
- if (sizeof(x) == sizeof(float)) { \
- volatile float __x; \
- __x = (x); \
- } else if (sizeof(x) == sizeof(double)) { \
- volatile double __x; \
- __x = (x); \
- } else { \
- volatile long double __x; \
- __x = (x); \
- } \
-} while(0)
-
-/* Get two 32 bit ints from a double. */
-#define EXTRACT_WORDS(hi,lo,d) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.f = (d); \
- (hi) = __u.i >> 32; \
- (lo) = (uint32_t)__u.i; \
-} while (0)
-
-/* Get the more significant 32 bit int from a double. */
-#define GET_HIGH_WORD(hi,d) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.f = (d); \
- (hi) = __u.i >> 32; \
-} while (0)
-
-/* Get the less significant 32 bit int from a double. */
-#define GET_LOW_WORD(lo,d) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.f = (d); \
- (lo) = (uint32_t)__u.i; \
-} while (0)
-
-/* Set a double from two 32 bit ints. */
-#define INSERT_WORDS(d,hi,lo) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
- (d) = __u.f; \
-} while (0)
-
-/* Set the more significant 32 bits of a double from an int. */
-#define SET_HIGH_WORD(d,hi) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.f = (d); \
- __u.i &= 0xffffffff; \
- __u.i |= (uint64_t)(hi) << 32; \
- (d) = __u.f; \
-} while (0)
-
-/* Set the less significant 32 bits of a double from an int. */
-#define SET_LOW_WORD(d,lo) \
-do { \
- union {double f; uint64_t i;} __u; \
- __u.f = (d); \
- __u.i &= 0xffffffff00000000ull; \
- __u.i |= (uint32_t)(lo); \
- (d) = __u.f; \
-} while (0)
-
-/* Get a 32 bit int from a float. */
-#define GET_FLOAT_WORD(w,d) \
-do { \
- union {float f; uint32_t i;} __u; \
- __u.f = (d); \
- (w) = __u.i; \
-} while (0)
-
-/* Set a float from a 32 bit int. */
-#define SET_FLOAT_WORD(d,w) \
-do { \
- union {float f; uint32_t i;} __u; \
- __u.i = (w); \
- (d) = __u.f; \
-} while (0)
-
-#undef __CMPLX
-#undef CMPLX
-#undef CMPLXF
-#undef CMPLXL
-
-#define __CMPLX(x, y, t) \
- ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
-
-#define CMPLX(x, y) __CMPLX(x, y, double)
-#define CMPLXF(x, y) __CMPLX(x, y, float)
-#define CMPLXL(x, y) __CMPLX(x, y, long double)
-
-#ifndef __MLIBC_ABI_ONLY
-
-/* fdlibm kernel functions */
-
-int __rem_pio2_large(double*,double*,int,int,int);
-
-int __rem_pio2(double,double*);
-double __sin(double,double,int);
-double __cos(double,double);
-double __tan(double,double,int);
-double __expo2(double);
-//double complex __ldexp_cexp(double complex,int);
-
-int __rem_pio2f(float,double*);
-float __sindf(double);
-float __cosdf(double);
-float __tandf(double,int);
-float __expo2f(float);
-//float complex __ldexp_cexpf(float complex,int);
-
-int __rem_pio2l(long double, long double *);
-long double __sinl(long double, long double, int);
-long double __cosl(long double, long double);
-long double __tanl(long double, long double, int);
-
-/* polynomial evaluation */
-long double __polevll(long double, const long double *, int);
-long double __p1evll(long double, const long double *, int);
-
-#endif /* !__MLIBC_ABI_ONLY */
-
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/llrint.c b/lib/mlibc/options/ansi/musl-generic-math/llrint.c
deleted file mode 100644
index 4f583ae..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/llrint.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-/* uses LLONG_MAX > 2^53, see comments in lrint.c */
-
-long long llrint(double x)
-{
- return rint(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/llrintf.c b/lib/mlibc/options/ansi/musl-generic-math/llrintf.c
deleted file mode 100644
index 96949a0..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/llrintf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-/* uses LLONG_MAX > 2^24, see comments in lrint.c */
-
-long long llrintf(float x)
-{
- return rintf(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/llrintl.c b/lib/mlibc/options/ansi/musl-generic-math/llrintl.c
deleted file mode 100644
index 3449f6f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/llrintl.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <limits.h>
-#include <fenv.h>
-#include "libm.h"
-
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long long llrintl(long double x)
-{
- return llrint(x);
-}
-#elif defined(FE_INEXACT)
-/*
-see comments in lrint.c
-
-Note that if LLONG_MAX == 0x7fffffffffffffff && LDBL_MANT_DIG == 64
-then x == 2**63 - 0.5 is the only input that overflows and
-raises inexact (with tonearest or upward rounding mode)
-*/
-long long llrintl(long double x)
-{
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
- x = rintl(x);
- if (!e && (x > LLONG_MAX || x < LLONG_MIN))
- feclearexcept(FE_INEXACT);
- /* conversion */
- return x;
-}
-#else
-long long llrintl(long double x)
-{
- return rintl(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/llround.c b/lib/mlibc/options/ansi/musl-generic-math/llround.c
deleted file mode 100644
index 4d94787..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/llround.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long long llround(double x)
-{
- return round(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/llroundf.c b/lib/mlibc/options/ansi/musl-generic-math/llroundf.c
deleted file mode 100644
index 19eb77e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/llroundf.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long long llroundf(float x)
-{
- return roundf(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/llroundl.c b/lib/mlibc/options/ansi/musl-generic-math/llroundl.c
deleted file mode 100644
index 2c2ee5e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/llroundl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long long llroundl(long double x)
-{
- return roundl(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log.c b/lib/mlibc/options/ansi/musl-generic-math/log.c
deleted file mode 100644
index e61e113..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_log.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* log(x)
- * Return the logarithm of x
- *
- * Method :
- * 1. Argument Reduction: find k and f such that
- * x = 2^k * (1+f),
- * where sqrt(2)/2 < 1+f < sqrt(2) .
- *
- * 2. Approximation of log(1+f).
- * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
- * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
- * = 2s + s*R
- * We use a special Remez algorithm on [0,0.1716] to generate
- * a polynomial of degree 14 to approximate R The maximum error
- * of this polynomial approximation is bounded by 2**-58.45. In
- * other words,
- * 2 4 6 8 10 12 14
- * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
- * (the values of Lg1 to Lg7 are listed in the program)
- * and
- * | 2 14 | -58.45
- * | Lg1*s +...+Lg7*s - R(z) | <= 2
- * | |
- * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
- * In order to guarantee error in log below 1ulp, we compute log
- * by
- * log(1+f) = f - s*(f - R) (if f is not too large)
- * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
- *
- * 3. Finally, log(x) = k*ln2 + log(1+f).
- * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
- * Here ln2 is split into two floating point number:
- * ln2_hi + ln2_lo,
- * where n*ln2_hi is always exact for |n| < 2000.
- *
- * Special cases:
- * log(x) is NaN with signal if x < 0 (including -INF) ;
- * log(+INF) is +INF; log(0) is -INF with signal;
- * log(NaN) is that NaN with no signal.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const double
-ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
-ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
-Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
-Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
-Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
-Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
-Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
-Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
-Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
-double log(double x)
-{
- union {double f; uint64_t i;} u = {x};
- double_t hfsq,f,s,z,R,w,t1,t2,dk;
- uint32_t hx;
- int k;
-
- hx = u.i>>32;
- k = 0;
- if (hx < 0x00100000 || hx>>31) {
- if (u.i<<1 == 0)
- return -1/(x*x); /* log(+-0)=-inf */
- if (hx>>31)
- return (x-x)/0.0; /* log(-#) = NaN */
- /* subnormal number, scale x up */
- k -= 54;
- x *= 0x1p54;
- u.f = x;
- hx = u.i>>32;
- } else if (hx >= 0x7ff00000) {
- return x;
- } else if (hx == 0x3ff00000 && u.i<<32 == 0)
- return 0;
-
- /* reduce x into [sqrt(2)/2, sqrt(2)] */
- hx += 0x3ff00000 - 0x3fe6a09e;
- k += (int)(hx>>20) - 0x3ff;
- hx = (hx&0x000fffff) + 0x3fe6a09e;
- u.i = (uint64_t)hx<<32 | (u.i&0xffffffff);
- x = u.f;
-
- f = x - 1.0;
- hfsq = 0.5*f*f;
- s = f/(2.0+f);
- z = s*s;
- w = z*z;
- t1 = w*(Lg2+w*(Lg4+w*Lg6));
- t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- R = t2 + t1;
- dk = k;
- return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log10.c b/lib/mlibc/options/ansi/musl-generic-math/log10.c
deleted file mode 100644
index 8102687..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log10.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_log10.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * Return the base 10 logarithm of x. See log.c for most comments.
- *
- * Reduce x to 2^k (1+f) and calculate r = log(1+f) - f + f*f/2
- * as in log.c, then combine and scale in extra precision:
- * log10(x) = (f - f*f/2 + r)/log(10) + k*log10(2)
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const double
-ivln10hi = 4.34294481878168880939e-01, /* 0x3fdbcb7b, 0x15200000 */
-ivln10lo = 2.50829467116452752298e-11, /* 0x3dbb9438, 0xca9aadd5 */
-log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
-log10_2lo = 3.69423907715893078616e-13, /* 0x3D59FEF3, 0x11F12B36 */
-Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
-Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
-Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
-Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
-Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
-Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
-Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
-double log10(double x)
-{
- union {double f; uint64_t i;} u = {x};
- double_t hfsq,f,s,z,R,w,t1,t2,dk,y,hi,lo,val_hi,val_lo;
- uint32_t hx;
- int k;
-
- hx = u.i>>32;
- k = 0;
- if (hx < 0x00100000 || hx>>31) {
- if (u.i<<1 == 0)
- return -1/(x*x); /* log(+-0)=-inf */
- if (hx>>31)
- return (x-x)/0.0; /* log(-#) = NaN */
- /* subnormal number, scale x up */
- k -= 54;
- x *= 0x1p54;
- u.f = x;
- hx = u.i>>32;
- } else if (hx >= 0x7ff00000) {
- return x;
- } else if (hx == 0x3ff00000 && u.i<<32 == 0)
- return 0;
-
- /* reduce x into [sqrt(2)/2, sqrt(2)] */
- hx += 0x3ff00000 - 0x3fe6a09e;
- k += (int)(hx>>20) - 0x3ff;
- hx = (hx&0x000fffff) + 0x3fe6a09e;
- u.i = (uint64_t)hx<<32 | (u.i&0xffffffff);
- x = u.f;
-
- f = x - 1.0;
- hfsq = 0.5*f*f;
- s = f/(2.0+f);
- z = s*s;
- w = z*z;
- t1 = w*(Lg2+w*(Lg4+w*Lg6));
- t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- R = t2 + t1;
-
- /* See log2.c for details. */
- /* hi+lo = f - hfsq + s*(hfsq+R) ~ log(1+f) */
- hi = f - hfsq;
- u.f = hi;
- u.i &= (uint64_t)-1<<32;
- hi = u.f;
- lo = f - hi - hfsq + s*(hfsq+R);
-
- /* val_hi+val_lo ~ log10(1+f) + k*log10(2) */
- val_hi = hi*ivln10hi;
- dk = k;
- y = dk*log10_2hi;
- val_lo = dk*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi;
-
- /*
- * Extra precision in for adding y is not strictly needed
- * since there is no very large cancellation near x = sqrt(2) or
- * x = 1/sqrt(2), but we do it anyway since it costs little on CPUs
- * with some parallelism and it reduces the error for many args.
- */
- w = y + val_hi;
- val_lo += (y - w) + val_hi;
- val_hi = w;
-
- return val_lo + val_hi;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log10f.c b/lib/mlibc/options/ansi/musl-generic-math/log10f.c
deleted file mode 100644
index 9ca2f01..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log10f.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_log10f.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * See comments in log10.c.
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const float
-ivln10hi = 4.3432617188e-01, /* 0x3ede6000 */
-ivln10lo = -3.1689971365e-05, /* 0xb804ead9 */
-log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
-log10_2lo = 7.9034151668e-07, /* 0x355427db */
-/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
-Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
-Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
-Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
-Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
-
-float log10f(float x)
-{
- union {float f; uint32_t i;} u = {x};
- float_t hfsq,f,s,z,R,w,t1,t2,dk,hi,lo;
- uint32_t ix;
- int k;
-
- ix = u.i;
- k = 0;
- if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */
- if (ix<<1 == 0)
- return -1/(x*x); /* log(+-0)=-inf */
- if (ix>>31)
- return (x-x)/0.0f; /* log(-#) = NaN */
- /* subnormal number, scale up x */
- k -= 25;
- x *= 0x1p25f;
- u.f = x;
- ix = u.i;
- } else if (ix >= 0x7f800000) {
- return x;
- } else if (ix == 0x3f800000)
- return 0;
-
- /* reduce x into [sqrt(2)/2, sqrt(2)] */
- ix += 0x3f800000 - 0x3f3504f3;
- k += (int)(ix>>23) - 0x7f;
- ix = (ix&0x007fffff) + 0x3f3504f3;
- u.i = ix;
- x = u.f;
-
- f = x - 1.0f;
- s = f/(2.0f + f);
- z = s*s;
- w = z*z;
- t1= w*(Lg2+w*Lg4);
- t2= z*(Lg1+w*Lg3);
- R = t2 + t1;
- hfsq = 0.5f*f*f;
-
- hi = f - hfsq;
- u.f = hi;
- u.i &= 0xfffff000;
- hi = u.f;
- lo = f - hi - hfsq + s*(hfsq+R);
- dk = k;
- return dk*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi + hi*ivln10hi + dk*log10_2hi;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log10l.c b/lib/mlibc/options/ansi/musl-generic-math/log10l.c
deleted file mode 100644
index 63dcc28..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log10l.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_log10l.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Common logarithm, long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, log10l();
- *
- * y = log10l( x );
- *
- *
- * DESCRIPTION:
- *
- * Returns the base 10 logarithm of x.
- *
- * The argument is separated into its exponent and fractional
- * parts. If the exponent is between -1 and +1, the logarithm
- * of the fraction is approximated by
- *
- * log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
- *
- * Otherwise, setting z = 2(x-1)/x+1),
- *
- * log(x) = z + z**3 P(z)/Q(z).
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- * IEEE 0.5, 2.0 30000 9.0e-20 2.6e-20
- * IEEE exp(+-10000) 30000 6.0e-20 2.3e-20
- *
- * In the tests over the interval exp(+-10000), the logarithms
- * of the random arguments were uniformly distributed over
- * [-10000, +10000].
- *
- * ERROR MESSAGES:
- *
- * log singularity: x = 0; returns MINLOG
- * log domain: x < 0; returns MINLOG
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double log10l(long double x)
-{
- return log10(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-/* Coefficients for log(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 6.2e-22
- */
-static const long double P[] = {
- 4.9962495940332550844739E-1L,
- 1.0767376367209449010438E1L,
- 7.7671073698359539859595E1L,
- 2.5620629828144409632571E2L,
- 4.2401812743503691187826E2L,
- 3.4258224542413922935104E2L,
- 1.0747524399916215149070E2L,
-};
-static const long double Q[] = {
-/* 1.0000000000000000000000E0,*/
- 2.3479774160285863271658E1L,
- 1.9444210022760132894510E2L,
- 7.7952888181207260646090E2L,
- 1.6911722418503949084863E3L,
- 2.0307734695595183428202E3L,
- 1.2695660352705325274404E3L,
- 3.2242573199748645407652E2L,
-};
-
-/* Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2),
- * where z = 2(x-1)/(x+1)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 6.16e-22
- */
-static const long double R[4] = {
- 1.9757429581415468984296E-3L,
--7.1990767473014147232598E-1L,
- 1.0777257190312272158094E1L,
--3.5717684488096787370998E1L,
-};
-static const long double S[4] = {
-/* 1.00000000000000000000E0L,*/
--2.6201045551331104417768E1L,
- 1.9361891836232102174846E2L,
--4.2861221385716144629696E2L,
-};
-/* log10(2) */
-#define L102A 0.3125L
-#define L102B -1.1470004336018804786261e-2L
-/* log10(e) */
-#define L10EA 0.5L
-#define L10EB -6.5705518096748172348871e-2L
-
-#define SQRTH 0.70710678118654752440L
-
-long double log10l(long double x)
-{
- long double y, z;
- int e;
-
- if (isnan(x))
- return x;
- if(x <= 0.0) {
- if(x == 0.0)
- return -1.0 / (x*x);
- return (x - x) / 0.0;
- }
- if (x == INFINITY)
- return INFINITY;
- /* separate mantissa from exponent */
- /* Note, frexp is used so that denormal numbers
- * will be handled properly.
- */
- x = frexpl(x, &e);
-
- /* logarithm using log(x) = z + z**3 P(z)/Q(z),
- * where z = 2(x-1)/x+1)
- */
- if (e > 2 || e < -2) {
- if (x < SQRTH) { /* 2(2x-1)/(2x+1) */
- e -= 1;
- z = x - 0.5;
- y = 0.5 * z + 0.5;
- } else { /* 2 (x-1)/(x+1) */
- z = x - 0.5;
- z -= 0.5;
- y = 0.5 * x + 0.5;
- }
- x = z / y;
- z = x*x;
- y = x * (z * __polevll(z, R, 3) / __p1evll(z, S, 3));
- goto done;
- }
-
- /* logarithm using log(1+x) = x - .5x**2 + x**3 P(x)/Q(x) */
- if (x < SQRTH) {
- e -= 1;
- x = 2.0*x - 1.0;
- } else {
- x = x - 1.0;
- }
- z = x*x;
- y = x * (z * __polevll(x, P, 6) / __p1evll(x, Q, 7));
- y = y - 0.5*z;
-
-done:
- /* Multiply log of fraction by log10(e)
- * and base 2 exponent by log10(2).
- *
- * ***CAUTION***
- *
- * This sequence of operations is critical and it may
- * be horribly defeated by some compiler optimizers.
- */
- z = y * (L10EB);
- z += x * (L10EB);
- z += e * (L102B);
- z += y * (L10EA);
- z += x * (L10EA);
- z += e * (L102A);
- return z;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double log10l(long double x)
-{
- return log10(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log1p.c b/lib/mlibc/options/ansi/musl-generic-math/log1p.c
deleted file mode 100644
index 0097134..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log1p.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_log1p.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* double log1p(double x)
- * Return the natural logarithm of 1+x.
- *
- * Method :
- * 1. Argument Reduction: find k and f such that
- * 1+x = 2^k * (1+f),
- * where sqrt(2)/2 < 1+f < sqrt(2) .
- *
- * Note. If k=0, then f=x is exact. However, if k!=0, then f
- * may not be representable exactly. In that case, a correction
- * term is need. Let u=1+x rounded. Let c = (1+x)-u, then
- * log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u),
- * and add back the correction term c/u.
- * (Note: when x > 2**53, one can simply return log(x))
- *
- * 2. Approximation of log(1+f): See log.c
- *
- * 3. Finally, log1p(x) = k*ln2 + log(1+f) + c/u. See log.c
- *
- * Special cases:
- * log1p(x) is NaN with signal if x < -1 (including -INF) ;
- * log1p(+INF) is +INF; log1p(-1) is -INF with signal;
- * log1p(NaN) is that NaN with no signal.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- *
- * Note: Assuming log() return accurate answer, the following
- * algorithm can be used to compute log1p(x) to within a few ULP:
- *
- * u = 1+x;
- * if(u==1.0) return x ; else
- * return log(u)*(x/(u-1.0));
- *
- * See HP-15C Advanced Functions Handbook, p.193.
- */
-
-#include "libm.h"
-
-static const double
-ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
-ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
-Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
-Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
-Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
-Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
-Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
-Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
-Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
-double log1p(double x)
-{
- union {double f; uint64_t i;} u = {x};
- double_t hfsq,f,c,s,z,R,w,t1,t2,dk;
- uint32_t hx,hu;
- int k;
-
- hx = u.i>>32;
- k = 1;
- if (hx < 0x3fda827a || hx>>31) { /* 1+x < sqrt(2)+ */
- if (hx >= 0xbff00000) { /* x <= -1.0 */
- if (x == -1)
- return x/0.0; /* log1p(-1) = -inf */
- return (x-x)/0.0; /* log1p(x<-1) = NaN */
- }
- if (hx<<1 < 0x3ca00000<<1) { /* |x| < 2**-53 */
- /* underflow if subnormal */
- if ((hx&0x7ff00000) == 0)
- FORCE_EVAL((float)x);
- return x;
- }
- if (hx <= 0xbfd2bec4) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */
- k = 0;
- c = 0;
- f = x;
- }
- } else if (hx >= 0x7ff00000)
- return x;
- if (k) {
- u.f = 1 + x;
- hu = u.i>>32;
- hu += 0x3ff00000 - 0x3fe6a09e;
- k = (int)(hu>>20) - 0x3ff;
- /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */
- if (k < 54) {
- c = k >= 2 ? 1-(u.f-x) : x-(u.f-1);
- c /= u.f;
- } else
- c = 0;
- /* reduce u into [sqrt(2)/2, sqrt(2)] */
- hu = (hu&0x000fffff) + 0x3fe6a09e;
- u.i = (uint64_t)hu<<32 | (u.i&0xffffffff);
- f = u.f - 1;
- }
- hfsq = 0.5*f*f;
- s = f/(2.0+f);
- z = s*s;
- w = z*z;
- t1 = w*(Lg2+w*(Lg4+w*Lg6));
- t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- R = t2 + t1;
- dk = k;
- return s*(hfsq+R) + (dk*ln2_lo+c) - hfsq + f + dk*ln2_hi;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log1pf.c b/lib/mlibc/options/ansi/musl-generic-math/log1pf.c
deleted file mode 100644
index 23985c3..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log1pf.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_log1pf.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float
-ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
-ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
-/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
-Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
-Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
-Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
-Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
-
-float log1pf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- float_t hfsq,f,c,s,z,R,w,t1,t2,dk;
- uint32_t ix,iu;
- int k;
-
- ix = u.i;
- k = 1;
- if (ix < 0x3ed413d0 || ix>>31) { /* 1+x < sqrt(2)+ */
- if (ix >= 0xbf800000) { /* x <= -1.0 */
- if (x == -1)
- return x/0.0f; /* log1p(-1)=+inf */
- return (x-x)/0.0f; /* log1p(x<-1)=NaN */
- }
- if (ix<<1 < 0x33800000<<1) { /* |x| < 2**-24 */
- /* underflow if subnormal */
- if ((ix&0x7f800000) == 0)
- FORCE_EVAL(x*x);
- return x;
- }
- if (ix <= 0xbe95f619) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */
- k = 0;
- c = 0;
- f = x;
- }
- } else if (ix >= 0x7f800000)
- return x;
- if (k) {
- u.f = 1 + x;
- iu = u.i;
- iu += 0x3f800000 - 0x3f3504f3;
- k = (int)(iu>>23) - 0x7f;
- /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */
- if (k < 25) {
- c = k >= 2 ? 1-(u.f-x) : x-(u.f-1);
- c /= u.f;
- } else
- c = 0;
- /* reduce u into [sqrt(2)/2, sqrt(2)] */
- iu = (iu&0x007fffff) + 0x3f3504f3;
- u.i = iu;
- f = u.f - 1;
- }
- s = f/(2.0f + f);
- z = s*s;
- w = z*z;
- t1= w*(Lg2+w*Lg4);
- t2= z*(Lg1+w*Lg3);
- R = t2 + t1;
- hfsq = 0.5f*f*f;
- dk = k;
- return s*(hfsq+R) + (dk*ln2_lo+c) - hfsq + f + dk*ln2_hi;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log1pl.c b/lib/mlibc/options/ansi/musl-generic-math/log1pl.c
deleted file mode 100644
index 141b5f0..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log1pl.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/s_log1pl.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Relative error logarithm
- * Natural logarithm of 1+x, long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, log1pl();
- *
- * y = log1pl( x );
- *
- *
- * DESCRIPTION:
- *
- * Returns the base e (2.718...) logarithm of 1+x.
- *
- * The argument 1+x is separated into its exponent and fractional
- * parts. If the exponent is between -1 and +1, the logarithm
- * of the fraction is approximated by
- *
- * log(1+x) = x - 0.5 x^2 + x^3 P(x)/Q(x).
- *
- * Otherwise, setting z = 2(x-1)/x+1),
- *
- * log(x) = z + z^3 P(z)/Q(z).
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- * IEEE -1.0, 9.0 100000 8.2e-20 2.5e-20
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double log1pl(long double x)
-{
- return log1p(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-/* Coefficients for log(1+x) = x - x^2 / 2 + x^3 P(x)/Q(x)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 2.32e-20
- */
-static const long double P[] = {
- 4.5270000862445199635215E-5L,
- 4.9854102823193375972212E-1L,
- 6.5787325942061044846969E0L,
- 2.9911919328553073277375E1L,
- 6.0949667980987787057556E1L,
- 5.7112963590585538103336E1L,
- 2.0039553499201281259648E1L,
-};
-static const long double Q[] = {
-/* 1.0000000000000000000000E0,*/
- 1.5062909083469192043167E1L,
- 8.3047565967967209469434E1L,
- 2.2176239823732856465394E2L,
- 3.0909872225312059774938E2L,
- 2.1642788614495947685003E2L,
- 6.0118660497603843919306E1L,
-};
-
-/* Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2),
- * where z = 2(x-1)/(x+1)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 6.16e-22
- */
-static const long double R[4] = {
- 1.9757429581415468984296E-3L,
--7.1990767473014147232598E-1L,
- 1.0777257190312272158094E1L,
--3.5717684488096787370998E1L,
-};
-static const long double S[4] = {
-/* 1.00000000000000000000E0L,*/
--2.6201045551331104417768E1L,
- 1.9361891836232102174846E2L,
--4.2861221385716144629696E2L,
-};
-static const long double C1 = 6.9314575195312500000000E-1L;
-static const long double C2 = 1.4286068203094172321215E-6L;
-
-#define SQRTH 0.70710678118654752440L
-
-long double log1pl(long double xm1)
-{
- long double x, y, z;
- int e;
-
- if (isnan(xm1))
- return xm1;
- if (xm1 == INFINITY)
- return xm1;
- if (xm1 == 0.0)
- return xm1;
-
- x = xm1 + 1.0;
-
- /* Test for domain errors. */
- if (x <= 0.0) {
- if (x == 0.0)
- return -1/(x*x); /* -inf with divbyzero */
- return 0/0.0f; /* nan with invalid */
- }
-
- /* Separate mantissa from exponent.
- Use frexp so that denormal numbers will be handled properly. */
- x = frexpl(x, &e);
-
- /* logarithm using log(x) = z + z^3 P(z)/Q(z),
- where z = 2(x-1)/x+1) */
- if (e > 2 || e < -2) {
- if (x < SQRTH) { /* 2(2x-1)/(2x+1) */
- e -= 1;
- z = x - 0.5;
- y = 0.5 * z + 0.5;
- } else { /* 2 (x-1)/(x+1) */
- z = x - 0.5;
- z -= 0.5;
- y = 0.5 * x + 0.5;
- }
- x = z / y;
- z = x*x;
- z = x * (z * __polevll(z, R, 3) / __p1evll(z, S, 3));
- z = z + e * C2;
- z = z + x;
- z = z + e * C1;
- return z;
- }
-
- /* logarithm using log(1+x) = x - .5x**2 + x**3 P(x)/Q(x) */
- if (x < SQRTH) {
- e -= 1;
- if (e != 0)
- x = 2.0 * x - 1.0;
- else
- x = xm1;
- } else {
- if (e != 0)
- x = x - 1.0;
- else
- x = xm1;
- }
- z = x*x;
- y = x * (z * __polevll(x, P, 6) / __p1evll(x, Q, 6));
- y = y + e * C2;
- z = y - 0.5 * z;
- z = z + x;
- z = z + e * C1;
- return z;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double log1pl(long double x)
-{
- return log1p(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log2.c b/lib/mlibc/options/ansi/musl-generic-math/log2.c
deleted file mode 100644
index 0aafad4..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log2.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_log2.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * Return the base 2 logarithm of x. See log.c for most comments.
- *
- * Reduce x to 2^k (1+f) and calculate r = log(1+f) - f + f*f/2
- * as in log.c, then combine and scale in extra precision:
- * log2(x) = (f - f*f/2 + r)/log(2) + k
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const double
-ivln2hi = 1.44269504072144627571e+00, /* 0x3ff71547, 0x65200000 */
-ivln2lo = 1.67517131648865118353e-10, /* 0x3de705fc, 0x2eefa200 */
-Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
-Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
-Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
-Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
-Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
-Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
-Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
-double log2(double x)
-{
- union {double f; uint64_t i;} u = {x};
- double_t hfsq,f,s,z,R,w,t1,t2,y,hi,lo,val_hi,val_lo;
- uint32_t hx;
- int k;
-
- hx = u.i>>32;
- k = 0;
- if (hx < 0x00100000 || hx>>31) {
- if (u.i<<1 == 0)
- return -1/(x*x); /* log(+-0)=-inf */
- if (hx>>31)
- return (x-x)/0.0; /* log(-#) = NaN */
- /* subnormal number, scale x up */
- k -= 54;
- x *= 0x1p54;
- u.f = x;
- hx = u.i>>32;
- } else if (hx >= 0x7ff00000) {
- return x;
- } else if (hx == 0x3ff00000 && u.i<<32 == 0)
- return 0;
-
- /* reduce x into [sqrt(2)/2, sqrt(2)] */
- hx += 0x3ff00000 - 0x3fe6a09e;
- k += (int)(hx>>20) - 0x3ff;
- hx = (hx&0x000fffff) + 0x3fe6a09e;
- u.i = (uint64_t)hx<<32 | (u.i&0xffffffff);
- x = u.f;
-
- f = x - 1.0;
- hfsq = 0.5*f*f;
- s = f/(2.0+f);
- z = s*s;
- w = z*z;
- t1 = w*(Lg2+w*(Lg4+w*Lg6));
- t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- R = t2 + t1;
-
- /*
- * f-hfsq must (for args near 1) be evaluated in extra precision
- * to avoid a large cancellation when x is near sqrt(2) or 1/sqrt(2).
- * This is fairly efficient since f-hfsq only depends on f, so can
- * be evaluated in parallel with R. Not combining hfsq with R also
- * keeps R small (though not as small as a true `lo' term would be),
- * so that extra precision is not needed for terms involving R.
- *
- * Compiler bugs involving extra precision used to break Dekker's
- * theorem for spitting f-hfsq as hi+lo, unless double_t was used
- * or the multi-precision calculations were avoided when double_t
- * has extra precision. These problems are now automatically
- * avoided as a side effect of the optimization of combining the
- * Dekker splitting step with the clear-low-bits step.
- *
- * y must (for args near sqrt(2) and 1/sqrt(2)) be added in extra
- * precision to avoid a very large cancellation when x is very near
- * these values. Unlike the above cancellations, this problem is
- * specific to base 2. It is strange that adding +-1 is so much
- * harder than adding +-ln2 or +-log10_2.
- *
- * This uses Dekker's theorem to normalize y+val_hi, so the
- * compiler bugs are back in some configurations, sigh. And I
- * don't want to used double_t to avoid them, since that gives a
- * pessimization and the support for avoiding the pessimization
- * is not yet available.
- *
- * The multi-precision calculations for the multiplications are
- * routine.
- */
-
- /* hi+lo = f - hfsq + s*(hfsq+R) ~ log(1+f) */
- hi = f - hfsq;
- u.f = hi;
- u.i &= (uint64_t)-1<<32;
- hi = u.f;
- lo = f - hi - hfsq + s*(hfsq+R);
-
- val_hi = hi*ivln2hi;
- val_lo = (lo+hi)*ivln2lo + lo*ivln2hi;
-
- /* spadd(val_hi, val_lo, y), except for not using double_t: */
- y = k;
- w = y + val_hi;
- val_lo += (y - w) + val_hi;
- val_hi = w;
-
- return val_lo + val_hi;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log2f.c b/lib/mlibc/options/ansi/musl-generic-math/log2f.c
deleted file mode 100644
index b3e305f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log2f.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_log2f.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * See comments in log2.c.
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const float
-ivln2hi = 1.4428710938e+00, /* 0x3fb8b000 */
-ivln2lo = -1.7605285393e-04, /* 0xb9389ad4 */
-/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
-Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
-Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
-Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
-Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
-
-float log2f(float x)
-{
- union {float f; uint32_t i;} u = {x};
- float_t hfsq,f,s,z,R,w,t1,t2,hi,lo;
- uint32_t ix;
- int k;
-
- ix = u.i;
- k = 0;
- if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */
- if (ix<<1 == 0)
- return -1/(x*x); /* log(+-0)=-inf */
- if (ix>>31)
- return (x-x)/0.0f; /* log(-#) = NaN */
- /* subnormal number, scale up x */
- k -= 25;
- x *= 0x1p25f;
- u.f = x;
- ix = u.i;
- } else if (ix >= 0x7f800000) {
- return x;
- } else if (ix == 0x3f800000)
- return 0;
-
- /* reduce x into [sqrt(2)/2, sqrt(2)] */
- ix += 0x3f800000 - 0x3f3504f3;
- k += (int)(ix>>23) - 0x7f;
- ix = (ix&0x007fffff) + 0x3f3504f3;
- u.i = ix;
- x = u.f;
-
- f = x - 1.0f;
- s = f/(2.0f + f);
- z = s*s;
- w = z*z;
- t1= w*(Lg2+w*Lg4);
- t2= z*(Lg1+w*Lg3);
- R = t2 + t1;
- hfsq = 0.5f*f*f;
-
- hi = f - hfsq;
- u.f = hi;
- u.i &= 0xfffff000;
- hi = u.f;
- lo = f - hi - hfsq + s*(hfsq+R);
- return (lo+hi)*ivln2lo + lo*ivln2hi + hi*ivln2hi + k;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/log2l.c b/lib/mlibc/options/ansi/musl-generic-math/log2l.c
deleted file mode 100644
index 722b451..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/log2l.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_log2l.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Base 2 logarithm, long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, log2l();
- *
- * y = log2l( x );
- *
- *
- * DESCRIPTION:
- *
- * Returns the base 2 logarithm of x.
- *
- * The argument is separated into its exponent and fractional
- * parts. If the exponent is between -1 and +1, the (natural)
- * logarithm of the fraction is approximated by
- *
- * log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
- *
- * Otherwise, setting z = 2(x-1)/x+1),
- *
- * log(x) = z + z**3 P(z)/Q(z).
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- * IEEE 0.5, 2.0 30000 9.8e-20 2.7e-20
- * IEEE exp(+-10000) 70000 5.4e-20 2.3e-20
- *
- * In the tests over the interval exp(+-10000), the logarithms
- * of the random arguments were uniformly distributed over
- * [-10000, +10000].
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double log2l(long double x)
-{
- return log2(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-/* Coefficients for ln(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 6.2e-22
- */
-static const long double P[] = {
- 4.9962495940332550844739E-1L,
- 1.0767376367209449010438E1L,
- 7.7671073698359539859595E1L,
- 2.5620629828144409632571E2L,
- 4.2401812743503691187826E2L,
- 3.4258224542413922935104E2L,
- 1.0747524399916215149070E2L,
-};
-static const long double Q[] = {
-/* 1.0000000000000000000000E0,*/
- 2.3479774160285863271658E1L,
- 1.9444210022760132894510E2L,
- 7.7952888181207260646090E2L,
- 1.6911722418503949084863E3L,
- 2.0307734695595183428202E3L,
- 1.2695660352705325274404E3L,
- 3.2242573199748645407652E2L,
-};
-
-/* Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2),
- * where z = 2(x-1)/(x+1)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 6.16e-22
- */
-static const long double R[4] = {
- 1.9757429581415468984296E-3L,
--7.1990767473014147232598E-1L,
- 1.0777257190312272158094E1L,
--3.5717684488096787370998E1L,
-};
-static const long double S[4] = {
-/* 1.00000000000000000000E0L,*/
--2.6201045551331104417768E1L,
- 1.9361891836232102174846E2L,
--4.2861221385716144629696E2L,
-};
-/* log2(e) - 1 */
-#define LOG2EA 4.4269504088896340735992e-1L
-
-#define SQRTH 0.70710678118654752440L
-
-long double log2l(long double x)
-{
- long double y, z;
- int e;
-
- if (isnan(x))
- return x;
- if (x == INFINITY)
- return x;
- if (x <= 0.0) {
- if (x == 0.0)
- return -1/(x*x); /* -inf with divbyzero */
- return 0/0.0f; /* nan with invalid */
- }
-
- /* separate mantissa from exponent */
- /* Note, frexp is used so that denormal numbers
- * will be handled properly.
- */
- x = frexpl(x, &e);
-
- /* logarithm using log(x) = z + z**3 P(z)/Q(z),
- * where z = 2(x-1)/x+1)
- */
- if (e > 2 || e < -2) {
- if (x < SQRTH) { /* 2(2x-1)/(2x+1) */
- e -= 1;
- z = x - 0.5;
- y = 0.5 * z + 0.5;
- } else { /* 2 (x-1)/(x+1) */
- z = x - 0.5;
- z -= 0.5;
- y = 0.5 * x + 0.5;
- }
- x = z / y;
- z = x*x;
- y = x * (z * __polevll(z, R, 3) / __p1evll(z, S, 3));
- goto done;
- }
-
- /* logarithm using log(1+x) = x - .5x**2 + x**3 P(x)/Q(x) */
- if (x < SQRTH) {
- e -= 1;
- x = 2.0*x - 1.0;
- } else {
- x = x - 1.0;
- }
- z = x*x;
- y = x * (z * __polevll(x, P, 6) / __p1evll(x, Q, 7));
- y = y - 0.5*z;
-
-done:
- /* Multiply log of fraction by log2(e)
- * and base 2 exponent by 1
- *
- * ***CAUTION***
- *
- * This sequence of operations is critical and it may
- * be horribly defeated by some compiler optimizers.
- */
- z = y * LOG2EA;
- z += x * LOG2EA;
- z += y;
- z += x;
- z += e;
- return z;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double log2l(long double x)
-{
- return log2(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/logb.c b/lib/mlibc/options/ansi/musl-generic-math/logb.c
deleted file mode 100644
index 7f8bdfa..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/logb.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <math.h>
-
-/*
-special cases:
- logb(+-0) = -inf, and raise divbyzero
- logb(+-inf) = +inf
- logb(nan) = nan
-*/
-
-double logb(double x)
-{
- if (!isfinite(x))
- return x * x;
- if (x == 0)
- return -1/(x*x);
- return ilogb(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/logbf.c b/lib/mlibc/options/ansi/musl-generic-math/logbf.c
deleted file mode 100644
index a0a0b5e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/logbf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-float logbf(float x)
-{
- if (!isfinite(x))
- return x * x;
- if (x == 0)
- return -1/(x*x);
- return ilogbf(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/logbl.c b/lib/mlibc/options/ansi/musl-generic-math/logbl.c
deleted file mode 100644
index 962973a..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/logbl.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <math.h>
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double logbl(long double x)
-{
- return logb(x);
-}
-#else
-long double logbl(long double x)
-{
- if (!isfinite(x))
- return x * x;
- if (x == 0)
- return -1/(x*x);
- return ilogbl(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/logf.c b/lib/mlibc/options/ansi/musl-generic-math/logf.c
deleted file mode 100644
index 52230a1..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/logf.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_logf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <math.h>
-#include <stdint.h>
-
-static const float
-ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
-ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
-/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
-Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
-Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
-Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
-Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
-
-float logf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- float_t hfsq,f,s,z,R,w,t1,t2,dk;
- uint32_t ix;
- int k;
-
- ix = u.i;
- k = 0;
- if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */
- if (ix<<1 == 0)
- return -1/(x*x); /* log(+-0)=-inf */
- if (ix>>31)
- return (x-x)/0.0f; /* log(-#) = NaN */
- /* subnormal number, scale up x */
- k -= 25;
- x *= 0x1p25f;
- u.f = x;
- ix = u.i;
- } else if (ix >= 0x7f800000) {
- return x;
- } else if (ix == 0x3f800000)
- return 0;
-
- /* reduce x into [sqrt(2)/2, sqrt(2)] */
- ix += 0x3f800000 - 0x3f3504f3;
- k += (int)(ix>>23) - 0x7f;
- ix = (ix&0x007fffff) + 0x3f3504f3;
- u.i = ix;
- x = u.f;
-
- f = x - 1.0f;
- s = f/(2.0f + f);
- z = s*s;
- w = z*z;
- t1= w*(Lg2+w*Lg4);
- t2= z*(Lg1+w*Lg3);
- R = t2 + t1;
- hfsq = 0.5f*f*f;
- dk = k;
- return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/logl.c b/lib/mlibc/options/ansi/musl-generic-math/logl.c
deleted file mode 100644
index 5d53659..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/logl.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_logl.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Natural logarithm, long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, logl();
- *
- * y = logl( x );
- *
- *
- * DESCRIPTION:
- *
- * Returns the base e (2.718...) logarithm of x.
- *
- * The argument is separated into its exponent and fractional
- * parts. If the exponent is between -1 and +1, the logarithm
- * of the fraction is approximated by
- *
- * log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
- *
- * Otherwise, setting z = 2(x-1)/(x+1),
- *
- * log(x) = log(1+z/2) - log(1-z/2) = z + z**3 P(z)/Q(z).
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- * IEEE 0.5, 2.0 150000 8.71e-20 2.75e-20
- * IEEE exp(+-10000) 100000 5.39e-20 2.34e-20
- *
- * In the tests over the interval exp(+-10000), the logarithms
- * of the random arguments were uniformly distributed over
- * [-10000, +10000].
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double logl(long double x)
-{
- return log(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-/* Coefficients for log(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 2.32e-20
- */
-static const long double P[] = {
- 4.5270000862445199635215E-5L,
- 4.9854102823193375972212E-1L,
- 6.5787325942061044846969E0L,
- 2.9911919328553073277375E1L,
- 6.0949667980987787057556E1L,
- 5.7112963590585538103336E1L,
- 2.0039553499201281259648E1L,
-};
-static const long double Q[] = {
-/* 1.0000000000000000000000E0,*/
- 1.5062909083469192043167E1L,
- 8.3047565967967209469434E1L,
- 2.2176239823732856465394E2L,
- 3.0909872225312059774938E2L,
- 2.1642788614495947685003E2L,
- 6.0118660497603843919306E1L,
-};
-
-/* Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2),
- * where z = 2(x-1)/(x+1)
- * 1/sqrt(2) <= x < sqrt(2)
- * Theoretical peak relative error = 6.16e-22
- */
-static const long double R[4] = {
- 1.9757429581415468984296E-3L,
--7.1990767473014147232598E-1L,
- 1.0777257190312272158094E1L,
--3.5717684488096787370998E1L,
-};
-static const long double S[4] = {
-/* 1.00000000000000000000E0L,*/
--2.6201045551331104417768E1L,
- 1.9361891836232102174846E2L,
--4.2861221385716144629696E2L,
-};
-static const long double C1 = 6.9314575195312500000000E-1L;
-static const long double C2 = 1.4286068203094172321215E-6L;
-
-#define SQRTH 0.70710678118654752440L
-
-long double logl(long double x)
-{
- long double y, z;
- int e;
-
- if (isnan(x))
- return x;
- if (x == INFINITY)
- return x;
- if (x <= 0.0) {
- if (x == 0.0)
- return -1/(x*x); /* -inf with divbyzero */
- return 0/0.0f; /* nan with invalid */
- }
-
- /* separate mantissa from exponent */
- /* Note, frexp is used so that denormal numbers
- * will be handled properly.
- */
- x = frexpl(x, &e);
-
- /* logarithm using log(x) = z + z**3 P(z)/Q(z),
- * where z = 2(x-1)/(x+1)
- */
- if (e > 2 || e < -2) {
- if (x < SQRTH) { /* 2(2x-1)/(2x+1) */
- e -= 1;
- z = x - 0.5;
- y = 0.5 * z + 0.5;
- } else { /* 2 (x-1)/(x+1) */
- z = x - 0.5;
- z -= 0.5;
- y = 0.5 * x + 0.5;
- }
- x = z / y;
- z = x*x;
- z = x * (z * __polevll(z, R, 3) / __p1evll(z, S, 3));
- z = z + e * C2;
- z = z + x;
- z = z + e * C1;
- return z;
- }
-
- /* logarithm using log(1+x) = x - .5x**2 + x**3 P(x)/Q(x) */
- if (x < SQRTH) {
- e -= 1;
- x = 2.0*x - 1.0;
- } else {
- x = x - 1.0;
- }
- z = x*x;
- y = x * (z * __polevll(x, P, 6) / __p1evll(x, Q, 6));
- y = y + e * C2;
- z = y - 0.5*z;
- /* Note, the sum of above terms does not exceed x/4,
- * so it contributes at most about 1/4 lsb to the error.
- */
- z = z + x;
- z = z + e * C1; /* This sum has an error of 1/2 lsb. */
- return z;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double logl(long double x)
-{
- return log(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lrint.c b/lib/mlibc/options/ansi/musl-generic-math/lrint.c
deleted file mode 100644
index bdca8b7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lrint.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <limits.h>
-#include <fenv.h>
-#include "libm.h"
-
-/*
-If the result cannot be represented (overflow, nan), then
-lrint raises the invalid exception.
-
-Otherwise if the input was not an integer then the inexact
-exception is raised.
-
-C99 is a bit vague about whether inexact exception is
-allowed to be raised when invalid is raised.
-(F.9 explicitly allows spurious inexact exceptions, F.9.6.5
-does not make it clear if that rule applies to lrint, but
-IEEE 754r 7.8 seems to forbid spurious inexact exception in
-the ineger conversion functions)
-
-So we try to make sure that no spurious inexact exception is
-raised in case of an overflow.
-
-If the bit size of long > precision of double, then there
-cannot be inexact rounding in case the result overflows,
-otherwise LONG_MAX and LONG_MIN can be represented exactly
-as a double.
-*/
-
-#if LONG_MAX < 1U<<53 && defined(FE_INEXACT)
-long lrint(double x)
-{
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
- x = rint(x);
- if (!e && (x > LONG_MAX || x < LONG_MIN))
- feclearexcept(FE_INEXACT);
- /* conversion */
- return x;
-}
-#else
-long lrint(double x)
-{
- return rint(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lrintf.c b/lib/mlibc/options/ansi/musl-generic-math/lrintf.c
deleted file mode 100644
index ca0b6a4..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lrintf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-/* uses LONG_MAX > 2^24, see comments in lrint.c */
-
-long lrintf(float x)
-{
- return rintf(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lrintl.c b/lib/mlibc/options/ansi/musl-generic-math/lrintl.c
deleted file mode 100644
index b2a8106..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lrintl.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <limits.h>
-#include <fenv.h>
-#include "libm.h"
-
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long lrintl(long double x)
-{
- return lrint(x);
-}
-#elif defined(FE_INEXACT)
-/*
-see comments in lrint.c
-
-Note that if LONG_MAX == 0x7fffffffffffffff && LDBL_MANT_DIG == 64
-then x == 2**63 - 0.5 is the only input that overflows and
-raises inexact (with tonearest or upward rounding mode)
-*/
-long lrintl(long double x)
-{
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
- x = rintl(x);
- if (!e && (x > LONG_MAX || x < LONG_MIN))
- feclearexcept(FE_INEXACT);
- /* conversion */
- return x;
-}
-#else
-long lrintl(long double x)
-{
- return rintl(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lround.c b/lib/mlibc/options/ansi/musl-generic-math/lround.c
deleted file mode 100644
index b8b7954..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lround.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long lround(double x)
-{
- return round(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lroundf.c b/lib/mlibc/options/ansi/musl-generic-math/lroundf.c
deleted file mode 100644
index c4707e7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lroundf.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long lroundf(float x)
-{
- return roundf(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/lroundl.c b/lib/mlibc/options/ansi/musl-generic-math/lroundl.c
deleted file mode 100644
index 094fdf6..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/lroundl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long lroundl(long double x)
-{
- return roundl(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/modf.c b/lib/mlibc/options/ansi/musl-generic-math/modf.c
deleted file mode 100644
index 1c8a1db..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/modf.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "libm.h"
-
-double modf(double x, double *iptr)
-{
- union {double f; uint64_t i;} u = {x};
- uint64_t mask;
- int e = (int)(u.i>>52 & 0x7ff) - 0x3ff;
-
- /* no fractional part */
- if (e >= 52) {
- *iptr = x;
- if (e == 0x400 && u.i<<12 != 0) /* nan */
- return x;
- u.i &= 1ULL<<63;
- return u.f;
- }
-
- /* no integral part*/
- if (e < 0) {
- u.i &= 1ULL<<63;
- *iptr = u.f;
- return x;
- }
-
- mask = -1ULL>>12>>e;
- if ((u.i & mask) == 0) {
- *iptr = x;
- u.i &= 1ULL<<63;
- return u.f;
- }
- u.i &= ~mask;
- *iptr = u.f;
- return x - u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/modff.c b/lib/mlibc/options/ansi/musl-generic-math/modff.c
deleted file mode 100644
index 639514e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/modff.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "libm.h"
-
-float modff(float x, float *iptr)
-{
- union {float f; uint32_t i;} u = {x};
- uint32_t mask;
- int e = (int)(u.i>>23 & 0xff) - 0x7f;
-
- /* no fractional part */
- if (e >= 23) {
- *iptr = x;
- if (e == 0x80 && u.i<<9 != 0) { /* nan */
- return x;
- }
- u.i &= 0x80000000;
- return u.f;
- }
- /* no integral part */
- if (e < 0) {
- u.i &= 0x80000000;
- *iptr = u.f;
- return x;
- }
-
- mask = 0x007fffff>>e;
- if ((u.i & mask) == 0) {
- *iptr = x;
- u.i &= 0x80000000;
- return u.f;
- }
- u.i &= ~mask;
- *iptr = u.f;
- return x - u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/modfl.c b/lib/mlibc/options/ansi/musl-generic-math/modfl.c
deleted file mode 100644
index a47b192..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/modfl.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double modfl(long double x, long double *iptr)
-{
- double d;
- long double r;
-
- r = modf(x, &d);
- *iptr = d;
- return r;
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-static const long double toint = 1/LDBL_EPSILON;
-
-long double modfl(long double x, long double *iptr)
-{
- union ldshape u = {x};
- int e = (u.i.se & 0x7fff) - 0x3fff;
- int s = u.i.se >> 15;
- long double absx;
- long double y;
-
- /* no fractional part */
- if (e >= LDBL_MANT_DIG-1) {
- *iptr = x;
- if (isnan(x))
- return x;
- return s ? -0.0 : 0.0;
- }
-
- /* no integral part*/
- if (e < 0) {
- *iptr = s ? -0.0 : 0.0;
- return x;
- }
-
- /* raises spurious inexact */
- absx = s ? -x : x;
- y = absx + toint - toint - absx;
- if (y == 0) {
- *iptr = x;
- return s ? -0.0 : 0.0;
- }
- if (y > 0)
- y -= 1;
- if (s)
- y = -y;
- *iptr = x + y;
- return -y;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nan.c b/lib/mlibc/options/ansi/musl-generic-math/nan.c
deleted file mode 100644
index 9e0826c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nan.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-double nan(const char *s)
-{
- return NAN;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nanf.c b/lib/mlibc/options/ansi/musl-generic-math/nanf.c
deleted file mode 100644
index 752ce54..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nanf.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-float nanf(const char *s)
-{
- return NAN;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nanl.c b/lib/mlibc/options/ansi/musl-generic-math/nanl.c
deleted file mode 100644
index 969af56..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nanl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long double nanl(const char *s)
-{
- return NAN;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nearbyint.c b/lib/mlibc/options/ansi/musl-generic-math/nearbyint.c
deleted file mode 100644
index f4e8aac..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nearbyint.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <fenv.h>
-#include <math.h>
-
-/* nearbyint is the same as rint, but it must not raise the inexact exception */
-
-double nearbyint(double x)
-{
-#ifdef FE_INEXACT
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
-#endif
- x = rint(x);
-#ifdef FE_INEXACT
- if (!e)
- feclearexcept(FE_INEXACT);
-#endif
- return x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nearbyintf.c b/lib/mlibc/options/ansi/musl-generic-math/nearbyintf.c
deleted file mode 100644
index 092e9ff..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nearbyintf.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <fenv.h>
-#include <math.h>
-
-float nearbyintf(float x)
-{
-#ifdef FE_INEXACT
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
-#endif
- x = rintf(x);
-#ifdef FE_INEXACT
- if (!e)
- feclearexcept(FE_INEXACT);
-#endif
- return x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nearbyintl.c b/lib/mlibc/options/ansi/musl-generic-math/nearbyintl.c
deleted file mode 100644
index 8285249..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nearbyintl.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <math.h>
-#include <float.h>
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double nearbyintl(long double x)
-{
- return nearbyint(x);
-}
-#else
-#include <fenv.h>
-long double nearbyintl(long double x)
-{
-#ifdef FE_INEXACT
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
-#endif
- x = rintl(x);
-#ifdef FE_INEXACT
- if (!e)
- feclearexcept(FE_INEXACT);
-#endif
- return x;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nextafter.c b/lib/mlibc/options/ansi/musl-generic-math/nextafter.c
deleted file mode 100644
index ab5795a..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nextafter.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "libm.h"
-
-double nextafter(double x, double y)
-{
- union {double f; uint64_t i;} ux={x}, uy={y};
- uint64_t ax, ay;
- int e;
-
- if (isnan(x) || isnan(y))
- return x + y;
- if (ux.i == uy.i)
- return y;
- ax = ux.i & -1ULL/2;
- ay = uy.i & -1ULL/2;
- if (ax == 0) {
- if (ay == 0)
- return y;
- ux.i = (uy.i & 1ULL<<63) | 1;
- } else if (ax > ay || ((ux.i ^ uy.i) & 1ULL<<63))
- ux.i--;
- else
- ux.i++;
- e = ux.i >> 52 & 0x7ff;
- /* raise overflow if ux.f is infinite and x is finite */
- if (e == 0x7ff)
- FORCE_EVAL(x+x);
- /* raise underflow if ux.f is subnormal or zero */
- if (e == 0)
- FORCE_EVAL(x*x + ux.f*ux.f);
- return ux.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nextafterf.c b/lib/mlibc/options/ansi/musl-generic-math/nextafterf.c
deleted file mode 100644
index 75a09f7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nextafterf.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "libm.h"
-
-float nextafterf(float x, float y)
-{
- union {float f; uint32_t i;} ux={x}, uy={y};
- uint32_t ax, ay, e;
-
- if (isnan(x) || isnan(y))
- return x + y;
- if (ux.i == uy.i)
- return y;
- ax = ux.i & 0x7fffffff;
- ay = uy.i & 0x7fffffff;
- if (ax == 0) {
- if (ay == 0)
- return y;
- ux.i = (uy.i & 0x80000000) | 1;
- } else if (ax > ay || ((ux.i ^ uy.i) & 0x80000000))
- ux.i--;
- else
- ux.i++;
- e = ux.i & 0x7f800000;
- /* raise overflow if ux.f is infinite and x is finite */
- if (e == 0x7f800000)
- FORCE_EVAL(x+x);
- /* raise underflow if ux.f is subnormal or zero */
- if (e == 0)
- FORCE_EVAL(x*x + ux.f*ux.f);
- return ux.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nextafterl.c b/lib/mlibc/options/ansi/musl-generic-math/nextafterl.c
deleted file mode 100644
index 37e858f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nextafterl.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double nextafterl(long double x, long double y)
-{
- return nextafter(x, y);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-long double nextafterl(long double x, long double y)
-{
- union ldshape ux, uy;
-
- if (isnan(x) || isnan(y))
- return x + y;
- if (x == y)
- return y;
- ux.f = x;
- if (x == 0) {
- uy.f = y;
- ux.i.m = 1;
- ux.i.se = uy.i.se & 0x8000;
- } else if ((x < y) == !(ux.i.se & 0x8000)) {
- ux.i.m++;
- if (ux.i.m << 1 == 0) {
- ux.i.m = 1ULL << 63;
- ux.i.se++;
- }
- } else {
- if (ux.i.m << 1 == 0) {
- ux.i.se--;
- if (ux.i.se)
- ux.i.m = 0;
- }
- ux.i.m--;
- }
- /* raise overflow if ux is infinite and x is finite */
- if ((ux.i.se & 0x7fff) == 0x7fff)
- return x + x;
- /* raise underflow if ux is subnormal or zero */
- if ((ux.i.se & 0x7fff) == 0)
- FORCE_EVAL(x*x + ux.f*ux.f);
- return ux.f;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-long double nextafterl(long double x, long double y)
-{
- union ldshape ux, uy;
-
- if (isnan(x) || isnan(y))
- return x + y;
- if (x == y)
- return y;
- ux.f = x;
- if (x == 0) {
- uy.f = y;
- ux.i.lo = 1;
- ux.i.se = uy.i.se & 0x8000;
- } else if ((x < y) == !(ux.i.se & 0x8000)) {
- ux.i2.lo++;
- if (ux.i2.lo == 0)
- ux.i2.hi++;
- } else {
- if (ux.i2.lo == 0)
- ux.i2.hi--;
- ux.i2.lo--;
- }
- /* raise overflow if ux is infinite and x is finite */
- if ((ux.i.se & 0x7fff) == 0x7fff)
- return x + x;
- /* raise underflow if ux is subnormal or zero */
- if ((ux.i.se & 0x7fff) == 0)
- FORCE_EVAL(x*x + ux.f*ux.f);
- return ux.f;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nexttoward.c b/lib/mlibc/options/ansi/musl-generic-math/nexttoward.c
deleted file mode 100644
index 827ee5c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nexttoward.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-double nexttoward(double x, long double y)
-{
- return nextafter(x, y);
-}
-#else
-double nexttoward(double x, long double y)
-{
- union {double f; uint64_t i;} ux = {x};
- int e;
-
- if (isnan(x) || isnan(y))
- return x + y;
- if (x == y)
- return y;
- if (x == 0) {
- ux.i = 1;
- if (signbit(y))
- ux.i |= 1ULL<<63;
- } else if (x < y) {
- if (signbit(x))
- ux.i--;
- else
- ux.i++;
- } else {
- if (signbit(x))
- ux.i++;
- else
- ux.i--;
- }
- e = ux.i>>52 & 0x7ff;
- /* raise overflow if ux.f is infinite and x is finite */
- if (e == 0x7ff)
- FORCE_EVAL(x+x);
- /* raise underflow if ux.f is subnormal or zero */
- if (e == 0)
- FORCE_EVAL(x*x + ux.f*ux.f);
- return ux.f;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nexttowardf.c b/lib/mlibc/options/ansi/musl-generic-math/nexttowardf.c
deleted file mode 100644
index bbf172f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nexttowardf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "libm.h"
-
-float nexttowardf(float x, long double y)
-{
- union {float f; uint32_t i;} ux = {x};
- uint32_t e;
-
- if (isnan(x) || isnan(y))
- return x + y;
- if (x == y)
- return y;
- if (x == 0) {
- ux.i = 1;
- if (signbit(y))
- ux.i |= 0x80000000;
- } else if (x < y) {
- if (signbit(x))
- ux.i--;
- else
- ux.i++;
- } else {
- if (signbit(x))
- ux.i++;
- else
- ux.i--;
- }
- e = ux.i & 0x7f800000;
- /* raise overflow if ux.f is infinite and x is finite */
- if (e == 0x7f800000)
- FORCE_EVAL(x+x);
- /* raise underflow if ux.f is subnormal or zero */
- if (e == 0)
- FORCE_EVAL(x*x + ux.f*ux.f);
- return ux.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/nexttowardl.c b/lib/mlibc/options/ansi/musl-generic-math/nexttowardl.c
deleted file mode 100644
index 67a6340..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/nexttowardl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-long double nexttowardl(long double x, long double y)
-{
- return nextafterl(x, y);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/pow.c b/lib/mlibc/options/ansi/musl-generic-math/pow.c
deleted file mode 100644
index 3ddc1b6..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/pow.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_pow.c */
-/*
- * ====================================================
- * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* pow(x,y) return x**y
- *
- * n
- * Method: Let x = 2 * (1+f)
- * 1. Compute and return log2(x) in two pieces:
- * log2(x) = w1 + w2,
- * where w1 has 53-24 = 29 bit trailing zeros.
- * 2. Perform y*log2(x) = n+y' by simulating muti-precision
- * arithmetic, where |y'|<=0.5.
- * 3. Return x**y = 2**n*exp(y'*log2)
- *
- * Special cases:
- * 1. (anything) ** 0 is 1
- * 2. 1 ** (anything) is 1
- * 3. (anything except 1) ** NAN is NAN
- * 4. NAN ** (anything except 0) is NAN
- * 5. +-(|x| > 1) ** +INF is +INF
- * 6. +-(|x| > 1) ** -INF is +0
- * 7. +-(|x| < 1) ** +INF is +0
- * 8. +-(|x| < 1) ** -INF is +INF
- * 9. -1 ** +-INF is 1
- * 10. +0 ** (+anything except 0, NAN) is +0
- * 11. -0 ** (+anything except 0, NAN, odd integer) is +0
- * 12. +0 ** (-anything except 0, NAN) is +INF, raise divbyzero
- * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF, raise divbyzero
- * 14. -0 ** (+odd integer) is -0
- * 15. -0 ** (-odd integer) is -INF, raise divbyzero
- * 16. +INF ** (+anything except 0,NAN) is +INF
- * 17. +INF ** (-anything except 0,NAN) is +0
- * 18. -INF ** (+odd integer) is -INF
- * 19. -INF ** (anything) = -0 ** (-anything), (anything except odd integer)
- * 20. (anything) ** 1 is (anything)
- * 21. (anything) ** -1 is 1/(anything)
- * 22. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
- * 23. (-anything except 0 and inf) ** (non-integer) is NAN
- *
- * Accuracy:
- * pow(x,y) returns x**y nearly rounded. In particular
- * pow(integer,integer)
- * always returns the correct integer provided it is
- * representable.
- *
- * Constants :
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "libm.h"
-
-static const double
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
-dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
-two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */
-huge = 1.0e300,
-tiny = 1.0e-300,
-/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
-L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
-L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
-L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
-L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
-L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
-P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
-lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
-lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
-lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
-ovt = 8.0085662595372944372e-017, /* -(1024-log2(ovfl+.5ulp)) */
-cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
-cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
-cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
-ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
-ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
-ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
-
-double pow(double x, double y)
-{
- double z,ax,z_h,z_l,p_h,p_l;
- double y1,t1,t2,r,s,t,u,v,w;
- int32_t i,j,k,yisint,n;
- int32_t hx,hy,ix,iy;
- uint32_t lx,ly;
-
- EXTRACT_WORDS(hx, lx, x);
- EXTRACT_WORDS(hy, ly, y);
- ix = hx & 0x7fffffff;
- iy = hy & 0x7fffffff;
-
- /* x**0 = 1, even if x is NaN */
- if ((iy|ly) == 0)
- return 1.0;
- /* 1**y = 1, even if y is NaN */
- if (hx == 0x3ff00000 && lx == 0)
- return 1.0;
- /* NaN if either arg is NaN */
- if (ix > 0x7ff00000 || (ix == 0x7ff00000 && lx != 0) ||
- iy > 0x7ff00000 || (iy == 0x7ff00000 && ly != 0))
- return x + y;
-
- /* determine if y is an odd int when x < 0
- * yisint = 0 ... y is not an integer
- * yisint = 1 ... y is an odd int
- * yisint = 2 ... y is an even int
- */
- yisint = 0;
- if (hx < 0) {
- if (iy >= 0x43400000)
- yisint = 2; /* even integer y */
- else if (iy >= 0x3ff00000) {
- k = (iy>>20) - 0x3ff; /* exponent */
- if (k > 20) {
- uint32_t j = ly>>(52-k);
- if ((j<<(52-k)) == ly)
- yisint = 2 - (j&1);
- } else if (ly == 0) {
- uint32_t j = iy>>(20-k);
- if ((j<<(20-k)) == iy)
- yisint = 2 - (j&1);
- }
- }
- }
-
- /* special value of y */
- if (ly == 0) {
- if (iy == 0x7ff00000) { /* y is +-inf */
- if (((ix-0x3ff00000)|lx) == 0) /* (-1)**+-inf is 1 */
- return 1.0;
- else if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */
- return hy >= 0 ? y : 0.0;
- else /* (|x|<1)**+-inf = 0,inf */
- return hy >= 0 ? 0.0 : -y;
- }
- if (iy == 0x3ff00000) { /* y is +-1 */
- if (hy >= 0)
- return x;
- y = 1/x;
-#if FLT_EVAL_METHOD!=0
- {
- union {double f; uint64_t i;} u = {y};
- uint64_t i = u.i & -1ULL/2;
- if (i>>52 == 0 && (i&(i-1)))
- FORCE_EVAL((float)y);
- }
-#endif
- return y;
- }
- if (hy == 0x40000000) /* y is 2 */
- return x*x;
- if (hy == 0x3fe00000) { /* y is 0.5 */
- if (hx >= 0) /* x >= +0 */
- return sqrt(x);
- }
- }
-
- ax = fabs(x);
- /* special value of x */
- if (lx == 0) {
- if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) { /* x is +-0,+-inf,+-1 */
- z = ax;
- if (hy < 0) /* z = (1/|x|) */
- z = 1.0/z;
- if (hx < 0) {
- if (((ix-0x3ff00000)|yisint) == 0) {
- z = (z-z)/(z-z); /* (-1)**non-int is NaN */
- } else if (yisint == 1)
- z = -z; /* (x<0)**odd = -(|x|**odd) */
- }
- return z;
- }
- }
-
- s = 1.0; /* sign of result */
- if (hx < 0) {
- if (yisint == 0) /* (x<0)**(non-int) is NaN */
- return (x-x)/(x-x);
- if (yisint == 1) /* (x<0)**(odd int) */
- s = -1.0;
- }
-
- /* |y| is huge */
- if (iy > 0x41e00000) { /* if |y| > 2**31 */
- if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */
- if (ix <= 0x3fefffff)
- return hy < 0 ? huge*huge : tiny*tiny;
- if (ix >= 0x3ff00000)
- return hy > 0 ? huge*huge : tiny*tiny;
- }
- /* over/underflow if x is not close to one */
- if (ix < 0x3fefffff)
- return hy < 0 ? s*huge*huge : s*tiny*tiny;
- if (ix > 0x3ff00000)
- return hy > 0 ? s*huge*huge : s*tiny*tiny;
- /* now |1-x| is tiny <= 2**-20, suffice to compute
- log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = ax - 1.0; /* t has 20 trailing zeros */
- w = (t*t)*(0.5 - t*(0.3333333333333333333333-t*0.25));
- u = ivln2_h*t; /* ivln2_h has 21 sig. bits */
- v = t*ivln2_l - w*ivln2;
- t1 = u + v;
- SET_LOW_WORD(t1, 0);
- t2 = v - (t1-u);
- } else {
- double ss,s2,s_h,s_l,t_h,t_l;
- n = 0;
- /* take care subnormal number */
- if (ix < 0x00100000) {
- ax *= two53;
- n -= 53;
- GET_HIGH_WORD(ix,ax);
- }
- n += ((ix)>>20) - 0x3ff;
- j = ix & 0x000fffff;
- /* determine interval */
- ix = j | 0x3ff00000; /* normalize ix */
- if (j <= 0x3988E) /* |x|<sqrt(3/2) */
- k = 0;
- else if (j < 0xBB67A) /* |x|<sqrt(3) */
- k = 1;
- else {
- k = 0;
- n += 1;
- ix -= 0x00100000;
- }
- SET_HIGH_WORD(ax, ix);
-
- /* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
- u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
- v = 1.0/(ax+bp[k]);
- ss = u*v;
- s_h = ss;
- SET_LOW_WORD(s_h, 0);
- /* t_h=ax+bp[k] High */
- t_h = 0.0;
- SET_HIGH_WORD(t_h, ((ix>>1)|0x20000000) + 0x00080000 + (k<<18));
- t_l = ax - (t_h-bp[k]);
- s_l = v*((u-s_h*t_h)-s_h*t_l);
- /* compute log(ax) */
- s2 = ss*ss;
- r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
- r += s_l*(s_h+ss);
- s2 = s_h*s_h;
- t_h = 3.0 + s2 + r;
- SET_LOW_WORD(t_h, 0);
- t_l = r - ((t_h-3.0)-s2);
- /* u+v = ss*(1+...) */
- u = s_h*t_h;
- v = s_l*t_h + t_l*ss;
- /* 2/(3log2)*(ss+...) */
- p_h = u + v;
- SET_LOW_WORD(p_h, 0);
- p_l = v - (p_h-u);
- z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
- z_l = cp_l*p_h+p_l*cp + dp_l[k];
- /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */
- t = (double)n;
- t1 = ((z_h + z_l) + dp_h[k]) + t;
- SET_LOW_WORD(t1, 0);
- t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
- }
-
- /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
- y1 = y;
- SET_LOW_WORD(y1, 0);
- p_l = (y-y1)*t1 + y*t2;
- p_h = y1*t1;
- z = p_l + p_h;
- EXTRACT_WORDS(j, i, z);
- if (j >= 0x40900000) { /* z >= 1024 */
- if (((j-0x40900000)|i) != 0) /* if z > 1024 */
- return s*huge*huge; /* overflow */
- if (p_l + ovt > z - p_h)
- return s*huge*huge; /* overflow */
- } else if ((j&0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */ // FIXME: instead of abs(j) use unsigned j
- if (((j-0xc090cc00)|i) != 0) /* z < -1075 */
- return s*tiny*tiny; /* underflow */
- if (p_l <= z - p_h)
- return s*tiny*tiny; /* underflow */
- }
- /*
- * compute 2**(p_h+p_l)
- */
- i = j & 0x7fffffff;
- k = (i>>20) - 0x3ff;
- n = 0;
- if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
- n = j + (0x00100000>>(k+1));
- k = ((n&0x7fffffff)>>20) - 0x3ff; /* new k for n */
- t = 0.0;
- SET_HIGH_WORD(t, n & ~(0x000fffff>>k));
- n = ((n&0x000fffff)|0x00100000)>>(20-k);
- if (j < 0)
- n = -n;
- p_h -= t;
- }
- t = p_l + p_h;
- SET_LOW_WORD(t, 0);
- u = t*lg2_h;
- v = (p_l-(t-p_h))*lg2 + t*lg2_l;
- z = u + v;
- w = v - (z-u);
- t = z*z;
- t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- r = (z*t1)/(t1-2.0) - (w + z*w);
- z = 1.0 - (r-z);
- GET_HIGH_WORD(j, z);
- j += n<<20;
- if ((j>>20) <= 0) /* subnormal output */
- z = scalbn(z,n);
- else
- SET_HIGH_WORD(z, j);
- return s*z;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/powf.c b/lib/mlibc/options/ansi/musl-generic-math/powf.c
deleted file mode 100644
index 427c896..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/powf.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_powf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
-dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
-two24 = 16777216.0, /* 0x4b800000 */
-huge = 1.0e30,
-tiny = 1.0e-30,
-/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1 = 6.0000002384e-01, /* 0x3f19999a */
-L2 = 4.2857143283e-01, /* 0x3edb6db7 */
-L3 = 3.3333334327e-01, /* 0x3eaaaaab */
-L4 = 2.7272811532e-01, /* 0x3e8ba305 */
-L5 = 2.3066075146e-01, /* 0x3e6c3255 */
-L6 = 2.0697501302e-01, /* 0x3e53f142 */
-P1 = 1.6666667163e-01, /* 0x3e2aaaab */
-P2 = -2.7777778450e-03, /* 0xbb360b61 */
-P3 = 6.6137559770e-05, /* 0x388ab355 */
-P4 = -1.6533901999e-06, /* 0xb5ddea0e */
-P5 = 4.1381369442e-08, /* 0x3331bb4c */
-lg2 = 6.9314718246e-01, /* 0x3f317218 */
-lg2_h = 6.93145752e-01, /* 0x3f317200 */
-lg2_l = 1.42860654e-06, /* 0x35bfbe8c */
-ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
-cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
-cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */
-cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */
-ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
-ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
-ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
-
-float powf(float x, float y)
-{
- float z,ax,z_h,z_l,p_h,p_l;
- float y1,t1,t2,r,s,sn,t,u,v,w;
- int32_t i,j,k,yisint,n;
- int32_t hx,hy,ix,iy,is;
-
- GET_FLOAT_WORD(hx, x);
- GET_FLOAT_WORD(hy, y);
- ix = hx & 0x7fffffff;
- iy = hy & 0x7fffffff;
-
- /* x**0 = 1, even if x is NaN */
- if (iy == 0)
- return 1.0f;
- /* 1**y = 1, even if y is NaN */
- if (hx == 0x3f800000)
- return 1.0f;
- /* NaN if either arg is NaN */
- if (ix > 0x7f800000 || iy > 0x7f800000)
- return x + y;
-
- /* determine if y is an odd int when x < 0
- * yisint = 0 ... y is not an integer
- * yisint = 1 ... y is an odd int
- * yisint = 2 ... y is an even int
- */
- yisint = 0;
- if (hx < 0) {
- if (iy >= 0x4b800000)
- yisint = 2; /* even integer y */
- else if (iy >= 0x3f800000) {
- k = (iy>>23) - 0x7f; /* exponent */
- j = iy>>(23-k);
- if ((j<<(23-k)) == iy)
- yisint = 2 - (j & 1);
- }
- }
-
- /* special value of y */
- if (iy == 0x7f800000) { /* y is +-inf */
- if (ix == 0x3f800000) /* (-1)**+-inf is 1 */
- return 1.0f;
- else if (ix > 0x3f800000) /* (|x|>1)**+-inf = inf,0 */
- return hy >= 0 ? y : 0.0f;
- else /* (|x|<1)**+-inf = 0,inf */
- return hy >= 0 ? 0.0f: -y;
- }
- if (iy == 0x3f800000) /* y is +-1 */
- return hy >= 0 ? x : 1.0f/x;
- if (hy == 0x40000000) /* y is 2 */
- return x*x;
- if (hy == 0x3f000000) { /* y is 0.5 */
- if (hx >= 0) /* x >= +0 */
- return sqrtf(x);
- }
-
- ax = fabsf(x);
- /* special value of x */
- if (ix == 0x7f800000 || ix == 0 || ix == 0x3f800000) { /* x is +-0,+-inf,+-1 */
- z = ax;
- if (hy < 0) /* z = (1/|x|) */
- z = 1.0f/z;
- if (hx < 0) {
- if (((ix-0x3f800000)|yisint) == 0) {
- z = (z-z)/(z-z); /* (-1)**non-int is NaN */
- } else if (yisint == 1)
- z = -z; /* (x<0)**odd = -(|x|**odd) */
- }
- return z;
- }
-
- sn = 1.0f; /* sign of result */
- if (hx < 0) {
- if (yisint == 0) /* (x<0)**(non-int) is NaN */
- return (x-x)/(x-x);
- if (yisint == 1) /* (x<0)**(odd int) */
- sn = -1.0f;
- }
-
- /* |y| is huge */
- if (iy > 0x4d000000) { /* if |y| > 2**27 */
- /* over/underflow if x is not close to one */
- if (ix < 0x3f7ffff8)
- return hy < 0 ? sn*huge*huge : sn*tiny*tiny;
- if (ix > 0x3f800007)
- return hy > 0 ? sn*huge*huge : sn*tiny*tiny;
- /* now |1-x| is tiny <= 2**-20, suffice to compute
- log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = ax - 1; /* t has 20 trailing zeros */
- w = (t*t)*(0.5f - t*(0.333333333333f - t*0.25f));
- u = ivln2_h*t; /* ivln2_h has 16 sig. bits */
- v = t*ivln2_l - w*ivln2;
- t1 = u + v;
- GET_FLOAT_WORD(is, t1);
- SET_FLOAT_WORD(t1, is & 0xfffff000);
- t2 = v - (t1-u);
- } else {
- float s2,s_h,s_l,t_h,t_l;
- n = 0;
- /* take care subnormal number */
- if (ix < 0x00800000) {
- ax *= two24;
- n -= 24;
- GET_FLOAT_WORD(ix, ax);
- }
- n += ((ix)>>23) - 0x7f;
- j = ix & 0x007fffff;
- /* determine interval */
- ix = j | 0x3f800000; /* normalize ix */
- if (j <= 0x1cc471) /* |x|<sqrt(3/2) */
- k = 0;
- else if (j < 0x5db3d7) /* |x|<sqrt(3) */
- k = 1;
- else {
- k = 0;
- n += 1;
- ix -= 0x00800000;
- }
- SET_FLOAT_WORD(ax, ix);
-
- /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
- u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
- v = 1.0f/(ax+bp[k]);
- s = u*v;
- s_h = s;
- GET_FLOAT_WORD(is, s_h);
- SET_FLOAT_WORD(s_h, is & 0xfffff000);
- /* t_h=ax+bp[k] High */
- is = ((ix>>1) & 0xfffff000) | 0x20000000;
- SET_FLOAT_WORD(t_h, is + 0x00400000 + (k<<21));
- t_l = ax - (t_h - bp[k]);
- s_l = v*((u - s_h*t_h) - s_h*t_l);
- /* compute log(ax) */
- s2 = s*s;
- r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
- r += s_l*(s_h+s);
- s2 = s_h*s_h;
- t_h = 3.0f + s2 + r;
- GET_FLOAT_WORD(is, t_h);
- SET_FLOAT_WORD(t_h, is & 0xfffff000);
- t_l = r - ((t_h - 3.0f) - s2);
- /* u+v = s*(1+...) */
- u = s_h*t_h;
- v = s_l*t_h + t_l*s;
- /* 2/(3log2)*(s+...) */
- p_h = u + v;
- GET_FLOAT_WORD(is, p_h);
- SET_FLOAT_WORD(p_h, is & 0xfffff000);
- p_l = v - (p_h - u);
- z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
- z_l = cp_l*p_h + p_l*cp+dp_l[k];
- /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
- t = (float)n;
- t1 = (((z_h + z_l) + dp_h[k]) + t);
- GET_FLOAT_WORD(is, t1);
- SET_FLOAT_WORD(t1, is & 0xfffff000);
- t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
- }
-
- /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
- GET_FLOAT_WORD(is, y);
- SET_FLOAT_WORD(y1, is & 0xfffff000);
- p_l = (y-y1)*t1 + y*t2;
- p_h = y1*t1;
- z = p_l + p_h;
- GET_FLOAT_WORD(j, z);
- if (j > 0x43000000) /* if z > 128 */
- return sn*huge*huge; /* overflow */
- else if (j == 0x43000000) { /* if z == 128 */
- if (p_l + ovt > z - p_h)
- return sn*huge*huge; /* overflow */
- } else if ((j&0x7fffffff) > 0x43160000) /* z < -150 */ // FIXME: check should be (uint32_t)j > 0xc3160000
- return sn*tiny*tiny; /* underflow */
- else if (j == 0xc3160000) { /* z == -150 */
- if (p_l <= z-p_h)
- return sn*tiny*tiny; /* underflow */
- }
- /*
- * compute 2**(p_h+p_l)
- */
- i = j & 0x7fffffff;
- k = (i>>23) - 0x7f;
- n = 0;
- if (i > 0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */
- n = j + (0x00800000>>(k+1));
- k = ((n&0x7fffffff)>>23) - 0x7f; /* new k for n */
- SET_FLOAT_WORD(t, n & ~(0x007fffff>>k));
- n = ((n&0x007fffff)|0x00800000)>>(23-k);
- if (j < 0)
- n = -n;
- p_h -= t;
- }
- t = p_l + p_h;
- GET_FLOAT_WORD(is, t);
- SET_FLOAT_WORD(t, is & 0xffff8000);
- u = t*lg2_h;
- v = (p_l-(t-p_h))*lg2 + t*lg2_l;
- z = u + v;
- w = v - (z - u);
- t = z*z;
- t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- r = (z*t1)/(t1-2.0f) - (w+z*w);
- z = 1.0f - (r - z);
- GET_FLOAT_WORD(j, z);
- j += n<<23;
- if ((j>>23) <= 0) /* subnormal output */
- z = scalbnf(z, n);
- else
- SET_FLOAT_WORD(z, j);
- return sn*z;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/powl.c b/lib/mlibc/options/ansi/musl-generic-math/powl.c
deleted file mode 100644
index 5b6da07..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/powl.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_powl.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* powl.c
- *
- * Power function, long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, z, powl();
- *
- * z = powl( x, y );
- *
- *
- * DESCRIPTION:
- *
- * Computes x raised to the yth power. Analytically,
- *
- * x**y = exp( y log(x) ).
- *
- * Following Cody and Waite, this program uses a lookup table
- * of 2**-i/32 and pseudo extended precision arithmetic to
- * obtain several extra bits of accuracy in both the logarithm
- * and the exponential.
- *
- *
- * ACCURACY:
- *
- * The relative error of pow(x,y) can be estimated
- * by y dl ln(2), where dl is the absolute error of
- * the internally computed base 2 logarithm. At the ends
- * of the approximation interval the logarithm equal 1/32
- * and its relative error is about 1 lsb = 1.1e-19. Hence
- * the predicted relative error in the result is 2.3e-21 y .
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- *
- * IEEE +-1000 40000 2.8e-18 3.7e-19
- * .001 < x < 1000, with log(x) uniformly distributed.
- * -1000 < y < 1000, y uniformly distributed.
- *
- * IEEE 0,8700 60000 6.5e-18 1.0e-18
- * 0.99 < x < 1.01, 0 < y < 8700, uniformly distributed.
- *
- *
- * ERROR MESSAGES:
- *
- * message condition value returned
- * pow overflow x**y > MAXNUM INFINITY
- * pow underflow x**y < 1/MAXNUM 0.0
- * pow domain x<0 and y noninteger 0.0
- *
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double powl(long double x, long double y)
-{
- return pow(x, y);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-
-/* Table size */
-#define NXT 32
-
-/* log(1+x) = x - .5x^2 + x^3 * P(z)/Q(z)
- * on the domain 2^(-1/32) - 1 <= x <= 2^(1/32) - 1
- */
-static const long double P[] = {
- 8.3319510773868690346226E-4L,
- 4.9000050881978028599627E-1L,
- 1.7500123722550302671919E0L,
- 1.4000100839971580279335E0L,
-};
-static const long double Q[] = {
-/* 1.0000000000000000000000E0L,*/
- 5.2500282295834889175431E0L,
- 8.4000598057587009834666E0L,
- 4.2000302519914740834728E0L,
-};
-/* A[i] = 2^(-i/32), rounded to IEEE long double precision.
- * If i is even, A[i] + B[i/2] gives additional accuracy.
- */
-static const long double A[33] = {
- 1.0000000000000000000000E0L,
- 9.7857206208770013448287E-1L,
- 9.5760328069857364691013E-1L,
- 9.3708381705514995065011E-1L,
- 9.1700404320467123175367E-1L,
- 8.9735453750155359320742E-1L,
- 8.7812608018664974155474E-1L,
- 8.5930964906123895780165E-1L,
- 8.4089641525371454301892E-1L,
- 8.2287773907698242225554E-1L,
- 8.0524516597462715409607E-1L,
- 7.8799042255394324325455E-1L,
- 7.7110541270397041179298E-1L,
- 7.5458221379671136985669E-1L,
- 7.3841307296974965571198E-1L,
- 7.2259040348852331001267E-1L,
- 7.0710678118654752438189E-1L,
- 6.9195494098191597746178E-1L,
- 6.7712777346844636413344E-1L,
- 6.6261832157987064729696E-1L,
- 6.4841977732550483296079E-1L,
- 6.3452547859586661129850E-1L,
- 6.2092890603674202431705E-1L,
- 6.0762367999023443907803E-1L,
- 5.9460355750136053334378E-1L,
- 5.8186242938878875689693E-1L,
- 5.6939431737834582684856E-1L,
- 5.5719337129794626814472E-1L,
- 5.4525386633262882960438E-1L,
- 5.3357020033841180906486E-1L,
- 5.2213689121370692017331E-1L,
- 5.1094857432705833910408E-1L,
- 5.0000000000000000000000E-1L,
-};
-static const long double B[17] = {
- 0.0000000000000000000000E0L,
- 2.6176170809902549338711E-20L,
--1.0126791927256478897086E-20L,
- 1.3438228172316276937655E-21L,
- 1.2207982955417546912101E-20L,
--6.3084814358060867200133E-21L,
- 1.3164426894366316434230E-20L,
--1.8527916071632873716786E-20L,
- 1.8950325588932570796551E-20L,
- 1.5564775779538780478155E-20L,
- 6.0859793637556860974380E-21L,
--2.0208749253662532228949E-20L,
- 1.4966292219224761844552E-20L,
- 3.3540909728056476875639E-21L,
--8.6987564101742849540743E-22L,
--1.2327176863327626135542E-20L,
- 0.0000000000000000000000E0L,
-};
-
-/* 2^x = 1 + x P(x),
- * on the interval -1/32 <= x <= 0
- */
-static const long double R[] = {
- 1.5089970579127659901157E-5L,
- 1.5402715328927013076125E-4L,
- 1.3333556028915671091390E-3L,
- 9.6181291046036762031786E-3L,
- 5.5504108664798463044015E-2L,
- 2.4022650695910062854352E-1L,
- 6.9314718055994530931447E-1L,
-};
-
-#define MEXP (NXT*16384.0L)
-/* The following if denormal numbers are supported, else -MEXP: */
-#define MNEXP (-NXT*(16384.0L+64.0L))
-/* log2(e) - 1 */
-#define LOG2EA 0.44269504088896340735992L
-
-#define F W
-#define Fa Wa
-#define Fb Wb
-#define G W
-#define Ga Wa
-#define Gb u
-#define H W
-#define Ha Wb
-#define Hb Wb
-
-static const long double MAXLOGL = 1.1356523406294143949492E4L;
-static const long double MINLOGL = -1.13994985314888605586758E4L;
-static const long double LOGE2L = 6.9314718055994530941723E-1L;
-static const long double huge = 0x1p10000L;
-/* XXX Prevent gcc from erroneously constant folding this. */
-static const volatile long double twom10000 = 0x1p-10000L;
-
-static long double reducl(long double);
-static long double powil(long double, int);
-
-long double powl(long double x, long double y)
-{
- /* double F, Fa, Fb, G, Ga, Gb, H, Ha, Hb */
- int i, nflg, iyflg, yoddint;
- long e;
- volatile long double z=0;
- long double w=0, W=0, Wa=0, Wb=0, ya=0, yb=0, u=0;
-
- /* make sure no invalid exception is raised by nan comparision */
- if (isnan(x)) {
- if (!isnan(y) && y == 0.0)
- return 1.0;
- return x;
- }
- if (isnan(y)) {
- if (x == 1.0)
- return 1.0;
- return y;
- }
- if (x == 1.0)
- return 1.0; /* 1**y = 1, even if y is nan */
- if (x == -1.0 && !isfinite(y))
- return 1.0; /* -1**inf = 1 */
- if (y == 0.0)
- return 1.0; /* x**0 = 1, even if x is nan */
- if (y == 1.0)
- return x;
- if (y >= LDBL_MAX) {
- if (x > 1.0 || x < -1.0)
- return INFINITY;
- if (x != 0.0)
- return 0.0;
- }
- if (y <= -LDBL_MAX) {
- if (x > 1.0 || x < -1.0)
- return 0.0;
- if (x != 0.0 || y == -INFINITY)
- return INFINITY;
- }
- if (x >= LDBL_MAX) {
- if (y > 0.0)
- return INFINITY;
- return 0.0;
- }
-
- w = floorl(y);
-
- /* Set iyflg to 1 if y is an integer. */
- iyflg = 0;
- if (w == y)
- iyflg = 1;
-
- /* Test for odd integer y. */
- yoddint = 0;
- if (iyflg) {
- ya = fabsl(y);
- ya = floorl(0.5 * ya);
- yb = 0.5 * fabsl(w);
- if( ya != yb )
- yoddint = 1;
- }
-
- if (x <= -LDBL_MAX) {
- if (y > 0.0) {
- if (yoddint)
- return -INFINITY;
- return INFINITY;
- }
- if (y < 0.0) {
- if (yoddint)
- return -0.0;
- return 0.0;
- }
- }
- nflg = 0; /* (x<0)**(odd int) */
- if (x <= 0.0) {
- if (x == 0.0) {
- if (y < 0.0) {
- if (signbit(x) && yoddint)
- /* (-0.0)**(-odd int) = -inf, divbyzero */
- return -1.0/0.0;
- /* (+-0.0)**(negative) = inf, divbyzero */
- return 1.0/0.0;
- }
- if (signbit(x) && yoddint)
- return -0.0;
- return 0.0;
- }
- if (iyflg == 0)
- return (x - x) / (x - x); /* (x<0)**(non-int) is NaN */
- /* (x<0)**(integer) */
- if (yoddint)
- nflg = 1; /* negate result */
- x = -x;
- }
- /* (+integer)**(integer) */
- if (iyflg && floorl(x) == x && fabsl(y) < 32768.0) {
- w = powil(x, (int)y);
- return nflg ? -w : w;
- }
-
- /* separate significand from exponent */
- x = frexpl(x, &i);
- e = i;
-
- /* find significand in antilog table A[] */
- i = 1;
- if (x <= A[17])
- i = 17;
- if (x <= A[i+8])
- i += 8;
- if (x <= A[i+4])
- i += 4;
- if (x <= A[i+2])
- i += 2;
- if (x >= A[1])
- i = -1;
- i += 1;
-
- /* Find (x - A[i])/A[i]
- * in order to compute log(x/A[i]):
- *
- * log(x) = log( a x/a ) = log(a) + log(x/a)
- *
- * log(x/a) = log(1+v), v = x/a - 1 = (x-a)/a
- */
- x -= A[i];
- x -= B[i/2];
- x /= A[i];
-
- /* rational approximation for log(1+v):
- *
- * log(1+v) = v - v**2/2 + v**3 P(v) / Q(v)
- */
- z = x*x;
- w = x * (z * __polevll(x, P, 3) / __p1evll(x, Q, 3));
- w = w - 0.5*z;
-
- /* Convert to base 2 logarithm:
- * multiply by log2(e) = 1 + LOG2EA
- */
- z = LOG2EA * w;
- z += w;
- z += LOG2EA * x;
- z += x;
-
- /* Compute exponent term of the base 2 logarithm. */
- w = -i;
- w /= NXT;
- w += e;
- /* Now base 2 log of x is w + z. */
-
- /* Multiply base 2 log by y, in extended precision. */
-
- /* separate y into large part ya
- * and small part yb less than 1/NXT
- */
- ya = reducl(y);
- yb = y - ya;
-
- /* (w+z)(ya+yb)
- * = w*ya + w*yb + z*y
- */
- F = z * y + w * yb;
- Fa = reducl(F);
- Fb = F - Fa;
-
- G = Fa + w * ya;
- Ga = reducl(G);
- Gb = G - Ga;
-
- H = Fb + Gb;
- Ha = reducl(H);
- w = (Ga + Ha) * NXT;
-
- /* Test the power of 2 for overflow */
- if (w > MEXP)
- return huge * huge; /* overflow */
- if (w < MNEXP)
- return twom10000 * twom10000; /* underflow */
-
- e = w;
- Hb = H - Ha;
-
- if (Hb > 0.0) {
- e += 1;
- Hb -= 1.0/NXT; /*0.0625L;*/
- }
-
- /* Now the product y * log2(x) = Hb + e/NXT.
- *
- * Compute base 2 exponential of Hb,
- * where -0.0625 <= Hb <= 0.
- */
- z = Hb * __polevll(Hb, R, 6); /* z = 2**Hb - 1 */
-
- /* Express e/NXT as an integer plus a negative number of (1/NXT)ths.
- * Find lookup table entry for the fractional power of 2.
- */
- if (e < 0)
- i = 0;
- else
- i = 1;
- i = e/NXT + i;
- e = NXT*i - e;
- w = A[e];
- z = w * z; /* 2**-e * ( 1 + (2**Hb-1) ) */
- z = z + w;
- z = scalbnl(z, i); /* multiply by integer power of 2 */
-
- if (nflg)
- z = -z;
- return z;
-}
-
-
-/* Find a multiple of 1/NXT that is within 1/NXT of x. */
-static long double reducl(long double x)
-{
- long double t;
-
- t = x * NXT;
- t = floorl(t);
- t = t / NXT;
- return t;
-}
-
-/*
- * Positive real raised to integer power, long double precision
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, powil();
- * int n;
- *
- * y = powil( x, n );
- *
- *
- * DESCRIPTION:
- *
- * Returns argument x>0 raised to the nth power.
- * The routine efficiently decomposes n as a sum of powers of
- * two. The desired power is a product of two-to-the-kth
- * powers of x. Thus to compute the 32767 power of x requires
- * 28 multiplications instead of 32767 multiplications.
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic x domain n domain # trials peak rms
- * IEEE .001,1000 -1022,1023 50000 4.3e-17 7.8e-18
- * IEEE 1,2 -1022,1023 20000 3.9e-17 7.6e-18
- * IEEE .99,1.01 0,8700 10000 3.6e-16 7.2e-17
- *
- * Returns MAXNUM on overflow, zero on underflow.
- */
-
-static long double powil(long double x, int nn)
-{
- long double ww, y;
- long double s;
- int n, e, sign, lx;
-
- if (nn == 0)
- return 1.0;
-
- if (nn < 0) {
- sign = -1;
- n = -nn;
- } else {
- sign = 1;
- n = nn;
- }
-
- /* Overflow detection */
-
- /* Calculate approximate logarithm of answer */
- s = x;
- s = frexpl( s, &lx);
- e = (lx - 1)*n;
- if ((e == 0) || (e > 64) || (e < -64)) {
- s = (s - 7.0710678118654752e-1L) / (s + 7.0710678118654752e-1L);
- s = (2.9142135623730950L * s - 0.5 + lx) * nn * LOGE2L;
- } else {
- s = LOGE2L * e;
- }
-
- if (s > MAXLOGL)
- return huge * huge; /* overflow */
-
- if (s < MINLOGL)
- return twom10000 * twom10000; /* underflow */
- /* Handle tiny denormal answer, but with less accuracy
- * since roundoff error in 1.0/x will be amplified.
- * The precise demarcation should be the gradual underflow threshold.
- */
- if (s < -MAXLOGL+2.0) {
- x = 1.0/x;
- sign = -sign;
- }
-
- /* First bit of the power */
- if (n & 1)
- y = x;
- else
- y = 1.0;
-
- ww = x;
- n >>= 1;
- while (n) {
- ww = ww * ww; /* arg to the 2-to-the-kth power */
- if (n & 1) /* if that bit is set, then include in product */
- y *= ww;
- n >>= 1;
- }
-
- if (sign < 0)
- y = 1.0/y;
- return y;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double powl(long double x, long double y)
-{
- return pow(x, y);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/remainder.c b/lib/mlibc/options/ansi/musl-generic-math/remainder.c
deleted file mode 100644
index e4abcd7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/remainder.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <math.h>
-#include "weak_alias.h"
-//#include "libc.h"
-
-double remainder(double x, double y)
-{
- int q;
- return remquo(x, y, &q);
-}
-
-weak_alias(remainder, drem);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/remainderf.c b/lib/mlibc/options/ansi/musl-generic-math/remainderf.c
deleted file mode 100644
index e1fcdaa..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/remainderf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <math.h>
-#include "weak_alias.h"
-//#include "libc.h"
-
-float remainderf(float x, float y)
-{
- int q;
- return remquof(x, y, &q);
-}
-
-weak_alias(remainderf, dremf);
diff --git a/lib/mlibc/options/ansi/musl-generic-math/remainderl.c b/lib/mlibc/options/ansi/musl-generic-math/remainderl.c
deleted file mode 100644
index 2a13c1d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/remainderl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-#include <float.h>
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double remainderl(long double x, long double y)
-{
- return remainder(x, y);
-}
-#else
-long double remainderl(long double x, long double y)
-{
- int q;
- return remquol(x, y, &q);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/remquo.c b/lib/mlibc/options/ansi/musl-generic-math/remquo.c
deleted file mode 100644
index 59d5ad5..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/remquo.c
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-double remquo(double x, double y, int *quo)
-{
- union {double f; uint64_t i;} ux = {x}, uy = {y};
- int ex = ux.i>>52 & 0x7ff;
- int ey = uy.i>>52 & 0x7ff;
- int sx = ux.i>>63;
- int sy = uy.i>>63;
- uint32_t q;
- uint64_t i;
- uint64_t uxi = ux.i;
-
- *quo = 0;
- if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff)
- return (x*y)/(x*y);
- if (ux.i<<1 == 0)
- return x;
-
- /* normalize x and y */
- if (!ex) {
- for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1);
- uxi <<= -ex + 1;
- } else {
- uxi &= -1ULL >> 12;
- uxi |= 1ULL << 52;
- }
- if (!ey) {
- for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1);
- uy.i <<= -ey + 1;
- } else {
- uy.i &= -1ULL >> 12;
- uy.i |= 1ULL << 52;
- }
-
- q = 0;
- if (ex < ey) {
- if (ex+1 == ey)
- goto end;
- return x;
- }
-
- /* x mod y */
- for (; ex > ey; ex--) {
- i = uxi - uy.i;
- if (i >> 63 == 0) {
- uxi = i;
- q++;
- }
- uxi <<= 1;
- q <<= 1;
- }
- i = uxi - uy.i;
- if (i >> 63 == 0) {
- uxi = i;
- q++;
- }
- if (uxi == 0)
- ex = -60;
- else
- for (; uxi>>52 == 0; uxi <<= 1, ex--);
-end:
- /* scale result and decide between |x| and |x|-|y| */
- if (ex > 0) {
- uxi -= 1ULL << 52;
- uxi |= (uint64_t)ex << 52;
- } else {
- uxi >>= -ex + 1;
- }
- ux.i = uxi;
- x = ux.f;
- if (sy)
- y = -y;
- if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
- x -= y;
- q++;
- }
- q &= 0x7fffffff;
- *quo = sx^sy ? -(int)q : (int)q;
- return sx ? -x : x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/remquof.c b/lib/mlibc/options/ansi/musl-generic-math/remquof.c
deleted file mode 100644
index 2f41ff7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/remquof.c
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float remquof(float x, float y, int *quo)
-{
- union {float f; uint32_t i;} ux = {x}, uy = {y};
- int ex = ux.i>>23 & 0xff;
- int ey = uy.i>>23 & 0xff;
- int sx = ux.i>>31;
- int sy = uy.i>>31;
- uint32_t q;
- uint32_t i;
- uint32_t uxi = ux.i;
-
- *quo = 0;
- if (uy.i<<1 == 0 || isnan(y) || ex == 0xff)
- return (x*y)/(x*y);
- if (ux.i<<1 == 0)
- return x;
-
- /* normalize x and y */
- if (!ex) {
- for (i = uxi<<9; i>>31 == 0; ex--, i <<= 1);
- uxi <<= -ex + 1;
- } else {
- uxi &= -1U >> 9;
- uxi |= 1U << 23;
- }
- if (!ey) {
- for (i = uy.i<<9; i>>31 == 0; ey--, i <<= 1);
- uy.i <<= -ey + 1;
- } else {
- uy.i &= -1U >> 9;
- uy.i |= 1U << 23;
- }
-
- q = 0;
- if (ex < ey) {
- if (ex+1 == ey)
- goto end;
- return x;
- }
-
- /* x mod y */
- for (; ex > ey; ex--) {
- i = uxi - uy.i;
- if (i >> 31 == 0) {
- uxi = i;
- q++;
- }
- uxi <<= 1;
- q <<= 1;
- }
- i = uxi - uy.i;
- if (i >> 31 == 0) {
- uxi = i;
- q++;
- }
- if (uxi == 0)
- ex = -30;
- else
- for (; uxi>>23 == 0; uxi <<= 1, ex--);
-end:
- /* scale result and decide between |x| and |x|-|y| */
- if (ex > 0) {
- uxi -= 1U << 23;
- uxi |= (uint32_t)ex << 23;
- } else {
- uxi >>= -ex + 1;
- }
- ux.i = uxi;
- x = ux.f;
- if (sy)
- y = -y;
- if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
- x -= y;
- q++;
- }
- q &= 0x7fffffff;
- *quo = sx^sy ? -(int)q : (int)q;
- return sx ? -x : x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/remquol.c b/lib/mlibc/options/ansi/musl-generic-math/remquol.c
deleted file mode 100644
index 9b065c0..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/remquol.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double remquol(long double x, long double y, int *quo)
-{
- return remquo(x, y, quo);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double remquol(long double x, long double y, int *quo)
-{
- union ldshape ux = {x}, uy = {y};
- int ex = ux.i.se & 0x7fff;
- int ey = uy.i.se & 0x7fff;
- int sx = ux.i.se >> 15;
- int sy = uy.i.se >> 15;
- uint32_t q;
-
- *quo = 0;
- if (y == 0 || isnan(y) || ex == 0x7fff)
- return (x*y)/(x*y);
- if (x == 0)
- return x;
-
- /* normalize x and y */
- if (!ex) {
- ux.i.se = ex;
- ux.f *= 0x1p120f;
- ex = ux.i.se - 120;
- }
- if (!ey) {
- uy.i.se = ey;
- uy.f *= 0x1p120f;
- ey = uy.i.se - 120;
- }
-
- q = 0;
- if (ex >= ey) {
- /* x mod y */
-#if LDBL_MANT_DIG == 64
- uint64_t i, mx, my;
- mx = ux.i.m;
- my = uy.i.m;
- for (; ex > ey; ex--) {
- i = mx - my;
- if (mx >= my) {
- mx = 2*i;
- q++;
- q <<= 1;
- } else if (2*mx < mx) {
- mx = 2*mx - my;
- q <<= 1;
- q++;
- } else {
- mx = 2*mx;
- q <<= 1;
- }
- }
- i = mx - my;
- if (mx >= my) {
- mx = i;
- q++;
- }
- if (mx == 0)
- ex = -120;
- else
- for (; mx >> 63 == 0; mx *= 2, ex--);
- ux.i.m = mx;
-#elif LDBL_MANT_DIG == 113
- uint64_t hi, lo, xhi, xlo, yhi, ylo;
- xhi = (ux.i2.hi & -1ULL>>16) | 1ULL<<48;
- yhi = (uy.i2.hi & -1ULL>>16) | 1ULL<<48;
- xlo = ux.i2.lo;
- ylo = ux.i2.lo;
- for (; ex > ey; ex--) {
- hi = xhi - yhi;
- lo = xlo - ylo;
- if (xlo < ylo)
- hi -= 1;
- if (hi >> 63 == 0) {
- xhi = 2*hi + (lo>>63);
- xlo = 2*lo;
- q++;
- } else {
- xhi = 2*xhi + (xlo>>63);
- xlo = 2*xlo;
- }
- q <<= 1;
- }
- hi = xhi - yhi;
- lo = xlo - ylo;
- if (xlo < ylo)
- hi -= 1;
- if (hi >> 63 == 0) {
- xhi = hi;
- xlo = lo;
- q++;
- }
- if ((xhi|xlo) == 0)
- ex = -120;
- else
- for (; xhi >> 48 == 0; xhi = 2*xhi + (xlo>>63), xlo = 2*xlo, ex--);
- ux.i2.hi = xhi;
- ux.i2.lo = xlo;
-#endif
- }
-
- /* scale result and decide between |x| and |x|-|y| */
- if (ex <= 0) {
- ux.i.se = ex + 120;
- ux.f *= 0x1p-120f;
- } else
- ux.i.se = ex;
- x = ux.f;
- if (sy)
- y = -y;
- if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
- x -= y;
- q++;
- }
- q &= 0x7fffffff;
- *quo = sx^sy ? -(int)q : (int)q;
- return sx ? -x : x;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/rint.c b/lib/mlibc/options/ansi/musl-generic-math/rint.c
deleted file mode 100644
index fbba390..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/rint.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double rint(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i>>52 & 0x7ff;
- int s = u.i>>63;
- double_t y;
-
- if (e >= 0x3ff+52)
- return x;
- if (s)
- y = x - toint + toint;
- else
- y = x + toint - toint;
- if (y == 0)
- return s ? -0.0 : 0;
- return y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/rintf.c b/lib/mlibc/options/ansi/musl-generic-math/rintf.c
deleted file mode 100644
index 9047688..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/rintf.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-
-#if FLT_EVAL_METHOD==0
-#define EPS FLT_EPSILON
-#elif FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const float_t toint = 1/EPS;
-
-float rintf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = u.i>>23 & 0xff;
- int s = u.i>>31;
- float_t y;
-
- if (e >= 0x7f+23)
- return x;
- if (s)
- y = x - toint + toint;
- else
- y = x + toint - toint;
- if (y == 0)
- return s ? -0.0f : 0.0f;
- return y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/rintl.c b/lib/mlibc/options/ansi/musl-generic-math/rintl.c
deleted file mode 100644
index 374327d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/rintl.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double rintl(long double x)
-{
- return rint(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-static const long double toint = 1/LDBL_EPSILON;
-
-long double rintl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- int s = u.i.se >> 15;
- long double y;
-
- if (e >= 0x3fff+LDBL_MANT_DIG-1)
- return x;
- if (s)
- y = x - toint + toint;
- else
- y = x + toint - toint;
- if (y == 0)
- return 0*x;
- return y;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/round.c b/lib/mlibc/options/ansi/musl-generic-math/round.c
deleted file mode 100644
index 130d58d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/round.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double round(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i >> 52 & 0x7ff;
- double_t y;
-
- if (e >= 0x3ff+52)
- return x;
- if (u.i >> 63)
- x = -x;
- if (e < 0x3ff-1) {
- /* raise inexact if x!=0 */
- FORCE_EVAL(x + toint);
- return 0*u.f;
- }
- y = x + toint - toint - x;
- if (y > 0.5)
- y = y + x - 1;
- else if (y <= -0.5)
- y = y + x + 1;
- else
- y = y + x;
- if (u.i >> 63)
- y = -y;
- return y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/roundf.c b/lib/mlibc/options/ansi/musl-generic-math/roundf.c
deleted file mode 100644
index e8210af..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/roundf.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0
-#define EPS FLT_EPSILON
-#elif FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const float_t toint = 1/EPS;
-
-float roundf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = u.i >> 23 & 0xff;
- float_t y;
-
- if (e >= 0x7f+23)
- return x;
- if (u.i >> 31)
- x = -x;
- if (e < 0x7f-1) {
- FORCE_EVAL(x + toint);
- return 0*u.f;
- }
- y = x + toint - toint - x;
- if (y > 0.5f)
- y = y + x - 1;
- else if (y <= -0.5f)
- y = y + x + 1;
- else
- y = y + x;
- if (u.i >> 31)
- y = -y;
- return y;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/roundl.c b/lib/mlibc/options/ansi/musl-generic-math/roundl.c
deleted file mode 100644
index f4ff682..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/roundl.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double roundl(long double x)
-{
- return round(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-static const long double toint = 1/LDBL_EPSILON;
-
-long double roundl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- long double y;
-
- if (e >= 0x3fff+LDBL_MANT_DIG-1)
- return x;
- if (u.i.se >> 15)
- x = -x;
- if (e < 0x3fff-1) {
- FORCE_EVAL(x + toint);
- return 0*u.f;
- }
- y = x + toint - toint - x;
- if (y > 0.5)
- y = y + x - 1;
- else if (y <= -0.5)
- y = y + x + 1;
- else
- y = y + x;
- if (u.i.se >> 15)
- y = -y;
- return y;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalb.c b/lib/mlibc/options/ansi/musl-generic-math/scalb.c
deleted file mode 100644
index efe69e6..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalb.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_scalb.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/*
- * scalb(x, fn) is provide for
- * passing various standard test suite. One
- * should use scalbn() instead.
- */
-
-#define _GNU_SOURCE
-#include <math.h>
-
-double scalb(double x, double fn)
-{
- if (isnan(x) || isnan(fn))
- return x*fn;
- if (!isfinite(fn)) {
- if (fn > 0.0)
- return x*fn;
- else
- return x/(-fn);
- }
- if (rint(fn) != fn) return (fn-fn)/(fn-fn);
- if ( fn > 65000.0) return scalbn(x, 65000);
- if (-fn > 65000.0) return scalbn(x,-65000);
- return scalbn(x,(int)fn);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalbf.c b/lib/mlibc/options/ansi/musl-generic-math/scalbf.c
deleted file mode 100644
index f44ed5b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalbf.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_scalbf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#define _GNU_SOURCE
-#include <math.h>
-
-float scalbf(float x, float fn)
-{
- if (isnan(x) || isnan(fn)) return x*fn;
- if (!isfinite(fn)) {
- if (fn > 0.0f)
- return x*fn;
- else
- return x/(-fn);
- }
- if (rintf(fn) != fn) return (fn-fn)/(fn-fn);
- if ( fn > 65000.0f) return scalbnf(x, 65000);
- if (-fn > 65000.0f) return scalbnf(x,-65000);
- return scalbnf(x,(int)fn);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalbln.c b/lib/mlibc/options/ansi/musl-generic-math/scalbln.c
deleted file mode 100644
index 4fb3d06..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalbln.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <limits.h>
-#include <math.h>
-#include "libm.h"
-
-double scalbln(double x, long n)
-{
- if (n > INT_MAX)
- n = INT_MAX;
- else if (n < INT_MIN)
- n = INT_MIN;
- return scalbn(x, n);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalblnf.c b/lib/mlibc/options/ansi/musl-generic-math/scalblnf.c
deleted file mode 100644
index b6bdeed..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalblnf.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <limits.h>
-#include <math.h>
-#include "libm.h"
-
-float scalblnf(float x, long n)
-{
- if (n > INT_MAX)
- n = INT_MAX;
- else if (n < INT_MIN)
- n = INT_MIN;
- return scalbnf(x, n);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalblnl.c b/lib/mlibc/options/ansi/musl-generic-math/scalblnl.c
deleted file mode 100644
index b1a0f7f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalblnl.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <limits.h>
-#include <math.h>
-#include <float.h>
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double scalblnl(long double x, long n)
-{
- return scalbln(x, n);
-}
-#else
-long double scalblnl(long double x, long n)
-{
- if (n > INT_MAX)
- n = INT_MAX;
- else if (n < INT_MIN)
- n = INT_MIN;
- return scalbnl(x, n);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalbn.c b/lib/mlibc/options/ansi/musl-generic-math/scalbn.c
deleted file mode 100644
index 182f561..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalbn.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-double scalbn(double x, int n)
-{
- union {double f; uint64_t i;} u;
- double_t y = x;
-
- if (n > 1023) {
- y *= 0x1p1023;
- n -= 1023;
- if (n > 1023) {
- y *= 0x1p1023;
- n -= 1023;
- if (n > 1023)
- n = 1023;
- }
- } else if (n < -1022) {
- /* make sure final n < -53 to avoid double
- rounding in the subnormal range */
- y *= 0x1p-1022 * 0x1p53;
- n += 1022 - 53;
- if (n < -1022) {
- y *= 0x1p-1022 * 0x1p53;
- n += 1022 - 53;
- if (n < -1022)
- n = -1022;
- }
- }
- u.i = (uint64_t)(0x3ff+n)<<52;
- x = y * u.f;
- return x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalbnf.c b/lib/mlibc/options/ansi/musl-generic-math/scalbnf.c
deleted file mode 100644
index a5ad208..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalbnf.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float scalbnf(float x, int n)
-{
- union {float f; uint32_t i;} u;
- float_t y = x;
-
- if (n > 127) {
- y *= 0x1p127f;
- n -= 127;
- if (n > 127) {
- y *= 0x1p127f;
- n -= 127;
- if (n > 127)
- n = 127;
- }
- } else if (n < -126) {
- y *= 0x1p-126f * 0x1p24f;
- n += 126 - 24;
- if (n < -126) {
- y *= 0x1p-126f * 0x1p24f;
- n += 126 - 24;
- if (n < -126)
- n = -126;
- }
- }
- u.i = (uint32_t)(0x7f+n)<<23;
- x = y * u.f;
- return x;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/scalbnl.c b/lib/mlibc/options/ansi/musl-generic-math/scalbnl.c
deleted file mode 100644
index db44dab..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/scalbnl.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double scalbnl(long double x, int n)
-{
- return scalbn(x, n);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double scalbnl(long double x, int n)
-{
- union ldshape u;
-
- if (n > 16383) {
- x *= 0x1p16383L;
- n -= 16383;
- if (n > 16383) {
- x *= 0x1p16383L;
- n -= 16383;
- if (n > 16383)
- n = 16383;
- }
- } else if (n < -16382) {
- x *= 0x1p-16382L * 0x1p113L;
- n += 16382 - 113;
- if (n < -16382) {
- x *= 0x1p-16382L * 0x1p113L;
- n += 16382 - 113;
- if (n < -16382)
- n = -16382;
- }
- }
- u.f = 1.0;
- u.i.se = 0x3fff + n;
- return x * u.f;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/signgam.c b/lib/mlibc/options/ansi/musl-generic-math/signgam.c
deleted file mode 100644
index 3a5b9f7..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/signgam.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <math.h>
-#include "weak_alias.h"
-//#include "libc.h"
-
-int signgam = 0;
diff --git a/lib/mlibc/options/ansi/musl-generic-math/significand.c b/lib/mlibc/options/ansi/musl-generic-math/significand.c
deleted file mode 100644
index 40d9aa9..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/significand.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#define _GNU_SOURCE
-#include <math.h>
-
-double significand(double x)
-{
- return scalbn(x, -ilogb(x));
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/significandf.c b/lib/mlibc/options/ansi/musl-generic-math/significandf.c
deleted file mode 100644
index 8a697e1..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/significandf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#define _GNU_SOURCE
-#include <math.h>
-
-float significandf(float x)
-{
- return scalbnf(x, -ilogbf(x));
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sin.c b/lib/mlibc/options/ansi/musl-generic-math/sin.c
deleted file mode 100644
index 055e215..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sin.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* sin(x)
- * Return sine function of x.
- *
- * kernel function:
- * __sin ... sine function on [-pi/4,pi/4]
- * __cos ... cose function on [-pi/4,pi/4]
- * __rem_pio2 ... argument reduction routine
- *
- * Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- * in [-pi/4 , +pi/4], and let n = k mod 4.
- * We have
- *
- * n sin(x) cos(x) tan(x)
- * ----------------------------------------------------------
- * 0 S C T
- * 1 C -S -1/T
- * 2 -S -C T
- * 3 -C S -1/T
- * ----------------------------------------------------------
- *
- * Special cases:
- * Let trig be any of sin, cos, or tan.
- * trig(+-INF) is NaN, with signals;
- * trig(NaN) is that NaN;
- *
- * Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "libm.h"
-
-double sin(double x)
-{
- double y[2];
- uint32_t ix;
- unsigned n;
-
- /* High word of x. */
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
-
- /* |x| ~< pi/4 */
- if (ix <= 0x3fe921fb) {
- if (ix < 0x3e500000) { /* |x| < 2**-26 */
- /* raise inexact if x != 0 and underflow if subnormal*/
- FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
- return x;
- }
- return __sin(x, 0.0, 0);
- }
-
- /* sin(Inf or NaN) is NaN */
- if (ix >= 0x7ff00000)
- return x - x;
-
- /* argument reduction needed */
- n = __rem_pio2(x, y);
- switch (n&3) {
- case 0: return __sin(y[0], y[1], 1);
- case 1: return __cos(y[0], y[1]);
- case 2: return -__sin(y[0], y[1], 1);
- default:
- return -__cos(y[0], y[1]);
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sincos.c b/lib/mlibc/options/ansi/musl-generic-math/sincos.c
deleted file mode 100644
index 35b2d92..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sincos.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_sin.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#define _GNU_SOURCE
-#include "libm.h"
-
-void sincos(double x, double *sin, double *cos)
-{
- double y[2], s, c;
- uint32_t ix;
- unsigned n;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
-
- /* |x| ~< pi/4 */
- if (ix <= 0x3fe921fb) {
- /* if |x| < 2**-27 * sqrt(2) */
- if (ix < 0x3e46a09e) {
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
- *sin = x;
- *cos = 1.0;
- return;
- }
- *sin = __sin(x, 0.0, 0);
- *cos = __cos(x, 0.0);
- return;
- }
-
- /* sincos(Inf or NaN) is NaN */
- if (ix >= 0x7ff00000) {
- *sin = *cos = x - x;
- return;
- }
-
- /* argument reduction needed */
- n = __rem_pio2(x, y);
- s = __sin(y[0], y[1], 1);
- c = __cos(y[0], y[1]);
- switch (n&3) {
- case 0:
- *sin = s;
- *cos = c;
- break;
- case 1:
- *sin = c;
- *cos = -s;
- break;
- case 2:
- *sin = -s;
- *cos = -c;
- break;
- case 3:
- default:
- *sin = -c;
- *cos = s;
- break;
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sincosf.c b/lib/mlibc/options/ansi/musl-generic-math/sincosf.c
deleted file mode 100644
index f8ca723..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sincosf.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#define _GNU_SOURCE
-#include "libm.h"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
-s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
-s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
-s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
-void sincosf(float x, float *sin, float *cos)
-{
- double y;
- float_t s, c;
- uint32_t ix;
- unsigned n, sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
-
- /* |x| ~<= pi/4 */
- if (ix <= 0x3f490fda) {
- /* |x| < 2**-12 */
- if (ix < 0x39800000) {
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
- *sin = x;
- *cos = 1.0f;
- return;
- }
- *sin = __sindf(x);
- *cos = __cosdf(x);
- return;
- }
-
- /* |x| ~<= 5*pi/4 */
- if (ix <= 0x407b53d1) {
- if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
- if (sign) {
- *sin = -__cosdf(x + s1pio2);
- *cos = __sindf(x + s1pio2);
- } else {
- *sin = __cosdf(s1pio2 - x);
- *cos = __sindf(s1pio2 - x);
- }
- return;
- }
- /* -sin(x+c) is not correct if x+c could be 0: -0 vs +0 */
- *sin = -__sindf(sign ? x + s2pio2 : x - s2pio2);
- *cos = -__cosdf(sign ? x + s2pio2 : x - s2pio2);
- return;
- }
-
- /* |x| ~<= 9*pi/4 */
- if (ix <= 0x40e231d5) {
- if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
- if (sign) {
- *sin = __cosdf(x + s3pio2);
- *cos = -__sindf(x + s3pio2);
- } else {
- *sin = -__cosdf(x - s3pio2);
- *cos = __sindf(x - s3pio2);
- }
- return;
- }
- *sin = __sindf(sign ? x + s4pio2 : x - s4pio2);
- *cos = __cosdf(sign ? x + s4pio2 : x - s4pio2);
- return;
- }
-
- /* sin(Inf or NaN) is NaN */
- if (ix >= 0x7f800000) {
- *sin = *cos = x - x;
- return;
- }
-
- /* general argument reduction needed */
- n = __rem_pio2f(x, &y);
- s = __sindf(y);
- c = __cosdf(y);
- switch (n&3) {
- case 0:
- *sin = s;
- *cos = c;
- break;
- case 1:
- *sin = c;
- *cos = -s;
- break;
- case 2:
- *sin = -s;
- *cos = -c;
- break;
- case 3:
- default:
- *sin = -c;
- *cos = s;
- break;
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sincosl.c b/lib/mlibc/options/ansi/musl-generic-math/sincosl.c
deleted file mode 100644
index d3ac1c4..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sincosl.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#define _GNU_SOURCE
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-void sincosl(long double x, long double *sin, long double *cos)
-{
- double sind, cosd;
- sincos(x, &sind, &cosd);
- *sin = sind;
- *cos = cosd;
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-void sincosl(long double x, long double *sin, long double *cos)
-{
- union ldshape u = {x};
- unsigned n;
- long double y[2], s, c;
-
- u.i.se &= 0x7fff;
- if (u.i.se == 0x7fff) {
- *sin = *cos = x - x;
- return;
- }
- if (u.f < M_PI_4) {
- if (u.i.se < 0x3fff - LDBL_MANT_DIG) {
- /* raise underflow if subnormal */
- if (u.i.se == 0) FORCE_EVAL(x*0x1p-120f);
- *sin = x;
- /* raise inexact if x!=0 */
- *cos = 1.0 + x;
- return;
- }
- *sin = __sinl(x, 0, 0);
- *cos = __cosl(x, 0);
- return;
- }
- n = __rem_pio2l(x, y);
- s = __sinl(y[0], y[1], 1);
- c = __cosl(y[0], y[1]);
- switch (n & 3) {
- case 0:
- *sin = s;
- *cos = c;
- break;
- case 1:
- *sin = c;
- *cos = -s;
- break;
- case 2:
- *sin = -s;
- *cos = -c;
- break;
- case 3:
- default:
- *sin = -c;
- *cos = s;
- break;
- }
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sinf.c b/lib/mlibc/options/ansi/musl-generic-math/sinf.c
deleted file mode 100644
index 64e39f5..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sinf.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
-s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
-s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
-s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
-float sinf(float x)
-{
- double y;
- uint32_t ix;
- int n, sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
-
- if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f);
- return x;
- }
- return __sindf(x);
- }
- if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
- if (sign)
- return -__cosdf(x + s1pio2);
- else
- return __cosdf(x - s1pio2);
- }
- return __sindf(sign ? -(x + s2pio2) : -(x - s2pio2));
- }
- if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
- if (sign)
- return __cosdf(x + s3pio2);
- else
- return -__cosdf(x - s3pio2);
- }
- return __sindf(sign ? x + s4pio2 : x - s4pio2);
- }
-
- /* sin(Inf or NaN) is NaN */
- if (ix >= 0x7f800000)
- return x - x;
-
- /* general argument reduction needed */
- n = __rem_pio2f(x, &y);
- switch (n&3) {
- case 0: return __sindf(y);
- case 1: return __cosdf(y);
- case 2: return __sindf(-y);
- default:
- return -__cosdf(y);
- }
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sinh.c b/lib/mlibc/options/ansi/musl-generic-math/sinh.c
deleted file mode 100644
index 00022c4..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sinh.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "libm.h"
-
-/* sinh(x) = (exp(x) - 1/exp(x))/2
- * = (exp(x)-1 + (exp(x)-1)/exp(x))/2
- * = x + x^3/6 + o(x^5)
- */
-double sinh(double x)
-{
- union {double f; uint64_t i;} u = {.f = x};
- uint32_t w;
- double t, h, absx;
-
- h = 0.5;
- if (u.i >> 63)
- h = -h;
- /* |x| */
- u.i &= (uint64_t)-1/2;
- absx = u.f;
- w = u.i >> 32;
-
- /* |x| < log(DBL_MAX) */
- if (w < 0x40862e42) {
- t = expm1(absx);
- if (w < 0x3ff00000) {
- if (w < 0x3ff00000 - (26<<20))
- /* note: inexact and underflow are raised by expm1 */
- /* note: this branch avoids spurious underflow */
- return x;
- return h*(2*t - t*t/(t+1));
- }
- /* note: |x|>log(0x1p26)+eps could be just h*exp(x) */
- return h*(t + t/(t+1));
- }
-
- /* |x| > log(DBL_MAX) or nan */
- /* note: the result is stored to handle overflow */
- t = 2*h*__expo2(absx);
- return t;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sinhf.c b/lib/mlibc/options/ansi/musl-generic-math/sinhf.c
deleted file mode 100644
index 6ad19ea..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sinhf.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "libm.h"
-
-float sinhf(float x)
-{
- union {float f; uint32_t i;} u = {.f = x};
- uint32_t w;
- float t, h, absx;
-
- h = 0.5;
- if (u.i >> 31)
- h = -h;
- /* |x| */
- u.i &= 0x7fffffff;
- absx = u.f;
- w = u.i;
-
- /* |x| < log(FLT_MAX) */
- if (w < 0x42b17217) {
- t = expm1f(absx);
- if (w < 0x3f800000) {
- if (w < 0x3f800000 - (12<<23))
- return x;
- return h*(2*t - t*t/(t+1));
- }
- return h*(t + t/(t+1));
- }
-
- /* |x| > logf(FLT_MAX) or nan */
- t = 2*h*__expo2f(absx);
- return t;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sinhl.c b/lib/mlibc/options/ansi/musl-generic-math/sinhl.c
deleted file mode 100644
index b305d4d..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sinhl.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double sinhl(long double x)
-{
- return sinh(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-long double sinhl(long double x)
-{
- union ldshape u = {x};
- unsigned ex = u.i.se & 0x7fff;
- long double h, t, absx;
-
- h = 0.5;
- if (u.i.se & 0x8000)
- h = -h;
- /* |x| */
- u.i.se = ex;
- absx = u.f;
-
- /* |x| < log(LDBL_MAX) */
- if (ex < 0x3fff+13 || (ex == 0x3fff+13 && u.i.m>>32 < 0xb17217f7)) {
- t = expm1l(absx);
- if (ex < 0x3fff) {
- if (ex < 0x3fff-32)
- return x;
- return h*(2*t - t*t/(1+t));
- }
- return h*(t + t/(t+1));
- }
-
- /* |x| > log(LDBL_MAX) or nan */
- t = expl(0.5*absx);
- return h*t*t;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double sinhl(long double x)
-{
- return sinh(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sinl.c b/lib/mlibc/options/ansi/musl-generic-math/sinl.c
deleted file mode 100644
index 9c0b16e..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sinl.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double sinl(long double x)
-{
- return sin(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double sinl(long double x)
-{
- union ldshape u = {x};
- unsigned n;
- long double y[2], hi, lo;
-
- u.i.se &= 0x7fff;
- if (u.i.se == 0x7fff)
- return x - x;
- if (u.f < M_PI_4) {
- if (u.i.se < 0x3fff - LDBL_MANT_DIG/2) {
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(u.i.se == 0 ? x*0x1p-120f : x+0x1p120f);
- return x;
- }
- return __sinl(x, 0.0, 0);
- }
- n = __rem_pio2l(x, y);
- hi = y[0];
- lo = y[1];
- switch (n & 3) {
- case 0:
- return __sinl(hi, lo, 1);
- case 1:
- return __cosl(hi, lo);
- case 2:
- return -__sinl(hi, lo, 1);
- case 3:
- default:
- return -__cosl(hi, lo);
- }
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sqrt.c b/lib/mlibc/options/ansi/musl-generic-math/sqrt.c
deleted file mode 100644
index b277567..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sqrt.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrt.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* sqrt(x)
- * Return correctly rounded sqrt.
- * ------------------------------------------
- * | Use the hardware sqrt if you have one |
- * ------------------------------------------
- * Method:
- * Bit by bit method using integer arithmetic. (Slow, but portable)
- * 1. Normalization
- * Scale x to y in [1,4) with even powers of 2:
- * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then
- * sqrt(x) = 2^k * sqrt(y)
- * 2. Bit by bit computation
- * Let q = sqrt(y) truncated to i bit after binary point (q = 1),
- * i 0
- * i+1 2
- * s = 2*q , and y = 2 * ( y - q ). (1)
- * i i i i
- *
- * To compute q from q , one checks whether
- * i+1 i
- *
- * -(i+1) 2
- * (q + 2 ) <= y. (2)
- * i
- * -(i+1)
- * If (2) is false, then q = q ; otherwise q = q + 2 .
- * i+1 i i+1 i
- *
- * With some algebric manipulation, it is not difficult to see
- * that (2) is equivalent to
- * -(i+1)
- * s + 2 <= y (3)
- * i i
- *
- * The advantage of (3) is that s and y can be computed by
- * i i
- * the following recurrence formula:
- * if (3) is false
- *
- * s = s , y = y ; (4)
- * i+1 i i+1 i
- *
- * otherwise,
- * -i -(i+1)
- * s = s + 2 , y = y - s - 2 (5)
- * i+1 i i+1 i i
- *
- * One may easily use induction to prove (4) and (5).
- * Note. Since the left hand side of (3) contain only i+2 bits,
- * it does not necessary to do a full (53-bit) comparison
- * in (3).
- * 3. Final rounding
- * After generating the 53 bits result, we compute one more bit.
- * Together with the remainder, we can decide whether the
- * result is exact, bigger than 1/2ulp, or less than 1/2ulp
- * (it will never equal to 1/2ulp).
- * The rounding mode can be detected by checking whether
- * huge + tiny is equal to huge, and whether huge - tiny is
- * equal to huge for some floating point number "huge" and "tiny".
- *
- * Special cases:
- * sqrt(+-0) = +-0 ... exact
- * sqrt(inf) = inf
- * sqrt(-ve) = NaN ... with invalid signal
- * sqrt(NaN) = NaN ... with invalid signal for signaling NaN
- */
-
-#include "libm.h"
-
-static const double tiny = 1.0e-300;
-
-double sqrt(double x)
-{
- double z;
- int32_t sign = (int)0x80000000;
- int32_t ix0,s0,q,m,t,i;
- uint32_t r,t1,s1,ix1,q1;
-
- EXTRACT_WORDS(ix0, ix1, x);
-
- /* take care of Inf and NaN */
- if ((ix0&0x7ff00000) == 0x7ff00000) {
- return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */
- }
- /* take care of zero */
- if (ix0 <= 0) {
- if (((ix0&~sign)|ix1) == 0)
- return x; /* sqrt(+-0) = +-0 */
- if (ix0 < 0)
- return (x-x)/(x-x); /* sqrt(-ve) = sNaN */
- }
- /* normalize x */
- m = ix0>>20;
- if (m == 0) { /* subnormal x */
- while (ix0 == 0) {
- m -= 21;
- ix0 |= (ix1>>11);
- ix1 <<= 21;
- }
- for (i=0; (ix0&0x00100000) == 0; i++)
- ix0<<=1;
- m -= i - 1;
- ix0 |= ix1>>(32-i);
- ix1 <<= i;
- }
- m -= 1023; /* unbias exponent */
- ix0 = (ix0&0x000fffff)|0x00100000;
- if (m & 1) { /* odd m, double x to make it even */
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- }
- m >>= 1; /* m = [m/2] */
-
- /* generate sqrt(x) bit by bit */
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */
- r = 0x00200000; /* r = moving bit from right to left */
-
- while (r != 0) {
- t = s0 + r;
- if (t <= ix0) {
- s0 = t + r;
- ix0 -= t;
- q += r;
- }
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- r >>= 1;
- }
-
- r = sign;
- while (r != 0) {
- t1 = s1 + r;
- t = s0;
- if (t < ix0 || (t == ix0 && t1 <= ix1)) {
- s1 = t1 + r;
- if ((t1&sign) == sign && (s1&sign) == 0)
- s0++;
- ix0 -= t;
- if (ix1 < t1)
- ix0--;
- ix1 -= t1;
- q1 += r;
- }
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- r >>= 1;
- }
-
- /* use floating add to find out rounding direction */
- if ((ix0|ix1) != 0) {
- z = 1.0 - tiny; /* raise inexact flag */
- if (z >= 1.0) {
- z = 1.0 + tiny;
- if (q1 == (uint32_t)0xffffffff) {
- q1 = 0;
- q++;
- } else if (z > 1.0) {
- if (q1 == (uint32_t)0xfffffffe)
- q++;
- q1 += 2;
- } else
- q1 += q1 & 1;
- }
- }
- ix0 = (q>>1) + 0x3fe00000;
- ix1 = q1>>1;
- if (q&1)
- ix1 |= sign;
- ix0 += m << 20;
- INSERT_WORDS(z, ix0, ix1);
- return z;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sqrtf.c b/lib/mlibc/options/ansi/musl-generic-math/sqrtf.c
deleted file mode 100644
index 28cb4ad..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sqrtf.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrtf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-static const float tiny = 1.0e-30;
-
-float sqrtf(float x)
-{
- float z;
- int32_t sign = (int)0x80000000;
- int32_t ix,s,q,m,t,i;
- uint32_t r;
-
- GET_FLOAT_WORD(ix, x);
-
- /* take care of Inf and NaN */
- if ((ix&0x7f800000) == 0x7f800000)
- return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */
-
- /* take care of zero */
- if (ix <= 0) {
- if ((ix&~sign) == 0)
- return x; /* sqrt(+-0) = +-0 */
- if (ix < 0)
- return (x-x)/(x-x); /* sqrt(-ve) = sNaN */
- }
- /* normalize x */
- m = ix>>23;
- if (m == 0) { /* subnormal x */
- for (i = 0; (ix&0x00800000) == 0; i++)
- ix<<=1;
- m -= i - 1;
- }
- m -= 127; /* unbias exponent */
- ix = (ix&0x007fffff)|0x00800000;
- if (m&1) /* odd m, double x to make it even */
- ix += ix;
- m >>= 1; /* m = [m/2] */
-
- /* generate sqrt(x) bit by bit */
- ix += ix;
- q = s = 0; /* q = sqrt(x) */
- r = 0x01000000; /* r = moving bit from right to left */
-
- while (r != 0) {
- t = s + r;
- if (t <= ix) {
- s = t+r;
- ix -= t;
- q += r;
- }
- ix += ix;
- r >>= 1;
- }
-
- /* use floating add to find out rounding direction */
- if (ix != 0) {
- z = 1.0f - tiny; /* raise inexact flag */
- if (z >= 1.0f) {
- z = 1.0f + tiny;
- if (z > 1.0f)
- q += 2;
- else
- q += q & 1;
- }
- }
- ix = (q>>1) + 0x3f000000;
- ix += m << 23;
- SET_FLOAT_WORD(z, ix);
- return z;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/sqrtl.c b/lib/mlibc/options/ansi/musl-generic-math/sqrtl.c
deleted file mode 100644
index 83a8f80..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/sqrtl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-long double sqrtl(long double x)
-{
- /* FIXME: implement in C, this is for LDBL_MANT_DIG == 64 only */
- return sqrt(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tan.c b/lib/mlibc/options/ansi/musl-generic-math/tan.c
deleted file mode 100644
index 9c724a4..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tan.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-/* tan(x)
- * Return tangent function of x.
- *
- * kernel function:
- * __tan ... tangent function on [-pi/4,pi/4]
- * __rem_pio2 ... argument reduction routine
- *
- * Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- * in [-pi/4 , +pi/4], and let n = k mod 4.
- * We have
- *
- * n sin(x) cos(x) tan(x)
- * ----------------------------------------------------------
- * 0 S C T
- * 1 C -S -1/T
- * 2 -S -C T
- * 3 -C S -1/T
- * ----------------------------------------------------------
- *
- * Special cases:
- * Let trig be any of sin, cos, or tan.
- * trig(+-INF) is NaN, with signals;
- * trig(NaN) is that NaN;
- *
- * Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "libm.h"
-
-double tan(double x)
-{
- double y[2];
- uint32_t ix;
- unsigned n;
-
- GET_HIGH_WORD(ix, x);
- ix &= 0x7fffffff;
-
- /* |x| ~< pi/4 */
- if (ix <= 0x3fe921fb) {
- if (ix < 0x3e400000) { /* |x| < 2**-27 */
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
- return x;
- }
- return __tan(x, 0.0, 0);
- }
-
- /* tan(Inf or NaN) is NaN */
- if (ix >= 0x7ff00000)
- return x - x;
-
- /* argument reduction */
- n = __rem_pio2(x, y);
- return __tan(y[0], y[1], n&1);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tanf.c b/lib/mlibc/options/ansi/musl-generic-math/tanf.c
deleted file mode 100644
index aba1977..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tanf.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* origin: FreeBSD /usr/src/lib/msun/src/s_tanf.c */
-/*
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "libm.h"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-t1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
-t2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
-t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
-t4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
-float tanf(float x)
-{
- double y;
- uint32_t ix;
- unsigned n, sign;
-
- GET_FLOAT_WORD(ix, x);
- sign = ix >> 31;
- ix &= 0x7fffffff;
-
- if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f);
- return x;
- }
- return __tandf(x, 0);
- }
- if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if (ix <= 0x4016cbe3) /* |x| ~<= 3pi/4 */
- return __tandf((sign ? x+t1pio2 : x-t1pio2), 1);
- else
- return __tandf((sign ? x+t2pio2 : x-t2pio2), 0);
- }
- if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if (ix <= 0x40afeddf) /* |x| ~<= 7*pi/4 */
- return __tandf((sign ? x+t3pio2 : x-t3pio2), 1);
- else
- return __tandf((sign ? x+t4pio2 : x-t4pio2), 0);
- }
-
- /* tan(Inf or NaN) is NaN */
- if (ix >= 0x7f800000)
- return x - x;
-
- /* argument reduction */
- n = __rem_pio2f(x, &y);
- return __tandf(y, n&1);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tanh.c b/lib/mlibc/options/ansi/musl-generic-math/tanh.c
deleted file mode 100644
index 20d6dbc..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tanh.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "libm.h"
-
-/* tanh(x) = (exp(x) - exp(-x))/(exp(x) + exp(-x))
- * = (exp(2*x) - 1)/(exp(2*x) - 1 + 2)
- * = (1 - exp(-2*x))/(exp(-2*x) - 1 + 2)
- */
-double tanh(double x)
-{
- union {double f; uint64_t i;} u = {.f = x};
- uint32_t w;
- int sign;
- double_t t;
-
- /* x = |x| */
- sign = u.i >> 63;
- u.i &= (uint64_t)-1/2;
- x = u.f;
- w = u.i >> 32;
-
- if (w > 0x3fe193ea) {
- /* |x| > log(3)/2 ~= 0.5493 or nan */
- if (w > 0x40340000) {
- /* |x| > 20 or nan */
- /* note: this branch avoids raising overflow */
- t = 1 - 0/x;
- } else {
- t = expm1(2*x);
- t = 1 - 2/(t+2);
- }
- } else if (w > 0x3fd058ae) {
- /* |x| > log(5/3)/2 ~= 0.2554 */
- t = expm1(2*x);
- t = t/(t+2);
- } else if (w >= 0x00100000) {
- /* |x| >= 0x1p-1022, up to 2ulp error in [0.1,0.2554] */
- t = expm1(-2*x);
- t = -t/(t+2);
- } else {
- /* |x| is subnormal */
- /* note: the branch above would not raise underflow in [0x1p-1023,0x1p-1022) */
- FORCE_EVAL((float)x);
- t = x;
- }
- return sign ? -t : t;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tanhf.c b/lib/mlibc/options/ansi/musl-generic-math/tanhf.c
deleted file mode 100644
index 10636fb..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tanhf.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "libm.h"
-
-float tanhf(float x)
-{
- union {float f; uint32_t i;} u = {.f = x};
- uint32_t w;
- int sign;
- float t;
-
- /* x = |x| */
- sign = u.i >> 31;
- u.i &= 0x7fffffff;
- x = u.f;
- w = u.i;
-
- if (w > 0x3f0c9f54) {
- /* |x| > log(3)/2 ~= 0.5493 or nan */
- if (w > 0x41200000) {
- /* |x| > 10 */
- t = 1 + 0/x;
- } else {
- t = expm1f(2*x);
- t = 1 - 2/(t+2);
- }
- } else if (w > 0x3e82c578) {
- /* |x| > log(5/3)/2 ~= 0.2554 */
- t = expm1f(2*x);
- t = t/(t+2);
- } else if (w >= 0x00800000) {
- /* |x| >= 0x1p-126 */
- t = expm1f(-2*x);
- t = -t/(t+2);
- } else {
- /* |x| is subnormal */
- FORCE_EVAL(x*x);
- t = x;
- }
- return sign ? -t : t;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tanhl.c b/lib/mlibc/options/ansi/musl-generic-math/tanhl.c
deleted file mode 100644
index 4e1aa9f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tanhl.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double tanhl(long double x)
-{
- return tanh(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-long double tanhl(long double x)
-{
- union ldshape u = {x};
- unsigned ex = u.i.se & 0x7fff;
- unsigned sign = u.i.se & 0x8000;
- uint32_t w;
- long double t;
-
- /* x = |x| */
- u.i.se = ex;
- x = u.f;
- w = u.i.m >> 32;
-
- if (ex > 0x3ffe || (ex == 0x3ffe && w > 0x8c9f53d5)) {
- /* |x| > log(3)/2 ~= 0.5493 or nan */
- if (ex >= 0x3fff+5) {
- /* |x| >= 32 */
- t = 1 + 0/(x + 0x1p-120f);
- } else {
- t = expm1l(2*x);
- t = 1 - 2/(t+2);
- }
- } else if (ex > 0x3ffd || (ex == 0x3ffd && w > 0x82c577d4)) {
- /* |x| > log(5/3)/2 ~= 0.2554 */
- t = expm1l(2*x);
- t = t/(t+2);
- } else {
- /* |x| is small */
- t = expm1l(-2*x);
- t = -t/(t+2);
- }
- return sign ? -t : t;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double tanhl(long double x)
-{
- return tanh(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tanl.c b/lib/mlibc/options/ansi/musl-generic-math/tanl.c
deleted file mode 100644
index 6af0671..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tanl.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double tanl(long double x)
-{
- return tan(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-long double tanl(long double x)
-{
- union ldshape u = {x};
- long double y[2];
- unsigned n;
-
- u.i.se &= 0x7fff;
- if (u.i.se == 0x7fff)
- return x - x;
- if (u.f < M_PI_4) {
- if (u.i.se < 0x3fff - LDBL_MANT_DIG/2) {
- /* raise inexact if x!=0 and underflow if subnormal */
- FORCE_EVAL(u.i.se == 0 ? x*0x1p-120f : x+0x1p120f);
- return x;
- }
- return __tanl(x, 0, 0);
- }
- n = __rem_pio2l(x, y);
- return __tanl(y[0], y[1], n&1);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tgamma.c b/lib/mlibc/options/ansi/musl-generic-math/tgamma.c
deleted file mode 100644
index 28f6e0f..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tgamma.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
-"A Precision Approximation of the Gamma Function" - Cornelius Lanczos (1964)
-"Lanczos Implementation of the Gamma Function" - Paul Godfrey (2001)
-"An Analysis of the Lanczos Gamma Approximation" - Glendon Ralph Pugh (2004)
-
-approximation method:
-
- (x - 0.5) S(x)
-Gamma(x) = (x + g - 0.5) * ----------------
- exp(x + g - 0.5)
-
-with
- a1 a2 a3 aN
-S(x) ~= [ a0 + ----- + ----- + ----- + ... + ----- ]
- x + 1 x + 2 x + 3 x + N
-
-with a0, a1, a2, a3,.. aN constants which depend on g.
-
-for x < 0 the following reflection formula is used:
-
-Gamma(x)*Gamma(-x) = -pi/(x sin(pi x))
-
-most ideas and constants are from boost and python
-*/
-#include "libm.h"
-
-static const double pi = 3.141592653589793238462643383279502884;
-
-/* sin(pi x) with x > 0x1p-100, if sin(pi*x)==0 the sign is arbitrary */
-static double sinpi(double x)
-{
- int n;
-
- /* argument reduction: x = |x| mod 2 */
- /* spurious inexact when x is odd int */
- x = x * 0.5;
- x = 2 * (x - floor(x));
-
- /* reduce x into [-.25,.25] */
- n = 4 * x;
- n = (n+1)/2;
- x -= n * 0.5;
-
- x *= pi;
- switch (n) {
- default: /* case 4 */
- case 0:
- return __sin(x, 0, 0);
- case 1:
- return __cos(x, 0);
- case 2:
- return __sin(-x, 0, 0);
- case 3:
- return -__cos(x, 0);
- }
-}
-
-#define N 12
-//static const double g = 6.024680040776729583740234375;
-static const double gmhalf = 5.524680040776729583740234375;
-static const double Snum[N+1] = {
- 23531376880.410759688572007674451636754734846804940,
- 42919803642.649098768957899047001988850926355848959,
- 35711959237.355668049440185451547166705960488635843,
- 17921034426.037209699919755754458931112671403265390,
- 6039542586.3520280050642916443072979210699388420708,
- 1439720407.3117216736632230727949123939715485786772,
- 248874557.86205415651146038641322942321632125127801,
- 31426415.585400194380614231628318205362874684987640,
- 2876370.6289353724412254090516208496135991145378768,
- 186056.26539522349504029498971604569928220784236328,
- 8071.6720023658162106380029022722506138218516325024,
- 210.82427775157934587250973392071336271166969580291,
- 2.5066282746310002701649081771338373386264310793408,
-};
-static const double Sden[N+1] = {
- 0, 39916800, 120543840, 150917976, 105258076, 45995730, 13339535,
- 2637558, 357423, 32670, 1925, 66, 1,
-};
-/* n! for small integer n */
-static const double fact[] = {
- 1, 1, 2, 6, 24, 120, 720, 5040.0, 40320.0, 362880.0, 3628800.0, 39916800.0,
- 479001600.0, 6227020800.0, 87178291200.0, 1307674368000.0, 20922789888000.0,
- 355687428096000.0, 6402373705728000.0, 121645100408832000.0,
- 2432902008176640000.0, 51090942171709440000.0, 1124000727777607680000.0,
-};
-
-/* S(x) rational function for positive x */
-static double S(double x)
-{
- double_t num = 0, den = 0;
- int i;
-
- /* to avoid overflow handle large x differently */
- if (x < 8)
- for (i = N; i >= 0; i--) {
- num = num * x + Snum[i];
- den = den * x + Sden[i];
- }
- else
- for (i = 0; i <= N; i++) {
- num = num / x + Snum[i];
- den = den / x + Sden[i];
- }
- return num/den;
-}
-
-double tgamma(double x)
-{
- union {double f; uint64_t i;} u = {x};
- double absx, y;
- double_t dy, z, r;
- uint32_t ix = u.i>>32 & 0x7fffffff;
- int sign = u.i>>63;
-
- /* special cases */
- if (ix >= 0x7ff00000)
- /* tgamma(nan)=nan, tgamma(inf)=inf, tgamma(-inf)=nan with invalid */
- return x + INFINITY;
- if (ix < (0x3ff-54)<<20)
- /* |x| < 2^-54: tgamma(x) ~ 1/x, +-0 raises div-by-zero */
- return 1/x;
-
- /* integer arguments */
- /* raise inexact when non-integer */
- if (x == floor(x)) {
- if (sign)
- return 0/0.0;
- if (x <= sizeof fact/sizeof *fact)
- return fact[(int)x - 1];
- }
-
- /* x >= 172: tgamma(x)=inf with overflow */
- /* x =< -184: tgamma(x)=+-0 with underflow */
- if (ix >= 0x40670000) { /* |x| >= 184 */
- if (sign) {
- FORCE_EVAL((float)(0x1p-126/x));
- if (floor(x) * 0.5 == floor(x * 0.5))
- return 0;
- return -0.0;
- }
- x *= 0x1p1023;
- return x;
- }
-
- absx = sign ? -x : x;
-
- /* handle the error of x + g - 0.5 */
- y = absx + gmhalf;
- if (absx > gmhalf) {
- dy = y - absx;
- dy -= gmhalf;
- } else {
- dy = y - gmhalf;
- dy -= absx;
- }
-
- z = absx - 0.5;
- r = S(absx) * exp(-y);
- if (x < 0) {
- /* reflection formula for negative x */
- /* sinpi(absx) is not 0, integers are already handled */
- r = -pi / (sinpi(absx) * absx * r);
- dy = -dy;
- z = -z;
- }
- r += dy * (gmhalf+0.5) * r / y;
- z = pow(y, 0.5*z);
- y = r * z * z;
- return y;
-}
-
-#if 0
-double __lgamma_r(double x, int *sign)
-{
- double r, absx;
-
- *sign = 1;
-
- /* special cases */
- if (!isfinite(x))
- /* lgamma(nan)=nan, lgamma(+-inf)=inf */
- return x*x;
-
- /* integer arguments */
- if (x == floor(x) && x <= 2) {
- /* n <= 0: lgamma(n)=inf with divbyzero */
- /* n == 1,2: lgamma(n)=0 */
- if (x <= 0)
- return 1/0.0;
- return 0;
- }
-
- absx = fabs(x);
-
- /* lgamma(x) ~ -log(|x|) for tiny |x| */
- if (absx < 0x1p-54) {
- *sign = 1 - 2*!!signbit(x);
- return -log(absx);
- }
-
- /* use tgamma for smaller |x| */
- if (absx < 128) {
- x = tgamma(x);
- *sign = 1 - 2*!!signbit(x);
- return log(fabs(x));
- }
-
- /* second term (log(S)-g) could be more precise here.. */
- /* or with stirling: (|x|-0.5)*(log(|x|)-1) + poly(1/|x|) */
- r = (absx-0.5)*(log(absx+gmhalf)-1) + (log(S(absx)) - (gmhalf+0.5));
- if (x < 0) {
- /* reflection formula for negative x */
- x = sinpi(absx);
- *sign = 2*!!signbit(x) - 1;
- r = log(pi/(fabs(x)*absx)) - r;
- }
- return r;
-}
-
-weak_alias(__lgamma_r, lgamma_r);
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tgammaf.c b/lib/mlibc/options/ansi/musl-generic-math/tgammaf.c
deleted file mode 100644
index b4ca51c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tgammaf.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math.h>
-
-float tgammaf(float x)
-{
- return tgamma(x);
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/tgammal.c b/lib/mlibc/options/ansi/musl-generic-math/tgammal.c
deleted file mode 100644
index 5336c5b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/tgammal.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/* origin: OpenBSD /usr/src/lib/libm/src/ld80/e_tgammal.c */
-/*
- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * Gamma function
- *
- *
- * SYNOPSIS:
- *
- * long double x, y, tgammal();
- *
- * y = tgammal( x );
- *
- *
- * DESCRIPTION:
- *
- * Returns gamma function of the argument. The result is
- * correctly signed.
- *
- * Arguments |x| <= 13 are reduced by recurrence and the function
- * approximated by a rational function of degree 7/8 in the
- * interval (2,3). Large arguments are handled by Stirling's
- * formula. Large negative arguments are made positive using
- * a reflection formula.
- *
- *
- * ACCURACY:
- *
- * Relative error:
- * arithmetic domain # trials peak rms
- * IEEE -40,+40 10000 3.6e-19 7.9e-20
- * IEEE -1755,+1755 10000 4.8e-18 6.5e-19
- *
- * Accuracy for large arguments is dominated by error in powl().
- *
- */
-
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double tgammal(long double x)
-{
- return tgamma(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-/*
-tgamma(x+2) = tgamma(x+2) P(x)/Q(x)
-0 <= x <= 1
-Relative error
-n=7, d=8
-Peak error = 1.83e-20
-Relative error spread = 8.4e-23
-*/
-static const long double P[8] = {
- 4.212760487471622013093E-5L,
- 4.542931960608009155600E-4L,
- 4.092666828394035500949E-3L,
- 2.385363243461108252554E-2L,
- 1.113062816019361559013E-1L,
- 3.629515436640239168939E-1L,
- 8.378004301573126728826E-1L,
- 1.000000000000000000009E0L,
-};
-static const long double Q[9] = {
--1.397148517476170440917E-5L,
- 2.346584059160635244282E-4L,
--1.237799246653152231188E-3L,
--7.955933682494738320586E-4L,
- 2.773706565840072979165E-2L,
--4.633887671244534213831E-2L,
--2.243510905670329164562E-1L,
- 4.150160950588455434583E-1L,
- 9.999999999999999999908E-1L,
-};
-
-/*
-static const long double P[] = {
--3.01525602666895735709e0L,
--3.25157411956062339893e1L,
--2.92929976820724030353e2L,
--1.70730828800510297666e3L,
--7.96667499622741999770e3L,
--2.59780216007146401957e4L,
--5.99650230220855581642e4L,
--7.15743521530849602425e4L
-};
-static const long double Q[] = {
- 1.00000000000000000000e0L,
--1.67955233807178858919e1L,
- 8.85946791747759881659e1L,
- 5.69440799097468430177e1L,
--1.98526250512761318471e3L,
- 3.31667508019495079814e3L,
- 1.60577839621734713377e4L,
--2.97045081369399940529e4L,
--7.15743521530849602412e4L
-};
-*/
-#define MAXGAML 1755.455L
-/*static const long double LOGPI = 1.14472988584940017414L;*/
-
-/* Stirling's formula for the gamma function
-tgamma(x) = sqrt(2 pi) x^(x-.5) exp(-x) (1 + 1/x P(1/x))
-z(x) = x
-13 <= x <= 1024
-Relative error
-n=8, d=0
-Peak error = 9.44e-21
-Relative error spread = 8.8e-4
-*/
-static const long double STIR[9] = {
- 7.147391378143610789273E-4L,
--2.363848809501759061727E-5L,
--5.950237554056330156018E-4L,
- 6.989332260623193171870E-5L,
- 7.840334842744753003862E-4L,
--2.294719747873185405699E-4L,
--2.681327161876304418288E-3L,
- 3.472222222230075327854E-3L,
- 8.333333333333331800504E-2L,
-};
-
-#define MAXSTIR 1024.0L
-static const long double SQTPI = 2.50662827463100050242E0L;
-
-/* 1/tgamma(x) = z P(z)
- * z(x) = 1/x
- * 0 < x < 0.03125
- * Peak relative error 4.2e-23
- */
-static const long double S[9] = {
--1.193945051381510095614E-3L,
- 7.220599478036909672331E-3L,
--9.622023360406271645744E-3L,
--4.219773360705915470089E-2L,
- 1.665386113720805206758E-1L,
--4.200263503403344054473E-2L,
--6.558780715202540684668E-1L,
- 5.772156649015328608253E-1L,
- 1.000000000000000000000E0L,
-};
-
-/* 1/tgamma(-x) = z P(z)
- * z(x) = 1/x
- * 0 < x < 0.03125
- * Peak relative error 5.16e-23
- * Relative error spread = 2.5e-24
- */
-static const long double SN[9] = {
- 1.133374167243894382010E-3L,
- 7.220837261893170325704E-3L,
- 9.621911155035976733706E-3L,
--4.219773343731191721664E-2L,
--1.665386113944413519335E-1L,
--4.200263503402112910504E-2L,
- 6.558780715202536547116E-1L,
- 5.772156649015328608727E-1L,
--1.000000000000000000000E0L,
-};
-
-static const long double PIL = 3.1415926535897932384626L;
-
-/* Gamma function computed by Stirling's formula.
- */
-static long double stirf(long double x)
-{
- long double y, w, v;
-
- w = 1.0/x;
- /* For large x, use rational coefficients from the analytical expansion. */
- if (x > 1024.0)
- w = (((((6.97281375836585777429E-5L * w
- + 7.84039221720066627474E-4L) * w
- - 2.29472093621399176955E-4L) * w
- - 2.68132716049382716049E-3L) * w
- + 3.47222222222222222222E-3L) * w
- + 8.33333333333333333333E-2L) * w
- + 1.0;
- else
- w = 1.0 + w * __polevll(w, STIR, 8);
- y = expl(x);
- if (x > MAXSTIR) { /* Avoid overflow in pow() */
- v = powl(x, 0.5L * x - 0.25L);
- y = v * (v / y);
- } else {
- y = powl(x, x - 0.5L) / y;
- }
- y = SQTPI * y * w;
- return y;
-}
-
-long double tgammal(long double x)
-{
- long double p, q, z;
-
- if (!isfinite(x))
- return x + INFINITY;
-
- q = fabsl(x);
- if (q > 13.0) {
- if (x < 0.0) {
- p = floorl(q);
- z = q - p;
- if (z == 0)
- return 0 / z;
- if (q > MAXGAML) {
- z = 0;
- } else {
- if (z > 0.5) {
- p += 1.0;
- z = q - p;
- }
- z = q * sinl(PIL * z);
- z = fabsl(z) * stirf(q);
- z = PIL/z;
- }
- if (0.5 * p == floorl(q * 0.5))
- z = -z;
- } else if (x > MAXGAML) {
- z = x * 0x1p16383L;
- } else {
- z = stirf(x);
- }
- return z;
- }
-
- z = 1.0;
- while (x >= 3.0) {
- x -= 1.0;
- z *= x;
- }
- while (x < -0.03125L) {
- z /= x;
- x += 1.0;
- }
- if (x <= 0.03125L)
- goto small;
- while (x < 2.0) {
- z /= x;
- x += 1.0;
- }
- if (x == 2.0)
- return z;
-
- x -= 2.0;
- p = __polevll(x, P, 7);
- q = __polevll(x, Q, 8);
- z = z * p / q;
- return z;
-
-small:
- /* z==1 if x was originally +-0 */
- if (x == 0 && z != 1)
- return x / x;
- if (x < 0.0) {
- x = -x;
- q = z / (x * __polevll(x, SN, 8));
- } else
- q = z / (x * __polevll(x, S, 8));
- return q;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-// TODO: broken implementation to make things compile
-long double tgammal(long double x)
-{
- return tgamma(x);
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/trunc.c b/lib/mlibc/options/ansi/musl-generic-math/trunc.c
deleted file mode 100644
index d13711b..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/trunc.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "libm.h"
-
-double trunc(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff + 12;
- uint64_t m;
-
- if (e >= 52 + 12)
- return x;
- if (e < 12)
- e = 1;
- m = -1ULL >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- u.i &= ~m;
- return u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/truncf.c b/lib/mlibc/options/ansi/musl-generic-math/truncf.c
deleted file mode 100644
index 1a7d03c..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/truncf.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "libm.h"
-
-float truncf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9;
- uint32_t m;
-
- if (e >= 23 + 9)
- return x;
- if (e < 9)
- e = 1;
- m = -1U >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- u.i &= ~m;
- return u.f;
-}
diff --git a/lib/mlibc/options/ansi/musl-generic-math/truncl.c b/lib/mlibc/options/ansi/musl-generic-math/truncl.c
deleted file mode 100644
index f07b193..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/truncl.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double truncl(long double x)
-{
- return trunc(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-static const long double toint = 1/LDBL_EPSILON;
-
-long double truncl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- int s = u.i.se >> 15;
- long double y;
-
- if (e >= 0x3fff+LDBL_MANT_DIG-1)
- return x;
- if (e <= 0x3fff-1) {
- FORCE_EVAL(x + 0x1p120f);
- return x*0;
- }
- /* y = int(|x|) - |x|, where int(|x|) is an integer neighbor of |x| */
- if (s)
- x = -x;
- y = x + toint - toint - x;
- if (y > 0)
- y -= 1;
- x += y;
- return s ? -x : x;
-}
-#endif
diff --git a/lib/mlibc/options/ansi/musl-generic-math/weak_alias.h b/lib/mlibc/options/ansi/musl-generic-math/weak_alias.h
deleted file mode 100644
index 785f9d1..0000000
--- a/lib/mlibc/options/ansi/musl-generic-math/weak_alias.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _WEAK_ALIAS_H
-#define _WEAK_ALIAS_H
-
-#define weak_alias(name, alias_to) \
- extern __typeof (name) alias_to __attribute__((__weak__, __alias__(#name)));
-
-#endif