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

Keith Packard <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.