summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2013-05-06 17:52:48 +0000
committerSzabolcs Nagy <nsz@port70.net>2013-05-06 17:52:48 +0000
commit2897bfdd602f3d6a0724bbfdd543e962926b5bbe (patch)
tree53a906d10bbf92835d782cbdd5ffcf265a32ad63
parentda49b872f5ef56026713855b66783c8e32570c4b (diff)
downloadmusl-2897bfdd602f3d6a0724bbfdd543e962926b5bbe.tar.gz
remove compound literals from math.h to please c++
__FLOAT_BITS and __DOUBLE_BITS macros used union compound literals, now they are changed into static inline functions. A good C compiler generates the same code for both and the later is C++ conformant.
-rw-r--r--include/math.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/include/math.h b/include/math.h
index c4da4116..01428152 100644
--- a/include/math.h
+++ b/include/math.h
@@ -43,11 +43,16 @@ int __fpclassify(double);
int __fpclassifyf(float);
int __fpclassifyl(long double);
-union __float_repr { float __f; __uint32_t __i; };
-union __double_repr { double __f; __uint64_t __i; };
-
-#define __FLOAT_BITS(f) (((union __float_repr){ (float)(f) }).__i)
-#define __DOUBLE_BITS(f) (((union __double_repr){ (double)(f) }).__i)
+static __inline __uint32_t __FLOAT_BITS(float __f)
+{
+ union {float __f; __uint32_t __i;} __u = {__f};
+ return __u.__i;
+}
+static __inline __uint64_t __DOUBLE_BITS(double __f)
+{
+ union {double __f; __uint64_t __i;} __u = {__f};
+ return __u.__i;
+}
#define fpclassify(x) ( \
sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \