long double cleanup, initial commit
[musl] / src / internal / libm.h
index a71c4c0..52ac61e 100644 (file)
@@ -17,6 +17,7 @@
 #include <float.h>
 #include <math.h>
 #include <complex.h>
+#include <endian.h>
 
 #include "longdbl.h"
 
@@ -32,6 +33,33 @@ union dshape {
        uint64_t bits;
 };
 
+#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
+union ldshape {
+       long double f;
+       struct {
+               uint64_t m;
+               uint16_t se;
+       } i;
+};
+#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
+union ldshape {
+       long double f;
+       struct {
+               uint64_t lo;
+               uint32_t mid;
+               uint16_t top;
+               uint16_t se;
+       } i;
+       struct {
+               uint64_t lo;
+               uint64_t hi;
+       } i2;
+};
+#else
+#error Unsupported long double representation
+#endif
+
 #define FORCE_EVAL(x) do {                          \
        if (sizeof(x) == sizeof(float)) {           \
                volatile float __x;                 \
@@ -157,38 +185,15 @@ long double __tanl(long double, long double, int);
 long double __polevll(long double, const long double *, int);
 long double __p1evll(long double, const long double *, int);
 
-// FIXME: not needed when -fexcess-precision=standard is supported (>=gcc4.5)
-/*
- * Attempt to get strict C99 semantics for assignment with non-C99 compilers.
- */
-#if 1
+#if 0
+/* Attempt to get strict C99 semantics for assignment with non-C99 compilers. */
 #define STRICT_ASSIGN(type, lval, rval) do {    \
         volatile type __v = (rval);             \
         (lval) = __v;                           \
 } while (0)
 #else
+/* Should work with -fexcess-precision=standard (>=gcc-4.5) or -ffloat-store */
 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))
 #endif
 
-
-/* complex */
-
-union dcomplex {
-       double complex z;
-       double a[2];
-};
-union fcomplex {
-       float complex z;
-       float a[2];
-};
-union lcomplex {
-       long double complex z;
-       long double a[2];
-};
-
-/* x + y*I is not supported properly by gcc */
-#define cpack(x,y) ((union dcomplex){.a={(x),(y)}}.z)
-#define cpackf(x,y) ((union fcomplex){.a={(x),(y)}}.z)
-#define cpackl(x,y) ((union lcomplex){.a={(x),(y)}}.z)
-
 #endif