Mercurial > hg > octave-kai > gnulib-hg
annotate lib/math.in.h @ 10667:678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 19 Oct 2008 14:05:30 +0200 |
parents | 8668b19a7032 |
children | 08a197428e92 |
rev | line source |
---|---|
9255 | 1 /* A GNU-like <math.h>. |
2 | |
9898
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
3 Copyright (C) 2002-2003, 2007-2008 Free Software Foundation, Inc. |
9255 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9297
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
9255 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9297
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9297
diff
changeset
|
8 (at your option) any later version. |
9255 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9297
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
9255 | 17 |
18 #ifndef _GL_MATH_H | |
19 | |
10655
8668b19a7032
Avoid gcc warnings because of #pragma GCC system_header on older gcc.
Bruno Haible <bruno@clisp.org>
parents:
10375
diff
changeset
|
20 #if __GNUC__ >= 3 |
10375
f96e845fc36d
Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents:
10287
diff
changeset
|
21 @PRAGMA_SYSTEM_HEADER@ |
10655
8668b19a7032
Avoid gcc warnings because of #pragma GCC system_header on older gcc.
Bruno Haible <bruno@clisp.org>
parents:
10375
diff
changeset
|
22 #endif |
10375
f96e845fc36d
Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents:
10287
diff
changeset
|
23 |
9255 | 24 /* The include_next requires a split double-inclusion guard. */ |
25 #@INCLUDE_NEXT@ @NEXT_MATH_H@ | |
26 | |
27 #ifndef _GL_MATH_H | |
28 #define _GL_MATH_H | |
29 | |
30 | |
31 /* The definition of GL_LINK_WARNING is copied here. */ | |
32 | |
33 | |
34 #ifdef __cplusplus | |
35 extern "C" { | |
36 #endif | |
37 | |
38 | |
9850 | 39 /* POSIX allows platforms that don't support NAN. But all major |
40 machines in the past 15 years have supported something close to | |
9898
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
41 IEEE NaN, so we define this unconditionally. We also must define |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
42 it on platforms like Solaris 10, where NAN is present but defined |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
43 as a function pointer rather than a floating point constant. */ |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
44 #if !defined NAN || @REPLACE_NAN@ |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
45 # undef NAN |
9850 | 46 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ |
47 # ifdef __DECC | |
48 static float | |
49 _NaN () | |
50 { | |
51 static float zero = 0.0f; | |
52 return zero / zero; | |
53 } | |
54 # define NAN (_NaN()) | |
55 # else | |
56 # define NAN (0.0f / 0.0f) | |
57 # endif | |
58 #endif | |
59 | |
9898
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
60 /* Solaris 10 defines HUGE_VAL, but as a function pointer rather |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
61 than a floating point constant. */ |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
62 #if @REPLACE_HUGE_VAL@ |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
63 # undef HUGE_VAL |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
64 # define HUGE_VAL (1.0 / 0.0) |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
65 #endif |
02bfc9acab82
Work around Solaris 10 math.h bug.
Eric Blake <ebb9@byu.net>
parents:
9850
diff
changeset
|
66 |
9255 | 67 /* Write x as |
68 x = mantissa * 2^exp | |
69 where | |
70 If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | |
71 If x is zero: mantissa = x, exp = 0. | |
72 If x is infinite or NaN: mantissa = x, exp unspecified. | |
9312
bec01fc15c2f
Rename parameter 'exp' to 'expptr', to avoid gcc warnings.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
73 Store exp in *EXPPTR and return mantissa. */ |
9255 | 74 #if @GNULIB_FREXP@ |
75 # if @REPLACE_FREXP@ | |
76 # define frexp rpl_frexp | |
9312
bec01fc15c2f
Rename parameter 'exp' to 'expptr', to avoid gcc warnings.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
77 extern double frexp (double x, int *expptr); |
9255 | 78 # endif |
79 #elif defined GNULIB_POSIXCHECK | |
80 # undef frexp | |
81 # define frexp(x,e) \ | |
82 (GL_LINK_WARNING ("frexp is unportable - " \ | |
83 "use gnulib module frexp for portability"), \ | |
84 frexp (x, e)) | |
85 #endif | |
86 | |
87 | |
88 #if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@ | |
89 extern long double acosl (long double x); | |
90 #endif | |
91 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
92 # undef acosl | |
93 # define acosl(x) \ | |
94 (GL_LINK_WARNING ("acosl is unportable - " \ | |
95 "use gnulib module mathl for portability"), \ | |
96 acosl (x)) | |
97 #endif | |
98 | |
9285 | 99 |
9255 | 100 #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@ |
101 extern long double asinl (long double x); | |
102 #endif | |
103 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
104 # undef asinl | |
105 # define asinl(x) \ | |
106 (GL_LINK_WARNING ("asinl is unportable - " \ | |
107 "use gnulib module mathl for portability"), \ | |
108 asinl (x)) | |
109 #endif | |
110 | |
9285 | 111 |
9255 | 112 #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@ |
113 extern long double atanl (long double x); | |
114 #endif | |
115 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
116 # undef atanl | |
117 # define atanl(x) \ | |
118 (GL_LINK_WARNING ("atanl is unportable - " \ | |
119 "use gnulib module mathl for portability"), \ | |
120 atanl (x)) | |
121 #endif | |
122 | |
9285 | 123 |
9295 | 124 #if @GNULIB_CEILF@ |
9420
9e0484f26251
Fix link errors with Sun C 5.0 on Solaris 10.
Bruno Haible <bruno@clisp.org>
parents:
9418
diff
changeset
|
125 # if @REPLACE_CEILF@ |
9295 | 126 # define ceilf rpl_ceilf |
127 extern float ceilf (float x); | |
128 # endif | |
129 #elif defined GNULIB_POSIXCHECK | |
130 # undef ceilf | |
131 # define ceilf(x) \ | |
132 (GL_LINK_WARNING ("ceilf is unportable - " \ | |
133 "use gnulib module ceilf for portability"), \ | |
134 ceilf (x)) | |
135 #endif | |
136 | |
9297 | 137 #if @GNULIB_CEILL@ |
9420
9e0484f26251
Fix link errors with Sun C 5.0 on Solaris 10.
Bruno Haible <bruno@clisp.org>
parents:
9418
diff
changeset
|
138 # if @REPLACE_CEILL@ |
9297 | 139 # define ceill rpl_ceill |
9255 | 140 extern long double ceill (long double x); |
9297 | 141 # endif |
142 #elif defined GNULIB_POSIXCHECK | |
9255 | 143 # undef ceill |
144 # define ceill(x) \ | |
145 (GL_LINK_WARNING ("ceill is unportable - " \ | |
9297 | 146 "use gnulib module ceill for portability"), \ |
9255 | 147 ceill (x)) |
148 #endif | |
149 | |
9285 | 150 |
9255 | 151 #if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@ |
152 extern long double cosl (long double x); | |
153 #endif | |
154 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
155 # undef cosl | |
156 # define cosl(x) \ | |
157 (GL_LINK_WARNING ("cosl is unportable - " \ | |
158 "use gnulib module mathl for portability"), \ | |
159 cosl (x)) | |
160 #endif | |
161 | |
9285 | 162 |
9255 | 163 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@ |
164 extern long double expl (long double x); | |
165 #endif | |
166 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
167 # undef expl | |
168 # define expl(x) \ | |
169 (GL_LINK_WARNING ("expl is unportable - " \ | |
170 "use gnulib module mathl for portability"), \ | |
171 expl (x)) | |
172 #endif | |
173 | |
9285 | 174 |
9291 | 175 #if @GNULIB_FLOORF@ |
9420
9e0484f26251
Fix link errors with Sun C 5.0 on Solaris 10.
Bruno Haible <bruno@clisp.org>
parents:
9418
diff
changeset
|
176 # if @REPLACE_FLOORF@ |
9291 | 177 # define floorf rpl_floorf |
178 extern float floorf (float x); | |
179 # endif | |
180 #elif defined GNULIB_POSIXCHECK | |
181 # undef floorf | |
182 # define floorf(x) \ | |
183 (GL_LINK_WARNING ("floorf is unportable - " \ | |
184 "use gnulib module floorf for portability"), \ | |
185 floorf (x)) | |
186 #endif | |
187 | |
9293 | 188 #if @GNULIB_FLOORL@ |
9420
9e0484f26251
Fix link errors with Sun C 5.0 on Solaris 10.
Bruno Haible <bruno@clisp.org>
parents:
9418
diff
changeset
|
189 # if @REPLACE_FLOORL@ |
9293 | 190 # define floorl rpl_floorl |
9255 | 191 extern long double floorl (long double x); |
9293 | 192 # endif |
193 #elif defined GNULIB_POSIXCHECK | |
9255 | 194 # undef floorl |
195 # define floorl(x) \ | |
196 (GL_LINK_WARNING ("floorl is unportable - " \ | |
9293 | 197 "use gnulib module floorl for portability"), \ |
9255 | 198 floorl (x)) |
199 #endif | |
200 | |
9285 | 201 |
9255 | 202 /* Write x as |
203 x = mantissa * 2^exp | |
204 where | |
205 If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | |
206 If x is zero: mantissa = x, exp = 0. | |
207 If x is infinite or NaN: mantissa = x, exp unspecified. | |
9312
bec01fc15c2f
Rename parameter 'exp' to 'expptr', to avoid gcc warnings.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
208 Store exp in *EXPPTR and return mantissa. */ |
9255 | 209 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ |
210 # define frexpl rpl_frexpl | |
211 #endif | |
212 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@ | |
9312
bec01fc15c2f
Rename parameter 'exp' to 'expptr', to avoid gcc warnings.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
213 extern long double frexpl (long double x, int *expptr); |
9255 | 214 #endif |
215 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK | |
216 # undef frexpl | |
217 # define frexpl(x,e) \ | |
218 (GL_LINK_WARNING ("frexpl is unportable - " \ | |
219 "use gnulib module frexpl for portability"), \ | |
220 frexpl (x, e)) | |
221 #endif | |
222 | |
9285 | 223 |
9255 | 224 /* Return x * 2^exp. */ |
225 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ | |
226 # define ldexpl rpl_ldexpl | |
227 #endif | |
228 #if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@ | |
229 extern long double ldexpl (long double x, int exp); | |
230 #endif | |
231 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK | |
232 # undef ldexpl | |
233 # define ldexpl(x,e) \ | |
234 (GL_LINK_WARNING ("ldexpl is unportable - " \ | |
235 "use gnulib module ldexpl for portability"), \ | |
236 ldexpl (x, e)) | |
237 #endif | |
238 | |
9285 | 239 |
9255 | 240 #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@ |
241 extern long double logl (long double x); | |
242 #endif | |
243 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
244 # undef logl | |
245 # define logl(x) \ | |
246 (GL_LINK_WARNING ("logl is unportable - " \ | |
247 "use gnulib module mathl for portability"), \ | |
248 logl (x)) | |
249 #endif | |
250 | |
9285 | 251 |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
252 #if @GNULIB_ROUNDF@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
253 # if @REPLACE_ROUNDF@ |
9413
9572edc3cc57
Check whether round* exist in libraries, not just whether they are declared.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9375
diff
changeset
|
254 # undef roundf |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
255 # define roundf rpl_roundf |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
256 extern float roundf (float x); |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
257 # endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
258 #elif defined GNULIB_POSIXCHECK |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
259 # undef roundf |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
260 # define roundf(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
261 (GL_LINK_WARNING ("roundf is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
262 "use gnulib module roundf for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
263 roundf (x)) |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
264 #endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
265 |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
266 #if @GNULIB_ROUND@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
267 # if @REPLACE_ROUND@ |
9413
9572edc3cc57
Check whether round* exist in libraries, not just whether they are declared.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9375
diff
changeset
|
268 # undef round |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
269 # define round rpl_round |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
270 extern double round (double x); |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
271 # endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
272 #elif defined GNULIB_POSIXCHECK |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
273 # undef round |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
274 # define round(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
275 (GL_LINK_WARNING ("round is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
276 "use gnulib module round for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
277 round (x)) |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
278 #endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
279 |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
280 #if @GNULIB_ROUNDL@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
281 # if @REPLACE_ROUNDL@ |
9413
9572edc3cc57
Check whether round* exist in libraries, not just whether they are declared.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9375
diff
changeset
|
282 # undef roundl |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
283 # define roundl rpl_roundl |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
284 extern long double roundl (long double x); |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
285 # endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
286 #elif defined GNULIB_POSIXCHECK |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
287 # undef roundl |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
288 # define roundl(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
289 (GL_LINK_WARNING ("roundl is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
290 "use gnulib module roundl for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
291 roundl (x)) |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
292 #endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
293 |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
294 |
9255 | 295 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@ |
296 extern long double sinl (long double x); | |
297 #endif | |
298 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
299 # undef sinl | |
300 # define sinl(x) \ | |
301 (GL_LINK_WARNING ("sinl is unportable - " \ | |
302 "use gnulib module mathl for portability"), \ | |
303 sinl (x)) | |
304 #endif | |
305 | |
9285 | 306 |
9255 | 307 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@ |
308 extern long double sqrtl (long double x); | |
309 #endif | |
310 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
311 # undef sqrtl | |
312 # define sqrtl(x) \ | |
313 (GL_LINK_WARNING ("sqrtl is unportable - " \ | |
314 "use gnulib module mathl for portability"), \ | |
315 sqrtl (x)) | |
316 #endif | |
317 | |
9285 | 318 |
9255 | 319 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@ |
320 extern long double tanl (long double x); | |
321 #endif | |
322 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
323 # undef tanl | |
324 # define tanl(x) \ | |
325 (GL_LINK_WARNING ("tanl is unportable - " \ | |
326 "use gnulib module mathl for portability"), \ | |
327 tanl (x)) | |
328 #endif | |
329 | |
9285 | 330 |
331 #if @GNULIB_TRUNCF@ | |
332 # if !@HAVE_DECL_TRUNCF@ | |
333 # define truncf rpl_truncf | |
334 extern float truncf (float x); | |
335 # endif | |
336 #elif defined GNULIB_POSIXCHECK | |
337 # undef truncf | |
338 # define truncf(x) \ | |
339 (GL_LINK_WARNING ("truncf is unportable - " \ | |
340 "use gnulib module truncf for portability"), \ | |
341 truncf (x)) | |
342 #endif | |
343 | |
9282 | 344 #if @GNULIB_TRUNC@ |
345 # if !@HAVE_DECL_TRUNC@ | |
346 # define trunc rpl_trunc | |
347 extern double trunc (double x); | |
348 # endif | |
349 #elif defined GNULIB_POSIXCHECK | |
350 # undef trunc | |
351 # define trunc(x) \ | |
352 (GL_LINK_WARNING ("trunc is unportable - " \ | |
353 "use gnulib module trunc for portability"), \ | |
354 trunc (x)) | |
355 #endif | |
356 | |
9287 | 357 #if @GNULIB_TRUNCL@ |
9913
d3f5a70dc1ba
Make truncl work on OSF/1 4.0.
Bruno Haible <bruno@clisp.org>
parents:
9898
diff
changeset
|
358 # if @REPLACE_TRUNCL@ |
d3f5a70dc1ba
Make truncl work on OSF/1 4.0.
Bruno Haible <bruno@clisp.org>
parents:
9898
diff
changeset
|
359 # undef truncl |
9287 | 360 # define truncl rpl_truncl |
361 extern long double truncl (long double x); | |
362 # endif | |
363 #elif defined GNULIB_POSIXCHECK | |
364 # undef truncl | |
365 # define truncl(x) \ | |
366 (GL_LINK_WARNING ("truncl is unportable - " \ | |
367 "use gnulib module truncl for portability"), \ | |
368 truncl (x)) | |
369 #endif | |
370 | |
9418
5e7b33ec70ff
Add/remove some blank lines.
Bruno Haible <bruno@clisp.org>
parents:
9414
diff
changeset
|
371 |
9414
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
372 #if @GNULIB_ISFINITE@ |
9423
fa47aa8bb105
Use REPLACE_ISFINITE instead of HAVE_DECL_ISFINITE.
Bruno Haible <bruno@clisp.org>
parents:
9420
diff
changeset
|
373 # if @REPLACE_ISFINITE@ |
9414
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
374 extern int gl_isfinitef (float x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
375 extern int gl_isfinited (double x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
376 extern int gl_isfinitel (long double x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
377 # undef isfinite |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
378 # define isfinite(x) \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
379 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
380 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
381 gl_isfinitef (x)) |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
382 # endif |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
383 #elif defined GNULIB_POSIXCHECK |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
384 /* How to override a macro? */ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
385 #endif |
9255 | 386 |
9418
5e7b33ec70ff
Add/remove some blank lines.
Bruno Haible <bruno@clisp.org>
parents:
9414
diff
changeset
|
387 |
10287 | 388 #if @GNULIB_ISINF@ |
389 # if @REPLACE_ISINF@ | |
390 extern int gl_isinff (float x); | |
391 extern int gl_isinfd (double x); | |
392 extern int gl_isinfl (long double x); | |
393 # undef isinf | |
394 # define isinf(x) \ | |
395 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ | |
396 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ | |
397 gl_isinff (x)) | |
398 # endif | |
399 #elif defined GNULIB_POSIXCHECK | |
400 /* How to override a macro? */ | |
401 #endif | |
402 | |
403 | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
404 #if @GNULIB_ISNANF@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
405 /* Test for NaN for 'float' numbers. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
406 # if @HAVE_ISNANF@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
407 /* The original <math.h> included above provides a declaration of isnan macro |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
408 or (older) isnanf function. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
409 # include <math.h> |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
410 # if __GNUC__ >= 4 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
411 /* GCC 4.0 and newer provides three built-ins for isnan. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
412 # undef isnanf |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
413 # define isnanf(x) __builtin_isnanf ((float)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
414 # elif defined isnan |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
415 # undef isnanf |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
416 # define isnanf(x) isnan ((float)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
417 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
418 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
419 /* Test whether X is a NaN. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
420 # undef isnanf |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
421 # define isnanf rpl_isnanf |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
422 extern int isnanf (float x); |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
423 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
424 #endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
425 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
426 #if @GNULIB_ISNAND@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
427 /* Test for NaN for 'double' numbers. |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
428 This function is a gnulib extension, unlike isnan() which applied only |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
429 to 'double' numbers earlier but now is a type-generic macro. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
430 # if @HAVE_ISNAND@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
431 /* The original <math.h> included above provides a declaration of isnan macro. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
432 # include <math.h> |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
433 # if __GNUC__ >= 4 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
434 /* GCC 4.0 and newer provides three built-ins for isnan. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
435 # undef isnand |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
436 # define isnand(x) __builtin_isnan ((double)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
437 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
438 # undef isnand |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
439 # define isnand(x) isnan ((double)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
440 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
441 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
442 /* Test whether X is a NaN. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
443 # undef isnand |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
444 # define isnand rpl_isnand |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
445 extern int isnand (double x); |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
446 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
447 #endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
448 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
449 #if @GNULIB_ISNANL@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
450 /* Test for NaN for 'long double' numbers. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
451 # if @HAVE_ISNANL@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
452 /* The original <math.h> included above provides a declaration of isnan macro or (older) isnanl function. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
453 # include <math.h> |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
454 # if __GNUC__ >= 4 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
455 /* GCC 4.0 and newer provides three built-ins for isnan. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
456 # undef isnanl |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
457 # define isnanl(x) __builtin_isnanl ((long double)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
458 # elif defined isnan |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
459 # undef isnanl |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
460 # define isnanl(x) isnan ((long double)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
461 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
462 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
463 /* Test whether X is a NaN. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
464 # undef isnanl |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
465 # define isnanl rpl_isnanl |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
466 extern int isnanl (long double x); |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
467 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
468 #endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
469 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
470 /* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */ |
10267 | 471 #if @GNULIB_ISNAN@ |
472 # if @REPLACE_ISNAN@ | |
473 /* We can't just use the isnanf macro (e.g.) as exposed by | |
474 isnanf.h (e.g.) here, because those may end up being macros | |
475 that recursively expand back to isnan. So use the gnulib | |
476 replacements for them directly. */ | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
477 # if @HAVE_ISNANF@ && __GNUC__ >= 4 |
10267 | 478 # define gl_isnan_f(x) __builtin_isnan ((float)(x)) |
479 # else | |
480 extern int rpl_isnanf (float x); | |
481 # define gl_isnan_f(x) rpl_isnanf (x) | |
482 # endif | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
483 # if @HAVE_ISNAND@ && __GNUC__ >= 4 |
10267 | 484 # define gl_isnan_d(x) __builtin_isnan ((double)(x)) |
485 # else | |
486 extern int rpl_isnand (double x); | |
487 # define gl_isnan_d(x) rpl_isnand (x) | |
488 # endif | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
489 # if @HAVE_ISNANL@ && __GNUC__ >= 4 |
10267 | 490 # define gl_isnan_l(x) __builtin_isnan ((long double)(x)) |
491 # else | |
492 extern int rpl_isnanl (long double x); | |
493 # define gl_isnan_l(x) rpl_isnanl (x) | |
494 # endif | |
495 # undef isnan | |
496 # define isnan(x) \ | |
497 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ | |
498 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ | |
499 gl_isnan_f (x)) | |
500 # endif | |
501 #elif defined GNULIB_POSIXCHECK | |
502 /* How to override a macro? */ | |
503 #endif | |
504 | |
505 | |
9255 | 506 #if @GNULIB_SIGNBIT@ |
9645
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
507 # if @REPLACE_SIGNBIT_USING_GCC@ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
508 # undef signbit |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
509 /* GCC 4.0 and newer provides three built-ins for signbit. */ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
510 # define signbit(x) \ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
511 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
512 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
513 __builtin_signbitf (x)) |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
514 # endif |
9255 | 515 # if @REPLACE_SIGNBIT@ |
516 # undef signbit | |
517 extern int gl_signbitf (float arg); | |
518 extern int gl_signbitd (double arg); | |
519 extern int gl_signbitl (long double arg); | |
520 # if __GNUC__ >= 2 && !__STRICT_ANSI__ | |
521 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT | |
522 # define gl_signbitf(arg) \ | |
523 ({ union { float _value; \ | |
524 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | |
525 } _m; \ | |
526 _m._value = (arg); \ | |
527 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ | |
528 }) | |
529 # endif | |
530 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT | |
531 # define gl_signbitd(arg) \ | |
532 ({ union { double _value; \ | |
533 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | |
534 } _m; \ | |
535 _m._value = (arg); \ | |
536 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ | |
537 }) | |
538 # endif | |
539 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT | |
540 # define gl_signbitl(arg) \ | |
541 ({ union { long double _value; \ | |
542 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | |
543 } _m; \ | |
544 _m._value = (arg); \ | |
545 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ | |
546 }) | |
547 # endif | |
548 # endif | |
549 # define signbit(x) \ | |
550 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ | |
551 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ | |
552 gl_signbitf (x)) | |
553 # endif | |
554 #elif defined GNULIB_POSIXCHECK | |
555 /* How to override a macro? */ | |
556 #endif | |
557 | |
558 | |
559 #ifdef __cplusplus | |
560 } | |
561 #endif | |
562 | |
563 #endif /* _GL_MATH_H */ | |
564 #endif /* _GL_MATH_H */ |