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