diff options
author | nsz <nsz@port70.net> | 2012-05-06 21:24:28 +0200 |
---|---|---|
committer | nsz <nsz@port70.net> | 2012-05-06 21:24:28 +0200 |
commit | 6ab8136b4477fd75381c06fa0e7fa93c89c712a1 (patch) | |
tree | fea8ff7bf34e2a41e797528571d62097413b3685 /src/internal/libm.h | |
parent | 4e597feef0595caefa39ab43c813734a1244fa84 (diff) | |
download | musl-6ab8136b4477fd75381c06fa0e7fa93c89c712a1.tar.gz musl-6ab8136b4477fd75381c06fa0e7fa93c89c712a1.tar.xz musl-6ab8136b4477fd75381c06fa0e7fa93c89c712a1.zip |
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/libm.h')
-rw-r--r-- | src/internal/libm.h | 13 |
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 { \ |