Browse Source

math: move complex math out of libm.h

This makes it easier to build musl math code with a compiler that
does not support complex types (tcc) and in general more sensible
factorization of the internal headers.
Szabolcs Nagy 6 years ago
parent
commit
2d72b58070
67 changed files with 87 additions and 80 deletions
  1. 1 1
      src/complex/__cexp.c
  2. 1 1
      src/complex/__cexpf.c
  3. 1 1
      src/complex/cabs.c
  4. 1 1
      src/complex/cabsf.c
  5. 1 1
      src/complex/cabsl.c
  6. 1 1
      src/complex/cacos.c
  7. 1 1
      src/complex/cacosf.c
  8. 1 1
      src/complex/cacosh.c
  9. 1 1
      src/complex/cacoshf.c
  10. 1 1
      src/complex/cacoshl.c
  11. 1 1
      src/complex/cacosl.c
  12. 1 1
      src/complex/carg.c
  13. 1 1
      src/complex/cargf.c
  14. 1 1
      src/complex/cargl.c
  15. 1 1
      src/complex/casin.c
  16. 1 1
      src/complex/casinf.c
  17. 1 1
      src/complex/casinh.c
  18. 1 1
      src/complex/casinhf.c
  19. 1 1
      src/complex/casinhl.c
  20. 1 1
      src/complex/casinl.c
  21. 1 1
      src/complex/catan.c
  22. 1 1
      src/complex/catanf.c
  23. 1 1
      src/complex/catanh.c
  24. 1 1
      src/complex/catanhf.c
  25. 1 1
      src/complex/catanhl.c
  26. 1 1
      src/complex/catanl.c
  27. 1 1
      src/complex/ccos.c
  28. 1 1
      src/complex/ccosf.c
  29. 1 1
      src/complex/ccosh.c
  30. 1 1
      src/complex/ccoshf.c
  31. 1 1
      src/complex/ccoshl.c
  32. 1 1
      src/complex/ccosl.c
  33. 1 1
      src/complex/cexp.c
  34. 1 1
      src/complex/cexpf.c
  35. 1 1
      src/complex/cexpl.c
  36. 1 1
      src/complex/cimag.c
  37. 1 1
      src/complex/cimagf.c
  38. 1 1
      src/complex/cimagl.c
  39. 1 1
      src/complex/clog.c
  40. 1 1
      src/complex/clogf.c
  41. 1 1
      src/complex/clogl.c
  42. 1 1
      src/complex/conj.c
  43. 1 1
      src/complex/conjf.c
  44. 1 1
      src/complex/conjl.c
  45. 1 1
      src/complex/cpow.c
  46. 1 1
      src/complex/cpowf.c
  47. 1 1
      src/complex/cpowl.c
  48. 1 1
      src/complex/cproj.c
  49. 1 1
      src/complex/cprojf.c
  50. 1 1
      src/complex/cprojl.c
  51. 1 1
      src/complex/csin.c
  52. 1 1
      src/complex/csinf.c
  53. 1 1
      src/complex/csinh.c
  54. 1 1
      src/complex/csinhf.c
  55. 1 1
      src/complex/csinhl.c
  56. 1 1
      src/complex/csinl.c
  57. 1 1
      src/complex/csqrt.c
  58. 1 1
      src/complex/csqrtf.c
  59. 1 1
      src/complex/csqrtl.c
  60. 1 1
      src/complex/ctan.c
  61. 1 1
      src/complex/ctanf.c
  62. 1 1
      src/complex/ctanh.c
  63. 1 1
      src/complex/ctanhf.c
  64. 1 1
      src/complex/ctanhl.c
  65. 1 1
      src/complex/ctanl.c
  66. 22 0
      src/internal/complex_impl.h
  67. 0 15
      src/internal/libm.h

+ 1 - 1
src/complex/__cexp.c

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const uint32_t k = 1799; /* constant for reduction */
 static const double kln2 = 1246.97177782734161156; /* k * ln2 */

+ 1 - 1
src/complex/__cexpf.c

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const uint32_t k = 235; /* constant for reduction */
 static const float kln2 = 162.88958740F; /* k * ln2 */

