Mercurial > hg > octave-kai > gnulib-hg
annotate lib/math.in.h @ 9850:7f3ed6b093be
Guarantee a definition of NAN.
* lib/math.in.h (NAN): Define if missing.
* tests/test-math.c (main): Test it.
* doc/posix-headers/math.texi (math.h): Document this.
* lib/isnan.c (rpl_isnand): Use it.
* tests/test-ceilf1.c (NaN): Delete, and use NAN instead.
* tests/test-floorf1.c (NaN): Likewise.
* tests/test-frexp.c (NaN): Likewise.
* tests/test-isnand.c (NaN): Likewise.
* tests/test-isnanf.c (NaN): Likewise.
* tests/test-round1.c (NaN): Likewise.
* tests/test-roundf1.c (NaN): Likewise.
* tests/test-snprintf-posix.h (NaN): Likewise.
* tests/test-sprintf-posix.h (NaN): Likewise.
* tests/test-trunc1.c (NaN): Likewise.
* tests/test-truncf1.c (NaN): Likewise.
* tests/test-vasnprintf-posix.c (NaN): Likewise.
* tests/test-vasprintf-posix.c (NaN): Likewise.
* modules/isnand-nolibm (Depends-on): Add math.
* modules/isnanf-nolibm (Depends-on): Likewise.
* modules/isnanl (Depends-on): Likewise.
* modules/isnanl-nolibm (Depends-on): Likewise.
* modules/snprintf-posix-tests (Depends-on): Likewise.
* modules/sprintf-posix-tests (Depends-on): Likewise.
* modules/vsnprintf-posix-tests (Depends-on): Likewise.
* modules/vsprintf-posix-tests (Depends-on): Likewise.
* modules/vasnprintf-posix-tests (Depends-on): Likewise.
* modules/vasprintf-posix-tests (Depends-on): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Mon, 31 Mar 2008 20:56:25 -0600 |
parents | c8174371956e |
children | 02bfc9acab82 |
rev | line source |
---|---|
9255 | 1 /* A GNU-like <math.h>. |
2 | |
9850 | 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 | |
20 /* The include_next requires a split double-inclusion guard. */ | |
21 #@INCLUDE_NEXT@ @NEXT_MATH_H@ | |
22 | |
23 #ifndef _GL_MATH_H | |
24 #define _GL_MATH_H | |
25 | |
26 | |
27 /* The definition of GL_LINK_WARNING is copied here. */ | |
28 | |
29 | |
30 #ifdef __cplusplus | |
31 extern "C" { | |
32 #endif | |
33 | |
34 | |
9850 | 35 /* POSIX allows platforms that don't support NAN. But all major |
36 machines in the past 15 years have supported something close to | |
37 IEEE NaN, so we define this unconditionally. */ | |
38 #ifndef NAN | |
39 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ | |
40 # ifdef __DECC | |
41 static float | |
42 _NaN () | |
43 { | |
44 static float zero = 0.0f; | |
45 return zero / zero; | |
46 } | |
47 # define NAN (_NaN()) | |
48 # else | |
49 # define NAN (0.0f / 0.0f) | |
50 # endif | |
51 #endif | |
52 | |
9255 | 53 /* Write x as |
54 x = mantissa * 2^exp | |
55 where | |
56 If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | |
57 If x is zero: mantissa = x, exp = 0. | |
58 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
|
59 Store exp in *EXPPTR and return mantissa. */ |
9255 | 60 #if @GNULIB_FREXP@ |
61 # if @REPLACE_FREXP@ | |
62 # define frexp rpl_frexp | |
9312
bec01fc15c2f
Rename parameter 'exp' to 'expptr', to avoid gcc warnings.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
63 extern double frexp (double x, int *expptr); |
9255 | 64 # endif |
65 #elif defined GNULIB_POSIXCHECK | |
66 # undef frexp | |
67 # define frexp(x,e) \ | |
68 (GL_LINK_WARNING ("frexp is unportable - " \ | |
69 "use gnulib module frexp for portability"), \ | |
70 frexp (x, e)) | |
71 #endif | |
72 | |
73 | |
74 #if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@ | |
75 extern long double acosl (long double x); | |
76 #endif | |
77 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
78 # undef acosl | |
79 # define acosl(x) \ | |
80 (GL_LINK_WARNING ("acosl is unportable - " \ | |
81 "use gnulib module mathl for portability"), \ | |
82 acosl (x)) | |
83 #endif | |
84 | |
9285 | 85 |
9255 | 86 #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@ |
87 extern long double asinl (long double x); | |
88 #endif | |
89 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
90 # undef asinl | |
91 # define asinl(x) \ | |
92 (GL_LINK_WARNING ("asinl is unportable - " \ | |
93 "use gnulib module mathl for portability"), \ | |
94 asinl (x)) | |
95 #endif | |
96 | |
9285 | 97 |
9255 | 98 #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@ |
99 extern long double atanl (long double x); | |
100 #endif | |
101 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
102 # undef atanl | |
103 # define atanl(x) \ | |
104 (GL_LINK_WARNING ("atanl is unportable - " \ | |
105 "use gnulib module mathl for portability"), \ | |
106 atanl (x)) | |
107 #endif | |
108 | |
9285 | 109 |
9295 | 110 #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
|
111 # if @REPLACE_CEILF@ |
9295 | 112 # define ceilf rpl_ceilf |
113 extern float ceilf (float x); | |
114 # endif | |
115 #elif defined GNULIB_POSIXCHECK | |
116 # undef ceilf | |
117 # define ceilf(x) \ | |
118 (GL_LINK_WARNING ("ceilf is unportable - " \ | |
119 "use gnulib module ceilf for portability"), \ | |
120 ceilf (x)) | |
121 #endif | |
122 | |
9297 | 123 #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
|
124 # if @REPLACE_CEILL@ |
9297 | 125 # define ceill rpl_ceill |
9255 | 126 extern long double ceill (long double x); |
9297 | 127 # endif |
128 #elif defined GNULIB_POSIXCHECK | |
9255 | 129 # undef ceill |
130 # define ceill(x) \ | |
131 (GL_LINK_WARNING ("ceill is unportable - " \ | |
9297 | 132 "use gnulib module ceill for portability"), \ |
9255 | 133 ceill (x)) |
134 #endif | |
135 | |
9285 | 136 |
9255 | 137 #if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@ |
138 extern long double cosl (long double x); | |
139 #endif | |
140 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
141 # undef cosl | |
142 # define cosl(x) \ | |
143 (GL_LINK_WARNING ("cosl is unportable - " \ | |
144 "use gnulib module mathl for portability"), \ | |
145 cosl (x)) | |
146 #endif | |
147 | |
9285 | 148 |
9255 | 149 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@ |
150 extern long double expl (long double x); | |
151 #endif | |
152 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
153 # undef expl | |
154 # define expl(x) \ | |
155 (GL_LINK_WARNING ("expl is unportable - " \ | |
156 "use gnulib module mathl for portability"), \ | |
157 expl (x)) | |
158 #endif | |
159 | |
9285 | 160 |
9291 | 161 #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
|
162 # if @REPLACE_FLOORF@ |
9291 | 163 # define floorf rpl_floorf |
164 extern float floorf (float x); | |
165 # endif | |
166 #elif defined GNULIB_POSIXCHECK | |
167 # undef floorf | |
168 # define floorf(x) \ | |
169 (GL_LINK_WARNING ("floorf is unportable - " \ | |
170 "use gnulib module floorf for portability"), \ | |
171 floorf (x)) | |
172 #endif | |
173 | |
9293 | 174 #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
|
175 # if @REPLACE_FLOORL@ |
9293 | 176 # define floorl rpl_floorl |
9255 | 177 extern long double floorl (long double x); |
9293 | 178 # endif |
179 #elif defined GNULIB_POSIXCHECK | |
9255 | 180 # undef floorl |
181 # define floorl(x) \ | |
182 (GL_LINK_WARNING ("floorl is unportable - " \ | |
9293 | 183 "use gnulib module floorl for portability"), \ |
9255 | 184 floorl (x)) |
185 #endif | |
186 | |
9285 | 187 |
9255 | 188 /* Write x as |
189 x = mantissa * 2^exp | |
190 where | |
191 If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | |
192 If x is zero: mantissa = x, exp = 0. | |
193 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
|
194 Store exp in *EXPPTR and return mantissa. */ |
9255 | 195 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ |
196 # define frexpl rpl_frexpl | |
197 #endif | |
198 #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
|
199 extern long double frexpl (long double x, int *expptr); |
9255 | 200 #endif |
201 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK | |
202 # undef frexpl | |
203 # define frexpl(x,e) \ | |
204 (GL_LINK_WARNING ("frexpl is unportable - " \ | |
205 "use gnulib module frexpl for portability"), \ | |
206 frexpl (x, e)) | |
207 #endif | |
208 | |
9285 | 209 |
9255 | 210 /* Return x * 2^exp. */ |
211 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ | |
212 # define ldexpl rpl_ldexpl | |
213 #endif | |
214 #if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@ | |
215 extern long double ldexpl (long double x, int exp); | |
216 #endif | |
217 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK | |
218 # undef ldexpl | |
219 # define ldexpl(x,e) \ | |
220 (GL_LINK_WARNING ("ldexpl is unportable - " \ | |
221 "use gnulib module ldexpl for portability"), \ | |
222 ldexpl (x, e)) | |
223 #endif | |
224 | |
9285 | 225 |
9255 | 226 #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@ |
227 extern long double logl (long double x); | |
228 #endif | |
229 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
230 # undef logl | |
231 # define logl(x) \ | |
232 (GL_LINK_WARNING ("logl is unportable - " \ | |
233 "use gnulib module mathl for portability"), \ | |
234 logl (x)) | |
235 #endif | |
236 | |
9285 | 237 |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
238 #if @GNULIB_ROUNDF@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
239 # 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
|
240 # undef roundf |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
241 # define roundf rpl_roundf |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
242 extern float roundf (float x); |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
243 # endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
244 #elif defined GNULIB_POSIXCHECK |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
245 # undef roundf |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
246 # define roundf(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
247 (GL_LINK_WARNING ("roundf is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
248 "use gnulib module roundf for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
249 roundf (x)) |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
250 #endif |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
251 |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
252 #if @GNULIB_ROUND@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
253 # 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
|
254 # undef round |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
255 # define round rpl_round |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
256 extern double round (double 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 round |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
260 # define round(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
261 (GL_LINK_WARNING ("round is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
262 "use gnulib module round for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
263 round (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_ROUNDL@ |
9465
4a3319c82e39
Use REPLACE_ROUND instead of HAVE_DECL_ROUND.
Bruno Haible <bruno@clisp.org>
parents:
9423
diff
changeset
|
267 # 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
|
268 # undef roundl |
9375
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
269 # define roundl rpl_roundl |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
270 extern long double roundl (long 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 roundl |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
274 # define roundl(x) \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
275 (GL_LINK_WARNING ("roundl is unportable - " \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
276 "use gnulib module roundl for portability"), \ |
96fea5b2eb11
Implement 'round', 'roundf', 'roundl' modules.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9312
diff
changeset
|
277 roundl (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 |
9255 | 281 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@ |
282 extern long double sinl (long double x); | |
283 #endif | |
284 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
285 # undef sinl | |
286 # define sinl(x) \ | |
287 (GL_LINK_WARNING ("sinl is unportable - " \ | |
288 "use gnulib module mathl for portability"), \ | |
289 sinl (x)) | |
290 #endif | |
291 | |
9285 | 292 |
9255 | 293 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@ |
294 extern long double sqrtl (long double x); | |
295 #endif | |
296 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
297 # undef sqrtl | |
298 # define sqrtl(x) \ | |
299 (GL_LINK_WARNING ("sqrtl is unportable - " \ | |
300 "use gnulib module mathl for portability"), \ | |
301 sqrtl (x)) | |
302 #endif | |
303 | |
9285 | 304 |
9255 | 305 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@ |
306 extern long double tanl (long double x); | |
307 #endif | |
308 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | |
309 # undef tanl | |
310 # define tanl(x) \ | |
311 (GL_LINK_WARNING ("tanl is unportable - " \ | |
312 "use gnulib module mathl for portability"), \ | |
313 tanl (x)) | |
314 #endif | |
315 | |
9285 | 316 |
317 #if @GNULIB_TRUNCF@ | |
318 # if !@HAVE_DECL_TRUNCF@ | |
319 # define truncf rpl_truncf | |
320 extern float truncf (float x); | |
321 # endif | |
322 #elif defined GNULIB_POSIXCHECK | |
323 # undef truncf | |
324 # define truncf(x) \ | |
325 (GL_LINK_WARNING ("truncf is unportable - " \ | |
326 "use gnulib module truncf for portability"), \ | |
327 truncf (x)) | |
328 #endif | |
329 | |
9282 | 330 #if @GNULIB_TRUNC@ |
331 # if !@HAVE_DECL_TRUNC@ | |
332 # define trunc rpl_trunc | |
333 extern double trunc (double x); | |
334 # endif | |
335 #elif defined GNULIB_POSIXCHECK | |
336 # undef trunc | |
337 # define trunc(x) \ | |
338 (GL_LINK_WARNING ("trunc is unportable - " \ | |
339 "use gnulib module trunc for portability"), \ | |
340 trunc (x)) | |
341 #endif | |
342 | |
9287 | 343 #if @GNULIB_TRUNCL@ |
344 # if !@HAVE_DECL_TRUNCL@ | |
345 # define truncl rpl_truncl | |
346 extern long double truncl (long double x); | |
347 # endif | |
348 #elif defined GNULIB_POSIXCHECK | |
349 # undef truncl | |
350 # define truncl(x) \ | |
351 (GL_LINK_WARNING ("truncl is unportable - " \ | |
352 "use gnulib module truncl for portability"), \ | |
353 truncl (x)) | |
354 #endif | |
355 | |
9418
5e7b33ec70ff
Add/remove some blank lines.
Bruno Haible <bruno@clisp.org>
parents:
9414
diff
changeset
|
356 |
9414
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
357 #if @GNULIB_ISFINITE@ |
9423
fa47aa8bb105
Use REPLACE_ISFINITE instead of HAVE_DECL_ISFINITE.
Bruno Haible <bruno@clisp.org>
parents:
9420
diff
changeset
|
358 # if @REPLACE_ISFINITE@ |
9414
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
359 extern int gl_isfinitef (float x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
360 extern int gl_isfinited (double x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
361 extern int gl_isfinitel (long double x); |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
362 # undef isfinite |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
363 # define isfinite(x) \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
364 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
365 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
366 gl_isfinitef (x)) |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
367 # endif |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
368 #elif defined GNULIB_POSIXCHECK |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
369 /* How to override a macro? */ |
1c5d0b856e8b
Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9413
diff
changeset
|
370 #endif |
9255 | 371 |
9418
5e7b33ec70ff
Add/remove some blank lines.
Bruno Haible <bruno@clisp.org>
parents:
9414
diff
changeset
|
372 |
9255 | 373 #if @GNULIB_SIGNBIT@ |
9645
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
374 # if @REPLACE_SIGNBIT_USING_GCC@ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
375 # undef signbit |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
376 /* 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
|
377 # define signbit(x) \ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
378 (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
|
379 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
380 __builtin_signbitf (x)) |
c8174371956e
Exploit the __builtin_signbit GCC built-in.
Bruno Haible <bruno@clisp.org>
parents:
9465
diff
changeset
|
381 # endif |
9255 | 382 # if @REPLACE_SIGNBIT@ |
383 # undef signbit | |
384 extern int gl_signbitf (float arg); | |
385 extern int gl_signbitd (double arg); | |
386 extern int gl_signbitl (long double arg); | |
387 # if __GNUC__ >= 2 && !__STRICT_ANSI__ | |
388 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT | |
389 # define gl_signbitf(arg) \ | |
390 ({ union { float _value; \ | |
391 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | |
392 } _m; \ | |
393 _m._value = (arg); \ | |
394 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ | |
395 }) | |
396 # endif | |
397 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT | |
398 # define gl_signbitd(arg) \ | |
399 ({ union { double _value; \ | |
400 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | |
401 } _m; \ | |
402 _m._value = (arg); \ | |
403 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ | |
404 }) | |
405 # endif | |
406 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT | |
407 # define gl_signbitl(arg) \ | |
408 ({ union { long double _value; \ | |
409 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | |
410 } _m; \ | |
411 _m._value = (arg); \ | |
412 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ | |
413 }) | |
414 # endif | |
415 # endif | |
416 # define signbit(x) \ | |
417 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ | |
418 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ | |
419 gl_signbitf (x)) | |
420 # endif | |
421 #elif defined GNULIB_POSIXCHECK | |
422 /* How to override a macro? */ | |
423 #endif | |
424 | |
425 | |
426 #ifdef __cplusplus | |
427 } | |
428 #endif | |
429 | |
430 #endif /* _GL_MATH_H */ | |
431 #endif /* _GL_MATH_H */ |