summaryrefslogtreecommitdiffstats
path: root/lib/msun
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2004-05-17 01:04:37 +0000
committerdas <das@FreeBSD.org>2004-05-17 01:04:37 +0000
commitc49ff0a6a145dcd932e9bc105329859fe6c377af (patch)
tree49921cd3fd4d0a0d18c79366bcb21a2fb5c0cd6c /lib/msun
parent961476df3cb11340cbe56c861b05c4089e8ccaff (diff)
downloadFreeBSD-src-c49ff0a6a145dcd932e9bc105329859fe6c377af.zip
FreeBSD-src-c49ff0a6a145dcd932e9bc105329859fe6c377af.tar.gz
Remove some kludges designed to ensure that the compiler didn't round
constants the wrong way on the VAX. Instead, use C99 hexadecimal floating-point constants, which are guaranteed to be exact on binary IEEE machines. (The correct hexadecimal values were already provided in the source, but not used.) Also, convert the constants to lowercase to work around a gcc bug that wasn't fixed until gcc 3.4.0. Prompted by: stefanf
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/bsdsrc/b_exp.c50
-rw-r--r--lib/msun/bsdsrc/mathimpl.h47
2 files changed, 10 insertions, 87 deletions
diff --git a/lib/msun/bsdsrc/b_exp.c b/lib/msun/bsdsrc/b_exp.c
index 64d9a3d..dff6282 100644
--- a/lib/msun/bsdsrc/b_exp.c
+++ b/lib/msun/bsdsrc/b_exp.c
@@ -72,50 +72,20 @@ __FBSDID("$FreeBSD$");
* exp(x) returns the exponential of x nearly rounded. In a test run
* with 1,156,000 random arguments on a VAX, the maximum observed
* error was 0.869 ulps (units in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following constants.
- * The decimal values may be used, provided that the compiler will convert
- * from decimal to binary accurately enough to produce the hexadecimal values
- * shown.
*/
#include "mathimpl.h"
-vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
-vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
-vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010)
-vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF)
-vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1)
-vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1)
-vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94)
-vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F)
-vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84)
-vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683)
-
-#ifdef vccast
-#define ln2hi vccast(ln2hi)
-#define ln2lo vccast(ln2lo)
-#define lnhuge vccast(lnhuge)
-#define lntiny vccast(lntiny)
-#define invln2 vccast(invln2)
-#define p1 vccast(p1)
-#define p2 vccast(p2)
-#define p3 vccast(p3)
-#define p4 vccast(p4)
-#define p5 vccast(p5)
-#endif
-
-ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E)
-ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93)
-ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C)
-ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1)
-ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0)
-ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
-ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76)
-ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2)
-ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354)
-ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE)
+const static double p1 = 0x1.555555555553ep-3;
+const static double p2 = -0x1.6c16c16bebd93p-9;
+const static double p3 = 0x1.1566aaf25de2cp-14;
+const static double p4 = -0x1.bbd41c5d26bf1p-20;
+const static double p5 = 0x1.6376972bea4d0p-25;
+const static double ln2hi = 0x1.62e42fee00000p-1;
+const static double ln2lo = 0x1.a39ef35793c76p-33;
+const static double lnhuge = 0x1.6602b15b7ecf2p9;
+const static double lntiny = -0x1.77af8ebeae354p9;
+const static double invln2 = 0x1.71547652b82fep0;
#if 0
double exp(x)
diff --git a/lib/msun/bsdsrc/mathimpl.h b/lib/msun/bsdsrc/mathimpl.h
index d8e39f3..8c1f96f 100644
--- a/lib/msun/bsdsrc/mathimpl.h
+++ b/lib/msun/bsdsrc/mathimpl.h
@@ -37,53 +37,6 @@
#include <sys/cdefs.h>
#include <math.h>
-#if defined(vax)||defined(tahoe)
-
-/* Deal with different ways to concatenate in cpp */
-# define cat3(a,b,c) a ## b ## c
-
-/* Deal with vax/tahoe byte order issues */
-# ifdef vax
-# define cat3t(a,b,c) cat3(a,b,c)
-# else
-# define cat3t(a,b,c) cat3(a,c,b)
-# endif
-
-# define vccast(name) (*(const double *)(cat3(name,,x)))
-
- /*
- * Define a constant to high precision on a Vax or Tahoe.
- *
- * Args are the name to define, the decimal floating point value,
- * four 16-bit chunks of the float value in hex
- * (because the vax and tahoe differ in float format!), the power
- * of 2 of the hex-float exponent, and the hex-float mantissa.
- * Most of these arguments are not used at compile time; they are
- * used in a post-check to make sure the constants were compiled
- * correctly.
- *
- * People who want to use the constant will have to do their own
- * #define foo vccast(foo)
- * since CPP cannot do this for them from inside another macro (sigh).
- * We define "vccast" if this needs doing.
- */
-# define vc(name, value, x1,x2,x3,x4, bexp, xval) \
- const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
-
-# define ic(name, value, bexp, xval) ;
-
-#else /* vax or tahoe */
-
- /* Hooray, we have an IEEE machine */
-# undef vccast
-# define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
-
-# define ic(name, value, bexp, xval) \
- const static double name = value;
-
-#endif /* defined(vax)||defined(tahoe) */
-
-
/*
* Functions internal to the math package, yet not static.
*/
OpenPOWER on IntegriCloud