|
|
1.1 root 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: (1) source distributions retain this entire copyright
7: * notice and comment, and (2) distributions including binaries display
8: * the following acknowledgement: ``This product includes software
9: * developed by the University of California, Berkeley and its contributors''
10: * in the documentation or other materials provided with the distribution
11: * and in all advertising materials mentioning features or use of this
12: * software. Neither the name of the University nor the names of its
13: * contributors may be used to endorse or promote products derived
14: * from this software without specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: *
19: * All recipients should regard themselves as participants in an ongoing
20: * research project and hence should feel obligated to report their
21: * experiences (good or bad) with these elementary function codes, using
22: * the sendbug(8) program, to the authors.
23: *
24: * @(#)mathimpl.h 5.2 (Berkeley) 6/1/90
25: */
26:
27: #include <math.h>
28:
29: #ifdef __STDC__
30: #define const const
31: #else
32: #define const /**/
33: #endif
34:
35: #if defined(vax)||defined(tahoe)
36:
37: /* Deal with different ways to concatenate in cpp */
38: # ifdef __STDC__
39: # define cat3(a,b,c) a ## b ## c
40: # else
41: # define cat3(a,b,c) a/**/b/**/c
42: # endif
43:
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
50:
51: # define vccast(name) (*(const double *)(cat3(name,,x)))
52:
53: /*
54: * Define a constant to high precision on a Vax or Tahoe.
55: *
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.
63: *
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.
68: */
69: # define vc(name, value, x1,x2,x3,x4, bexp, xval) \
70: const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
71:
72: # define ic(name, value, bexp, xval) ;
73:
74: #else /* vax or tahoe */
75:
76: /* Hooray, we have an IEEE machine */
77: # undef vccast
78: # define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
79:
80: # define ic(name, value, bexp, xval) \
81: const static double name = value;
82:
83: #endif /* defined(vax)||defined(tahoe) */
84:
85:
86: /*
87: * Functions internal to the math package, yet not static.
88: */
89: extern double exp__E();
90: extern double log__L();
91:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.