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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9414
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
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
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
3
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
7 any later version.
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
8
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
12 GNU General Public License for more details.
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
13
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
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
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
16
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
17 /* Written by Ben Pfaff <blp@gnu.org>, 2007. */
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
18
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
19 #include <config.h>
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
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
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
23 #include "isnanl-nolibm.h"
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
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
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
38 int gl_isfinitef (float x)
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
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
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
41 }
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
42
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
43 int gl_isfinited (double x)
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
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
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
46 }
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
47
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
48 int gl_isfinitel (long double x)
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
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
1c5d0b856e8b Implement 'isfinite' module.
Ben Pfaff <blp@cs.stanford.edu>
parents:
diff changeset
51 }