lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 38dd359d 04/13: Apply 'fdlibm*.c' changes to


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 38dd359d 04/13: Apply 'fdlibm*.c' changes to 'fdlibm.h'
Date: Mon, 23 May 2022 17:40:26 -0400 (EDT)

branch: master
commit 38dd359d4342b09bc338b6e8e92706283d7cc72e
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Apply 'fdlibm*.c' changes to 'fdlibm.h'
---
 fdlibm.h.txt | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/fdlibm.h.txt b/fdlibm.h.txt
index d44712a9..5a0be7a0 100644
--- a/fdlibm.h.txt
+++ b/fdlibm.h.txt
@@ -5,28 +5,31 @@
  * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  */
 
-/* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly
-   but these catch some common cases. */
+// Apparently the clang maintainers believe that floating-point
+// endianness is necessarily the same as integer endianness.
+#if defined __clang__
+#   if !defined __FLOAT_WORD_ORDER__ && defined __BYTE_ORDER__
+#       define __FLOAT_WORD_ORDER__ __BYTE_ORDER__
+#   endif // !defined __FLOAT_WORD_ORDER__ && defined __BYTE_ORDER__
+#endif // defined __clang__
 
-#if defined(i386) || defined(i486) || \
-       defined(intel) || defined(x86) || defined(i86pc) || \
-       defined(__alpha) || defined(__osf__)
-#define __LITTLE_ENDIAN
-#endif
+#if !defined __FLOAT_WORD_ORDER__ || \
+    !defined __ORDER_BIG_ENDIAN__ || \
+    !defined __ORDER_LITTLE_ENDIAN__
+#   error Expected endianness macros not defined.
+#endif // expected endianness macros not defined
 
-#ifdef __LITTLE_ENDIAN
-#define __HI(x) *(1+(int*)&x)
-#define __LO(x) *(int*)&x
-#define __HIp(x) *(1+(int*)x)
-#define __LOp(x) *(int*)x
-#else
-#define __HI(x) *(int*)&x
-#define __LO(x) *(1+(int*)&x)
-#define __HIp(x) *(int*)x
-#define __LOp(x) *(1+(int*)x)
-#endif
+#if   __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#   define FDLIBM_HI(x) *(1+(int*)&x)
+#   define FDLIBM_LO(x) *(int*)&x
+#elif __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
+#   define FDLIBM_HI(x) *(int*)&x
+#   define FDLIBM_LO(x) *(1+(int*)&x)
+#else  // unknown endianness
+#   error Unknown endianness.
+#endif // unknown endianness



reply via email to

[Prev in Thread] Current Thread [Next in Thread]