Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/nan.h
+++ new/usr/src/head/nan.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 (c) 1996, by Sun Microsystems, Inc.
28 30 * All Rights Reserved
29 31 */
30 32
31 33 #ifndef _NAN_H
32 34 #define _NAN_H
33 35
34 -#pragma ident "%Z%%M% %I% %E% SMI"
35 -
36 36 /*
37 37 * Handling of Not_a_Number's (only in IEEE floating-point standard)
38 38 */
39 39
40 40 #include <sys/isa_defs.h>
41 41 #include <values.h>
42 42
43 43 #ifdef __cplusplus
44 44 extern "C" {
45 45 #endif
46 46
47 47 #if defined(_IEEE_754)
48 48 /*
49 49 * Structure order is endian dependent. Only the common variants of
50 50 * big and little endian are supported.
51 51 */
52 52
53 53 #if defined(_BIG_ENDIAN)
54 54
55 55 typedef union
56 56 {
57 57 struct
58 58 {
59 59 unsigned sign : 1;
60 60 unsigned exponent :11;
61 61 unsigned bits :20;
62 62 unsigned fraction_low :32;
63 63 } inf_parts;
64 64 struct
65 65 {
66 66 unsigned sign : 1;
67 67 unsigned exponent :11;
68 68 unsigned qnan_bit : 1;
69 69 unsigned bits :19;
70 70 unsigned fraction_low :32;
71 71 } nan_parts;
72 72 double d;
73 73
74 74 } dnan;
75 75
76 76 #else /* Must be _LITTLE_ENDIAN */
77 77
78 78 typedef union
79 79 {
80 80 struct {
81 81 unsigned fraction_low :32;
82 82 unsigned bits :20;
83 83 unsigned exponent :11;
84 84 unsigned sign : 1;
85 85 } inf_parts;
86 86 struct {
87 87 unsigned fraction_low :32;
88 88 unsigned bits :19;
89 89 unsigned qnan_bit : 1;
90 90 unsigned exponent :11;
91 91 unsigned sign : 1;
92 92 } nan_parts;
93 93 double d;
94 94 } dnan;
95 95
96 96 #endif /* Endian based selection */
97 97
98 98 /*
99 99 * IsNANorINF checks that exponent of double == 2047
100 100 * i.e. that number is a NaN or an infinity
101 101 */
102 102 #define IsNANorINF(X) (((dnan *)&(X))->nan_parts.exponent == 0x7ff)
103 103
104 104 /*
105 105 * IsINF must be used after IsNANorINF has checked the exponent
106 106 */
107 107 #define IsINF(X) (((dnan *)&(X))->inf_parts.bits == 0 && \
108 108 ((dnan *)&(X))->inf_parts.fraction_low == 0)
109 109
110 110 /*
111 111 * IsPosNAN and IsNegNAN can be used to check the sign of infinities too
112 112 */
↓ open down ↓ |
67 lines elided |
↑ open up ↑ |
113 113 #define IsPosNAN(X) (((dnan *)&(X))->nan_parts.sign == 0)
114 114
115 115 #define IsNegNAN(X) (((dnan *)&(X))->nan_parts.sign == 1)
116 116
117 117 /*
118 118 * GETNaNPC gets the leftmost 32 bits of the fraction part
119 119 */
120 120 #define GETNaNPC(dval) (((dnan *)&(dval))->inf_parts.bits << 12 | \
121 121 ((dnan *)&(dval))->nan_parts.fraction_low >> 20)
122 122
123 -#if defined(__STDC__)
124 123 #define KILLFPE() (void) _kill(_getpid(), 8)
125 -#else
126 -#define KILLFPE() (void) kill(getpid(), 8)
127 -#endif
128 124 #define NaN(X) (((dnan *)&(X))->nan_parts.exponent == 0x7ff)
129 125 #define KILLNaN(X) if (NaN(X)) KILLFPE()
130 126
131 127 #else /* defined(_IEEE_754) */
132 128 /* #error is strictly ansi-C, but works as well as anything for K&R systems. */
133 129 #error ISA not supported
134 130 #endif /* defined(_IEEE_754) */
135 131
136 132 #ifdef __cplusplus
137 133 }
138 134 #endif
139 135
140 136 #endif /* _NAN_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX