From 6ab8136b4477fd75381c06fa0e7fa93c89c712a1 Mon Sep 17 00:00:00 2001 From: nsz Date: Sun, 6 May 2012 21:24:28 +0200 Subject: 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. --- src/internal/libm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/internal/libm.h') 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 { \ -- cgit v1.2.1