Mercurial > hg > octave-kai > gnulib-hg
annotate lib/isfinite.c @ 17409:26a04e61f560
stdio: use __REDIRECT for fwrite, fwrite_unlocked
* lib/stdio.in.h (fwrite):
When working around bug 11959, use __REDIRECT rather than '#define
fwrite(...) ... fwrite (...) ...'. This is a more-targeted way to
fix the -Wunused-value issue with clang, and it works with GCC too.
Problem with targeting reported by Eric Blake in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00067.html>.
(fwrite_unlocked): Treat like fwrite. I ran into this issue while
debugging the fwrite issue.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 15 May 2013 15:52:42 -0700 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
9414 | 1 /* Test for finite value (zero, subnormal, or normal, and not infinite or NaN). |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16366
diff
changeset
|
2 Copyright (C) 2007-2013 Free Software Foundation, Inc. |
9414 | 3 |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License along | |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ |
9414 | 16 |
17 /* Written by Ben Pfaff <blp@gnu.org>, 2007. */ | |
18 | |
19 #include <config.h> | |
20 | |
10264
ebb7ea0c94e8
Rename isnand.h to isnand-nolibm.h, similarly for isnanf.h.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9646
diff
changeset
|
21 #include "isnanf-nolibm.h" |
ebb7ea0c94e8
Rename isnand.h to isnand-nolibm.h, similarly for isnanf.h.
Ben Pfaff <blp@cs.stanford.edu>
parents:
9646
diff
changeset
|
22 #include "isnand-nolibm.h" |
9414 | 23 #include "isnanl-nolibm.h" |
24 | |
14070
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
25 /* The "cc" compiler on HP-UX 11.11, when optimizing, simplifies the test |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
26 x - y == 0.0 to x == y, a simplification which is invalid when x and y |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
27 are Infinity. Disable this optimization. */ |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
28 #if defined __hpux && !defined __GNUC__ |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
29 static float zerof; |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
30 static double zerod; |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
31 static long double zerol; |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
32 #else |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
33 # define zerof 0.f |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
34 # define zerod 0. |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 # define zerol 0.L |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 #endif |
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 |
9414 | 38 int gl_isfinitef (float x) |
39 { | |
14070
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
40 return !isnanf (x) && x - x == zerof; |
9414 | 41 } |
42 | |
43 int gl_isfinited (double x) | |
44 { | |
14070
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
45 return !isnand (x) && x - x == zerod; |
9414 | 46 } |
47 | |
48 int gl_isfinitel (long double x) | |
49 { | |
14070
ca85283acd03
isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
50 return !isnanl (x) && x - x == zerol; |
9414 | 51 } |