annotate tests/infinity.h @ 40231:9b3c79fdfe0b

strtod: fix clash with strtold Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). * lib/strtod.c (compute_minus_zero, minus_zero): Simplify by remving the macro / external variable, and having just a function. User changed. This avoids the need for an external variable that might clash.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 11 Mar 2019 16:40:29 -0700
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Macros for infinity.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18685
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 /* Infinityf () returns a 'float' +Infinity. */
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
18372
d9961cf477d9 maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents: 18189
diff changeset
20 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f.
18685
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
21 The IBM XL C compiler on z/OS complains.
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
22 PGI 16.10 complains. */
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
23 #if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 static float
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 Infinityf ()
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 {
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 static float zero = 0.0f;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 return 1.0f / zero;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 }
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #else
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 # define Infinityf() (1.0f / 0.0f)
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #endif
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 /* Infinityd () returns a 'double' +Infinity. */
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36
18372
d9961cf477d9 maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents: 18189
diff changeset
37 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0.
18685
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
38 The IBM XL C compiler on z/OS complains.
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
39 PGI 16.10 complains. */
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
40 #if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 static double
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 Infinityd ()
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 {
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 static double zero = 0.0;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 return 1.0 / zero;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 }
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 #else
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 # define Infinityd() (1.0 / 0.0)
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 #endif
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 /* Infinityl () returns a 'long double' +Infinity. */
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53
18372
d9961cf477d9 maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents: 18189
diff changeset
54 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L.
18685
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
55 The IBM XL C compiler on z/OS complains.
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
56 PGI 16.10 complains. */
8560b803035e Port to PGI 16.10 x86-64
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
57 #if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI
18372
d9961cf477d9 maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents: 18189
diff changeset
58 static long double
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 Infinityl ()
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 {
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 static long double zero = 0.0L;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 return 1.0L / zero;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 }
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 #else
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 # define Infinityl() (1.0L / 0.0L)
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 #endif