Add missing <complex.h> functions.
FreeBSD doesn't seem interested in having low-quality implementations of
these functions:
cacoshl, cacosl, casinhl, casinl, catanhl, catanl, ccoshl, ccosl, cexpl,
clog, clogf, clogl, cpow, cpowf, cpowl, csinhl, csinl, ctanhl, ctanl.
And they still haven't got round to writing good implementations, so for
now let's just take the NetBSD ones so we have the full set.
Bug: http://b/27555792
Change-Id: I6b72003cf749b1043f006377a01fffe5e1d659bc
diff --git a/libm/include/complex.h b/libm/include/complex.h
index ff6b166..b54d2fc 100644
--- a/libm/include/complex.h
+++ b/libm/include/complex.h
@@ -32,9 +32,6 @@
#include <sys/cdefs.h>
#ifdef __GNUC__
-#if __STDC_VERSION__ < 199901
-#define _Complex __complex__
-#endif
#define _Complex_I ((float _Complex)1.0i)
#endif
@@ -51,7 +48,7 @@
#define CMPLX(x, y) ((double complex){ x, y })
#define CMPLXF(x, y) ((float complex){ x, y })
#define CMPLXL(x, y) ((long double complex){ x, y })
-#elif __GNUC_PREREQ__(4, 7)
+#else
#define CMPLX(x, y) __builtin_complex((double)(x), (double)(y))
#define CMPLXF(x, y) __builtin_complex((float)(x), (float)(y))
#define CMPLXL(x, y) __builtin_complex((long double)(x), (long double)(y))
@@ -61,56 +58,103 @@
__BEGIN_DECLS
#pragma GCC visibility push(default)
-double cabs(double complex);
-float cabsf(float complex);
-long double cabsl(long double complex);
-double complex cacos(double complex);
-float complex cacosf(float complex);
-double complex cacosh(double complex);
-float complex cacoshf(float complex);
-double carg(double complex);
-float cargf(float complex);
-long double cargl(long double complex);
-double complex casin(double complex);
-float complex casinf(float complex);
-double complex casinh(double complex);
-float complex casinhf(float complex);
-double complex catan(double complex);
-float complex catanf(float complex);
-double complex catanh(double complex);
-float complex catanhf(float complex);
-double complex ccos(double complex);
-float complex ccosf(float complex);
-double complex ccosh(double complex);
-float complex ccoshf(float complex);
-double complex cexp(double complex);
-float complex cexpf(float complex);
-double cimag(double complex) __pure2;
-float cimagf(float complex) __pure2;
-long double cimagl(long double complex) __pure2;
-double complex conj(double complex) __pure2;
-float complex conjf(float complex) __pure2;
-long double complex
- conjl(long double complex) __pure2;
-float complex cprojf(float complex) __pure2;
-double complex cproj(double complex) __pure2;
-long double complex
- cprojl(long double complex) __pure2;
-double creal(double complex) __pure2;
-float crealf(float complex) __pure2;
-long double creall(long double complex) __pure2;
-double complex csin(double complex);
-float complex csinf(float complex);
-double complex csinh(double complex);
-float complex csinhf(float complex);
-double complex csqrt(double complex);
-float complex csqrtf(float complex);
-long double complex
- csqrtl(long double complex);
-double complex ctan(double complex);
-float complex ctanf(float complex);
-double complex ctanh(double complex);
-float complex ctanhf(float complex);
+/* 7.3.5 Trigonometric functions */
+/* 7.3.5.1 The cacos functions */
+double complex cacos(double complex);
+float complex cacosf(float complex);
+long double complex cacosl(long double complex);
+/* 7.3.5.2 The casin functions */
+double complex casin(double complex);
+float complex casinf(float complex);
+long double complex casinl(long double complex);
+/* 7.3.5.1 The catan functions */
+double complex catan(double complex);
+float complex catanf(float complex);
+long double complex catanl(long double complex);
+/* 7.3.5.1 The ccos functions */
+double complex ccos(double complex);
+float complex ccosf(float complex);
+long double complex ccosl(long double complex);
+/* 7.3.5.1 The csin functions */
+double complex csin(double complex);
+float complex csinf(float complex);
+long double complex csinl(long double complex);
+/* 7.3.5.1 The ctan functions */
+double complex ctan(double complex);
+float complex ctanf(float complex);
+long double complex ctanl(long double complex);
+
+/* 7.3.6 Hyperbolic functions */
+/* 7.3.6.1 The cacosh functions */
+double complex cacosh(double complex);
+float complex cacoshf(float complex);
+long double complex cacoshl(long double complex);
+/* 7.3.6.2 The casinh functions */
+double complex casinh(double complex);
+float complex casinhf(float complex);
+long double complex casinhl(long double complex);
+/* 7.3.6.3 The catanh functions */
+double complex catanh(double complex);
+float complex catanhf(float complex);
+long double complex catanhl(long double complex);
+/* 7.3.6.4 The ccosh functions */
+double complex ccosh(double complex);
+float complex ccoshf(float complex);
+long double complex ccoshl(long double complex);
+/* 7.3.6.5 The csinh functions */
+double complex csinh(double complex);
+float complex csinhf(float complex);
+long double complex csinhl(long double complex);
+/* 7.3.6.6 The ctanh functions */
+double complex ctanh(double complex);
+float complex ctanhf(float complex);
+long double complex ctanhl(long double complex);
+
+/* 7.3.7 Exponential and logarithmic functions */
+/* 7.3.7.1 The cexp functions */
+double complex cexp(double complex);
+float complex cexpf(float complex);
+long double complex cexpl(long double complex);
+/* 7.3.7.2 The clog functions */
+double complex clog(double complex);
+float complex clogf(float complex);
+long double complex clogl(long double complex);
+
+/* 7.3.8 Power and absolute-value functions */
+/* 7.3.8.1 The cabs functions */
+double cabs(double complex);
+float cabsf(float complex);
+long double cabsl(long double complex);
+/* 7.3.8.2 The cpow functions */
+double complex cpow(double complex, double complex);
+float complex cpowf(float complex, float complex);
+long double complex cpowl(long double complex, long double complex);
+/* 7.3.8.3 The csqrt functions */
+double complex csqrt(double complex);
+float complex csqrtf(float complex);
+long double complex csqrtl(long double complex);
+
+/* 7.3.9 Manipulation functions */
+/* 7.3.9.1 The carg functions */
+double carg(double complex);
+float cargf(float complex);
+long double cargl(long double complex);
+/* 7.3.9.2 The cimag functions */
+double cimag(double complex);
+float cimagf(float complex);
+long double cimagl(long double complex);
+/* 7.3.9.3 The conj functions */
+double complex conj(double complex);
+float complex conjf(float complex);
+long double complex conjl(long double complex);
+/* 7.3.9.4 The cproj functions */
+double complex cproj(double complex);
+float complex cprojf(float complex);
+long double complex cprojl(long double complex);
+/* 7.3.9.5 The creal functions */
+double creal(double complex);
+float crealf(float complex);
+long double creall(long double complex);
#pragma GCC visibility pop
__END_DECLS
diff --git a/libm/include/math.h b/libm/include/math.h
index ce8e3b2..8e193cb 100644
--- a/libm/include/math.h
+++ b/libm/include/math.h
@@ -108,6 +108,22 @@
extern int signgam;
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
+#if __USE_GNU
+#define M_El 2.718281828459045235360287471352662498L /* e */
+#define M_LOG2El 1.442695040888963407359924681001892137L /* log 2e */
+#define M_LOG10El 0.434294481903251827651128918916605082L /* log 10e */
+#define M_LN2l 0.693147180559945309417232121458176568L /* log e2 */
+#define M_LN10l 2.302585092994045684017991454684364208L /* log e10 */
+#define M_PIl 3.141592653589793238462643383279502884L /* pi */
+#define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
+#define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
+#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
+#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
+#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
+#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
+#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
+#endif
+
#if __BSD_VISIBLE
#if 0
/* Old value from 4.4BSD-Lite math.h; this is probably better. */