[PATCH] ieeefp.c: Compute _LDBL_EQ_DBL in sys/config.h [v2]

Keith Packard keithp@keithp.com
Fri Sep 21 00:46:00 GMT 2018


Do this instead of computing it at configure time to avoid having a
compiler-option-specific value installed in newlib.h on a multilib
system.

v2:
	Move test to sys/config.h which should always get included
	whereever this is needed in both the library and applications
	using the library.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 newlib/libc/include/math.h       |  2 +-
 newlib/libc/include/sys/config.h | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 893a5d064..e60b8e7f4 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -4,7 +4,7 @@
 
 #include <sys/reent.h>
 #include <sys/cdefs.h>
-#include <machine/ieeefp.h>
+#include <ieeefp.h>
 #include "_ansi.h"
 
 _BEGIN_STD_C
diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index 2082dfdb1..407d214e8 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -3,6 +3,7 @@
 
 #include <machine/ieeefp.h>  /* floating point macros */
 #include <sys/features.h>	/* POSIX defs */
+#include <float.h>
 
 #ifdef __aarch64__
 #define MALLOC_ALIGNMENT 16
@@ -297,4 +298,13 @@
 #define _MB_EXTENDED_CHARSETS_WINDOWS 1
 #endif
 
+/* Figure out if long double is the same size as double. If the system
+ * doesn't provide long double, then those values will be undefined
+ * and cpp will substitute 0 for them in the test
+ */
+#if LDBL_MANT_DIG == DBL_MANT_DIG && LDBL_MIN_EXP == DBL_MIN_EXP && \
+    LDBL_MAX_EXP == DBL_MAX_EXP
+#define _LDBL_EQ_DBL
+#endif
+
 #endif /* __SYS_CONFIG_H__ */
-- 
2.19.0



More information about the Newlib mailing list