1 /* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * All recipients should regard themselves as participants in an ongoing 18 * research project and hence should feel obligated to report their 19 * experiences (good or bad) with these elementary function codes, using 20 * the sendbug(8) program, to the authors. 21 * 22 * @(#)mathimpl.h 5.1 (Berkeley) 06/01/90 23 */ 24 25 #include <math.h> 26 27 #ifdef __STDC__ 28 #define const const 29 #else 30 #define const /**/ 31 #endif 32 33 #if defined(vax)||defined(tahoe) 34 35 /* Deal with different ways to concatenate in cpp */ 36 # ifdef __STDC__ 37 # define cat3(a,b,c) a ## b ## c 38 # else 39 # define cat3(a,b,c) a/**/b/**/c 40 # endif 41 42 /* Deal with vax/tahoe byte order issues */ 43 # ifdef vax 44 # define cat3t(a,b,c) cat3(a,b,c) 45 # else 46 # define cat3t(a,b,c) cat3(a,c,b) 47 # endif 48 49 # define vccast(name) (*(const double *)(cat3(name,,x))) 50 51 /* 52 * Define a constant to high precision on a Vax or Tahoe. 53 * 54 * Args are the name to define, the decimal floating point value, 55 * four 16-bit chunks of the float value in hex 56 * (because the vax and tahoe differ in float format!), the power 57 * of 2 of the hex-float exponent, and the hex-float mantissa. 58 * Most of these arguments are not used at compile time; they are 59 * used in a post-check to make sure the constants were compiled 60 * correctly. 61 * 62 * People who want to use the constant will have to do their own 63 * #define foo vccast(foo) 64 * since CPP cannot do this for them from inside another macro (sigh). 65 * We define "vccast" if this needs doing. 66 */ 67 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \ 68 const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; 69 70 # define ic(name, value, bexp, xval) ; 71 72 #else /* vax or tahoe */ 73 74 /* Hooray, we have an IEEE machine */ 75 # undef vccast 76 # define vc(name, value, x1,x2,x3,x4, bexp, xval) ; 77 78 # define ic(name, value, bexp, xval) \ 79 const static double name = value; 80 81 #endif /* defined(vax)||defined(tahoe) */ 82 83 84 /* 85 * Functions internal to the math package, yet not static. 86 */ 87 extern double exp__E(); 88 extern double log__L(); 89 90