Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/values.h
+++ new/usr/src/head/values.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /* Copyright (c) 1988 AT&T */
23 23 /* All Rights Reserved */
24 24
25 25
26 26 /*
27 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28 + *
27 29 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 30 * Use is subject to license terms.
29 31 */
30 32
31 33 #ifndef _VALUES_H
32 34 #define _VALUES_H
33 35
34 -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.33 */
35 -
36 36 #include <sys/isa_defs.h>
37 37
38 38 #ifdef __cplusplus
39 39 extern "C" {
40 40 #endif
41 41
42 42 /*
43 43 * These values work with any binary representation of integers
44 44 * where the high-order bit contains the sign.
45 45 */
46 46
47 47 /* a number used normally for size of a shift */
48 48 #define BITSPERBYTE 8
49 49
50 50 #define BITS(type) (BITSPERBYTE * (long)sizeof (type))
51 51
52 52 /* short, regular and long ints with only the high-order bit turned on */
53 53 #define HIBITS ((short)(1 << (BITS(short) - 1)))
54 54
55 -#if defined(__STDC__)
56 -
57 55 #define HIBITI (1U << (BITS(int) - 1))
58 56 #define HIBITL (1UL << (BITS(long) - 1))
59 57
60 -#else
61 -
62 -#define HIBITI ((unsigned)1 << (BITS(int) - 1))
63 -#define HIBITL (1L << (BITS(long) - 1))
64 -
65 -#endif
66 -
67 58 /* largest short, regular and long int */
68 59 #define MAXSHORT ((short)~HIBITS)
69 60 #define MAXINT ((int)(~HIBITI))
70 61 #define MAXLONG ((long)(~HIBITL))
71 62
72 63 /*
73 64 * various values that describe the binary floating-point representation
74 65 * _EXPBASE - the exponent base
75 66 * DMAXEXP - the maximum exponent of a double (as returned by frexp())
76 67 * FMAXEXP - the maximum exponent of a float (as returned by frexp())
77 68 * DMINEXP - the minimum exponent of a double (as returned by frexp())
78 69 * FMINEXP - the minimum exponent of a float (as returned by frexp())
79 70 * MAXDOUBLE - the largest double
80 71 * ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
81 72 * MAXFLOAT - the largest float
82 73 * ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
83 74 * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1))
84 75 * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1))
85 76 * DSIGNIF - the number of significant bits in a double
86 77 * FSIGNIF - the number of significant bits in a float
87 78 * DMAXPOWTWO - the largest power of two exactly representable as a double
88 79 * FMAXPOWTWO - the largest power of two exactly representable as a float
89 80 * _IEEE - 1 if IEEE standard representation is used
90 81 * _DEXPLEN - the number of bits for the exponent of a double
91 82 * _FEXPLEN - the number of bits for the exponent of a float
92 83 * _HIDDENBIT - 1 if high-significance bit of mantissa is implicit
93 84 * LN_MAXDOUBLE - the natural log of the largest double -- log(MAXDOUBLE)
94 85 * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
95 86 * LN_MAXFLOAT - the natural log of the largest float -- log(MAXFLOAT)
96 87 * LN_MINFLOAT - the natural log of the smallest float -- log(MINFLOAT)
97 88 */
98 89
99 90 /*
100 91 * Currently, only IEEE-754 format is supported.
101 92 */
102 93 #if defined(_IEEE_754)
103 94 #define MAXDOUBLE 1.79769313486231570e+308
104 95 #define MAXFLOAT ((float)3.40282346638528860e+38)
105 96 #define MINDOUBLE 4.94065645841246544e-324
106 97 #define MINFLOAT ((float)1.40129846432481707e-45)
107 98 #define _IEEE 1
108 99 #define _DEXPLEN 11
109 100 #define _HIDDENBIT 1
110 101 #define _LENBASE 1
111 102 #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
112 103 #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
113 104 #else
114 105 /* #error is strictly ansi-C, but works as well as anything for K&R systems. */
115 106 #error "ISA not supported"
116 107 #endif
117 108
118 109 #define _EXPBASE (1 << _LENBASE)
119 110 #define _FEXPLEN 8
120 111 #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
121 112 #define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1)
122 113 #define DMAXPOWTWO ((double)(1 << (BITS(int) - 2)) * \
123 114 (1 << (DSIGNIF - BITS(int) + 1)))
124 115 #define FMAXPOWTWO ((float)(1 << (FSIGNIF - 1)))
125 116 #define DMAXEXP ((1 << (_DEXPLEN - 1)) - 1 + _IEEE)
126 117 #define FMAXEXP ((1 << (_FEXPLEN - 1)) - 1 + _IEEE)
127 118 #define LN_MAXDOUBLE (M_LN2 * DMAXEXP)
128 119 #define LN_MAXFLOAT (float)(M_LN2 * FMAXEXP)
129 120 #define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1))
130 121 #define LN_MINFLOAT (float)(M_LN2 * (FMINEXP - 1))
131 122 #define H_PREC (DSIGNIF % 2 ? (1 << DSIGNIF/2) * M_SQRT2 : 1 << DSIGNIF/2)
132 123 #define FH_PREC \
133 124 (float)(FSIGNIF % 2 ? (1 << FSIGNIF/2) * M_SQRT2 : 1 << FSIGNIF/2)
134 125 #define X_EPS (1.0/H_PREC)
135 126 #define FX_EPS (float)((float)1.0/FH_PREC)
136 127 #define X_PLOSS ((double)(int)(M_PI * H_PREC))
137 128 #define FX_PLOSS ((float)(int)(M_PI * FH_PREC))
138 129 #define X_TLOSS (M_PI * DMAXPOWTWO)
139 130 #define FX_TLOSS (float)(M_PI * FMAXPOWTWO)
140 131 #define M_LN2 0.69314718055994530942
141 132 #define M_PI 3.14159265358979323846
142 133 #define M_SQRT2 1.41421356237309504880
143 134 #define MAXBEXP DMAXEXP /* for backward compatibility */
144 135 #define MINBEXP DMINEXP /* for backward compatibility */
145 136 #define MAXPOWTWO DMAXPOWTWO /* for backward compatibility */
146 137
147 138 #ifdef __cplusplus
148 139 }
149 140 #endif
150 141
151 142 #endif /* _VALUES_H */
↓ open down ↓ |
75 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX