Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue,  8 Mar 2016 11:38:15 +0900
From: OGINO Masanori <masanori.ogino@...il.com>
To: musl@...ts.openwall.com
Cc: OGINO Masanori <masanori.ogino@...il.com>
Subject: [PATCH] Define LONG_DOUBLE_IS_* internal macros.

These macros indicate which format is used for long double with the
toolchain.

Although the meaning of "LDBL_DIG_MANT == 64 && LDBL_MAX_EXP == 16384"
is very clear to floating-point arithmetic guys, it is nice to have
descriptive names to such conditions.

Signed-off-by: OGINO Masanori <masanori.ogino@...il.com>
---
 src/complex/cabsl.c        |  2 +-
 src/complex/cacoshl.c      |  2 +-
 src/complex/cacosl.c       |  2 +-
 src/complex/cargl.c        |  2 +-
 src/complex/casinhl.c      |  2 +-
 src/complex/casinl.c       |  2 +-
 src/complex/catanhl.c      |  2 +-
 src/complex/catanl.c       |  2 +-
 src/complex/ccosl.c        |  2 +-
 src/complex/clogl.c        |  2 +-
 src/complex/cpowl.c        |  2 +-
 src/complex/cprojl.c       |  2 +-
 src/complex/csinl.c        |  2 +-
 src/complex/ctanl.c        |  2 +-
 src/internal/floatscan.c   |  7 ++++---
 src/internal/libm.h        | 10 ++++++----
 src/internal/long_double.h | 24 ++++++++++++++++++++++++
 src/math/__cosl.c          |  6 +++---
 src/math/__fpclassifyl.c   |  6 +++---
 src/math/__invtrigl.c      |  4 ++--
 src/math/__polevll.c       |  2 +-
 src/math/__rem_pio2l.c     |  6 +++---
 src/math/__signbitl.c      |  4 ++--
 src/math/__sinl.c          |  6 +++---
 src/math/__tanl.c          |  6 +++---
 src/math/acoshl.c          |  6 +++---
 src/math/acosl.c           |  8 ++++----
 src/math/asinhl.c          |  6 +++---
 src/math/asinl.c           |  8 ++++----
 src/math/atan2l.c          |  4 ++--
 src/math/atanhl.c          |  4 ++--
 src/math/atanl.c           |  8 ++++----
 src/math/cbrtl.c           |  8 ++++----
 src/math/ceill.c           |  4 ++--
 src/math/copysignl.c       |  4 ++--
 src/math/coshl.c           |  6 +++---
 src/math/cosl.c            |  4 ++--
 src/math/erfl.c            |  6 +++---
 src/math/exp10l.c          |  4 ++--
 src/math/exp2l.c           |  6 +++---
 src/math/expl.c            |  6 +++---
 src/math/expm1l.c          |  6 +++---
 src/math/fabsl.c           |  4 ++--
 src/math/fdiml.c           |  2 +-
 src/math/floorl.c          |  4 ++--
 src/math/fmal.c            |  8 ++++----
 src/math/fmaxl.c           |  2 +-
 src/math/fminl.c           |  2 +-
 src/math/fmodl.c           |  8 ++++----
 src/math/frexpl.c          |  4 ++--
 src/math/hypotl.c          |  8 ++++----
 src/math/ilogbl.c          |  6 +++---
 src/math/lgammal.c         |  6 +++---
 src/math/llrintl.c         |  2 +-
 src/math/log10l.c          |  6 +++---
 src/math/log1pl.c          |  6 +++---
 src/math/log2l.c           |  6 +++---
 src/math/logbl.c           |  2 +-
 src/math/logl.c            |  6 +++---
 src/math/lrintl.c          |  2 +-
 src/math/modfl.c           |  4 ++--
 src/math/nearbyintl.c      |  2 +-
 src/math/nextafterl.c      |  6 +++---
 src/math/nexttoward.c      |  2 +-
 src/math/powl.c            |  6 +++---
 src/math/remainderl.c      |  2 +-
 src/math/remquol.c         |  8 ++++----
 src/math/rintl.c           |  4 ++--
 src/math/roundl.c          |  4 ++--
 src/math/scalblnl.c        |  2 +-
 src/math/scalbnl.c         |  4 ++--
 src/math/sincosl.c         |  4 ++--
 src/math/sinhl.c           |  6 +++---
 src/math/sinl.c            |  4 ++--
 src/math/tanhl.c           |  6 +++---
 src/math/tanl.c            |  4 ++--
 src/math/tgammal.c         |  6 +++---
 src/math/truncl.c          |  4 ++--
 78 files changed, 198 insertions(+), 171 deletions(-)
 create mode 100644 src/internal/long_double.h

diff --git a/src/complex/cabsl.c b/src/complex/cabsl.c
index 40a067c..fd1e967 100644
--- a/src/complex/cabsl.c
+++ b/src/complex/cabsl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double cabsl(long double complex z)
 {
 	return cabs(z);
diff --git a/src/complex/cacoshl.c b/src/complex/cacoshl.c
index 6534255..4c90868 100644
--- a/src/complex/cacoshl.c
+++ b/src/complex/cacoshl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex cacoshl(long double complex z)
 {
 	return cacosh(z);
diff --git a/src/complex/cacosl.c b/src/complex/cacosl.c
index 7fd4a2f..d44d82b 100644
--- a/src/complex/cacosl.c
+++ b/src/complex/cacosl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex cacosl(long double complex z)
 {
 	return cacos(z);
diff --git a/src/complex/cargl.c b/src/complex/cargl.c
index e0d5047..944bf37 100644
--- a/src/complex/cargl.c
+++ b/src/complex/cargl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double cargl(long double complex z)
 {
 	return carg(z);
diff --git a/src/complex/casinhl.c b/src/complex/casinhl.c
index 714f189..f0bb8da 100644
--- a/src/complex/casinhl.c
+++ b/src/complex/casinhl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex casinhl(long double complex z)
 {
 	return casinh(z);
diff --git a/src/complex/casinl.c b/src/complex/casinl.c
index 0916c60..5ed05ed 100644
--- a/src/complex/casinl.c
+++ b/src/complex/casinl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex casinl(long double complex z)
 {
 	return casin(z);
diff --git a/src/complex/catanhl.c b/src/complex/catanhl.c
index a5dd538..089cdc8 100644
--- a/src/complex/catanhl.c
+++ b/src/complex/catanhl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex catanhl(long double complex z)
 {
 	return catanh(z);
diff --git a/src/complex/catanl.c b/src/complex/catanl.c
index 5ace770..5837d13 100644
--- a/src/complex/catanl.c
+++ b/src/complex/catanl.c
@@ -61,7 +61,7 @@
 #include <float.h>
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex catanl(long double complex z)
 {
 	return catan(z);
diff --git a/src/complex/ccosl.c b/src/complex/ccosl.c
index d787047..c0cceb8 100644
--- a/src/complex/ccosl.c
+++ b/src/complex/ccosl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex ccosl(long double complex z)
 {
 	return ccos(z);
diff --git a/src/complex/clogl.c b/src/complex/clogl.c
index 18f1608..dc88da8 100644
--- a/src/complex/clogl.c
+++ b/src/complex/clogl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex clogl(long double complex z)
 {
 	return clog(z);
diff --git a/src/complex/cpowl.c b/src/complex/cpowl.c
index c1a80a7..9900200 100644
--- a/src/complex/cpowl.c
+++ b/src/complex/cpowl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex cpowl(long double complex z, long double complex c)
 {
 	return cpow(z, c);
diff --git a/src/complex/cprojl.c b/src/complex/cprojl.c
index 6731aaa..75c44b2 100644
--- a/src/complex/cprojl.c
+++ b/src/complex/cprojl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex cprojl(long double complex z)
 {
 	return cproj(z);
diff --git a/src/complex/csinl.c b/src/complex/csinl.c
index 4e9f86c..d214339 100644
--- a/src/complex/csinl.c
+++ b/src/complex/csinl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex csinl(long double complex z)
 {
 	return csin(z);
diff --git a/src/complex/ctanl.c b/src/complex/ctanl.c
index ac1c3e0..f57da01 100644
--- a/src/complex/ctanl.c
+++ b/src/complex/ctanl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double complex ctanl(long double complex z)
 {
 	return ctan(z);
diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c
index eef70df..0d7c391 100644
--- a/src/internal/floatscan.c
+++ b/src/internal/floatscan.c
@@ -8,20 +8,21 @@
 
 #include "shgetc.h"
 #include "floatscan.h"
+#include "long_double.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 
 #define LD_B1B_DIG 2
 #define LD_B1B_MAX 9007199, 254740991
 #define KMAX 128
 
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 
 #define LD_B1B_DIG 3
 #define LD_B1B_MAX 18, 446744073, 709551615
 #define KMAX 2048
 
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 
 #define LD_B1B_DIG 4
 #define LD_B1B_MAX 10384593, 717069655, 257060992, 658440191
diff --git a/src/internal/libm.h b/src/internal/libm.h
index df86411..18bb089 100644
--- a/src/internal/libm.h
+++ b/src/internal/libm.h
@@ -19,8 +19,10 @@
 #include <complex.h>
 #include <endian.h>
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
+#include "long_double.h"
+
+#ifdef LONG_DOUBLE_IS_BINARY64
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) && __BYTE_ORDER == __LITTLE_ENDIAN
 union ldshape {
 	long double f;
 	struct {
@@ -28,7 +30,7 @@ union ldshape {
 		uint16_t se;
 	} i;
 };
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
+#elif defined(LONG_DOUBLE_IS_BINARY128) && __BYTE_ORDER == __LITTLE_ENDIAN
 union ldshape {
 	long double f;
 	struct {
@@ -42,7 +44,7 @@ union ldshape {
 		uint64_t hi;
 	} i2;
 };
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
+#elif defined(LONG_DOUBLE_IS_BINARY128) && __BYTE_ORDER == __BIG_ENDIAN
 union ldshape {
 	long double f;
 	struct {
diff --git a/src/internal/long_double.h b/src/internal/long_double.h
new file mode 100644
index 0000000..bb1737a
--- /dev/null
+++ b/src/internal/long_double.h
@@ -0,0 +1,24 @@
+/* This header defines a macro indicating which format is the representation of
+ * long double.
+ *
+ * LONG_DOUBLE_IS_BINARY64:
+ *     The format of long double is IEEE 754 binary64 format. (a.k.a. double)
+ * LONG_DOUBLE_IS_X87_EXTENDED:
+ *     The format of long double is Intel 8087 80-bit extended precision
+ *     format.
+ * LONG_DOUBLE_IS_BINARY128:
+ *     The format of long double is IEEE 754 binary128 format. (a.k.a. quad)
+ */
+
+#ifndef LONG_DOUBLE_H
+#define LONG_DOUBLE_H
+
+#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#define LONG_DOUBLE_IS_BINARY64
+#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#define LONG_DOUBLE_IS_X87_EXTENDED
+#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#define LONG_DOUBLE_IS_BINARY128
+#endif
+
+#endif
diff --git a/src/math/__cosl.c b/src/math/__cosl.c
index fa522dd..d41b0a6 100644
--- a/src/math/__cosl.c
+++ b/src/math/__cosl.c
@@ -15,8 +15,8 @@
 
 #include "libm.h"
 
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
+#if defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 /*
  * ld80 version of __cos.c.  See __cos.c for most comments.
  */
@@ -53,7 +53,7 @@ C5 =  0.0000000020876754400407278,      /*  0x11eed8caaeccf1.0p-81 */
 C6 = -1.1470297442401303e-11,           /* -0x19393412bd1529.0p-89 */
 C7 =  4.7383039476436467e-14;           /*  0x1aac9d9af5c43e.0p-97 */
 #define POLY(z) (z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*C7)))))))
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 /*
  * ld128 version of __cos.c.  See __cos.c for most comments.
  */
diff --git a/src/math/__fpclassifyl.c b/src/math/__fpclassifyl.c
index 481c0b9..c8ddbc6 100644
--- a/src/math/__fpclassifyl.c
+++ b/src/math/__fpclassifyl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 int __fpclassifyl(long double x)
 {
 	return __fpclassify(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 int __fpclassifyl(long double x)
 {
 	union ldshape u = {x};
@@ -19,7 +19,7 @@ int __fpclassifyl(long double x)
 		return u.i.m << 1 ? FP_NAN : FP_INFINITE;
 	return FP_NORMAL;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 int __fpclassifyl(long double x)
 {
 	union ldshape u = {x};
diff --git a/src/math/__invtrigl.c b/src/math/__invtrigl.c
index ef7f4e1..b08c147 100644
--- a/src/math/__invtrigl.c
+++ b/src/math/__invtrigl.c
@@ -1,7 +1,7 @@
 #include <float.h>
 #include "__invtrigl.h"
 
-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 static const long double
 pS0 =  1.66666666666666666631e-01L,
 pS1 = -4.16313987993683104320e-01L,
@@ -28,7 +28,7 @@ long double __invtrigl_R(long double z)
 	q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*(qS4+z*qS5))));
 	return p/q;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif LONG_DOUBLE_IS_BINARY128
 static const long double
 pS0 =  1.66666666666666666666666666666700314e-01L,
 pS1 = -7.32816946414566252574527475428622708e-01L,
diff --git a/src/math/__polevll.c b/src/math/__polevll.c
index ce1a840..485117f 100644
--- a/src/math/__polevll.c
+++ b/src/math/__polevll.c
@@ -56,7 +56,7 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 #else
 /*
  * Polynomial evaluator:
diff --git a/src/math/__rem_pio2l.c b/src/math/__rem_pio2l.c
index 77255bd..27cfd29 100644
--- a/src/math/__rem_pio2l.c
+++ b/src/math/__rem_pio2l.c
@@ -13,7 +13,7 @@
  * Optimized by Bruce D. Evans.
  */
 #include "libm.h"
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#if defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 /* ld80 and ld128 version of __rem_pio2(x,y)
  *
  * return the remainder of x rem pi/2 in y[0]+y[1]
@@ -22,7 +22,7 @@
 
 static const long double toint = 1.5/LDBL_EPSILON;
 
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 /* u ~< 0x1p25*pi/2 */
 #define SMALL(u) (((u.i.se & 0x7fffU)<<16 | u.i.m>>48) < ((0x3fff + 25)<<16 | 0x921f>>1 | 0x8000))
 #define QUOBITS(x) ((uint32_t)(int32_t)x & 0x7fffffff)
@@ -48,7 +48,7 @@ invpio2 =  6.36619772367581343076e-01L, /*  0xa2f9836e4e44152a.0p-64 */
 pio2_1t = -1.07463465549719416346e-12L, /* -0x973dcb3b399d747f.0p-103 */
 pio2_2t =  6.36831716351095013979e-25L, /*  0xc51701b839a25205.0p-144 */
 pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 /* u ~< 0x1p45*pi/2 */
 #define SMALL(u) (((u.i.se & 0x7fffU)<<16 | u.i.top) < ((0x3fff + 45)<<16 | 0x921f))
 #define QUOBITS(x) ((uint32_t)(int64_t)x & 0x7fffffff)
diff --git a/src/math/__signbitl.c b/src/math/__signbitl.c
index 63b3dc5..527078d 100644
--- a/src/math/__signbitl.c
+++ b/src/math/__signbitl.c
@@ -1,12 +1,12 @@
 #include "libm.h"
 
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#if defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 int __signbitl(long double x)
 {
 	union ldshape u = {x};
 	return u.i.se >> 15;
 }
-#elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#elif defined(LONG_DOUBLE_IS_BINARY64)
 int __signbitl(long double x)
 {
 	return __signbit(x);
diff --git a/src/math/__sinl.c b/src/math/__sinl.c
index 2525bbe..2001de9 100644
--- a/src/math/__sinl.c
+++ b/src/math/__sinl.c
@@ -14,8 +14,8 @@
 
 #include "libm.h"
 
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
+#if defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 /*
  * ld80 version of __sin.c.  See __sin.c for most comments.
  */
@@ -36,7 +36,7 @@ S6 =  1.6059006598854211e-10,     /*  0x161242b90243b5.0p-85 */
 S7 = -7.6429779983024564e-13,     /* -0x1ae42ebd1b2e00.0p-93 */
 S8 =  2.6174587166648325e-15;     /*  0x179372ea0b3f64.0p-101 */
 #define POLY(z) (S2+z*(S3+z*(S4+z*(S5+z*(S6+z*(S7+z*S8))))))
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 /*
  * ld128 version of __sin.c.  See __sin.c for most comments.
  */
diff --git a/src/math/__tanl.c b/src/math/__tanl.c
index 54abc3d..cf7be08 100644
--- a/src/math/__tanl.c
+++ b/src/math/__tanl.c
@@ -13,8 +13,8 @@
 
 #include "libm.h"
 
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
+#if defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 /*
  * ld80 version of __tan.c.  See __tan.c for most comments.
  */
@@ -48,7 +48,7 @@ T33 =  0.0000023261313142559411;        /*  0x13835436c0c87f.0p-71 */
 	w * (T25 + w * (T29 + w * T33)))))))
 #define VPOLY(w) (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 + \
 	w * (T27 + w * T31))))))
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 /*
  * ld128 version of __tan.c.  See __tan.c for most comments.
  */
diff --git a/src/math/acoshl.c b/src/math/acoshl.c
index 8d4b43f..50ccf0a 100644
--- a/src/math/acoshl.c
+++ b/src/math/acoshl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double acoshl(long double x)
 {
 	return acosh(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 /* acosh(x) = log(x + sqrt(x*x-1)) */
 long double acoshl(long double x)
 {
@@ -20,7 +20,7 @@ long double acoshl(long double x)
 		return logl(2*x - 1/(x+sqrtl(x*x-1)));
 	return logl(x) + 0.693147180559945309417232121458176568L;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double acoshl(long double x)
 {
diff --git a/src/math/acosl.c b/src/math/acosl.c
index c03bdf0..a5c8927 100644
--- a/src/math/acosl.c
+++ b/src/math/acosl.c
@@ -16,16 +16,16 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double acosl(long double x)
 {
 	return acos(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 #include "__invtrigl.h"
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 #define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 #define CLEARBOTTOM(u) (u.i.lo = 0)
 #endif
 
diff --git a/src/math/asinhl.c b/src/math/asinhl.c
index 8635f52..d10dca8 100644
--- a/src/math/asinhl.c
+++ b/src/math/asinhl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double asinhl(long double x)
 {
 	return asinh(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 /* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */
 long double asinhl(long double x)
 {
@@ -32,7 +32,7 @@ long double asinhl(long double x)
 	}
 	return s ? -x : x;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif LONG_DOUBLE_IS_BINARY128
 // TODO: broken implementation to make things compile
 long double asinhl(long double x)
 {
diff --git a/src/math/asinl.c b/src/math/asinl.c
index 347c535..5f53fb8 100644
--- a/src/math/asinl.c
+++ b/src/math/asinl.c
@@ -16,17 +16,17 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double asinl(long double x)
 {
 	return asin(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 #include "__invtrigl.h"
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 #define CLOSETO1(u) (u.i.m>>56 >= 0xf7)
 #define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 #define CLOSETO1(u) (u.i.top >= 0xee00)
 #define CLEARBOTTOM(u) (u.i.lo = 0)
 #endif
diff --git a/src/math/atan2l.c b/src/math/atan2l.c
index f0937a9..4012b9f 100644
--- a/src/math/atan2l.c
+++ b/src/math/atan2l.c
@@ -17,12 +17,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double atan2l(long double y, long double x)
 {
 	return atan2(y, x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 #include "__invtrigl.h"
 
 long double atan2l(long double y, long double x)
diff --git a/src/math/atanhl.c b/src/math/atanhl.c
index 87cd1cd..e2fa043 100644
--- a/src/math/atanhl.c
+++ b/src/math/atanhl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double atanhl(long double x)
 {
 	return atanh(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 /* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */
 long double atanhl(long double x)
 {
diff --git a/src/math/atanl.c b/src/math/atanl.c
index 79a3edb..6f10253 100644
--- a/src/math/atanl.c
+++ b/src/math/atanl.c
@@ -16,14 +16,14 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double atanl(long double x)
 {
 	return atan(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 #define EXPMAN(u) ((u.i.se & 0x7fff)<<8 | (u.i.m>>55 & 0xff))
 
 static const long double atanhi[] = {
@@ -67,7 +67,7 @@ static long double T_odd(long double x)
 	return aT[1] + x * (aT[3] + x * (aT[5] + x * (aT[7] +
 		x * (aT[9] + x * aT[11]))));
 }
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 #define EXPMAN(u) ((u.i.se & 0x7fff)<<8 | u.i.top>>8)
 
 const long double atanhi[] = {
diff --git a/src/math/cbrtl.c b/src/math/cbrtl.c
index ceff913..601e79f 100644
--- a/src/math/cbrtl.c
+++ b/src/math/cbrtl.c
@@ -17,12 +17,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double cbrtl(long double x)
 {
 	return cbrt(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 static const unsigned B1 = 709958130; /* B1 = (127-127.0/3-0.03306235651)*2**23 */
 
 long double cbrtl(long double x)
@@ -89,14 +89,14 @@ long double cbrtl(long double x)
 	dr = dt * dt * dt;
 	dt = dt * (dx + dx + dr) / (dx + dr + dr);
 
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 	/*
 	 * dt is cbrtl(x) to ~47 bits (after x has been reduced to 1 <= x < 8).
 	 * Round it away from zero to 32 bits (32 so that t*t is exact, and
 	 * away from zero for technical reasons).
 	 */
 	t = dt + (0x1.0p32L + 0x1.0p-31L) - 0x1.0p32;
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 	/*
 	 * Round dt away from zero to 47 bits.  Since we don't trust the 47,
 	 * add 2 47-bit ulps instead of 1 to round up.  Rounding is slow and
diff --git a/src/math/ceill.c b/src/math/ceill.c
index 60a8302..0459f53 100644
--- a/src/math/ceill.c
+++ b/src/math/ceill.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double ceill(long double x)
 {
 	return ceil(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 
 static const long double toint = 1/LDBL_EPSILON;
 
diff --git a/src/math/copysignl.c b/src/math/copysignl.c
index 9dd933c..1430467 100644
--- a/src/math/copysignl.c
+++ b/src/math/copysignl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double copysignl(long double x, long double y)
 {
 	return copysign(x, y);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double copysignl(long double x, long double y)
 {
 	union ldshape ux = {x}, uy = {y};
diff --git a/src/math/coshl.c b/src/math/coshl.c
index 06a56fe..a786936 100644
--- a/src/math/coshl.c
+++ b/src/math/coshl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double coshl(long double x)
 {
 	return cosh(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 long double coshl(long double x)
 {
 	union ldshape u = {x};
@@ -38,7 +38,7 @@ long double coshl(long double x)
 	t = expl(0.5*x);
 	return 0.5*t*t;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double coshl(long double x)
 {
diff --git a/src/math/cosl.c b/src/math/cosl.c
index 79c41c7..abe2015 100644
--- a/src/math/cosl.c
+++ b/src/math/cosl.c
@@ -1,10 +1,10 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double cosl(long double x) {
 	return cos(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double cosl(long double x)
 {
 	union ldshape u = {x};
diff --git a/src/math/erfl.c b/src/math/erfl.c
index e267c23..eb43d0c 100644
--- a/src/math/erfl.c
+++ b/src/math/erfl.c
@@ -100,7 +100,7 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double erfl(long double x)
 {
 	return erf(x);
@@ -109,7 +109,7 @@ long double erfcl(long double x)
 {
 	return erfc(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 static const long double
 erx = 0.845062911510467529296875L,
 
@@ -340,7 +340,7 @@ long double erfcl(long double x)
 	y = 0x1p-16382L;
 	return sign ? 2 - y : y*y;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif LONG_DOUBLE_IS_BINARY128
 // TODO: broken implementation to make things compile
 long double erfl(long double x)
 {
diff --git a/src/math/exp10l.c b/src/math/exp10l.c
index b758ebf..28973c4 100644
--- a/src/math/exp10l.c
+++ b/src/math/exp10l.c
@@ -4,12 +4,12 @@
 #include "libc.h"
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double exp10l(long double x)
 {
 	return exp10(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double exp10l(long double x)
 {
 	static const long double p10[] = {
diff --git a/src/math/exp2l.c b/src/math/exp2l.c
index 3565c1e..b56a65a 100644
--- a/src/math/exp2l.c
+++ b/src/math/exp2l.c
@@ -27,12 +27,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double exp2l(long double x)
 {
 	return exp2(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 #define TBLBITS 7
 #define TBLSIZE (1 << TBLBITS)
 
@@ -251,7 +251,7 @@ long double exp2l(long double x)
 
 	return scalbnl(r, k.i);
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 #define TBLBITS 7
 #define TBLSIZE (1 << TBLBITS)
 
diff --git a/src/math/expl.c b/src/math/expl.c
index 0a7f44f..d36276f 100644
--- a/src/math/expl.c
+++ b/src/math/expl.c
@@ -67,12 +67,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double expl(long double x)
 {
 	return exp(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif LONG_DOUBLE_IS_X87_EXTENDED
 
 static const long double P[3] = {
  1.2617719307481059087798E-4L,
@@ -119,7 +119,7 @@ long double expl(long double x)
 	x = 1.0 + 2.0 * x;
 	return scalbnl(x, k);
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double expl(long double x)
 {
diff --git a/src/math/expm1l.c b/src/math/expm1l.c
index d171507..e1af560 100644
--- a/src/math/expm1l.c
+++ b/src/math/expm1l.c
@@ -49,12 +49,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double expm1l(long double x)
 {
 	return expm1(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 
 /* exp(x) - 1 = x + 0.5 x^2 + x^3 P(x)/Q(x)
    -.5 ln 2  <  x  <  .5 ln 2
@@ -114,7 +114,7 @@ long double expm1l(long double x)
 	x = px * qx + (px - 1.0);
 	return x;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double expm1l(long double x)
 {
diff --git a/src/math/fabsl.c b/src/math/fabsl.c
index c4f36ec..5a8e634 100644
--- a/src/math/fabsl.c
+++ b/src/math/fabsl.c
@@ -1,10 +1,10 @@
 #include "libm.h"
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double fabsl(long double x)
 {
 	return fabs(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double fabsl(long double x)
 {
 	union ldshape u = {x};
diff --git a/src/math/fdiml.c b/src/math/fdiml.c
index 62e29b7..d029f2e 100644
--- a/src/math/fdiml.c
+++ b/src/math/fdiml.c
@@ -1,7 +1,7 @@
 #include <math.h>
 #include <float.h>
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double fdiml(long double x, long double y)
 {
 	return fdim(x, y);
diff --git a/src/math/floorl.c b/src/math/floorl.c
index 16aaec4..3634bf1 100644
--- a/src/math/floorl.c
+++ b/src/math/floorl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double floorl(long double x)
 {
 	return floor(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 
 static const long double toint = 1/LDBL_EPSILON;
 
diff --git a/src/math/fmal.c b/src/math/fmal.c
index 4506aac..7306442 100644
--- a/src/math/fmal.c
+++ b/src/math/fmal.c
@@ -27,17 +27,17 @@
 
 
 #include "libm.h"
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double fmal(long double x, long double y, long double z)
 {
 	return fma(x, y, z);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 #include <fenv.h>
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 #define LASTBIT(u) (u.i.m & 1)
 #define SPLIT (0x1p32L + 1)
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 #define LASTBIT(u) (u.i.lo & 1)
 #define SPLIT (0x1p57L + 1)
 #endif
diff --git a/src/math/fmaxl.c b/src/math/fmaxl.c
index 4b03158..9b4a317 100644
--- a/src/math/fmaxl.c
+++ b/src/math/fmaxl.c
@@ -1,7 +1,7 @@
 #include <math.h>
 #include <float.h>
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double fmaxl(long double x, long double y)
 {
 	return fmax(x, y);
diff --git a/src/math/fminl.c b/src/math/fminl.c
index 69bc24a..b071e82 100644
--- a/src/math/fminl.c
+++ b/src/math/fminl.c
@@ -1,7 +1,7 @@
 #include <math.h>
 #include <float.h>
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double fminl(long double x, long double y)
 {
 	return fmin(x, y);
diff --git a/src/math/fmodl.c b/src/math/fmodl.c
index 9f5b873..c1a4e2f 100644
--- a/src/math/fmodl.c
+++ b/src/math/fmodl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double fmodl(long double x, long double y)
 {
 	return fmod(x, y);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double fmodl(long double x, long double y)
 {
 	union ldshape ux = {x}, uy = {y};
@@ -34,7 +34,7 @@ long double fmodl(long double x, long double y)
 	}
 
 	/* x mod y */
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 	uint64_t i, mx, my;
 	mx = ux.i.m;
 	my = uy.i.m;
@@ -58,7 +58,7 @@ long double fmodl(long double x, long double y)
 	}
 	for (; mx >> 63 == 0; mx *= 2, ex--);
 	ux.i.m = mx;
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 	uint64_t hi, lo, xhi, xlo, yhi, ylo;
 	xhi = (ux.i2.hi & -1ULL>>16) | 1ULL<<48;
 	yhi = (uy.i2.hi & -1ULL>>16) | 1ULL<<48;
diff --git a/src/math/frexpl.c b/src/math/frexpl.c
index 3c1b553..9d9fbb4 100644
--- a/src/math/frexpl.c
+++ b/src/math/frexpl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double frexpl(long double x, int *e)
 {
 	return frexp(x, e);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double frexpl(long double x, int *e)
 {
 	union ldshape u = {x};
diff --git a/src/math/hypotl.c b/src/math/hypotl.c
index 479aa92..65f5737 100644
--- a/src/math/hypotl.c
+++ b/src/math/hypotl.c
@@ -1,14 +1,14 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double hypotl(long double x, long double y)
 {
 	return hypot(x, y);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#if LDBL_MANT_DIG == 64
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 #define SPLIT (0x1p32L+1)
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 #define SPLIT (0x1p57L+1)
 #endif
 
diff --git a/src/math/ilogbl.c b/src/math/ilogbl.c
index 7b1a9cf..c8407df 100644
--- a/src/math/ilogbl.c
+++ b/src/math/ilogbl.c
@@ -1,12 +1,12 @@
 #include <limits.h>
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#if LONG_DOUBLE_IS_BINARY64
 int ilogbl(long double x)
 {
 	return ilogb(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 int ilogbl(long double x)
 {
 	#pragma STDC FENV_ACCESS ON
@@ -29,7 +29,7 @@ int ilogbl(long double x)
 	}
 	return e - 0x3fff;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 int ilogbl(long double x)
 {
 	#pragma STDC FENV_ACCESS ON
diff --git a/src/math/lgammal.c b/src/math/lgammal.c
index 2b354a7..0407a7b 100644
--- a/src/math/lgammal.c
+++ b/src/math/lgammal.c
@@ -89,14 +89,14 @@
 #include "libm.h"
 #include "libc.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 double __lgamma_r(double x, int *sg);
 
 long double __lgammal_r(long double x, int *sg)
 {
 	return __lgamma_r(x, sg);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 static const long double
 pi = 3.14159265358979323846264L,
 
@@ -340,7 +340,7 @@ long double __lgammal_r(long double x, int *sg) {
 		r = nadj - r;
 	return r;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 double __lgamma_r(double x, int *sg);
 
diff --git a/src/math/llrintl.c b/src/math/llrintl.c
index 3449f6f..f65755d 100644
--- a/src/math/llrintl.c
+++ b/src/math/llrintl.c
@@ -3,7 +3,7 @@
 #include "libm.h"
 
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long long llrintl(long double x)
 {
 	return llrint(x);
diff --git a/src/math/log10l.c b/src/math/log10l.c
index 63dcc28..8822a38 100644
--- a/src/math/log10l.c
+++ b/src/math/log10l.c
@@ -59,12 +59,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double log10l(long double x)
 {
 	return log10(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 /* Coefficients for log(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
  * 1/sqrt(2) <= x < sqrt(2)
  * Theoretical peak relative error = 6.2e-22
@@ -182,7 +182,7 @@ done:
 	z += e * (L102A);
 	return z;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double log10l(long double x)
 {
diff --git a/src/math/log1pl.c b/src/math/log1pl.c
index 141b5f0..b8c47f8 100644
--- a/src/math/log1pl.c
+++ b/src/math/log1pl.c
@@ -50,12 +50,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double log1pl(long double x)
 {
 	return log1p(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 /* Coefficients for log(1+x) = x - x^2 / 2 + x^3 P(x)/Q(x)
  * 1/sqrt(2) <= x < sqrt(2)
  * Theoretical peak relative error = 2.32e-20
@@ -168,7 +168,7 @@ long double log1pl(long double xm1)
 	z = z + e * C1;
 	return z;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double log1pl(long double x)
 {
diff --git a/src/math/log2l.c b/src/math/log2l.c
index 722b451..8a3e342 100644
--- a/src/math/log2l.c
+++ b/src/math/log2l.c
@@ -54,12 +54,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double log2l(long double x)
 {
 	return log2(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 /* Coefficients for ln(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
  * 1/sqrt(2) <= x < sqrt(2)
  * Theoretical peak relative error = 6.2e-22
@@ -173,7 +173,7 @@ done:
 	z += e;
 	return z;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double log2l(long double x)
 {
diff --git a/src/math/logbl.c b/src/math/logbl.c
index 962973a..6e7f234 100644
--- a/src/math/logbl.c
+++ b/src/math/logbl.c
@@ -1,5 +1,5 @@
 #include <math.h>
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double logbl(long double x)
 {
 	return logb(x);
diff --git a/src/math/logl.c b/src/math/logl.c
index 5d53659..1273730 100644
--- a/src/math/logl.c
+++ b/src/math/logl.c
@@ -54,12 +54,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double logl(long double x)
 {
 	return log(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 /* Coefficients for log(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
  * 1/sqrt(2) <= x < sqrt(2)
  * Theoretical peak relative error = 2.32e-20
@@ -166,7 +166,7 @@ long double logl(long double x)
 	z = z + e * C1; /* This sum has an error of 1/2 lsb. */
 	return z;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double logl(long double x)
 {
diff --git a/src/math/lrintl.c b/src/math/lrintl.c
index b2a8106..dcfa628 100644
--- a/src/math/lrintl.c
+++ b/src/math/lrintl.c
@@ -3,7 +3,7 @@
 #include "libm.h"
 
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long lrintl(long double x)
 {
 	return lrint(x);
diff --git a/src/math/modfl.c b/src/math/modfl.c
index a47b192..e8ef568 100644
--- a/src/math/modfl.c
+++ b/src/math/modfl.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double modfl(long double x, long double *iptr)
 {
 	double d;
@@ -10,7 +10,7 @@ long double modfl(long double x, long double *iptr)
 	*iptr = d;
 	return r;
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 
 static const long double toint = 1/LDBL_EPSILON;
 
diff --git a/src/math/nearbyintl.c b/src/math/nearbyintl.c
index 8285249..0d0994e 100644
--- a/src/math/nearbyintl.c
+++ b/src/math/nearbyintl.c
@@ -1,7 +1,7 @@
 #include <math.h>
 #include <float.h>
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double nearbyintl(long double x)
 {
 	return nearbyint(x);
diff --git a/src/math/nextafterl.c b/src/math/nextafterl.c
index 37e858f..aebb5f1 100644
--- a/src/math/nextafterl.c
+++ b/src/math/nextafterl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double nextafterl(long double x, long double y)
 {
 	return nextafter(x, y);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 long double nextafterl(long double x, long double y)
 {
 	union ldshape ux, uy;
@@ -41,7 +41,7 @@ long double nextafterl(long double x, long double y)
 		FORCE_EVAL(x*x + ux.f*ux.f);
 	return ux.f;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif LONG_DOUBLE_IS_BINARY128
 long double nextafterl(long double x, long double y)
 {
 	union ldshape ux, uy;
diff --git a/src/math/nexttoward.c b/src/math/nexttoward.c
index 827ee5c..3b61d5b 100644
--- a/src/math/nexttoward.c
+++ b/src/math/nexttoward.c
@@ -1,6 +1,6 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 double nexttoward(double x, long double y)
 {
 	return nextafter(x, y);
diff --git a/src/math/powl.c b/src/math/powl.c
index 5b6da07..806e551 100644
--- a/src/math/powl.c
+++ b/src/math/powl.c
@@ -69,12 +69,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double powl(long double x, long double y)
 {
 	return pow(x, y);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 
 /* Table size */
 #define NXT 32
@@ -513,7 +513,7 @@ static long double powil(long double x, int nn)
 		y = 1.0/y;
 	return y;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double powl(long double x, long double y)
 {
diff --git a/src/math/remainderl.c b/src/math/remainderl.c
index 2a13c1d..b00a517 100644
--- a/src/math/remainderl.c
+++ b/src/math/remainderl.c
@@ -1,7 +1,7 @@
 #include <math.h>
 #include <float.h>
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double remainderl(long double x, long double y)
 {
 	return remainder(x, y);
diff --git a/src/math/remquol.c b/src/math/remquol.c
index 9b065c0..d2ac361 100644
--- a/src/math/remquol.c
+++ b/src/math/remquol.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double remquol(long double x, long double y, int *quo)
 {
 	return remquo(x, y, quo);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double remquol(long double x, long double y, int *quo)
 {
 	union ldshape ux = {x}, uy = {y};
@@ -36,7 +36,7 @@ long double remquol(long double x, long double y, int *quo)
 	q = 0;
 	if (ex >= ey) {
 		/* x mod y */
-#if LDBL_MANT_DIG == 64
+#ifdef LONG_DOUBLE_IS_X87_EXTENDED
 		uint64_t i, mx, my;
 		mx = ux.i.m;
 		my = uy.i.m;
@@ -65,7 +65,7 @@ long double remquol(long double x, long double y, int *quo)
 		else
 			for (; mx >> 63 == 0; mx *= 2, ex--);
 		ux.i.m = mx;
-#elif LDBL_MANT_DIG == 113
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 		uint64_t hi, lo, xhi, xlo, yhi, ylo;
 		xhi = (ux.i2.hi & -1ULL>>16) | 1ULL<<48;
 		yhi = (uy.i2.hi & -1ULL>>16) | 1ULL<<48;
diff --git a/src/math/rintl.c b/src/math/rintl.c
index 374327d..4f16c8f 100644
--- a/src/math/rintl.c
+++ b/src/math/rintl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double rintl(long double x)
 {
 	return rint(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 
 static const long double toint = 1/LDBL_EPSILON;
 
diff --git a/src/math/roundl.c b/src/math/roundl.c
index f4ff682..0fde942 100644
--- a/src/math/roundl.c
+++ b/src/math/roundl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double roundl(long double x)
 {
 	return round(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 
 static const long double toint = 1/LDBL_EPSILON;
 
diff --git a/src/math/scalblnl.c b/src/math/scalblnl.c
index 854c51c..20a66de 100644
--- a/src/math/scalblnl.c
+++ b/src/math/scalblnl.c
@@ -2,7 +2,7 @@
 #include <math.h>
 #include <float.h>
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double scalblnl(long double x, long n)
 {
 	return scalbln(x, n);
diff --git a/src/math/scalbnl.c b/src/math/scalbnl.c
index 08a4c58..10ab475 100644
--- a/src/math/scalbnl.c
+++ b/src/math/scalbnl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double scalbnl(long double x, int n)
 {
 	return scalbn(x, n);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double scalbnl(long double x, int n)
 {
 	union ldshape u;
diff --git a/src/math/sincosl.c b/src/math/sincosl.c
index d3ac1c4..c38143f 100644
--- a/src/math/sincosl.c
+++ b/src/math/sincosl.c
@@ -1,7 +1,7 @@
 #define _GNU_SOURCE
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 void sincosl(long double x, long double *sin, long double *cos)
 {
 	double sind, cosd;
@@ -9,7 +9,7 @@ void sincosl(long double x, long double *sin, long double *cos)
 	*sin = sind;
 	*cos = cosd;
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 void sincosl(long double x, long double *sin, long double *cos)
 {
 	union ldshape u = {x};
diff --git a/src/math/sinhl.c b/src/math/sinhl.c
index b305d4d..6e56db8 100644
--- a/src/math/sinhl.c
+++ b/src/math/sinhl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double sinhl(long double x)
 {
 	return sinh(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 long double sinhl(long double x)
 {
 	union ldshape u = {x};
@@ -34,7 +34,7 @@ long double sinhl(long double x)
 	t = expl(0.5*absx);
 	return h*t*t;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double sinhl(long double x)
 {
diff --git a/src/math/sinl.c b/src/math/sinl.c
index 9c0b16e..e006f03 100644
--- a/src/math/sinl.c
+++ b/src/math/sinl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double sinl(long double x)
 {
 	return sin(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double sinl(long double x)
 {
 	union ldshape u = {x};
diff --git a/src/math/tanhl.c b/src/math/tanhl.c
index 4e1aa9f..0f9825a 100644
--- a/src/math/tanhl.c
+++ b/src/math/tanhl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double tanhl(long double x)
 {
 	return tanh(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 long double tanhl(long double x)
 {
 	union ldshape u = {x};
@@ -39,7 +39,7 @@ long double tanhl(long double x)
 	}
 	return sign ? -t : t;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double tanhl(long double x)
 {
diff --git a/src/math/tanl.c b/src/math/tanl.c
index 6af0671..52c3f8a 100644
--- a/src/math/tanl.c
+++ b/src/math/tanl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double tanl(long double x)
 {
 	return tan(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 long double tanl(long double x)
 {
 	union ldshape u = {x};
diff --git a/src/math/tgammal.c b/src/math/tgammal.c
index 5336c5b..4f95a80 100644
--- a/src/math/tgammal.c
+++ b/src/math/tgammal.c
@@ -50,12 +50,12 @@
 
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double tgammal(long double x)
 {
 	return tgamma(x);
 }
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED)
 /*
 tgamma(x+2) = tgamma(x+2) P(x)/Q(x)
 0 <= x <= 1
@@ -272,7 +272,7 @@ small:
 		q = z / (x * __polevll(x, S, 8));
 	return q;
 }
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_BINARY128)
 // TODO: broken implementation to make things compile
 long double tgammal(long double x)
 {
diff --git a/src/math/truncl.c b/src/math/truncl.c
index f07b193..ca783cc 100644
--- a/src/math/truncl.c
+++ b/src/math/truncl.c
@@ -1,11 +1,11 @@
 #include "libm.h"
 
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+#ifdef LONG_DOUBLE_IS_BINARY64
 long double truncl(long double x)
 {
 	return trunc(x);
 }
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+#elif defined(LONG_DOUBLE_IS_X87_EXTENDED) || defined(LONG_DOUBLE_IS_BINARY128)
 
 static const long double toint = 1/LDBL_EPSILON;
 
-- 
2.4.10

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.