From 159a2b867c93dddc3de426336b519f3a5c4bba00 Mon Sep 17 00:00:00 2001 From: Martin Nilsson <nilsson@opera.com> Date: Wed, 3 Sep 2014 23:29:00 +0200 Subject: [PATCH] ldexp is C89 and 4.3BSD --- src/acconfig.h | 3 --- src/configure.in | 16 +--------------- src/encode.c | 4 ++-- src/port.c | 7 ------- src/port.h | 5 +---- src/sprintf.c | 4 ++-- src/sscanf.c | 2 +- 7 files changed, 7 insertions(+), 34 deletions(-) diff --git a/src/acconfig.h b/src/acconfig.h index 44b55d2b87..e2a924e152 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -307,9 +307,6 @@ /* Define this if you have dlopen */ #undef HAVE_DLOPEN -/* Define if you have ldexp. */ -#undef HAVE_LDEXP - /* Define if you have rint. */ #undef HAVE_RINT diff --git a/src/configure.in b/src/configure.in index 4664c56ccc..870aa40eda 100644 --- a/src/configure.in +++ b/src/configure.in @@ -5684,6 +5684,7 @@ MY_CHECK_FUNCTION(isunordered, int t = isunordered(0.0, 0.0); exit(0); ]) + ######################################################################## MY_CHECK_FUNCTION(dlopen, [ @@ -5692,21 +5693,6 @@ MY_CHECK_FUNCTION(dlopen, dlopen(0, 0); exit(0); ]) -######################################################################## - -MY_CHECK_FUNCTION(ldexp, -[ -#include <math.h> -], [ - double x; - int p; - - for(x=0.0;x<2.0;x+=1.0/64.0) - for(p=-6;p<7;p++) - if(ldexp(x,p) != x*pow(2.0, (double)p)) - exit(1); - exit(0); -]) ######################################################################## MY_CHECK_FUNCTION(rint, diff --git a/src/encode.c b/src/encode.c index 4644ea96bd..09627c65a8 100644 --- a/src/encode.c +++ b/src/encode.c @@ -2631,13 +2631,13 @@ static void decode_value2(struct decode_data *data) break; default: - push_float(DO_NOT_WARN((FLOAT_TYPE)LDEXP(res, num))); + push_float(DO_NOT_WARN((FLOAT_TYPE)ldexp(res, num))); break; } break; } - push_float(DO_NOT_WARN((FLOAT_TYPE)LDEXP(res, num))); + push_float(DO_NOT_WARN((FLOAT_TYPE)ldexp(res, num))); break; } diff --git a/src/port.c b/src/port.c index 20ef64351a..bc62b35b15 100644 --- a/src/port.c +++ b/src/port.c @@ -597,13 +597,6 @@ long long gethrtime() #endif /* OWN_GETHRTIME */ -#ifndef HAVE_LDEXP -double LDEXP(double x, int exp) -{ - return x * pow(2.0,(double)exp); -} -#endif - #ifdef __MINGW32__ struct errmapping { const int winerr; diff --git a/src/port.h b/src/port.h index 1f25bf32b2..ec839a4615 100644 --- a/src/port.h +++ b/src/port.h @@ -366,11 +366,8 @@ long long gethrtime(void); #define HAVE_FREXP 1 #define FREXP frexp -#ifdef HAVE_LDEXP +#define HAVE_LDEXP 1 #define LDEXP ldexp -#else -double LDEXP(double x, int exp); -#endif #ifdef __MINGW32__ #ifndef HAVE__DOSMAPERR diff --git a/src/sprintf.c b/src/sprintf.c index 16e2b94956..2638053c83 100644 --- a/src/sprintf.c +++ b/src/sprintf.c @@ -505,7 +505,7 @@ static void low_write_IEEE_float(char *b, double d, int sz) e += 126; d *= 16777216.0; if(e<=0) { - d = LDEXP(d, e-1); + d = ldexp(d, e-1); e = 0; } f = ((INT32)floor(d))&maxf; @@ -514,7 +514,7 @@ static void low_write_IEEE_float(char *b, double d, int sz) e += 1022; d *= 2097152.0; if(e<=0) { - d = LDEXP(d, e-1); + d = ldexp(d, e-1); e = 0; } d2 = floor(d); diff --git a/src/sscanf.c b/src/sscanf.c index e548106e09..740523dd65 100644 --- a/src/sscanf.c +++ b/src/sscanf.c @@ -460,7 +460,7 @@ static INLINE FLOAT_TYPE low_parse_IEEE_float(char *b, int sz) r = (double)f; if(extra_f) r += ((double)extra_f)/4294967296.0; - return (FLOAT_TYPE)(s? -LDEXP(r, e):LDEXP(r, e)); + return (FLOAT_TYPE)(s? -ldexp(r, e):ldexp(r, e)); } #endif -- GitLab