>From 83d63c0c52b6e23ca1bb87eb496496ecbff9b17b Mon Sep 17 00:00:00 2001 From: bauen1 Date: Wed, 15 Apr 2020 18:37:29 +0200 Subject: [PATCH] build using tcc --- arch/x86_64/syscall_arch.h | 2 + include/alltypes.h.in | 6 ++ include/stdarg.h | 21 ----- src/complex/__cexp.c | 87 --------------------- src/complex/__cexpf.c | 68 ---------------- src/complex/cabs.c | 6 -- src/complex/cabsf.c | 6 -- src/complex/cabsl.c | 13 ---- src/complex/cacos.c | 11 --- src/complex/cacosf.c | 9 --- src/complex/cacosh.c | 12 --- src/complex/cacoshf.c | 10 --- src/complex/cacoshl.c | 17 ---- src/complex/cacosl.c | 16 ---- src/complex/carg.c | 6 -- src/complex/cargf.c | 6 -- src/complex/cargl.c | 13 ---- src/complex/casin.c | 17 ---- src/complex/casinf.c | 15 ---- src/complex/casinh.c | 9 --- src/complex/casinhf.c | 7 -- src/complex/casinhl.c | 14 ---- src/complex/casinl.c | 21 ----- src/complex/catan.c | 107 -------------------------- src/complex/catanf.c | 103 ------------------------- src/complex/catanh.c | 9 --- src/complex/catanhf.c | 7 -- src/complex/catanhl.c | 14 ---- src/complex/catanl.c | 114 --------------------------- src/complex/ccos.c | 8 -- src/complex/ccosf.c | 6 -- src/complex/ccosh.c | 140 --------------------------------- src/complex/ccoshf.c | 90 ---------------------- src/complex/ccoshl.c | 7 -- src/complex/ccosl.c | 13 ---- src/complex/cexp.c | 83 -------------------- src/complex/cexpf.c | 83 -------------------- src/complex/cexpl.c | 7 -- src/complex/cimag.c | 6 -- src/complex/cimagf.c | 6 -- src/complex/cimagl.c | 6 -- src/complex/clog.c | 14 ---- src/complex/clogf.c | 12 --- src/complex/clogl.c | 18 ----- src/complex/conj.c | 6 -- src/complex/conjf.c | 6 -- src/complex/conjl.c | 6 -- src/complex/cpow.c | 8 -- src/complex/cpowf.c | 6 -- src/complex/cpowl.c | 13 ---- src/complex/cproj.c | 8 -- src/complex/cprojf.c | 8 -- src/complex/cprojl.c | 15 ---- src/complex/creal.c | 6 -- src/complex/crealf.c | 6 -- src/complex/creall.c | 6 -- src/complex/csin.c | 9 --- src/complex/csinf.c | 7 -- src/complex/csinh.c | 141 ---------------------------------- src/complex/csinhf.c | 90 ---------------------- src/complex/csinhl.c | 7 -- src/complex/csinl.c | 14 ---- src/complex/csqrt.c | 100 ------------------------ src/complex/csqrtf.c | 82 -------------------- src/complex/csqrtl.c | 7 -- src/complex/ctan.c | 9 --- src/complex/ctanf.c | 7 -- src/complex/ctanh.c | 129 ------------------------------- src/complex/ctanhf.c | 66 ---------------- src/complex/ctanhl.c | 7 -- src/complex/ctanl.c | 14 ---- src/fenv/x86_64/fenv.s | 98 ----------------------- src/internal/syscall.h | 2 + src/math/x86_64/__invtrigl.s | 0 src/math/x86_64/acosl.s | 16 ---- src/math/x86_64/asinl.s | 12 --- src/math/x86_64/atan2l.s | 7 -- src/math/x86_64/atanl.s | 7 -- src/math/x86_64/ceill.s | 1 - src/math/x86_64/exp2l.s | 83 -------------------- src/math/x86_64/expl.s | 101 ------------------------ src/math/x86_64/expm1l.s | 1 - src/math/x86_64/fabs.s | 9 --- src/math/x86_64/fabsf.s | 7 -- src/math/x86_64/fabsl.s | 6 -- src/math/x86_64/floorl.s | 27 ------- src/math/x86_64/fma.c | 23 ------ src/math/x86_64/fmaf.c | 23 ------ src/math/x86_64/fmodl.s | 11 --- src/math/x86_64/llrint.s | 5 -- src/math/x86_64/llrintf.s | 5 -- src/math/x86_64/llrintl.s | 7 -- src/math/x86_64/log10l.s | 7 -- src/math/x86_64/log1pl.s | 15 ---- src/math/x86_64/log2l.s | 7 -- src/math/x86_64/logl.s | 7 -- src/math/x86_64/lrint.s | 5 -- src/math/x86_64/lrintf.s | 5 -- src/math/x86_64/lrintl.s | 7 -- src/math/x86_64/remainderl.s | 11 --- src/math/x86_64/rintl.s | 6 -- src/math/x86_64/sqrt.s | 4 - src/math/x86_64/sqrtf.s | 4 - src/math/x86_64/sqrtl.s | 5 -- src/math/x86_64/truncl.s | 1 - src/signal/x86_64/sigsetjmp.s | 24 ------ 106 files changed, 10 insertions(+), 2577 deletions(-) delete mode 100644 include/stdarg.h delete mode 100644 src/complex/__cexp.c delete mode 100644 src/complex/__cexpf.c delete mode 100644 src/complex/cabs.c delete mode 100644 src/complex/cabsf.c delete mode 100644 src/complex/cabsl.c delete mode 100644 src/complex/cacos.c delete mode 100644 src/complex/cacosf.c delete mode 100644 src/complex/cacosh.c delete mode 100644 src/complex/cacoshf.c delete mode 100644 src/complex/cacoshl.c delete mode 100644 src/complex/cacosl.c delete mode 100644 src/complex/carg.c delete mode 100644 src/complex/cargf.c delete mode 100644 src/complex/cargl.c delete mode 100644 src/complex/casin.c delete mode 100644 src/complex/casinf.c delete mode 100644 src/complex/casinh.c delete mode 100644 src/complex/casinhf.c delete mode 100644 src/complex/casinhl.c delete mode 100644 src/complex/casinl.c delete mode 100644 src/complex/catan.c delete mode 100644 src/complex/catanf.c delete mode 100644 src/complex/catanh.c delete mode 100644 src/complex/catanhf.c delete mode 100644 src/complex/catanhl.c delete mode 100644 src/complex/catanl.c delete mode 100644 src/complex/ccos.c delete mode 100644 src/complex/ccosf.c delete mode 100644 src/complex/ccosh.c delete mode 100644 src/complex/ccoshf.c delete mode 100644 src/complex/ccoshl.c delete mode 100644 src/complex/ccosl.c delete mode 100644 src/complex/cexp.c delete mode 100644 src/complex/cexpf.c delete mode 100644 src/complex/cexpl.c delete mode 100644 src/complex/cimag.c delete mode 100644 src/complex/cimagf.c delete mode 100644 src/complex/cimagl.c delete mode 100644 src/complex/clog.c delete mode 100644 src/complex/clogf.c delete mode 100644 src/complex/clogl.c delete mode 100644 src/complex/conj.c delete mode 100644 src/complex/conjf.c delete mode 100644 src/complex/conjl.c delete mode 100644 src/complex/cpow.c delete mode 100644 src/complex/cpowf.c delete mode 100644 src/complex/cpowl.c delete mode 100644 src/complex/cproj.c delete mode 100644 src/complex/cprojf.c delete mode 100644 src/complex/cprojl.c delete mode 100644 src/complex/creal.c delete mode 100644 src/complex/crealf.c delete mode 100644 src/complex/creall.c delete mode 100644 src/complex/csin.c delete mode 100644 src/complex/csinf.c delete mode 100644 src/complex/csinh.c delete mode 100644 src/complex/csinhf.c delete mode 100644 src/complex/csinhl.c delete mode 100644 src/complex/csinl.c delete mode 100644 src/complex/csqrt.c delete mode 100644 src/complex/csqrtf.c delete mode 100644 src/complex/csqrtl.c delete mode 100644 src/complex/ctan.c delete mode 100644 src/complex/ctanf.c delete mode 100644 src/complex/ctanh.c delete mode 100644 src/complex/ctanhf.c delete mode 100644 src/complex/ctanhl.c delete mode 100644 src/complex/ctanl.c delete mode 100644 src/fenv/x86_64/fenv.s delete mode 100644 src/math/x86_64/__invtrigl.s delete mode 100644 src/math/x86_64/acosl.s delete mode 100644 src/math/x86_64/asinl.s delete mode 100644 src/math/x86_64/atan2l.s delete mode 100644 src/math/x86_64/atanl.s delete mode 100644 src/math/x86_64/ceill.s delete mode 100644 src/math/x86_64/exp2l.s delete mode 100644 src/math/x86_64/expl.s delete mode 100644 src/math/x86_64/expm1l.s delete mode 100644 src/math/x86_64/fabs.s delete mode 100644 src/math/x86_64/fabsf.s delete mode 100644 src/math/x86_64/fabsl.s delete mode 100644 src/math/x86_64/floorl.s delete mode 100644 src/math/x86_64/fma.c delete mode 100644 src/math/x86_64/fmaf.c delete mode 100644 src/math/x86_64/fmodl.s delete mode 100644 src/math/x86_64/llrint.s delete mode 100644 src/math/x86_64/llrintf.s delete mode 100644 src/math/x86_64/llrintl.s delete mode 100644 src/math/x86_64/log10l.s delete mode 100644 src/math/x86_64/log1pl.s delete mode 100644 src/math/x86_64/log2l.s delete mode 100644 src/math/x86_64/logl.s delete mode 100644 src/math/x86_64/lrint.s delete mode 100644 src/math/x86_64/lrintf.s delete mode 100644 src/math/x86_64/lrintl.s delete mode 100644 src/math/x86_64/remainderl.s delete mode 100644 src/math/x86_64/rintl.s delete mode 100644 src/math/x86_64/sqrt.s delete mode 100644 src/math/x86_64/sqrtf.s delete mode 100644 src/math/x86_64/sqrtl.s delete mode 100644 src/math/x86_64/truncl.s delete mode 100644 src/signal/x86_64/sigsetjmp.s diff --git a/arch/x86_64/syscall_arch.h b/arch/x86_64/syscall_arch.h index 92d5c179..1283a7c3 100644 --- a/arch/x86_64/syscall_arch.h +++ b/arch/x86_64/syscall_arch.h @@ -31,6 +31,7 @@ static __inline long __syscall3(long n, long a1, long a2, long a3) return ret; } +#if !defined(__TINYC__) static __inline long __syscall4(long n, long a1, long a2, long a3, long a4) { unsigned long ret; @@ -60,6 +61,7 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long "d"(a3), "r"(r10), "r"(r8), "r"(r9) : "rcx", "r11", "memory"); return ret; } +#endif #define VDSO_USEFUL #define VDSO_CGT_SYM "__vdso_clock_gettime" diff --git a/include/alltypes.h.in b/include/alltypes.h.in index d9ff462e..2dc091cf 100644 --- a/include/alltypes.h.in +++ b/include/alltypes.h.in @@ -66,8 +66,14 @@ TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t; STRUCT _IO_FILE { char __x; }; TYPEDEF struct _IO_FILE FILE; +#if defined(__TINYC__) +#include +#undef __isoc_va_list +typedef va_list __isoc_va_list; +#else TYPEDEF __builtin_va_list va_list; TYPEDEF __builtin_va_list __isoc_va_list; +#endif TYPEDEF struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t; diff --git a/include/stdarg.h b/include/stdarg.h deleted file mode 100644 index 3256f805..00000000 --- a/include/stdarg.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _STDARG_H -#define _STDARG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __NEED_va_list - -#include - -#define va_start(v,l) __builtin_va_start(v,l) -#define va_end(v) __builtin_va_end(v) -#define va_arg(v,l) __builtin_va_arg(v,l) -#define va_copy(d,s) __builtin_va_copy(d,s) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/complex/__cexp.c b/src/complex/__cexp.c deleted file mode 100644 index 003d20af..00000000 --- a/src/complex/__cexp.c +++ /dev/null @@ -1,87 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/k_exp.c */ -/*- - * Copyright (c) 2011 David Schultz - * 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 "complex_impl.h" - -static const uint32_t k = 1799; /* constant for reduction */ -static const double kln2 = 1246.97177782734161156; /* k * ln2 */ - -/* - * Compute exp(x), scaled to avoid spurious overflow. An exponent is - * returned separately in 'expt'. - * - * Input: ln(DBL_MAX) <= x < ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91 - * Output: 2**1023 <= y < 2**1024 - */ -static double __frexp_exp(double x, int *expt) -{ - double exp_x; - uint32_t hx; - - /* - * We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to - * minimize |exp(kln2) - 2**k|. We also scale the exponent of - * exp_x to MAX_EXP so that the result can be multiplied by - * a tiny number without losing accuracy due to denormalization. - */ - exp_x = exp(x - kln2); - GET_HIGH_WORD(hx, exp_x); - *expt = (hx >> 20) - (0x3ff + 1023) + k; - SET_HIGH_WORD(exp_x, (hx & 0xfffff) | ((0x3ff + 1023) << 20)); - return exp_x; -} - -/* - * __ldexp_cexp(x, expt) compute exp(x) * 2**expt. - * It is intended for large arguments (real part >= ln(DBL_MAX)) - * where care is needed to avoid overflow. - * - * The present implementation is narrowly tailored for our hyperbolic and - * exponential functions. We assume expt is small (0 or -1), and the caller - * has filtered out very large x, for which overflow would be inevitable. - */ -double complex __ldexp_cexp(double complex z, int expt) -{ - double x, y, exp_x, scale1, scale2; - int ex_expt, half_expt; - - x = creal(z); - y = cimag(z); - exp_x = __frexp_exp(x, &ex_expt); - expt += ex_expt; - - /* - * Arrange so that scale1 * scale2 == 2**expt. We use this to - * compensate for scalbn being horrendously slow. - */ - half_expt = expt / 2; - INSERT_WORDS(scale1, (0x3ff + half_expt) << 20, 0); - half_expt = expt - half_expt; - INSERT_WORDS(scale2, (0x3ff + half_expt) << 20, 0); - - return CMPLX(cos(y) * exp_x * scale1 * scale2, sin(y) * exp_x * scale1 * scale2); -} diff --git a/src/complex/__cexpf.c b/src/complex/__cexpf.c deleted file mode 100644 index ee5ff2bc..00000000 --- a/src/complex/__cexpf.c +++ /dev/null @@ -1,68 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/k_expf.c */ -/*- - * Copyright (c) 2011 David Schultz - * 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 "complex_impl.h" - -static const uint32_t k = 235; /* constant for reduction */ -static const float kln2 = 162.88958740F; /* k * ln2 */ - -/* - * See __cexp.c for details. - * - * Input: ln(FLT_MAX) <= x < ln(2 * FLT_MAX / FLT_MIN_DENORM) ~= 192.7 - * Output: 2**127 <= y < 2**128 - */ -static float __frexp_expf(float x, int *expt) -{ - float exp_x; - uint32_t hx; - - exp_x = expf(x - kln2); - GET_FLOAT_WORD(hx, exp_x); - *expt = (hx >> 23) - (0x7f + 127) + k; - SET_FLOAT_WORD(exp_x, (hx & 0x7fffff) | ((0x7f + 127) << 23)); - return exp_x; -} - -float complex __ldexp_cexpf(float complex z, int expt) -{ - float x, y, exp_x, scale1, scale2; - int ex_expt, half_expt; - - x = crealf(z); - y = cimagf(z); - exp_x = __frexp_expf(x, &ex_expt); - expt += ex_expt; - - half_expt = expt / 2; - SET_FLOAT_WORD(scale1, (0x7f + half_expt) << 23); - half_expt = expt - half_expt; - SET_FLOAT_WORD(scale2, (0x7f + half_expt) << 23); - - return CMPLXF(cosf(y) * exp_x * scale1 * scale2, - sinf(y) * exp_x * scale1 * scale2); -} diff --git a/src/complex/cabs.c b/src/complex/cabs.c deleted file mode 100644 index c5ad58ab..00000000 --- a/src/complex/cabs.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -double cabs(double complex z) -{ - return hypot(creal(z), cimag(z)); -} diff --git a/src/complex/cabsf.c b/src/complex/cabsf.c deleted file mode 100644 index 619f28d3..00000000 --- a/src/complex/cabsf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -float cabsf(float complex z) -{ - return hypotf(crealf(z), cimagf(z)); -} diff --git a/src/complex/cabsl.c b/src/complex/cabsl.c deleted file mode 100644 index d37e3f2e..00000000 --- a/src/complex/cabsl.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double cabsl(long double complex z) -{ - return cabs(z); -} -#else -long double cabsl(long double complex z) -{ - return hypotl(creall(z), cimagl(z)); -} -#endif diff --git a/src/complex/cacos.c b/src/complex/cacos.c deleted file mode 100644 index c39d257b..00000000 --- a/src/complex/cacos.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "complex_impl.h" - -// FIXME: Hull et al. "Implementing the complex arcsine and arccosine functions using exception handling" 1997 - -/* acos(z) = pi/2 - asin(z) */ - -double complex cacos(double complex z) -{ - z = casin(z); - return CMPLX(M_PI_2 - creal(z), -cimag(z)); -} diff --git a/src/complex/cacosf.c b/src/complex/cacosf.c deleted file mode 100644 index 2e048540..00000000 --- a/src/complex/cacosf.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "complex_impl.h" - -// FIXME - -float complex cacosf(float complex z) -{ - z = casinf(z); - return CMPLXF((float)M_PI_2 - crealf(z), -cimagf(z)); -} diff --git a/src/complex/cacosh.c b/src/complex/cacosh.c deleted file mode 100644 index 76127f75..00000000 --- a/src/complex/cacosh.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "complex_impl.h" - -/* acosh(z) = i acos(z) */ - -double complex cacosh(double complex z) -{ - int zineg = signbit(cimag(z)); - - z = cacos(z); - if (zineg) return CMPLX(cimag(z), -creal(z)); - else return CMPLX(-cimag(z), creal(z)); -} diff --git a/src/complex/cacoshf.c b/src/complex/cacoshf.c deleted file mode 100644 index 8bd80581..00000000 --- a/src/complex/cacoshf.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "complex_impl.h" - -float complex cacoshf(float complex z) -{ - int zineg = signbit(cimagf(z)); - - z = cacosf(z); - if (zineg) return CMPLXF(cimagf(z), -crealf(z)); - else return CMPLXF(-cimagf(z), crealf(z)); -} diff --git a/src/complex/cacoshl.c b/src/complex/cacoshl.c deleted file mode 100644 index 3a284be9..00000000 --- a/src/complex/cacoshl.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex cacoshl(long double complex z) -{ - return cacosh(z); -} -#else -long double complex cacoshl(long double complex z) -{ - int zineg = signbit(cimagl(z)); - - z = cacosl(z); - if (zineg) return CMPLXL(cimagl(z), -creall(z)); - else return CMPLXL(-cimagl(z), creall(z)); -} -#endif diff --git a/src/complex/cacosl.c b/src/complex/cacosl.c deleted file mode 100644 index cc20dcd7..00000000 --- a/src/complex/cacosl.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex cacosl(long double complex z) -{ - return cacos(z); -} -#else -// FIXME -#define PI_2 1.57079632679489661923132169163975144L -long double complex cacosl(long double complex z) -{ - z = casinl(z); - return CMPLXL(PI_2 - creall(z), -cimagl(z)); -} -#endif diff --git a/src/complex/carg.c b/src/complex/carg.c deleted file mode 100644 index dfe9b97a..00000000 --- a/src/complex/carg.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -double carg(double complex z) -{ - return atan2(cimag(z), creal(z)); -} diff --git a/src/complex/cargf.c b/src/complex/cargf.c deleted file mode 100644 index 9a6c19b6..00000000 --- a/src/complex/cargf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -float cargf(float complex z) -{ - return atan2f(cimagf(z), crealf(z)); -} diff --git a/src/complex/cargl.c b/src/complex/cargl.c deleted file mode 100644 index 88f95f96..00000000 --- a/src/complex/cargl.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double cargl(long double complex z) -{ - return carg(z); -} -#else -long double cargl(long double complex z) -{ - return atan2l(cimagl(z), creall(z)); -} -#endif diff --git a/src/complex/casin.c b/src/complex/casin.c deleted file mode 100644 index 3244bebb..00000000 --- a/src/complex/casin.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "complex_impl.h" - -// FIXME - -/* asin(z) = -i log(i z + sqrt(1 - z*z)) */ - -double complex casin(double complex z) -{ - double complex w; - double x, y; - - x = creal(z); - y = cimag(z); - w = CMPLX(1.0 - (x - y)*(x + y), -2.0*x*y); - double complex r = clog(CMPLX(-y, x) + csqrt(w)); - return CMPLX(cimag(r), -creal(r)); -} diff --git a/src/complex/casinf.c b/src/complex/casinf.c deleted file mode 100644 index 2cda2f08..00000000 --- a/src/complex/casinf.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "complex_impl.h" - -// FIXME - -float complex casinf(float complex z) -{ - float complex w; - float x, y; - - x = crealf(z); - y = cimagf(z); - w = CMPLXF(1.0 - (x - y)*(x + y), -2.0*x*y); - float complex r = clogf(CMPLXF(-y, x) + csqrtf(w)); - return CMPLXF(cimagf(r), -crealf(r)); -} diff --git a/src/complex/casinh.c b/src/complex/casinh.c deleted file mode 100644 index 50bf27ce..00000000 --- a/src/complex/casinh.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "complex_impl.h" - -/* asinh(z) = -i asin(i z) */ - -double complex casinh(double complex z) -{ - z = casin(CMPLX(-cimag(z), creal(z))); - return CMPLX(cimag(z), -creal(z)); -} diff --git a/src/complex/casinhf.c b/src/complex/casinhf.c deleted file mode 100644 index 93d82e5f..00000000 --- a/src/complex/casinhf.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -float complex casinhf(float complex z) -{ - z = casinf(CMPLXF(-cimagf(z), crealf(z))); - return CMPLXF(cimagf(z), -crealf(z)); -} diff --git a/src/complex/casinhl.c b/src/complex/casinhl.c deleted file mode 100644 index 68ba3ddf..00000000 --- a/src/complex/casinhl.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex casinhl(long double complex z) -{ - return casinh(z); -} -#else -long double complex casinhl(long double complex z) -{ - z = casinl(CMPLXL(-cimagl(z), creall(z))); - return CMPLXL(cimagl(z), -creall(z)); -} -#endif diff --git a/src/complex/casinl.c b/src/complex/casinl.c deleted file mode 100644 index 072adc45..00000000 --- a/src/complex/casinl.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex casinl(long double complex z) -{ - return casin(z); -} -#else -// FIXME -long double complex casinl(long double complex z) -{ - long double complex w; - long double x, y; - - x = creall(z); - y = cimagl(z); - w = CMPLXL(1.0 - (x - y)*(x + y), -2.0*x*y); - long double complex r = clogl(CMPLXL(-y, x) + csqrtl(w)); - return CMPLXL(cimagl(r), -creall(r)); -} -#endif diff --git a/src/complex/catan.c b/src/complex/catan.c deleted file mode 100644 index ccc2fb53..00000000 --- a/src/complex/catan.c +++ /dev/null @@ -1,107 +0,0 @@ -/* origin: OpenBSD /usr/src/lib/libm/src/s_catan.c */ -/* - * Copyright (c) 2008 Stephen L. Moshier - * - * 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. - */ -/* - * Complex circular arc tangent - * - * - * SYNOPSIS: - * - * double complex catan(); - * double complex z, w; - * - * w = catan (z); - * - * - * DESCRIPTION: - * - * If - * z = x + iy, - * - * then - * 1 ( 2x ) - * Re w = - arctan(-----------) + k PI - * 2 ( 2 2) - * (1 - x - y ) - * - * ( 2 2) - * 1 (x + (y+1) ) - * Im w = - log(------------) - * 4 ( 2 2) - * (x + (y-1) ) - * - * Where k is an arbitrary integer. - * - * catan(z) = -i catanh(iz). - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 5900 1.3e-16 7.8e-18 - * IEEE -10,+10 30000 2.3e-15 8.5e-17 - * The check catan( ctan(z) ) = z, with |x| and |y| < PI/2, - * had peak relative error 1.5e-16, rms relative error - * 2.9e-17. See also clog(). - */ - -#include "complex_impl.h" - -#define MAXNUM 1.0e308 - -static const double DP1 = 3.14159265160560607910E0; -static const double DP2 = 1.98418714791870343106E-9; -static const double DP3 = 1.14423774522196636802E-17; - -static double _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; -} - -double complex catan(double complex z) -{ - double complex w; - double a, t, x, x2, y; - - x = creal(z); - y = cimag(z); - - x2 = x * x; - a = 1.0 - x2 - (y * y); - - t = 0.5 * atan2(2.0 * x, a); - w = _redupi(t); - - t = y - 1.0; - a = x2 + (t * t); - - t = y + 1.0; - a = (x2 + t * t)/a; - w = CMPLX(w, 0.25 * log(a)); - return w; -} diff --git a/src/complex/catanf.c b/src/complex/catanf.c deleted file mode 100644 index ef3907a5..00000000 --- a/src/complex/catanf.c +++ /dev/null @@ -1,103 +0,0 @@ -/* origin: OpenBSD /usr/src/lib/libm/src/s_catanf.c */ -/* - * Copyright (c) 2008 Stephen L. Moshier - * - * 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. - */ -/* - * Complex circular arc tangent - * - * - * SYNOPSIS: - * - * float complex catanf(); - * float complex z, w; - * - * w = catanf( z ); - * - * - * DESCRIPTION: - * - * If - * z = x + iy, - * - * then - * 1 ( 2x ) - * Re w = - arctan(-----------) + k PI - * 2 ( 2 2) - * (1 - x - y ) - * - * ( 2 2) - * 1 (x + (y+1) ) - * Im w = - log(------------) - * 4 ( 2 2) - * (x + (y-1) ) - * - * Where k is an arbitrary integer. - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 2.3e-6 5.2e-8 - */ - -#include "complex_impl.h" - -#define MAXNUMF 1.0e38F - -static const double DP1 = 3.140625; -static const double DP2 = 9.67502593994140625E-4; -static const double DP3 = 1.509957990978376432E-7; - -static float _redupif(float xx) -{ - float x, t; - long i; - - x = xx; - 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; -} - -float complex catanf(float complex z) -{ - float complex w; - float a, t, x, x2, y; - - x = crealf(z); - y = cimagf(z); - - x2 = x * x; - a = 1.0f - x2 - (y * y); - - t = 0.5f * atan2f(2.0f * x, a); - w = _redupif(t); - - t = y - 1.0f; - a = x2 + (t * t); - - t = y + 1.0f; - a = (x2 + (t * t))/a; - w = CMPLXF(w, 0.25f * logf(a)); - return w; -} diff --git a/src/complex/catanh.c b/src/complex/catanh.c deleted file mode 100644 index c324c7f2..00000000 --- a/src/complex/catanh.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "complex_impl.h" - -/* atanh = -i atan(i z) */ - -double complex catanh(double complex z) -{ - z = catan(CMPLX(-cimag(z), creal(z))); - return CMPLX(cimag(z), -creal(z)); -} diff --git a/src/complex/catanhf.c b/src/complex/catanhf.c deleted file mode 100644 index b0505f60..00000000 --- a/src/complex/catanhf.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -float complex catanhf(float complex z) -{ - z = catanf(CMPLXF(-cimagf(z), crealf(z))); - return CMPLXF(cimagf(z), -crealf(z)); -} diff --git a/src/complex/catanhl.c b/src/complex/catanhl.c deleted file mode 100644 index 6025c414..00000000 --- a/src/complex/catanhl.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex catanhl(long double complex z) -{ - return catanh(z); -} -#else -long double complex catanhl(long double complex z) -{ - z = catanl(CMPLXL(-cimagl(z), creall(z))); - return CMPLXL(cimagl(z), -creall(z)); -} -#endif diff --git a/src/complex/catanl.c b/src/complex/catanl.c deleted file mode 100644 index e62526c0..00000000 --- a/src/complex/catanl.c +++ /dev/null @@ -1,114 +0,0 @@ -/* origin: OpenBSD /usr/src/lib/libm/src/s_catanl.c */ -/* - * Copyright (c) 2008 Stephen L. Moshier - * - * 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. - */ -/* - * Complex circular arc tangent - * - * - * SYNOPSIS: - * - * long double complex catanl(); - * long double complex z, w; - * - * w = catanl( z ); - * - * - * DESCRIPTION: - * - * If - * z = x + iy, - * - * then - * 1 ( 2x ) - * Re w = - arctan(-----------) + k PI - * 2 ( 2 2) - * (1 - x - y ) - * - * ( 2 2) - * 1 (x + (y+1) ) - * Im w = - log(------------) - * 4 ( 2 2) - * (x + (y-1) ) - * - * Where k is an arbitrary integer. - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 5900 1.3e-16 7.8e-18 - * IEEE -10,+10 30000 2.3e-15 8.5e-17 - * The check catan( ctan(z) ) = z, with |x| and |y| < PI/2, - * had peak relative error 1.5e-16, rms relative error - * 2.9e-17. See also clog(). - */ - -#include -#include -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex catanl(long double complex z) -{ - return catan(z); -} -#else -static const long double PIL = 3.141592653589793238462643383279502884197169L; -static const long double DP1 = 3.14159265358979323829596852490908531763125L; -static const long double DP2 = 1.6667485837041756656403424829301998703007e-19L; -static const long double DP3 = 1.8830410776607851167459095484560349402753e-39L; - -static long double redupil(long double x) -{ - long double t; - long i; - - t = x / PIL; - if (t >= 0.0L) - t += 0.5L; - else - t -= 0.5L; - - i = t; /* the multiple */ - t = i; - t = ((x - t * DP1) - t * DP2) - t * DP3; - return t; -} - -long double complex catanl(long double complex z) -{ - long double complex w; - long double a, t, x, x2, y; - - x = creall(z); - y = cimagl(z); - - x2 = x * x; - a = 1.0L - x2 - (y * y); - - t = atan2l(2.0L * x, a) * 0.5L; - w = redupil(t); - - t = y - 1.0L; - a = x2 + (t * t); - - t = y + 1.0L; - a = (x2 + (t * t)) / a; - w = CMPLXF(w, 0.25L * logl(a)); - return w; -} -#endif diff --git a/src/complex/ccos.c b/src/complex/ccos.c deleted file mode 100644 index f32e1fad..00000000 --- a/src/complex/ccos.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "complex_impl.h" - -/* cos(z) = cosh(i z) */ - -double complex ccos(double complex z) -{ - return ccosh(CMPLX(-cimag(z), creal(z))); -} diff --git a/src/complex/ccosf.c b/src/complex/ccosf.c deleted file mode 100644 index 490be9b3..00000000 --- a/src/complex/ccosf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -float complex ccosf(float complex z) -{ - return ccoshf(CMPLXF(-cimagf(z), crealf(z))); -} diff --git a/src/complex/ccosh.c b/src/complex/ccosh.c deleted file mode 100644 index c995da7b..00000000 --- a/src/complex/ccosh.c +++ /dev/null @@ -1,140 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_ccosh.c */ -/*- - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl - * 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 unmodified, 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 ``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 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. - */ -/* - * Hyperbolic cosine of a complex argument z = x + i y. - * - * cosh(z) = cosh(x+iy) - * = cosh(x) cos(y) + i sinh(x) sin(y). - * - * Exceptional values are noted in the comments within the source code. - * These values and the return value were taken from n1124.pdf. - */ - -#include "complex_impl.h" - -static const double huge = 0x1p1023; - -double complex ccosh(double complex z) -{ - double x, y, h; - int32_t hx, hy, ix, iy, lx, ly; - - x = creal(z); - y = cimag(z); - - EXTRACT_WORDS(hx, lx, x); - EXTRACT_WORDS(hy, ly, y); - - ix = 0x7fffffff & hx; - iy = 0x7fffffff & hy; - - /* Handle the nearly-non-exceptional cases where x and y are finite. */ - if (ix < 0x7ff00000 && iy < 0x7ff00000) { - if ((iy | ly) == 0) - return CMPLX(cosh(x), x * y); - if (ix < 0x40360000) /* small x: normal case */ - return CMPLX(cosh(x) * cos(y), sinh(x) * sin(y)); - - /* |x| >= 22, so cosh(x) ~= exp(|x|) */ - if (ix < 0x40862e42) { - /* x < 710: exp(|x|) won't overflow */ - h = exp(fabs(x)) * 0.5; - return CMPLX(h * cos(y), copysign(h, x) * sin(y)); - } else if (ix < 0x4096bbaa) { - /* x < 1455: scale to avoid overflow */ - z = __ldexp_cexp(CMPLX(fabs(x), y), -1); - return CMPLX(creal(z), cimag(z) * copysign(1, x)); - } else { - /* x >= 1455: the result always overflows */ - h = huge * x; - return CMPLX(h * h * cos(y), h * sin(y)); - } - } - - /* - * cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0. - * The sign of 0 in the result is unspecified. Choice = normally - * the same as dNaN. Raise the invalid floating-point exception. - * - * cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0. - * The sign of 0 in the result is unspecified. Choice = normally - * the same as d(NaN). - */ - if ((ix | lx) == 0 && iy >= 0x7ff00000) - return CMPLX(y - y, copysign(0, x * (y - y))); - - /* - * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0. - * - * cosh(NaN +- I 0) = d(NaN) + I sign(d(NaN, +-0))0. - * The sign of 0 in the result is unspecified. - */ - if ((iy | ly) == 0 && ix >= 0x7ff00000) { - if (((hx & 0xfffff) | lx) == 0) - return CMPLX(x * x, copysign(0, x) * y); - return CMPLX(x * x, copysign(0, (x + x) * y)); - } - - /* - * cosh(x +- I Inf) = dNaN + I dNaN. - * Raise the invalid floating-point exception for finite nonzero x. - * - * cosh(x + I NaN) = d(NaN) + I d(NaN). - * Optionally raises the invalid floating-point exception for finite - * nonzero x. Choice = don't raise (except for signaling NaNs). - */ - if (ix < 0x7ff00000 && iy >= 0x7ff00000) - return CMPLX(y - y, x * (y - y)); - - /* - * cosh(+-Inf + I NaN) = +Inf + I d(NaN). - * - * cosh(+-Inf +- I Inf) = +Inf + I dNaN. - * The sign of Inf in the result is unspecified. Choice = always +. - * Raise the invalid floating-point exception. - * - * cosh(+-Inf + I y) = +Inf cos(y) +- I Inf sin(y) - */ - if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) { - if (iy >= 0x7ff00000) - return CMPLX(x * x, x * (y - y)); - return CMPLX((x * x) * cos(y), x * sin(y)); - } - - /* - * cosh(NaN + I NaN) = d(NaN) + I d(NaN). - * - * cosh(NaN +- I Inf) = d(NaN) + I d(NaN). - * Optionally raises the invalid floating-point exception. - * Choice = raise. - * - * cosh(NaN + I y) = d(NaN) + I d(NaN). - * Optionally raises the invalid floating-point exception for finite - * nonzero y. Choice = don't raise (except for signaling NaNs). - */ - return CMPLX((x * x) * (y - y), (x + x) * (y - y)); -} diff --git a/src/complex/ccoshf.c b/src/complex/ccoshf.c deleted file mode 100644 index 189ce946..00000000 --- a/src/complex/ccoshf.c +++ /dev/null @@ -1,90 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_ccoshf.c */ -/*- - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl - * 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 unmodified, 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 ``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 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. - */ -/* - * Hyperbolic cosine of a complex argument. See s_ccosh.c for details. - */ - -#include "complex_impl.h" - -static const float huge = 0x1p127; - -float complex ccoshf(float complex z) -{ - float x, y, h; - int32_t hx, hy, ix, iy; - - x = crealf(z); - y = cimagf(z); - - GET_FLOAT_WORD(hx, x); - GET_FLOAT_WORD(hy, y); - - ix = 0x7fffffff & hx; - iy = 0x7fffffff & hy; - - if (ix < 0x7f800000 && iy < 0x7f800000) { - if (iy == 0) - return CMPLXF(coshf(x), x * y); - if (ix < 0x41100000) /* small x: normal case */ - return CMPLXF(coshf(x) * cosf(y), sinhf(x) * sinf(y)); - - /* |x| >= 9, so cosh(x) ~= exp(|x|) */ - if (ix < 0x42b17218) { - /* x < 88.7: expf(|x|) won't overflow */ - h = expf(fabsf(x)) * 0.5f; - return CMPLXF(h * cosf(y), copysignf(h, x) * sinf(y)); - } else if (ix < 0x4340b1e7) { - /* x < 192.7: scale to avoid overflow */ - z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1); - return CMPLXF(crealf(z), cimagf(z) * copysignf(1, x)); - } else { - /* x >= 192.7: the result always overflows */ - h = huge * x; - return CMPLXF(h * h * cosf(y), h * sinf(y)); - } - } - - if (ix == 0 && iy >= 0x7f800000) - return CMPLXF(y - y, copysignf(0, x * (y - y))); - - if (iy == 0 && ix >= 0x7f800000) { - if ((hx & 0x7fffff) == 0) - return CMPLXF(x * x, copysignf(0, x) * y); - return CMPLXF(x * x, copysignf(0, (x + x) * y)); - } - - if (ix < 0x7f800000 && iy >= 0x7f800000) - return CMPLXF(y - y, x * (y - y)); - - if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { - if (iy >= 0x7f800000) - return CMPLXF(x * x, x * (y - y)); - return CMPLXF((x * x) * cosf(y), x * sinf(y)); - } - - return CMPLXF((x * x) * (y - y), (x + x) * (y - y)); -} diff --git a/src/complex/ccoshl.c b/src/complex/ccoshl.c deleted file mode 100644 index ffb4d8a1..00000000 --- a/src/complex/ccoshl.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -//FIXME -long double complex ccoshl(long double complex z) -{ - return ccosh(z); -} diff --git a/src/complex/ccosl.c b/src/complex/ccosl.c deleted file mode 100644 index 2530006b..00000000 --- a/src/complex/ccosl.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex ccosl(long double complex z) -{ - return ccos(z); -} -#else -long double complex ccosl(long double complex z) -{ - return ccoshl(CMPLXL(-cimagl(z), creall(z))); -} -#endif diff --git a/src/complex/cexp.c b/src/complex/cexp.c deleted file mode 100644 index 7fb489bb..00000000 --- a/src/complex/cexp.c +++ /dev/null @@ -1,83 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_cexp.c */ -/*- - * Copyright (c) 2011 David Schultz - * 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 "complex_impl.h" - -static const uint32_t -exp_ovfl = 0x40862e42, /* high bits of MAX_EXP * ln2 ~= 710 */ -cexp_ovfl = 0x4096b8e4; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ - -double complex cexp(double complex z) -{ - double x, y, exp_x; - uint32_t hx, hy, lx, ly; - - x = creal(z); - y = cimag(z); - - EXTRACT_WORDS(hy, ly, y); - hy &= 0x7fffffff; - - /* cexp(x + I 0) = exp(x) + I 0 */ - if ((hy | ly) == 0) - return CMPLX(exp(x), y); - EXTRACT_WORDS(hx, lx, x); - /* cexp(0 + I y) = cos(y) + I sin(y) */ - if (((hx & 0x7fffffff) | lx) == 0) - return CMPLX(cos(y), sin(y)); - - if (hy >= 0x7ff00000) { - if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) { - /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ - return CMPLX(y - y, y - y); - } else if (hx & 0x80000000) { - /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ - return CMPLX(0.0, 0.0); - } else { - /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ - return CMPLX(x, y - y); - } - } - - if (hx >= exp_ovfl && hx <= cexp_ovfl) { - /* - * x is between 709.7 and 1454.3, so we must scale to avoid - * overflow in exp(x). - */ - return __ldexp_cexp(z, 0); - } else { - /* - * Cases covered here: - * - x < exp_ovfl and exp(x) won't overflow (common case) - * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 - * - x = +-Inf (generated by exp()) - * - x = NaN (spurious inexact exception from y) - */ - exp_x = exp(x); - return CMPLX(exp_x * cos(y), exp_x * sin(y)); - } -} diff --git a/src/complex/cexpf.c b/src/complex/cexpf.c deleted file mode 100644 index 00d258f3..00000000 --- a/src/complex/cexpf.c +++ /dev/null @@ -1,83 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_cexpf.c */ -/*- - * Copyright (c) 2011 David Schultz - * 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 "complex_impl.h" - -static const uint32_t -exp_ovfl = 0x42b17218, /* MAX_EXP * ln2 ~= 88.722839355 */ -cexp_ovfl = 0x43400074; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ - -float complex cexpf(float complex z) -{ - float x, y, exp_x; - uint32_t hx, hy; - - x = crealf(z); - y = cimagf(z); - - GET_FLOAT_WORD(hy, y); - hy &= 0x7fffffff; - - /* cexp(x + I 0) = exp(x) + I 0 */ - if (hy == 0) - return CMPLXF(expf(x), y); - GET_FLOAT_WORD(hx, x); - /* cexp(0 + I y) = cos(y) + I sin(y) */ - if ((hx & 0x7fffffff) == 0) - return CMPLXF(cosf(y), sinf(y)); - - if (hy >= 0x7f800000) { - if ((hx & 0x7fffffff) != 0x7f800000) { - /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ - return CMPLXF(y - y, y - y); - } else if (hx & 0x80000000) { - /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ - return CMPLXF(0.0, 0.0); - } else { - /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ - return CMPLXF(x, y - y); - } - } - - if (hx >= exp_ovfl && hx <= cexp_ovfl) { - /* - * x is between 88.7 and 192, so we must scale to avoid - * overflow in expf(x). - */ - return __ldexp_cexpf(z, 0); - } else { - /* - * Cases covered here: - * - x < exp_ovfl and exp(x) won't overflow (common case) - * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 - * - x = +-Inf (generated by exp()) - * - x = NaN (spurious inexact exception from y) - */ - exp_x = expf(x); - return CMPLXF(exp_x * cosf(y), exp_x * sinf(y)); - } -} diff --git a/src/complex/cexpl.c b/src/complex/cexpl.c deleted file mode 100644 index d4df950e..00000000 --- a/src/complex/cexpl.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -//FIXME -long double complex cexpl(long double complex z) -{ - return cexp(z); -} diff --git a/src/complex/cimag.c b/src/complex/cimag.c deleted file mode 100644 index d6b0e683..00000000 --- a/src/complex/cimag.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -double (cimag)(double complex z) -{ - return cimag(z); -} diff --git a/src/complex/cimagf.c b/src/complex/cimagf.c deleted file mode 100644 index b7166dcf..00000000 --- a/src/complex/cimagf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -float (cimagf)(float complex z) -{ - return cimagf(z); -} diff --git a/src/complex/cimagl.c b/src/complex/cimagl.c deleted file mode 100644 index 4db77f20..00000000 --- a/src/complex/cimagl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -long double (cimagl)(long double complex z) -{ - return cimagl(z); -} diff --git a/src/complex/clog.c b/src/complex/clog.c deleted file mode 100644 index b587c291..00000000 --- a/src/complex/clog.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "complex_impl.h" - -// FIXME - -/* log(z) = log(|z|) + i arg(z) */ - -double complex clog(double complex z) -{ - double r, phi; - - r = cabs(z); - phi = carg(z); - return CMPLX(log(r), phi); -} diff --git a/src/complex/clogf.c b/src/complex/clogf.c deleted file mode 100644 index 0389d472..00000000 --- a/src/complex/clogf.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "complex_impl.h" - -// FIXME - -float complex clogf(float complex z) -{ - float r, phi; - - r = cabsf(z); - phi = cargf(z); - return CMPLXF(logf(r), phi); -} diff --git a/src/complex/clogl.c b/src/complex/clogl.c deleted file mode 100644 index 88e83e87..00000000 --- a/src/complex/clogl.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex clogl(long double complex z) -{ - return clog(z); -} -#else -// FIXME -long double complex clogl(long double complex z) -{ - long double r, phi; - - r = cabsl(z); - phi = cargl(z); - return CMPLXL(logl(r), phi); -} -#endif diff --git a/src/complex/conj.c b/src/complex/conj.c deleted file mode 100644 index a3b19a4a..00000000 --- a/src/complex/conj.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -double complex conj(double complex z) -{ - return CMPLX(creal(z), -cimag(z)); -} diff --git a/src/complex/conjf.c b/src/complex/conjf.c deleted file mode 100644 index b2195c84..00000000 --- a/src/complex/conjf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -float complex conjf(float complex z) -{ - return CMPLXF(crealf(z), -cimagf(z)); -} diff --git a/src/complex/conjl.c b/src/complex/conjl.c deleted file mode 100644 index 87a4ebec..00000000 --- a/src/complex/conjl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -long double complex conjl(long double complex z) -{ - return CMPLXL(creall(z), -cimagl(z)); -} diff --git a/src/complex/cpow.c b/src/complex/cpow.c deleted file mode 100644 index 1137d391..00000000 --- a/src/complex/cpow.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "complex_impl.h" - -/* pow(z, c) = exp(c log(z)), See C99 G.6.4.1 */ - -double complex cpow(double complex z, double complex c) -{ - return cexp(c * clog(z)); -} diff --git a/src/complex/cpowf.c b/src/complex/cpowf.c deleted file mode 100644 index f3fd4b7b..00000000 --- a/src/complex/cpowf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "complex_impl.h" - -float complex cpowf(float complex z, float complex c) -{ - return cexpf(c * clogf(z)); -} diff --git a/src/complex/cpowl.c b/src/complex/cpowl.c deleted file mode 100644 index be36f046..00000000 --- a/src/complex/cpowl.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex cpowl(long double complex z, long double complex c) -{ - return cpow(z, c); -} -#else -long double complex cpowl(long double complex z, long double complex c) -{ - return cexpl(c * clogl(z)); -} -#endif diff --git a/src/complex/cproj.c b/src/complex/cproj.c deleted file mode 100644 index 9ae1e17c..00000000 --- a/src/complex/cproj.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "complex_impl.h" - -double complex cproj(double complex z) -{ - if (isinf(creal(z)) || isinf(cimag(z))) - return CMPLX(INFINITY, copysign(0.0, creal(z))); - return z; -} diff --git a/src/complex/cprojf.c b/src/complex/cprojf.c deleted file mode 100644 index 03fab339..00000000 --- a/src/complex/cprojf.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "complex_impl.h" - -float complex cprojf(float complex z) -{ - if (isinf(crealf(z)) || isinf(cimagf(z))) - return CMPLXF(INFINITY, copysignf(0.0, crealf(z))); - return z; -} diff --git a/src/complex/cprojl.c b/src/complex/cprojl.c deleted file mode 100644 index 38a494c5..00000000 --- a/src/complex/cprojl.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex cprojl(long double complex z) -{ - return cproj(z); -} -#else -long double complex cprojl(long double complex z) -{ - if (isinf(creall(z)) || isinf(cimagl(z))) - return CMPLXL(INFINITY, copysignl(0.0, creall(z))); - return z; -} -#endif diff --git a/src/complex/creal.c b/src/complex/creal.c deleted file mode 100644 index f6703040..00000000 --- a/src/complex/creal.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -double (creal)(double complex z) -{ - return creal(z); -} diff --git a/src/complex/crealf.c b/src/complex/crealf.c deleted file mode 100644 index 5dc3ff1d..00000000 --- a/src/complex/crealf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -float (crealf)(float complex z) -{ - return crealf(z); -} diff --git a/src/complex/creall.c b/src/complex/creall.c deleted file mode 100644 index fd9dc347..00000000 --- a/src/complex/creall.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -long double (creall)(long double complex z) -{ - return creall(z); -} diff --git a/src/complex/csin.c b/src/complex/csin.c deleted file mode 100644 index 535c4bf8..00000000 --- a/src/complex/csin.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "complex_impl.h" - -/* sin(z) = -i sinh(i z) */ - -double complex csin(double complex z) -{ - z = csinh(CMPLX(-cimag(z), creal(z))); - return CMPLX(cimag(z), -creal(z)); -} diff --git a/src/complex/csinf.c b/src/complex/csinf.c deleted file mode 100644 index 69f5164e..00000000 --- a/src/complex/csinf.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -float complex csinf(float complex z) -{ - z = csinhf(CMPLXF(-cimagf(z), crealf(z))); - return CMPLXF(cimagf(z), -crealf(z)); -} diff --git a/src/complex/csinh.c b/src/complex/csinh.c deleted file mode 100644 index eda0ab59..00000000 --- a/src/complex/csinh.c +++ /dev/null @@ -1,141 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_csinh.c */ -/*- - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl - * 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 unmodified, 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 ``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 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. - */ -/* - * Hyperbolic sine of a complex argument z = x + i y. - * - * sinh(z) = sinh(x+iy) - * = sinh(x) cos(y) + i cosh(x) sin(y). - * - * Exceptional values are noted in the comments within the source code. - * These values and the return value were taken from n1124.pdf. - */ - -#include "complex_impl.h" - -static const double huge = 0x1p1023; - -double complex csinh(double complex z) -{ - double x, y, h; - int32_t hx, hy, ix, iy, lx, ly; - - x = creal(z); - y = cimag(z); - - EXTRACT_WORDS(hx, lx, x); - EXTRACT_WORDS(hy, ly, y); - - ix = 0x7fffffff & hx; - iy = 0x7fffffff & hy; - - /* Handle the nearly-non-exceptional cases where x and y are finite. */ - if (ix < 0x7ff00000 && iy < 0x7ff00000) { - if ((iy | ly) == 0) - return CMPLX(sinh(x), y); - if (ix < 0x40360000) /* small x: normal case */ - return CMPLX(sinh(x) * cos(y), cosh(x) * sin(y)); - - /* |x| >= 22, so cosh(x) ~= exp(|x|) */ - if (ix < 0x40862e42) { - /* x < 710: exp(|x|) won't overflow */ - h = exp(fabs(x)) * 0.5; - return CMPLX(copysign(h, x) * cos(y), h * sin(y)); - } else if (ix < 0x4096bbaa) { - /* x < 1455: scale to avoid overflow */ - z = __ldexp_cexp(CMPLX(fabs(x), y), -1); - return CMPLX(creal(z) * copysign(1, x), cimag(z)); - } else { - /* x >= 1455: the result always overflows */ - h = huge * x; - return CMPLX(h * cos(y), h * h * sin(y)); - } - } - - /* - * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN. - * The sign of 0 in the result is unspecified. Choice = normally - * the same as dNaN. Raise the invalid floating-point exception. - * - * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN). - * The sign of 0 in the result is unspecified. Choice = normally - * the same as d(NaN). - */ - if ((ix | lx) == 0 && iy >= 0x7ff00000) - return CMPLX(copysign(0, x * (y - y)), y - y); - - /* - * sinh(+-Inf +- I 0) = +-Inf + I +-0. - * - * sinh(NaN +- I 0) = d(NaN) + I +-0. - */ - if ((iy | ly) == 0 && ix >= 0x7ff00000) { - if (((hx & 0xfffff) | lx) == 0) - return CMPLX(x, y); - return CMPLX(x, copysign(0, y)); - } - - /* - * sinh(x +- I Inf) = dNaN + I dNaN. - * Raise the invalid floating-point exception for finite nonzero x. - * - * sinh(x + I NaN) = d(NaN) + I d(NaN). - * Optionally raises the invalid floating-point exception for finite - * nonzero x. Choice = don't raise (except for signaling NaNs). - */ - if (ix < 0x7ff00000 && iy >= 0x7ff00000) - return CMPLX(y - y, x * (y - y)); - - /* - * sinh(+-Inf + I NaN) = +-Inf + I d(NaN). - * The sign of Inf in the result is unspecified. Choice = normally - * the same as d(NaN). - * - * sinh(+-Inf +- I Inf) = +Inf + I dNaN. - * The sign of Inf in the result is unspecified. Choice = always +. - * Raise the invalid floating-point exception. - * - * sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y) - */ - if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) { - if (iy >= 0x7ff00000) - return CMPLX(x * x, x * (y - y)); - return CMPLX(x * cos(y), INFINITY * sin(y)); - } - - /* - * sinh(NaN + I NaN) = d(NaN) + I d(NaN). - * - * sinh(NaN +- I Inf) = d(NaN) + I d(NaN). - * Optionally raises the invalid floating-point exception. - * Choice = raise. - * - * sinh(NaN + I y) = d(NaN) + I d(NaN). - * Optionally raises the invalid floating-point exception for finite - * nonzero y. Choice = don't raise (except for signaling NaNs). - */ - return CMPLX((x * x) * (y - y), (x + x) * (y - y)); -} diff --git a/src/complex/csinhf.c b/src/complex/csinhf.c deleted file mode 100644 index eb1d98c5..00000000 --- a/src/complex/csinhf.c +++ /dev/null @@ -1,90 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_csinhf.c */ -/*- - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl - * 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 unmodified, 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 ``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 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. - */ -/* - * Hyperbolic sine of a complex argument z. See s_csinh.c for details. - */ - -#include "complex_impl.h" - -static const float huge = 0x1p127; - -float complex csinhf(float complex z) -{ - float x, y, h; - int32_t hx, hy, ix, iy; - - x = crealf(z); - y = cimagf(z); - - GET_FLOAT_WORD(hx, x); - GET_FLOAT_WORD(hy, y); - - ix = 0x7fffffff & hx; - iy = 0x7fffffff & hy; - - if (ix < 0x7f800000 && iy < 0x7f800000) { - if (iy == 0) - return CMPLXF(sinhf(x), y); - if (ix < 0x41100000) /* small x: normal case */ - return CMPLXF(sinhf(x) * cosf(y), coshf(x) * sinf(y)); - - /* |x| >= 9, so cosh(x) ~= exp(|x|) */ - if (ix < 0x42b17218) { - /* x < 88.7: expf(|x|) won't overflow */ - h = expf(fabsf(x)) * 0.5f; - return CMPLXF(copysignf(h, x) * cosf(y), h * sinf(y)); - } else if (ix < 0x4340b1e7) { - /* x < 192.7: scale to avoid overflow */ - z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1); - return CMPLXF(crealf(z) * copysignf(1, x), cimagf(z)); - } else { - /* x >= 192.7: the result always overflows */ - h = huge * x; - return CMPLXF(h * cosf(y), h * h * sinf(y)); - } - } - - if (ix == 0 && iy >= 0x7f800000) - return CMPLXF(copysignf(0, x * (y - y)), y - y); - - if (iy == 0 && ix >= 0x7f800000) { - if ((hx & 0x7fffff) == 0) - return CMPLXF(x, y); - return CMPLXF(x, copysignf(0, y)); - } - - if (ix < 0x7f800000 && iy >= 0x7f800000) - return CMPLXF(y - y, x * (y - y)); - - if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { - if (iy >= 0x7f800000) - return CMPLXF(x * x, x * (y - y)); - return CMPLXF(x * cosf(y), INFINITY * sinf(y)); - } - - return CMPLXF((x * x) * (y - y), (x + x) * (y - y)); -} diff --git a/src/complex/csinhl.c b/src/complex/csinhl.c deleted file mode 100644 index 09fd18f9..00000000 --- a/src/complex/csinhl.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -//FIXME -long double complex csinhl(long double complex z) -{ - return csinh(z); -} diff --git a/src/complex/csinl.c b/src/complex/csinl.c deleted file mode 100644 index 90a4eb37..00000000 --- a/src/complex/csinl.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex csinl(long double complex z) -{ - return csin(z); -} -#else -long double complex csinl(long double complex z) -{ - z = csinhl(CMPLXL(-cimagl(z), creall(z))); - return CMPLXL(cimagl(z), -creall(z)); -} -#endif diff --git a/src/complex/csqrt.c b/src/complex/csqrt.c deleted file mode 100644 index c36de001..00000000 --- a/src/complex/csqrt.c +++ /dev/null @@ -1,100 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_csqrt.c */ -/*- - * Copyright (c) 2007 David Schultz - * 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 "complex_impl.h" - -/* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. - */ -#pragma STDC CX_LIMITED_RANGE ON - -/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ -#define THRESH 0x1.a827999fcef32p+1022 - -double complex csqrt(double complex z) -{ - double complex result; - double a, b; - double t; - int scale; - - a = creal(z); - b = cimag(z); - - /* Handle special cases. */ - if (z == 0) - return CMPLX(0, b); - if (isinf(b)) - return CMPLX(INFINITY, b); - if (isnan(a)) { - t = (b - b) / (b - b); /* raise invalid if b is not a NaN */ - return CMPLX(a, t); /* return NaN + NaN i */ - } - if (isinf(a)) { - /* - * csqrt(inf + NaN i) = inf + NaN i - * csqrt(inf + y i) = inf + 0 i - * csqrt(-inf + NaN i) = NaN +- inf i - * csqrt(-inf + y i) = 0 + inf i - */ - if (signbit(a)) - return CMPLX(fabs(b - b), copysign(a, b)); - else - return CMPLX(a, copysign(b - b, b)); - } - /* - * The remaining special case (b is NaN) is handled just fine by - * the normal code path below. - */ - - /* Scale to avoid overflow. */ - if (fabs(a) >= THRESH || fabs(b) >= THRESH) { - a *= 0.25; - b *= 0.25; - scale = 1; - } else { - scale = 0; - } - - /* Algorithm 312, CACM vol 10, Oct 1967. */ - if (a >= 0) { - t = sqrt((a + hypot(a, b)) * 0.5); - result = CMPLX(t, b / (2 * t)); - } else { - t = sqrt((-a + hypot(a, b)) * 0.5); - result = CMPLX(fabs(b) / (2 * t), copysign(t, b)); - } - - /* Rescale. */ - if (scale) - result *= 2; - return result; -} diff --git a/src/complex/csqrtf.c b/src/complex/csqrtf.c deleted file mode 100644 index a6163974..00000000 --- a/src/complex/csqrtf.c +++ /dev/null @@ -1,82 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_csqrtf.c */ -/*- - * Copyright (c) 2007 David Schultz - * 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 "complex_impl.h" - -/* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. - */ -#pragma STDC CX_LIMITED_RANGE ON - -float complex csqrtf(float complex z) -{ - float a = crealf(z), b = cimagf(z); - double t; - - /* Handle special cases. */ - if (z == 0) - return CMPLXF(0, b); - if (isinf(b)) - return CMPLXF(INFINITY, b); - if (isnan(a)) { - t = (b - b) / (b - b); /* raise invalid if b is not a NaN */ - return CMPLXF(a, t); /* return NaN + NaN i */ - } - if (isinf(a)) { - /* - * csqrtf(inf + NaN i) = inf + NaN i - * csqrtf(inf + y i) = inf + 0 i - * csqrtf(-inf + NaN i) = NaN +- inf i - * csqrtf(-inf + y i) = 0 + inf i - */ - if (signbit(a)) - return CMPLXF(fabsf(b - b), copysignf(a, b)); - else - return CMPLXF(a, copysignf(b - b, b)); - } - /* - * The remaining special case (b is NaN) is handled just fine by - * the normal code path below. - */ - - /* - * We compute t in double precision to avoid overflow and to - * provide correct rounding in nearly all cases. - * This is Algorithm 312, CACM vol 10, Oct 1967. - */ - if (a >= 0) { - t = sqrt((a + hypot(a, b)) * 0.5); - return CMPLXF(t, b / (2.0 * t)); - } else { - t = sqrt((-a + hypot(a, b)) * 0.5); - return CMPLXF(fabsf(b) / (2.0 * t), copysignf(t, b)); - } -} diff --git a/src/complex/csqrtl.c b/src/complex/csqrtl.c deleted file mode 100644 index 22539379..00000000 --- a/src/complex/csqrtl.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -//FIXME -long double complex csqrtl(long double complex z) -{ - return csqrt(z); -} diff --git a/src/complex/ctan.c b/src/complex/ctan.c deleted file mode 100644 index 918717bf..00000000 --- a/src/complex/ctan.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "complex_impl.h" - -/* tan(z) = -i tanh(i z) */ - -double complex ctan(double complex z) -{ - z = ctanh(CMPLX(-cimag(z), creal(z))); - return CMPLX(cimag(z), -creal(z)); -} diff --git a/src/complex/ctanf.c b/src/complex/ctanf.c deleted file mode 100644 index 04c3ff19..00000000 --- a/src/complex/ctanf.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -float complex ctanf(float complex z) -{ - z = ctanhf(CMPLXF(-cimagf(z), crealf(z))); - return CMPLXF(cimagf(z), -crealf(z)); -} diff --git a/src/complex/ctanh.c b/src/complex/ctanh.c deleted file mode 100644 index 54004cd7..00000000 --- a/src/complex/ctanh.c +++ /dev/null @@ -1,129 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_ctanh.c */ -/*- - * Copyright (c) 2011 David Schultz - * 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 unmodified, 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 ``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 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. - */ -/* - * Hyperbolic tangent of a complex argument z = x + i y. - * - * The algorithm is from: - * - * W. Kahan. Branch Cuts for Complex Elementary Functions or Much - * Ado About Nothing's Sign Bit. In The State of the Art in - * Numerical Analysis, pp. 165 ff. Iserles and Powell, eds., 1987. - * - * Method: - * - * Let t = tan(x) - * beta = 1/cos^2(y) - * s = sinh(x) - * rho = cosh(x) - * - * We have: - * - * tanh(z) = sinh(z) / cosh(z) - * - * sinh(x) cos(y) + i cosh(x) sin(y) - * = --------------------------------- - * cosh(x) cos(y) + i sinh(x) sin(y) - * - * cosh(x) sinh(x) / cos^2(y) + i tan(y) - * = ------------------------------------- - * 1 + sinh^2(x) / cos^2(y) - * - * beta rho s + i t - * = ---------------- - * 1 + beta s^2 - * - * Modifications: - * - * I omitted the original algorithm's handling of overflow in tan(x) after - * verifying with nearpi.c that this can't happen in IEEE single or double - * precision. I also handle large x differently. - */ - -#include "complex_impl.h" - -double complex ctanh(double complex z) -{ - double x, y; - double t, beta, s, rho, denom; - uint32_t hx, ix, lx; - - x = creal(z); - y = cimag(z); - - EXTRACT_WORDS(hx, lx, x); - ix = hx & 0x7fffffff; - - /* - * ctanh(NaN + i 0) = NaN + i 0 - * - * ctanh(NaN + i y) = NaN + i NaN for y != 0 - * - * The imaginary part has the sign of x*sin(2*y), but there's no - * special effort to get this right. - * - * ctanh(+-Inf +- i Inf) = +-1 +- 0 - * - * ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite - * - * The imaginary part of the sign is unspecified. This special - * case is only needed to avoid a spurious invalid exception when - * y is infinite. - */ - if (ix >= 0x7ff00000) { - if ((ix & 0xfffff) | lx) /* x is NaN */ - return CMPLX(x, (y == 0 ? y : x * y)); - SET_HIGH_WORD(x, hx - 0x40000000); /* x = copysign(1, x) */ - return CMPLX(x, copysign(0, isinf(y) ? y : sin(y) * cos(y))); - } - - /* - * ctanh(+-0 + i NAN) = +-0 + i NaN - * ctanh(+-0 +- i Inf) = +-0 + i NaN - * ctanh(x + i NAN) = NaN + i NaN - * ctanh(x +- i Inf) = NaN + i NaN - */ - if (!isfinite(y)) - return CMPLX(x ? y - y : x, y - y); - - /* - * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the - * approximation sinh^2(huge) ~= exp(2*huge) / 4. - * We use a modified formula to avoid spurious overflow. - */ - if (ix >= 0x40360000) { /* x >= 22 */ - double exp_mx = exp(-fabs(x)); - return CMPLX(copysign(1, x), 4 * sin(y) * cos(y) * exp_mx * exp_mx); - } - - /* Kahan's algorithm */ - t = tan(y); - beta = 1.0 + t * t; /* = 1 / cos^2(y) */ - s = sinh(x); - rho = sqrt(1 + s * s); /* = cosh(x) */ - denom = 1 + beta * s * s; - return CMPLX((beta * rho * s) / denom, t / denom); -} diff --git a/src/complex/ctanhf.c b/src/complex/ctanhf.c deleted file mode 100644 index 7f422ba7..00000000 --- a/src/complex/ctanhf.c +++ /dev/null @@ -1,66 +0,0 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/s_ctanhf.c */ -/*- - * Copyright (c) 2011 David Schultz - * 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 unmodified, 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 ``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 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. - */ -/* - * Hyperbolic tangent of a complex argument z. See s_ctanh.c for details. - */ - -#include "complex_impl.h" - -float complex ctanhf(float complex z) -{ - float x, y; - float t, beta, s, rho, denom; - uint32_t hx, ix; - - x = crealf(z); - y = cimagf(z); - - GET_FLOAT_WORD(hx, x); - ix = hx & 0x7fffffff; - - if (ix >= 0x7f800000) { - if (ix & 0x7fffff) - return CMPLXF(x, (y == 0 ? y : x * y)); - SET_FLOAT_WORD(x, hx - 0x40000000); - return CMPLXF(x, copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))); - } - - if (!isfinite(y)) - return CMPLXF(ix ? y - y : x, y - y); - - if (ix >= 0x41300000) { /* x >= 11 */ - float exp_mx = expf(-fabsf(x)); - return CMPLXF(copysignf(1, x), 4 * sinf(y) * cosf(y) * exp_mx * exp_mx); - } - - t = tanf(y); - beta = 1.0 + t * t; - s = sinhf(x); - rho = sqrtf(1 + s * s); - denom = 1 + beta * s * s; - return CMPLXF((beta * rho * s) / denom, t / denom); -} diff --git a/src/complex/ctanhl.c b/src/complex/ctanhl.c deleted file mode 100644 index 45d5862c..00000000 --- a/src/complex/ctanhl.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "complex_impl.h" - -//FIXME -long double complex ctanhl(long double complex z) -{ - return ctanh(z); -} diff --git a/src/complex/ctanl.c b/src/complex/ctanl.c deleted file mode 100644 index 4b87420d..00000000 --- a/src/complex/ctanl.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "complex_impl.h" - -#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 -long double complex ctanl(long double complex z) -{ - return ctan(z); -} -#else -long double complex ctanl(long double complex z) -{ - z = ctanhl(CMPLXL(-cimagl(z), creall(z))); - return CMPLXL(cimagl(z), -creall(z)); -} -#endif diff --git a/src/fenv/x86_64/fenv.s b/src/fenv/x86_64/fenv.s deleted file mode 100644 index 98d876da..00000000 --- a/src/fenv/x86_64/fenv.s +++ /dev/null @@ -1,98 +0,0 @@ -.global feclearexcept -.type feclearexcept,@function -feclearexcept: - # maintain exceptions in the sse mxcsr, clear x87 exceptions - mov %edi,%ecx - and $0x3f,%ecx - fnstsw %ax - test %eax,%ecx - jz 1f - fnclex -1: stmxcsr -8(%rsp) - and $0x3f,%eax - or %eax,-8(%rsp) - test %ecx,-8(%rsp) - jz 1f - not %ecx - and %ecx,-8(%rsp) - ldmxcsr -8(%rsp) -1: xor %eax,%eax - ret - -.global feraiseexcept -.type feraiseexcept,@function -feraiseexcept: - and $0x3f,%edi - stmxcsr -8(%rsp) - or %edi,-8(%rsp) - ldmxcsr -8(%rsp) - xor %eax,%eax - ret - -.global __fesetround -.hidden __fesetround -.type __fesetround,@function -__fesetround: - push %rax - xor %eax,%eax - mov %edi,%ecx - fnstcw (%rsp) - andb $0xf3,1(%rsp) - or %ch,1(%rsp) - fldcw (%rsp) - stmxcsr (%rsp) - shl $3,%ch - andb $0x9f,1(%rsp) - or %ch,1(%rsp) - ldmxcsr (%rsp) - pop %rcx - ret - -.global fegetround -.type fegetround,@function -fegetround: - push %rax - stmxcsr (%rsp) - pop %rax - shr $3,%eax - and $0xc00,%eax - ret - -.global fegetenv -.type fegetenv,@function -fegetenv: - xor %eax,%eax - fnstenv (%rdi) - stmxcsr 28(%rdi) - ret - -.global fesetenv -.type fesetenv,@function -fesetenv: - xor %eax,%eax - inc %rdi - jz 1f - fldenv -1(%rdi) - ldmxcsr 27(%rdi) - ret -1: push %rax - push %rax - pushq $0xffff - pushq $0x37f - fldenv (%rsp) - pushq $0x1f80 - ldmxcsr (%rsp) - add $40,%rsp - ret - -.global fetestexcept -.type fetestexcept,@function -fetestexcept: - and $0x3f,%edi - push %rax - stmxcsr (%rsp) - pop %rsi - fnstsw %ax - or %esi,%eax - and %edi,%eax - ret diff --git a/src/internal/syscall.h b/src/internal/syscall.h index 975a0031..58e7ee2d 100644 --- a/src/internal/syscall.h +++ b/src/internal/syscall.h @@ -29,10 +29,12 @@ hidden long __syscall_ret(unsigned long), #define __syscall1(n,a) __syscall1(n,__scc(a)) #define __syscall2(n,a,b) __syscall2(n,__scc(a),__scc(b)) #define __syscall3(n,a,b,c) __syscall3(n,__scc(a),__scc(b),__scc(c)) +#if !defined(__TINYC__) #define __syscall4(n,a,b,c,d) __syscall4(n,__scc(a),__scc(b),__scc(c),__scc(d)) #define __syscall5(n,a,b,c,d,e) __syscall5(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e)) #define __syscall6(n,a,b,c,d,e,f) __syscall6(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f)) #define __syscall7(n,a,b,c,d,e,f,g) __syscall7(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g)) +#endif #define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n #define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,) diff --git a/src/math/x86_64/__invtrigl.s b/src/math/x86_64/__invtrigl.s deleted file mode 100644 index e69de29b..00000000 diff --git a/src/math/x86_64/acosl.s b/src/math/x86_64/acosl.s deleted file mode 100644 index 88e01b49..00000000 --- a/src/math/x86_64/acosl.s +++ /dev/null @@ -1,16 +0,0 @@ -# see ../i386/acos.s - -.global acosl -.type acosl,@function -acosl: - fldt 8(%rsp) -1: fld %st(0) - fld1 - fsub %st(0),%st(1) - fadd %st(2) - fmulp - fsqrt - fabs - fxch %st(1) - fpatan - ret diff --git a/src/math/x86_64/asinl.s b/src/math/x86_64/asinl.s deleted file mode 100644 index ed212d9a..00000000 --- a/src/math/x86_64/asinl.s +++ /dev/null @@ -1,12 +0,0 @@ -.global asinl -.type asinl,@function -asinl: - fldt 8(%rsp) -1: fld %st(0) - fld1 - fsub %st(0),%st(1) - fadd %st(2) - fmulp - fsqrt - fpatan - ret diff --git a/src/math/x86_64/atan2l.s b/src/math/x86_64/atan2l.s deleted file mode 100644 index e5f0a3de..00000000 --- a/src/math/x86_64/atan2l.s +++ /dev/null @@ -1,7 +0,0 @@ -.global atan2l -.type atan2l,@function -atan2l: - fldt 8(%rsp) - fldt 24(%rsp) - fpatan - ret diff --git a/src/math/x86_64/atanl.s b/src/math/x86_64/atanl.s deleted file mode 100644 index df76de5d..00000000 --- a/src/math/x86_64/atanl.s +++ /dev/null @@ -1,7 +0,0 @@ -.global atanl -.type atanl,@function -atanl: - fldt 8(%rsp) - fld1 - fpatan - ret diff --git a/src/math/x86_64/ceill.s b/src/math/x86_64/ceill.s deleted file mode 100644 index f5cfa3b3..00000000 --- a/src/math/x86_64/ceill.s +++ /dev/null @@ -1 +0,0 @@ -# see floorl.s diff --git a/src/math/x86_64/exp2l.s b/src/math/x86_64/exp2l.s deleted file mode 100644 index effab2bd..00000000 --- a/src/math/x86_64/exp2l.s +++ /dev/null @@ -1,83 +0,0 @@ -.global expm1l -.type expm1l,@function -expm1l: - fldt 8(%rsp) - fldl2e - fmulp - movl $0xc2820000,-4(%rsp) - flds -4(%rsp) - fucomip %st(1),%st - fld1 - jb 1f - # x*log2e <= -65, return -1 without underflow - fstp %st(1) - fchs - ret -1: fld %st(1) - fabs - fucomip %st(1),%st - fstp %st(0) - ja 1f - f2xm1 - ret -1: push %rax - call 1f - pop %rax - fld1 - fsubrp - ret - -.global exp2l -.type exp2l,@function -exp2l: - fldt 8(%rsp) -1: fld %st(0) - sub $16,%rsp - fstpt (%rsp) - mov 8(%rsp),%ax - and $0x7fff,%ax - cmp $0x3fff+13,%ax - jb 4f # |x| < 8192 - cmp $0x3fff+15,%ax - jae 3f # |x| >= 32768 - fsts (%rsp) - cmpl $0xc67ff800,(%rsp) - jb 2f # x > -16382 - movl $0x5f000000,(%rsp) - flds (%rsp) # 0x1p63 - fld %st(1) - fsub %st(1) - faddp - fucomip %st(1),%st - je 2f # x - 0x1p63 + 0x1p63 == x - movl $1,(%rsp) - flds (%rsp) # 0x1p-149 - fdiv %st(1) - fstps (%rsp) # raise underflow -2: fld1 - fld %st(1) - frndint - fxch %st(2) - fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x) - f2xm1 - faddp # 2^(x-rint(x)) -1: fscale - fstp %st(1) - add $16,%rsp - ret -3: xor %eax,%eax -4: cmp $0x3fff-64,%ax - fld1 - jb 1b # |x| < 0x1p-64 - fstpt (%rsp) - fistl 8(%rsp) - fildl 8(%rsp) - fsubrp %st(1) - addl $0x3fff,8(%rsp) - f2xm1 - fld1 - faddp # 2^(x-rint(x)) - fldt (%rsp) # 2^rint(x) - fmulp - add $16,%rsp - ret diff --git a/src/math/x86_64/expl.s b/src/math/x86_64/expl.s deleted file mode 100644 index 798261d2..00000000 --- a/src/math/x86_64/expl.s +++ /dev/null @@ -1,101 +0,0 @@ -# exp(x) = 2^hi + 2^hi (2^lo - 1) -# where hi+lo = log2e*x with 128bit precision -# exact log2e*x calculation depends on nearest rounding mode -# using the exact multiplication method of Dekker and Veltkamp - -.global expl -.type expl,@function -expl: - fldt 8(%rsp) - - # interesting case: 0x1p-32 <= |x| < 16384 - # check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13] - mov 16(%rsp), %ax - or $0x8000, %ax - sub $0xbfdf, %ax - cmp $45, %ax - jbe 2f - test %ax, %ax - fld1 - js 1f - # if |x|>=0x1p14 or nan return 2^trunc(x) - fscale - fstp %st(1) - ret - # if |x|<0x1p-32 return 1+x -1: faddp - ret - - # should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc - # it will be wrong on non-nearest rounding mode -2: fldl2e - subq $48, %rsp - # hi = log2e_hi*x - # 2^hi = exp2l(hi) - fmul %st(1),%st - fld %st(0) - fstpt (%rsp) - fstpt 16(%rsp) - fstpt 32(%rsp) - call exp2l@PLT - # if 2^hi == inf return 2^hi - fld %st(0) - fstpt (%rsp) - cmpw $0x7fff, 8(%rsp) - je 1f - fldt 32(%rsp) - fldt 16(%rsp) - # fpu stack: 2^hi x hi - # exact mult: x*log2e - fld %st(1) - # c = 0x1p32+1 - movq $0x41f0000000100000,%rax - pushq %rax - fldl (%rsp) - # xh = x - c*x + c*x - # xl = x - xh - fmulp - fld %st(2) - fsub %st(1), %st - faddp - fld %st(2) - fsub %st(1), %st - # yh = log2e_hi - c*log2e_hi + c*log2e_hi - movq $0x3ff7154765200000,%rax - pushq %rax - fldl (%rsp) - # fpu stack: 2^hi x hi xh xl yh - # lo = hi - xh*yh + xl*yh - fld %st(2) - fmul %st(1), %st - fsubp %st, %st(4) - fmul %st(1), %st - faddp %st, %st(3) - # yl = log2e_hi - yh - movq $0x3de705fc2f000000,%rax - pushq %rax - fldl (%rsp) - # fpu stack: 2^hi x lo xh xl yl - # lo += xh*yl + xl*yl - fmul %st, %st(2) - fmulp %st, %st(1) - fxch %st(2) - faddp - faddp - # log2e_lo - movq $0xbfbe,%rax - pushq %rax - movq $0x82f0025f2dc582ee,%rax - pushq %rax - fldt (%rsp) - addq $40,%rsp - # fpu stack: 2^hi x lo log2e_lo - # lo += log2e_lo*x - # return 2^hi + 2^hi (2^lo - 1) - fmulp %st, %st(2) - faddp - f2xm1 - fmul %st(1), %st - faddp -1: addq $48, %rsp - ret diff --git a/src/math/x86_64/expm1l.s b/src/math/x86_64/expm1l.s deleted file mode 100644 index e773f080..00000000 --- a/src/math/x86_64/expm1l.s +++ /dev/null @@ -1 +0,0 @@ -# see exp2l.s diff --git a/src/math/x86_64/fabs.s b/src/math/x86_64/fabs.s deleted file mode 100644 index 5715005e..00000000 --- a/src/math/x86_64/fabs.s +++ /dev/null @@ -1,9 +0,0 @@ -.global fabs -.type fabs,@function -fabs: - xor %eax,%eax - dec %rax - shr %rax - movq %rax,%xmm1 - andpd %xmm1,%xmm0 - ret diff --git a/src/math/x86_64/fabsf.s b/src/math/x86_64/fabsf.s deleted file mode 100644 index 501a1f17..00000000 --- a/src/math/x86_64/fabsf.s +++ /dev/null @@ -1,7 +0,0 @@ -.global fabsf -.type fabsf,@function -fabsf: - mov $0x7fffffff,%eax - movq %rax,%xmm1 - andps %xmm1,%xmm0 - ret diff --git a/src/math/x86_64/fabsl.s b/src/math/x86_64/fabsl.s deleted file mode 100644 index 4e7ab525..00000000 --- a/src/math/x86_64/fabsl.s +++ /dev/null @@ -1,6 +0,0 @@ -.global fabsl -.type fabsl,@function -fabsl: - fldt 8(%rsp) - fabs - ret diff --git a/src/math/x86_64/floorl.s b/src/math/x86_64/floorl.s deleted file mode 100644 index 80da4660..00000000 --- a/src/math/x86_64/floorl.s +++ /dev/null @@ -1,27 +0,0 @@ -.global floorl -.type floorl,@function -floorl: - fldt 8(%rsp) -1: mov $0x7,%al -1: fstcw 8(%rsp) - mov 9(%rsp),%ah - mov %al,9(%rsp) - fldcw 8(%rsp) - frndint - mov %ah,9(%rsp) - fldcw 8(%rsp) - ret - -.global ceill -.type ceill,@function -ceill: - fldt 8(%rsp) - mov $0xb,%al - jmp 1b - -.global truncl -.type truncl,@function -truncl: - fldt 8(%rsp) - mov $0xf,%al - jmp 1b diff --git a/src/math/x86_64/fma.c b/src/math/x86_64/fma.c deleted file mode 100644 index 4dd53f2a..00000000 --- a/src/math/x86_64/fma.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -#if __FMA__ - -double fma(double x, double y, double z) -{ - __asm__ ("vfmadd132sd %1, %2, %0" : "+x" (x) : "x" (y), "x" (z)); - return x; -} - -#elif __FMA4__ - -double fma(double x, double y, double z) -{ - __asm__ ("vfmaddsd %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z)); - return x; -} - -#else - -#include "../fma.c" - -#endif diff --git a/src/math/x86_64/fmaf.c b/src/math/x86_64/fmaf.c deleted file mode 100644 index 30b971ff..00000000 --- a/src/math/x86_64/fmaf.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -#if __FMA__ - -float fmaf(float x, float y, float z) -{ - __asm__ ("vfmadd132ss %1, %2, %0" : "+x" (x) : "x" (y), "x" (z)); - return x; -} - -#elif __FMA4__ - -float fmaf(float x, float y, float z) -{ - __asm__ ("vfmaddss %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z)); - return x; -} - -#else - -#include "../fmaf.c" - -#endif diff --git a/src/math/x86_64/fmodl.s b/src/math/x86_64/fmodl.s deleted file mode 100644 index ea07b402..00000000 --- a/src/math/x86_64/fmodl.s +++ /dev/null @@ -1,11 +0,0 @@ -.global fmodl -.type fmodl,@function -fmodl: - fldt 24(%rsp) - fldt 8(%rsp) -1: fprem - fnstsw %ax - testb $4,%ah - jnz 1b - fstp %st(1) - ret diff --git a/src/math/x86_64/llrint.s b/src/math/x86_64/llrint.s deleted file mode 100644 index bf476498..00000000 --- a/src/math/x86_64/llrint.s +++ /dev/null @@ -1,5 +0,0 @@ -.global llrint -.type llrint,@function -llrint: - cvtsd2si %xmm0,%rax - ret diff --git a/src/math/x86_64/llrintf.s b/src/math/x86_64/llrintf.s deleted file mode 100644 index d7204ac0..00000000 --- a/src/math/x86_64/llrintf.s +++ /dev/null @@ -1,5 +0,0 @@ -.global llrintf -.type llrintf,@function -llrintf: - cvtss2si %xmm0,%rax - ret diff --git a/src/math/x86_64/llrintl.s b/src/math/x86_64/llrintl.s deleted file mode 100644 index 1ec0817d..00000000 --- a/src/math/x86_64/llrintl.s +++ /dev/null @@ -1,7 +0,0 @@ -.global llrintl -.type llrintl,@function -llrintl: - fldt 8(%rsp) - fistpll 8(%rsp) - mov 8(%rsp),%rax - ret diff --git a/src/math/x86_64/log10l.s b/src/math/x86_64/log10l.s deleted file mode 100644 index 48ea4af7..00000000 --- a/src/math/x86_64/log10l.s +++ /dev/null @@ -1,7 +0,0 @@ -.global log10l -.type log10l,@function -log10l: - fldlg2 - fldt 8(%rsp) - fyl2x - ret diff --git a/src/math/x86_64/log1pl.s b/src/math/x86_64/log1pl.s deleted file mode 100644 index 955c9dbf..00000000 --- a/src/math/x86_64/log1pl.s +++ /dev/null @@ -1,15 +0,0 @@ -.global log1pl -.type log1pl,@function -log1pl: - mov 14(%rsp),%eax - fldln2 - and $0x7fffffff,%eax - fldt 8(%rsp) - cmp $0x3ffd9400,%eax - ja 1f - fyl2xp1 - ret -1: fld1 - faddp - fyl2x - ret diff --git a/src/math/x86_64/log2l.s b/src/math/x86_64/log2l.s deleted file mode 100644 index ba08b9fb..00000000 --- a/src/math/x86_64/log2l.s +++ /dev/null @@ -1,7 +0,0 @@ -.global log2l -.type log2l,@function -log2l: - fld1 - fldt 8(%rsp) - fyl2x - ret diff --git a/src/math/x86_64/logl.s b/src/math/x86_64/logl.s deleted file mode 100644 index 20dd1f81..00000000 --- a/src/math/x86_64/logl.s +++ /dev/null @@ -1,7 +0,0 @@ -.global logl -.type logl,@function -logl: - fldln2 - fldt 8(%rsp) - fyl2x - ret diff --git a/src/math/x86_64/lrint.s b/src/math/x86_64/lrint.s deleted file mode 100644 index 15fc2454..00000000 --- a/src/math/x86_64/lrint.s +++ /dev/null @@ -1,5 +0,0 @@ -.global lrint -.type lrint,@function -lrint: - cvtsd2si %xmm0,%rax - ret diff --git a/src/math/x86_64/lrintf.s b/src/math/x86_64/lrintf.s deleted file mode 100644 index 488423d2..00000000 --- a/src/math/x86_64/lrintf.s +++ /dev/null @@ -1,5 +0,0 @@ -.global lrintf -.type lrintf,@function -lrintf: - cvtss2si %xmm0,%rax - ret diff --git a/src/math/x86_64/lrintl.s b/src/math/x86_64/lrintl.s deleted file mode 100644 index d587b12b..00000000 --- a/src/math/x86_64/lrintl.s +++ /dev/null @@ -1,7 +0,0 @@ -.global lrintl -.type lrintl,@function -lrintl: - fldt 8(%rsp) - fistpll 8(%rsp) - mov 8(%rsp),%rax - ret diff --git a/src/math/x86_64/remainderl.s b/src/math/x86_64/remainderl.s deleted file mode 100644 index cb3857b4..00000000 --- a/src/math/x86_64/remainderl.s +++ /dev/null @@ -1,11 +0,0 @@ -.global remainderl -.type remainderl,@function -remainderl: - fldt 24(%rsp) - fldt 8(%rsp) -1: fprem1 - fnstsw %ax - testb $4,%ah - jnz 1b - fstp %st(1) - ret diff --git a/src/math/x86_64/rintl.s b/src/math/x86_64/rintl.s deleted file mode 100644 index 64e663cd..00000000 --- a/src/math/x86_64/rintl.s +++ /dev/null @@ -1,6 +0,0 @@ -.global rintl -.type rintl,@function -rintl: - fldt 8(%rsp) - frndint - ret diff --git a/src/math/x86_64/sqrt.s b/src/math/x86_64/sqrt.s deleted file mode 100644 index d3c609f9..00000000 --- a/src/math/x86_64/sqrt.s +++ /dev/null @@ -1,4 +0,0 @@ -.global sqrt -.type sqrt,@function -sqrt: sqrtsd %xmm0, %xmm0 - ret diff --git a/src/math/x86_64/sqrtf.s b/src/math/x86_64/sqrtf.s deleted file mode 100644 index eec48c60..00000000 --- a/src/math/x86_64/sqrtf.s +++ /dev/null @@ -1,4 +0,0 @@ -.global sqrtf -.type sqrtf,@function -sqrtf: sqrtss %xmm0, %xmm0 - ret diff --git a/src/math/x86_64/sqrtl.s b/src/math/x86_64/sqrtl.s deleted file mode 100644 index 23cd687d..00000000 --- a/src/math/x86_64/sqrtl.s +++ /dev/null @@ -1,5 +0,0 @@ -.global sqrtl -.type sqrtl,@function -sqrtl: fldt 8(%rsp) - fsqrt - ret diff --git a/src/math/x86_64/truncl.s b/src/math/x86_64/truncl.s deleted file mode 100644 index f5cfa3b3..00000000 --- a/src/math/x86_64/truncl.s +++ /dev/null @@ -1 +0,0 @@ -# see floorl.s diff --git a/src/signal/x86_64/sigsetjmp.s b/src/signal/x86_64/sigsetjmp.s deleted file mode 100644 index 9a7695f9..00000000 --- a/src/signal/x86_64/sigsetjmp.s +++ /dev/null @@ -1,24 +0,0 @@ -.global sigsetjmp -.global __sigsetjmp -.type sigsetjmp,@function -.type __sigsetjmp,@function -sigsetjmp: -__sigsetjmp: - test %esi,%esi - jz 1f - - popq 64(%rdi) - mov %rbx,72+8(%rdi) - mov %rdi,%rbx - - call setjmp@PLT - - pushq 64(%rbx) - mov %rbx,%rdi - mov %eax,%esi - mov 72+8(%rbx),%rbx - -.hidden __sigsetjmp_tail - jmp __sigsetjmp_tail - -1: jmp setjmp@PLT -- 2.26.0