mathimpl.h revision 1.7 1 /* $NetBSD: mathimpl.h,v 1.7 2003/08/07 16:44:49 agc Exp $ */
2 /*
3 * Copyright (c) 1988, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93
31 */
32 #ifndef _NOIEEE_SRC_MATHIMPL_H_
33 #define _NOIEEE_SRC_MATHIMPL_H_
34
35 #include <sys/cdefs.h>
36 #include <math.h>
37
38 #if defined(__vax__)||defined(tahoe)
39
40 /* Deal with different ways to concatenate in cpp */
41 #define cat3(a,b,c) a ## b ## c
42
43 /* Deal with vax/tahoe byte order issues */
44 # ifdef __vax__
45 # define cat3t(a,b,c) cat3(a,b,c)
46 # else
47 # define cat3t(a,b,c) cat3(a,c,b)
48 # endif
49
50 # define vccast(name) (*(const double *)(cat3(__,name,x)))
51
52 /*
53 * Define a constant to high precision on a Vax or Tahoe.
54 *
55 * Args are the name to define, the decimal floating point value,
56 * four 16-bit chunks of the float value in hex
57 * (because the vax and tahoe differ in float format!), the power
58 * of 2 of the hex-float exponent, and the hex-float mantissa.
59 * Most of these arguments are not used at compile time; they are
60 * used in a post-check to make sure the constants were compiled
61 * correctly.
62 *
63 * People who want to use the constant will have to do their own
64 * #define foo vccast(foo)
65 * since CPP cannot do this for them from inside another macro (sigh).
66 * We define "vccast" if this needs doing.
67 */
68 #ifdef _LIBM_DECLARE
69 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \
70 const long cat3(__,name,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
71 #elif defined(_LIBM_STATIC)
72 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \
73 static const long cat3(__,name,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
74 #else
75 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \
76 extern const long cat3(__,name,x)[];
77 #endif
78 # define ic(name, value, bexp, xval) ;
79
80 #else /* __vax__ or tahoe */
81
82 /* Hooray, we have an IEEE machine */
83 # undef vccast
84 # define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
85
86 #ifdef _LIBM_DECLARE
87 # define ic(name, value, bexp, xval) \
88 const double __CONCAT(__,name) = value;
89 #elif _LIBM_STATIC
90 # define ic(name, value, bexp, xval) \
91 static const double __CONCAT(__,name) = value;
92 #else
93 # define ic(name, value, bexp, xval) \
94 extern const double __CONCAT(__,name);
95 #endif
96
97 #endif /* defined(__vax__)||defined(tahoe) */
98
99
100 /*
101 * Functions internal to the math package, yet not static.
102 */
103 extern double __exp__E(double, double);
104 extern double __log__L(double);
105 extern int infnan(int);
106
107 struct Double {double a, b;};
108 double __exp__D(double, double);
109 struct Double __log__D(double);
110
111 #endif /* _NOIEEE_SRC_MATHIMPL_H_ */
112