Remove building with NOCRYPTO option
[minix3.git] / lib / libm / noieee_src / mathimpl.h
blobd716f1591e1b0a131898ac06a616d6e9c306c4e9
1 /* $NetBSD: mathimpl.h,v 1.10 2011/11/02 02:34:56 christos Exp $ */
2 /*
3 * Copyright (c) 1988, 1993
4 * The Regents of the University of California. All rights reserved.
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.
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.
30 * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93
32 #ifndef _NOIEEE_SRC_MATHIMPL_H_
33 #define _NOIEEE_SRC_MATHIMPL_H_
35 #include <sys/cdefs.h>
36 #include <math.h>
37 #include <stdint.h>
39 #if defined(__vax__) || defined(tahoe)
41 /* Deal with different ways to concatenate in cpp */
42 #define cat3(a,b,c) a ## b ## c
44 /* Deal with vax/tahoe byte order issues */
45 # ifdef __vax__
46 # define cat3t(a,b,c) cat3(a,b,c)
47 # else
48 # define cat3t(a,b,c) cat3(a,c,b)
49 # endif
51 # define vccast(name) (cat3(__,name,x).d)
54 * Define a constant to high precision on a Vax or Tahoe.
56 * Args are the name to define, the decimal floating point value,
57 * four 16-bit chunks of the float value in hex
58 * (because the vax and tahoe differ in float format!), the power
59 * of 2 of the hex-float exponent, and the hex-float mantissa.
60 * Most of these arguments are not used at compile time; they are
61 * used in a post-check to make sure the constants were compiled
62 * correctly.
64 * People who want to use the constant will have to do their own
65 * #define foo vccast(foo)
66 * since CPP cannot do this for them from inside another macro (sigh).
67 * We define "vccast" if this needs doing.
69 #ifdef _LIBM_DECLARE
70 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \
71 const union { uint32_t l[2]; double d; } cat3(__,name,x) = { \
72 .l = { [0] = cat3t(0x,x1,x2), [1] = cat3t(0x,x3,x4) } };
73 #elif defined(_LIBM_STATIC)
74 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \
75 static const union { uint32_t l[2]; double d; } cat3(__,name,x) = { \
76 .l = { [0] = cat3t(0x,x1,x2), [1] = cat3t(0x,x3,x4) } };
77 #else
78 # define vc(name, value, x1,x2,x3,x4, bexp, xval) \
79 extern const union { uint32_t l[2]; double d; } cat3(__,name,x);
80 #endif
81 # define ic(name, value, bexp, xval)
83 #else /* __vax__ or tahoe */
85 /* Hooray, we have an IEEE machine */
86 # undef vccast
87 # define vc(name, value, x1,x2,x3,x4, bexp, xval)
89 #ifdef _LIBM_DECLARE
90 # define ic(name, value, bexp, xval) \
91 const double __CONCAT(__,name) = value;
92 #elif _LIBM_STATIC
93 # define ic(name, value, bexp, xval) \
94 static const double __CONCAT(__,name) = value;
95 #else
96 # define ic(name, value, bexp, xval) \
97 extern const double __CONCAT(__,name);
98 #endif
100 #endif /* defined(__vax__)||defined(tahoe) */
102 #ifdef __vax__
103 #include <machine/float.h>
104 #define _TINY DBL_EPSILON
105 #define _TINYER DBL_EPSILON
106 #define _HUGE DBL_MAX
107 #else
108 #define _TINY 1e-300
109 #define _TINYER 1e-308
110 #define _HUGE 1e+300
111 #endif
115 * Functions internal to the math package, yet not static.
117 extern double __exp__E(double, double);
118 extern double __log__L(double);
119 extern int infnan(int);
121 struct Double {double a, b;};
122 double __exp__D(double, double);
123 struct Double __log__D(double);
125 #endif /* _NOIEEE_SRC_MATHIMPL_H_ */