+ 1 - 1
src/complex/cabs.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 double cabs(double complex z)
 {

+ 1 - 1
src/complex/cabsf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float cabsf(float complex z)
 {

+ 1 - 1
src/complex/cabsl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double cabsl(long double complex z)

+ 1 - 1
src/complex/cacos.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 // FIXME: Hull et al. "Implementing the complex arcsine and arccosine functions using exception handling" 1997
 

+ 1 - 1
src/complex/cacosf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 // FIXME
 

+ 1 - 1
src/complex/cacosh.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 /* acosh(z) = i acos(z) */
 

+ 1 - 1
src/complex/cacoshf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex cacoshf(float complex z)
 {

+ 1 - 1
src/complex/cacoshl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex cacoshl(long double complex z)

+ 1 - 1
src/complex/cacosl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex cacosl(long double complex z)

+ 1 - 1
src/complex/carg.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 double carg(double complex z)
 {

+ 1 - 1
src/complex/cargf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float cargf(float complex z)
 {

+ 1 - 1
src/complex/cargl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double cargl(long double complex z)

+ 1 - 1
src/complex/casin.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 // FIXME
 

+ 1 - 1
src/complex/casinf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 // FIXME
 

+ 1 - 1
src/complex/casinh.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 /* asinh(z) = -i asin(i z) */
 

+ 1 - 1
src/complex/casinhf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex casinhf(float complex z)
 {

+ 1 - 1
src/complex/casinhl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex casinhl(long double complex z)

+ 1 - 1
src/complex/casinl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex casinl(long double complex z)

+ 1 - 1
src/complex/catan.c

@@ -58,7 +58,7 @@
  * 2.9e-17.  See also clog().
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 #define MAXNUM 1.0e308
 

+ 1 - 1
src/complex/catanf.c

@@ -53,7 +53,7 @@
  *    IEEE      -10,+10     30000        2.3e-6      5.2e-8
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 #define MAXNUMF 1.0e38F
 

+ 1 - 1
src/complex/catanh.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 /* atanh = -i atan(i z) */
 

+ 1 - 1
src/complex/catanhf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex catanhf(float complex z)
 {

+ 1 - 1
src/complex/catanhl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex catanhl(long double complex z)

+ 1 - 1
src/complex/catanl.c

@@ -59,7 +59,7 @@
 
 #include <complex.h>
 #include <float.h>
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex catanl(long double complex z)

+ 1 - 1
src/complex/ccos.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 /* cos(z) = cosh(i z) */
 

+ 1 - 1
src/complex/ccosf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex ccosf(float complex z)
 {

+ 1 - 1
src/complex/ccosh.c

@@ -34,7 +34,7 @@
  * These values and the return value were taken from n1124.pdf.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const double huge = 0x1p1023;
 

+ 1 - 1
src/complex/ccoshf.c

@@ -28,7 +28,7 @@
  * Hyperbolic cosine of a complex argument.  See s_ccosh.c for details.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const float huge = 0x1p127;
 

+ 1 - 1
src/complex/ccoshl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 //FIXME
 long double complex ccoshl(long double complex z)

+ 1 - 1
src/complex/ccosl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex ccosl(long double complex z)

+ 1 - 1
src/complex/cexp.c

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const uint32_t
 exp_ovfl  = 0x40862e42,  /* high bits of MAX_EXP * ln2 ~= 710 */

+ 1 - 1
src/complex/cexpf.c

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const uint32_t
 exp_ovfl  = 0x42b17218,  /* MAX_EXP * ln2 ~= 88.722839355 */

+ 1 - 1
src/complex/cexpl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 //FIXME
 long double complex cexpl(long double complex z)

+ 1 - 1
src/complex/cimag.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 double (cimag)(double complex z)
 {

+ 1 - 1
src/complex/cimagf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float (cimagf)(float complex z)
 {

+ 1 - 1
src/complex/cimagl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 long double (cimagl)(long double complex z)
 {

+ 1 - 1
src/complex/clog.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 // FIXME
 

+ 1 - 1
src/complex/clogf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 // FIXME
 

+ 1 - 1
src/complex/clogl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex clogl(long double complex z)

+ 1 - 1
src/complex/conj.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 double complex conj(double complex z)
 {

+ 1 - 1
src/complex/conjf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex conjf(float complex z)
 {

+ 1 - 1
src/complex/conjl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 long double complex conjl(long double complex z)
 {

+ 1 - 1
src/complex/cpow.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 /* pow(z, c) = exp(c log(z)), See C99 G.6.4.1 */
 

+ 1 - 1
src/complex/cpowf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex cpowf(float complex z, float complex c)
 {

+ 1 - 1
src/complex/cpowl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#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)

+ 1 - 1
src/complex/cproj.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 double complex cproj(double complex z)
 {

+ 1 - 1
src/complex/cprojf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex cprojf(float complex z)
 {

+ 1 - 1
src/complex/cprojl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex cprojl(long double complex z)

+ 1 - 1
src/complex/csin.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 /* sin(z) = -i sinh(i z) */
 

+ 1 - 1
src/complex/csinf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex csinf(float complex z)
 {

+ 1 - 1
src/complex/csinh.c

@@ -34,7 +34,7 @@
  * These values and the return value were taken from n1124.pdf.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const double huge = 0x1p1023;
 

+ 1 - 1
src/complex/csinhf.c

@@ -28,7 +28,7 @@
  * Hyperbolic sine of a complex argument z.  See s_csinh.c for details.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 static const float huge = 0x1p127;
 

+ 1 - 1
src/complex/csinhl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 //FIXME
 long double complex csinhl(long double complex z)

+ 1 - 1
src/complex/csinl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex csinl(long double complex z)

+ 1 - 1
src/complex/csqrt.c

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 /*
  * gcc doesn't implement complex multiplication or division correctly,

+ 1 - 1
src/complex/csqrtf.c

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 /*
  * gcc doesn't implement complex multiplication or division correctly,

+ 1 - 1
src/complex/csqrtl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 //FIXME
 long double complex csqrtl(long double complex z)

+ 1 - 1
src/complex/ctan.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 /* tan(z) = -i tanh(i z) */
 

+ 1 - 1
src/complex/ctanf.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex ctanf(float complex z)
 {

+ 1 - 1
src/complex/ctanh.c

@@ -63,7 +63,7 @@
  *   precision.  I also handle large x differently.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 double complex ctanh(double complex z)
 {

+ 1 - 1
src/complex/ctanhf.c

@@ -28,7 +28,7 @@
  * Hyperbolic tangent of a complex argument z.  See s_ctanh.c for details.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 float complex ctanhf(float complex z)
 {

+ 1 - 1
src/complex/ctanhl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 //FIXME
 long double complex ctanhl(long double complex z)

+ 1 - 1
src/complex/ctanl.c

@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "complex_impl.h"
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double complex ctanl(long double complex z)

+ 22 - 0
src/internal/complex_impl.h

@@ -0,0 +1,22 @@
+#ifndef _COMPLEX_IMPL_H
+#define _COMPLEX_IMPL_H
+
+#include <complex.h>
+#include "libm.h"
+
+#undef __CMPLX
+#undef CMPLX
+#undef CMPLXF
+#undef CMPLXL
+
+#define __CMPLX(x, y, t) \
+	((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
+
+#define CMPLX(x, y) __CMPLX(x, y, double)
+#define CMPLXF(x, y) __CMPLX(x, y, float)
+#define CMPLXL(x, y) __CMPLX(x, y, long double)
+
+hidden double complex __ldexp_cexp(double complex,int);
+hidden float complex __ldexp_cexpf(float complex,int);
+
+#endif

+ 0 - 15
src/internal/libm.h

@@ -16,7 +16,6 @@
 #include <stdint.h>
 #include <float.h>
 #include <math.h>
-#include <complex.h>
 #include <endian.h>
 
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
@@ -153,18 +152,6 @@ do {                                              \
   (d) = __u.f;                                    \
 } while (0)
 
-#undef __CMPLX
-#undef CMPLX
-#undef CMPLXF
-#undef CMPLXL
-
-#define __CMPLX(x, y, t) \
-	((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
-
-#define CMPLX(x, y) __CMPLX(x, y, double)
-#define CMPLXF(x, y) __CMPLX(x, y, float)
-#define CMPLXL(x, y) __CMPLX(x, y, long double)
-
 /* fdlibm kernel functions */
 
 hidden int    __rem_pio2_large(double*,double*,int,int,int);
@@ -174,14 +161,12 @@ hidden double __sin(double,double,int);
 hidden double __cos(double,double);
 hidden double __tan(double,double,int);
 hidden double __expo2(double);
-hidden double complex __ldexp_cexp(double complex,int);
 
 hidden int    __rem_pio2f(float,double*);
 hidden float  __sindf(double);
 hidden float  __cosdf(double);
 hidden float  __tandf(double,int);
 hidden float  __expo2f(float);
-hidden float complex __ldexp_cexpf(float complex,int);
 
 hidden int __rem_pio2l(long double, long double *);
 hidden long double __sinl(long double, long double, int);