1 /* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * All recipients should regard themselves as participants in an ongoing 8 * research project and hence should feel obligated to report their 9 * experiences (good or bad) with these elementary function codes, using 10 * the sendbug(8) program, to the authors. 11 * 12 * @(#)mathimpl.h 5.2 (Berkeley) 06/01/90 13 */ 14 15 #include <math.h> 16 17 #ifdef __STDC__ 18 #define const const 19 #else 20 #define const /**/ 21 #endif 22 23 #if defined(vax)||defined(tahoe) 24 25 /* Deal with different ways to concatenate in cpp */ 26 # ifdef __STDC__ 27 # define cat3(a,b,c) a ## b ## c 28 # else 29 # define cat3(a,b,c) a/**/b/**/c 30 # endif 31 32 /* Deal with vax/tahoe byte order issues */ 33 # ifdef vax 34 # define cat3t(a,b,c) cat3(a,b,c) 35 # else 36 # define cat3t(a,b,c) cat3(a,c,b) 37 # endif 38 39 # define vccast(name) (*(const double *)(cat3(name,,x))) 40 41 /* 42 * Define a constant to high precision on a Vax or Tahoe. 43 * 44 * Args are the name to define, the decimal floating point value, 45 * four 16-bit chunks of the float value in hex 46 * (because the vax and tahoe differ in float format!), the power 47 * of 2 of the hex-float exponent, and the hex-float mantissa. 48 * Most of these arguments are not used at compile time; they are 49 * used in a post-check to make sure the constants were compiled 50 * correctly. 51 * 52 * People who want to use the constant will have to do their own 53 * #define foo vccast(foo) 54 * since CPP cannot do this for them from inside another macro (sigh). 55 * We define "vccast" if this needs doing. 56 */ 57 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \ 58 const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; 59 60 # define ic(name, value, bexp, xval) ; 61 62 #else /* vax or tahoe */ 63 64 /* Hooray, we have an IEEE machine */ 65 # undef vccast 66 # define vc(name, value, x1,x2,x3,x4, bexp, xval) ; 67 68 # define ic(name, value, bexp, xval) \ 69 const static double name = value; 70 71 #endif /* defined(vax)||defined(tahoe) */ 72 73 74 /* 75 * Functions internal to the math package, yet not static. 76 */ 77 extern double exp__E(); 78 extern double log__L(); 79 80