Mercurial > hg > octave-kai > gnulib-hg
annotate lib/math.in.h @ 12421:e8d2c6fc33ad
Use spaces for indentation, not tabs.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 10 Dec 2009 20:28:30 +0100 |
parents | 5f5c1c77ef82 |
children | f7842310a565 |
rev | line source |
---|---|
9255 | 1 /* A GNU-like <math.h>. |
2 | |
11506
d800366aa3fe
Avoid link error when creating a namespace clean library.
Bruno Haible <bruno@clisp.org>
parents:
10836
diff
changeset
|
3 Copyright (C) 2002-2003, 2007-2009 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. */ |
11583
dc80f2cc1327
Second attempt to work around an AIX 5.3, 6.1 compiler bug with include_next.
Eric Blake <ebb9@byu.net>
parents:
11525
diff
changeset
|
25 #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ |
9255 | 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 |
11735
1dc493668d2b
Avoid syntax error on QNX.
Bruno Haible <bruno@clisp.org>
parents:
11583
diff
changeset
|
151 #if @GNULIB_MATHL@ || (!@HAVE_DECL_COSL@ && !defined cosl) |
11741
5f5c1c77ef82
Avoid compilation error on QNX.
Bruno Haible <bruno@clisp.org>
parents:
11735
diff
changeset
|
152 # undef cosl |
9255 | 153 extern long double cosl (long double x); |
154 #endif | |
155 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
156 # undef cosl | |
157 # define cosl(x) \ | |
158 (GL_LINK_WARNING ("cosl is unportable - " \ | |
159 "use gnulib module mathl for portability"), \ | |
160 cosl (x)) | |
161 #endif | |
162 | |
9285 | 163 |
9255 | 164 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@ |
165 extern long double expl (long double x); | |
166 #endif | |
167 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
168 # undef expl | |
169 # define expl(x) \ | |
170 (GL_LINK_WARNING ("expl is unportable - " \ | |
171 "use gnulib module mathl for portability"), \ | |
172 expl (x)) | |
173 #endif | |
174 | |
9285 | 175 |
9291 | 176 #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
|
177 # if @REPLACE_FLOORF@ |
9291 | 178 # define floorf rpl_floorf |
179 extern float floorf (float x); | |
180 # endif | |
181 #elif defined GNULIB_POSIXCHECK | |
182 # undef floorf | |
183 # define floorf(x) \ | |
184 (GL_LINK_WARNING ("floorf is unportable - " \ | |
185 "use gnulib module floorf for portability"), \ | |
186 floorf (x)) | |
187 #endif | |
188 | |
9293 | 189 #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
|
190 # if @REPLACE_FLOORL@ |
9293 | 191 # define floorl rpl_floorl |
9255 | 192 extern long double floorl (long double x); |
9293 | 193 # endif |
194 #elif defined GNULIB_POSIXCHECK | |
9255 | 195 # undef floorl |
196 # define floorl(x) \ | |
197 (GL_LINK_WARNING ("floorl is unportable - " \ | |
9293 | 198 "use gnulib module floorl for portability"), \ |
9255 | 199 floorl (x)) |
200 #endif | |
201 | |
9285 | 202 |
9255 | 203 /* Write x as |
204 x = mantissa * 2^exp | |
205 where | |
206 If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | |
207 If x is zero: mantissa = x, exp = 0. | |
208 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
|
209 Store exp in *EXPPTR and return mantissa. */ |
9255 | 210 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ |
211 # define frexpl rpl_frexpl | |
212 #endif | |
213 #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
|
214 extern long double frexpl (long double x, int *expptr); |
9255 | 215 #endif |
216 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK | |
217 # undef frexpl | |
218 # define frexpl(x,e) \ | |
219 (GL_LINK_WARNING ("frexpl is unportable - " \ | |
220 "use gnulib module frexpl for portability"), \ | |
221 frexpl (x, e)) | |
222 #endif | |
223 | |
9285 | 224 |
9255 | 225 /* Return x * 2^exp. */ |
226 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ | |
227 # define ldexpl rpl_ldexpl | |
228 #endif | |
229 #if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@ | |
230 extern long double ldexpl (long double x, int exp); | |
231 #endif | |
232 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK | |
233 # undef ldexpl | |
234 # define ldexpl(x,e) \ | |
235 (GL_LINK_WARNING ("ldexpl is unportable - " \ | |
236 "use gnulib module ldexpl for portability"), \ | |
237 ldexpl (x, e)) | |
238 #endif | |
239 | |
9285 | 240 |
11735
1dc493668d2b
Avoid syntax error on QNX.
Bruno Haible <bruno@clisp.org>
parents:
11583
diff
changeset
|
241 #if @GNULIB_MATHL@ || (!@HAVE_DECL_LOGL@ && !defined logl) |
11741
5f5c1c77ef82
Avoid compilation error on QNX.
Bruno Haible <bruno@clisp.org>
parents:
11735
diff
changeset
|
242 # undef logl |
9255 | 243 extern long double logl (long double x); |
244 #endif | |
245 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
246 # undef logl | |
247 # define logl(x) \ | |
248 (GL_LINK_WARNING ("logl is unportable - " \ | |
249 "use gnulib module mathl for portability"), \ | |
250 logl (x)) | |
251 #endif | |
252 | |
9285 | 253 |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
254 #if @GNULIB_ROUNDF@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
255 # 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
|
256 # undef roundf |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
257 # define roundf rpl_roundf |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
258 extern float roundf (float x); |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
259 # endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
260 #elif defined GNULIB_POSIXCHECK |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
261 # undef roundf |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
262 # define roundf(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
263 (GL_LINK_WARNING ("roundf is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
264 "use gnulib module roundf for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
265 roundf (x)) |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
266 #endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
267 |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
268 #if @GNULIB_ROUND@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
269 # 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
|
270 # undef round |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
271 # define round rpl_round |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
272 extern double round (double x); |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
273 # endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
274 #elif defined GNULIB_POSIXCHECK |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
275 # undef round |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
276 # define round(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
277 (GL_LINK_WARNING ("round is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
278 "use gnulib module round for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
279 round (x)) |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
280 #endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
281 |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
282 #if @GNULIB_ROUNDL@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
283 # 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
|
284 # undef roundl |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
285 # define roundl rpl_roundl |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
286 extern long double roundl (long double x); |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
287 # endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
288 #elif defined GNULIB_POSIXCHECK |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
289 # undef roundl |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
290 # define roundl(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
291 (GL_LINK_WARNING ("roundl is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
292 "use gnulib module roundl for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
293 roundl (x)) |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
294 #endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
295 |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
296 |
11735
1dc493668d2b
Avoid syntax error on QNX.
Bruno Haible <bruno@clisp.org>
parents:
11583
diff
changeset
|
297 #if @GNULIB_MATHL@ || (!@HAVE_DECL_SINL@ && !defined sinl) |
11741
5f5c1c77ef82
Avoid compilation error on QNX.
Bruno Haible <bruno@clisp.org>
parents:
11735
diff
changeset
|
298 # undef sinl |
9255 | 299 extern long double sinl (long double x); |
300 #endif | |
301 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
302 # undef sinl | |
303 # define sinl(x) \ | |
304 (GL_LINK_WARNING ("sinl is unportable - " \ | |
305 "use gnulib module mathl for portability"), \ | |
306 sinl (x)) | |
307 #endif | |
308 | |
9285 | 309 |
9255 | 310 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@ |
311 extern long double sqrtl (long double x); | |
312 #endif | |
313 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
314 # undef sqrtl | |
315 # define sqrtl(x) \ | |
316 (GL_LINK_WARNING ("sqrtl is unportable - " \ | |
317 "use gnulib module mathl for portability"), \ | |
318 sqrtl (x)) | |
319 #endif | |
320 | |
9285 | 321 |
9255 | 322 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@ |
323 extern long double tanl (long double x); | |
324 #endif | |
325 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
326 # undef tanl | |
327 # define tanl(x) \ | |
328 (GL_LINK_WARNING ("tanl is unportable - " \ | |
329 "use gnulib module mathl for portability"), \ | |
330 tanl (x)) | |
331 #endif | |
332 | |
9285 | 333 |
334 #if @GNULIB_TRUNCF@ | |
335 # if !@HAVE_DECL_TRUNCF@ | |
336 # define truncf rpl_truncf | |
337 extern float truncf (float x); | |
338 # endif | |
339 #elif defined GNULIB_POSIXCHECK | |
340 # undef truncf | |
341 # define truncf(x) \ | |
342 (GL_LINK_WARNING ("truncf is unportable - " \ | |
343 "use gnulib module truncf for portability"), \ | |
344 truncf (x)) | |
345 #endif | |
346 | |
9282 | 347 #if @GNULIB_TRUNC@ |
348 # if !@HAVE_DECL_TRUNC@ | |
349 # define trunc rpl_trunc | |
350 extern double trunc (double x); | |
351 # endif | |
352 #elif defined GNULIB_POSIXCHECK | |
353 # undef trunc | |
354 # define trunc(x) \ | |
355 (GL_LINK_WARNING ("trunc is unportable - " \ | |
356 "use gnulib module trunc for portability"), \ | |
357 trunc (x)) | |
358 #endif | |
359 | |
9287 | 360 #if @GNULIB_TRUNCL@ |
9913
d3f5a70dc1ba
Make truncl work on OSF/1 4.0.
Bruno Haible <bruno@clisp.org>
parents:
9898
diff
changeset
|
361 # if @REPLACE_TRUNCL@ |
d3f5a70dc1ba
Make truncl work on OSF/1 4.0.
Bruno Haible <bruno@clisp.org>
parents:
9898
diff
changeset
|
362 # undef truncl |
9287 | 363 # define truncl rpl_truncl |
364 extern long double truncl (long double x); | |
365 # endif | |
366 #elif defined GNULIB_POSIXCHECK | |
367 # undef truncl | |
368 # define truncl(x) \ | |
369 (GL_LINK_WARNING ("truncl is unportable - " \ | |
370 "use gnulib module truncl for portability"), \ | |
371 truncl (x)) | |
372 #endif | |
373 | |
9418
5e7b33ec70ff
Add/remove some blank lines.
Bruno Haible <bruno@clisp.org>
parents:
9414
diff
changeset
|
374 |
9414
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
375 #if @GNULIB_ISFINITE@ |
9423
fa47aa8bb105
Use REPLACE_ISFINITE instead of HAVE_DECL_ISFINITE.
Bruno Haible <bruno@clisp.org>
parents:
9420
diff
changeset
|
376 # if @REPLACE_ISFINITE@ |
9414
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
377 extern int gl_isfinitef (float x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
378 extern int gl_isfinited (double x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
379 extern int gl_isfinitel (long double x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
380 # undef isfinite |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
381 # define isfinite(x) \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
382 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
383 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
384 gl_isfinitef (x)) |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
385 # endif |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
386 #elif defined GNULIB_POSIXCHECK |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
387 /* How to override a macro? */ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
388 #endif |
9255 | 389 |
9418
5e7b33ec70ff
Add/remove some blank lines.
Bruno Haible <bruno@clisp.org>
parents:
9414
diff
changeset
|
390 |
10287 | 391 #if @GNULIB_ISINF@ |
392 # if @REPLACE_ISINF@ | |
393 extern int gl_isinff (float x); | |
394 extern int gl_isinfd (double x); | |
395 extern int gl_isinfl (long double x); | |
396 # undef isinf | |
397 # define isinf(x) \ | |
398 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ | |
399 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ | |
400 gl_isinff (x)) | |
401 # endif | |
402 #elif defined GNULIB_POSIXCHECK | |
403 /* How to override a macro? */ | |
404 #endif | |
405 | |
406 | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
407 #if @GNULIB_ISNANF@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
408 /* 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
|
409 # if @HAVE_ISNANF@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
410 /* 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
|
411 or (older) isnanf function. */ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
412 # include <math.h> |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
413 # if __GNUC__ >= 4 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
414 /* 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
|
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) __builtin_isnanf ((float)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
417 # elif defined isnan |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
418 # undef isnanf |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
419 # 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
|
420 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
421 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
422 /* 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
|
423 # undef isnanf |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
424 # define isnanf rpl_isnanf |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
425 extern int isnanf (float x); |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
426 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
427 #endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
428 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
429 #if @GNULIB_ISNAND@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
430 /* 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
|
431 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
|
432 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
|
433 # if @HAVE_ISNAND@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
434 /* 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
|
435 # include <math.h> |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
436 # if __GNUC__ >= 4 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
437 /* 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
|
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) __builtin_isnan ((double)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
440 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
441 # undef isnand |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
442 # 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
|
443 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
444 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
445 /* 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
|
446 # undef isnand |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
447 # define isnand rpl_isnand |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
448 extern int isnand (double x); |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
449 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
450 #endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
451 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
452 #if @GNULIB_ISNANL@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
453 /* 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
|
454 # if @HAVE_ISNANL@ |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
455 /* 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
|
456 # include <math.h> |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
457 # if __GNUC__ >= 4 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
458 /* 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
|
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) __builtin_isnanl ((long double)(x)) |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
461 # elif defined isnan |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
462 # undef isnanl |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
463 # 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
|
464 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
465 # else |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
466 /* 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
|
467 # undef isnanl |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
468 # define isnanl rpl_isnanl |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
469 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
|
470 # endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
471 #endif |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
472 |
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
473 /* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */ |
10267 | 474 #if @GNULIB_ISNAN@ |
475 # if @REPLACE_ISNAN@ | |
476 /* We can't just use the isnanf macro (e.g.) as exposed by | |
477 isnanf.h (e.g.) here, because those may end up being macros | |
478 that recursively expand back to isnan. So use the gnulib | |
479 replacements for them directly. */ | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
480 # if @HAVE_ISNANF@ && __GNUC__ >= 4 |
10267 | 481 # define gl_isnan_f(x) __builtin_isnan ((float)(x)) |
482 # else | |
483 extern int rpl_isnanf (float x); | |
484 # define gl_isnan_f(x) rpl_isnanf (x) | |
485 # endif | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
486 # if @HAVE_ISNAND@ && __GNUC__ >= 4 |
10267 | 487 # define gl_isnan_d(x) __builtin_isnan ((double)(x)) |
488 # else | |
489 extern int rpl_isnand (double x); | |
490 # define gl_isnan_d(x) rpl_isnand (x) | |
491 # endif | |
10667
678640901735
Move the isnanf(), isnand(), isnanl() declarations to <math.h>.
Bruno Haible <bruno@clisp.org>
parents:
10655
diff
changeset
|
492 # if @HAVE_ISNANL@ && __GNUC__ >= 4 |
10267 | 493 # define gl_isnan_l(x) __builtin_isnan ((long double)(x)) |
494 # else | |
495 extern int rpl_isnanl (long double x); | |
496 # define gl_isnan_l(x) rpl_isnanl (x) | |
497 # endif | |
498 # undef isnan | |
499 # define isnan(x) \ | |
500 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ | |
501 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ | |
502 gl_isnan_f (x)) | |
503 # endif | |
504 #elif defined GNULIB_POSIXCHECK | |
505 /* How to override a macro? */ | |
506 #endif | |
507 | |
508 | |
9255 | 509 #if @GNULIB_SIGNBIT@ |
9645
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
510 # if @REPLACE_SIGNBIT_USING_GCC@ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
511 # undef signbit |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
512 /* 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
|
513 # define signbit(x) \ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
514 (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
|
515 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
516 __builtin_signbitf (x)) |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
517 # endif |
9255 | 518 # if @REPLACE_SIGNBIT@ |
519 # undef signbit | |
520 extern int gl_signbitf (float arg); | |
521 extern int gl_signbitd (double arg); | |
522 extern int gl_signbitl (long double arg); | |
523 # if __GNUC__ >= 2 && !__STRICT_ANSI__ | |
11506
d800366aa3fe
Avoid link error when creating a namespace clean library.
Bruno Haible <bruno@clisp.org>
parents:
10836
diff
changeset
|
524 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf |
11525
0b09102d516e
Fix compilation error introduced on 2009-04-25.
Bruno Haible <bruno@clisp.org>
parents:
11506
diff
changeset
|
525 # define gl_signbitf_OPTIMIZED_MACRO |
9255 | 526 # define gl_signbitf(arg) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
527 ({ union { float _value; \ |
9255 | 528 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
529 } _m; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
530 _m._value = (arg); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
531 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ |
9255 | 532 }) |
533 # endif | |
11506
d800366aa3fe
Avoid link error when creating a namespace clean library.
Bruno Haible <bruno@clisp.org>
parents:
10836
diff
changeset
|
534 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd |
11525
0b09102d516e
Fix compilation error introduced on 2009-04-25.
Bruno Haible <bruno@clisp.org>
parents:
11506
diff
changeset
|
535 # define gl_signbitd_OPTIMIZED_MACRO |
9255 | 536 # define gl_signbitd(arg) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
537 ({ union { double _value; \ |
9255 | 538 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
539 } _m; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
540 _m._value = (arg); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
541 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ |
9255 | 542 }) |
543 # endif | |
11506
d800366aa3fe
Avoid link error when creating a namespace clean library.
Bruno Haible <bruno@clisp.org>
parents:
10836
diff
changeset
|
544 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl |
11525
0b09102d516e
Fix compilation error introduced on 2009-04-25.
Bruno Haible <bruno@clisp.org>
parents:
11506
diff
changeset
|
545 # define gl_signbitl_OPTIMIZED_MACRO |
9255 | 546 # define gl_signbitl(arg) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
547 ({ union { long double _value; \ |
9255 | 548 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
549 } _m; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
550 _m._value = (arg); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11741
diff
changeset
|
551 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ |
9255 | 552 }) |
553 # endif | |
554 # endif | |
555 # define signbit(x) \ | |
556 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ | |
557 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ | |
558 gl_signbitf (x)) | |
559 # endif | |
560 #elif defined GNULIB_POSIXCHECK | |
561 /* How to override a macro? */ | |
562 #endif | |
563 | |
564 | |
565 #ifdef __cplusplus | |
566 } | |
567 #endif | |
568 | |
569 #endif /* _GL_MATH_H */ | |
570 #endif /* _GL_MATH_H */ |