summaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authornsz <nsz@port70.net>2012-05-06 21:24:28 +0200
committernsz <nsz@port70.net>2012-05-06 21:24:28 +0200
commit6ab8136b4477fd75381c06fa0e7fa93c89c712a1 (patch)
treefea8ff7bf34e2a41e797528571d62097413b3685 /src/internal
parent4e597feef0595caefa39ab43c813734a1244fa84 (diff)
downloadmusl-6ab8136b4477fd75381c06fa0e7fa93c89c712a1.tar.gz
add FORCE_EVAL macro to evaluate float expr for their side effect
updated nextafter* to use FORCE_EVAL, it can be used in many other places in the math code to improve readability.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/libm.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/internal/libm.h b/src/internal/libm.h
index 8c5474a8..a71c4c05 100644
--- a/src/internal/libm.h
+++ b/src/internal/libm.h
@@ -32,6 +32,19 @@ union dshape {
uint64_t bits;
};
+#define FORCE_EVAL(x) do { \
+ if (sizeof(x) == sizeof(float)) { \
+ volatile float __x; \
+ __x = (x); \
+ } else if (sizeof(x) == sizeof(double)) { \
+ volatile double __x; \
+ __x = (x); \
+ } else { \
+ volatile long double __x; \
+ __x = (x); \
+ } \
+} while(0)
+
/* Get two 32 bit ints from a double. */
#define EXTRACT_WORDS(hi,lo,d) \
do { \