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