]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/internal/libm.h
afaf6c2a44fefbd04dd3081ce08510e857e4ea20
1 /* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
22 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
23 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
31 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
32 /* This is the m68k variant of 80-bit long double, and this definition only works
33 * on archs where the alignment requirement of uint64_t is <= 4. */
42 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
56 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
71 #error Unsupported long double representation
74 #ifdef __wasilibc_unmodified_upstream
75 #define FORCE_EVAL(x) do { \
76 if (sizeof(x) == sizeof(float)) { \
79 } else if (sizeof(x) == sizeof(double)) { \
80 volatile double __x; \
83 volatile long double __x; \
89 * WebAssembly doesn't have floating-point status flags, so there's no reason
90 * to force evaluations.
92 #define FORCE_EVAL(x) ((void)(x))
95 /* Get two 32 bit ints from a double. */
96 #define EXTRACT_WORDS(hi,lo,d) \
98 union {double f; uint64_t i;} __u; \
100 (hi) = __u.i >> 32; \
101 (lo) = (uint32_t)__u.i; \
104 /* Get the more significant 32 bit int from a double. */
105 #define GET_HIGH_WORD(hi,d) \
107 union {double f; uint64_t i;} __u; \
109 (hi) = __u.i >> 32; \
112 /* Get the less significant 32 bit int from a double. */
113 #define GET_LOW_WORD(lo,d) \
115 union {double f; uint64_t i;} __u; \
117 (lo) = (uint32_t)__u.i; \
120 /* Set a double from two 32 bit ints. */
121 #define INSERT_WORDS(d,hi,lo) \
123 union {double f; uint64_t i;} __u; \
124 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
128 /* Set the more significant 32 bits of a double from an int. */
129 #define SET_HIGH_WORD(d,hi) \
131 union {double f; uint64_t i;} __u; \
133 __u.i &= 0xffffffff; \
134 __u.i |= (uint64_t)(hi) << 32; \
138 /* Set the less significant 32 bits of a double from an int. */
139 #define SET_LOW_WORD(d,lo) \
141 union {double f; uint64_t i;} __u; \
143 __u.i &= 0xffffffff00000000ull; \
144 __u.i |= (uint32_t)(lo); \
148 /* Get a 32 bit int from a float. */
149 #define GET_FLOAT_WORD(w,d) \
151 union {float f; uint32_t i;} __u; \
156 /* Set a float from a 32 bit int. */
157 #define SET_FLOAT_WORD(d,w) \
159 union {float f; uint32_t i;} __u; \
169 #define __CMPLX(x, y, t) \
170 ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
172 #define CMPLX(x, y) __CMPLX(x, y, double)
173 #define CMPLXF(x, y) __CMPLX(x, y, float)
174 #define CMPLXL(x, y) __CMPLX(x, y, long double)
176 /* fdlibm kernel functions */
178 hidden
int __rem_pio2_large(double*,double*,int,int,int);
180 hidden
int __rem_pio2(double,double*);
181 hidden
double __sin(double,double,int);
182 hidden
double __cos(double,double);
183 hidden
double __tan(double,double,int);
184 hidden
double __expo2(double);
185 hidden
double complex __ldexp_cexp(double complex,int);
187 hidden
int __rem_pio2f(float,double*);
188 hidden
float __sindf(double);
189 hidden
float __cosdf(double);
190 hidden
float __tandf(double,int);
191 hidden
float __expo2f(float);
192 hidden
float complex __ldexp_cexpf(float complex,int);
194 hidden
int __rem_pio2l(long double, long double *);
195 hidden
long double __sinl(long double, long double, int);
196 hidden
long double __cosl(long double, long double);
197 hidden
long double __tanl(long double, long double, int);
199 /* polynomial evaluation */
200 hidden
long double __polevll(long double, const long double *, int);
201 hidden
long double __p1evll(long double, const long double *, int);
203 extern int __signgam
;
204 hidden
double __lgamma_r(double, int *);
205 hidden
float __lgammaf_r(float, int *);