annotate tests/infinity.h @ 15595:328819af1c02

Support for MSVC compiler: Avoid division by a literal 0. * lib/math.in.h (NAN): Define through a function call also on MSVC. * m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Divide by 'zero' instead of 0.0. * m4/printf.m4 (gl_PRINTF_INFINITE, gl_PRINTF_DIRECTIVE_A, gl_PRINTF_DIRECTIVE_F, gl_PRINTF_FLAG_ZERO): Likewise. (gl_PRINTF_INFINITE_LONG_DOUBLE): Divide by 'zeroL' instead of 0.0L. * tests/infinity.h: New file. * tests/nan.h (NaNf, NaNd, NaNl): Define through a function call also on MSVC. * tests/test-ceilf1.c: Include infinity.h. (main): Use Infinityf. * tests/test-ceil1.c: Include infinity.h. (main): Use Infinityd. * tests/test-ceill.c: Include infinity.h. (main): Use Infinityl. * tests/test-dprintf-posix.c: Include infinity.h. (test_function): Use Infinityd. * tests/test-floorf1.c: Include infinity.h. (main): Use Infinityf. * tests/test-floor1.c: Include infinity.h. (main): Use Infinityd. * tests/test-floorl.c: Include infinity.h. (main): Use Infinityl. * tests/test-fprintf-posix.c: Include infinity.h. (test_function): Use Infinityd. * tests/test-frexp.c: Include infinity.h. (main): Use Infinityd. * tests/test-frexpl.c: Include infinity.h. (main): Use Infinityl. * tests/test-isfinite.c: Include infinity.h. (test_isfinitef): Use Infinityf. (test_isfinited): Use Infinityd. (test_isfinitel): Use Infinityl. * tests/test-isinf.c: Include infinity.h. (test_isinff): Use Infinityf. (test_isinfd): Use Infinityd. (test_isinfl): Use Infinityl. * tests/test-isnan.c: Include infinity.h. (test_float): Use Infinityf. (test_double): Use Infinityd. (test_long_double): Use Infinityl. * tests/test-isnanf.h: Include infinity.h. (main): Use Infinityf. * tests/test-isnand.h: Include infinity.h. (main): Use Infinityd. * tests/test-isnanl.h: Include infinity.h. (main): Use Infinityl. * tests/test-ldexpl.c: Include infinity.h. (main): Use Infinityl. * tests/test-printf-posix.h: Include infinity.h. (test_function): Use Infinityd. * tests/test-roundf1.c: Include infinity.h. (main): Use Infinityf. * tests/test-round1.c: Include infinity.h. (main): Use Infinityd. * tests/test-roundl.c: Include infinity.h. (main): Use Infinityl. * tests/test-signbit.c: Include infinity.h. (test_signbitf): Use Infinityf. (test_signbitd): Use Infinityd. (test_signbitl): Use Infinityl. * tests/test-snprintf-posix.h: Include infinity.h. (test_function): Use Infinityd, Infinityl. * tests/test-sprintf-posix.h: Include infinity.h. (test_function): Use Infinityd, Infinityl. * tests/test-truncf1.c: Include infinity.h. (main): Use Infinityf. * tests/test-trunc1.c: Include infinity.h. (main): Use Infinityd. * tests/test-truncl.c: Include infinity.h. (main): Use Infinityl. * tests/test-vasnprintf-posix.c: Include infinity.h. (test_function): Use Infinityd, Infinityl. * tests/test-vasprintf-posix.c: Include infinity.h. (test_function): Use Infinityd, Infinityl. * modules/ceilf-tests (Files): Add tests/infinity.h. * modules/ceil-tests (Files): Likewise. * modules/ceill-tests (Files): Likewise. * modules/dprintf-posix-tests (Files): Likewise. * modules/floorf-tests (Files): Likewise. * modules/floor-tests (Files): Likewise. * modules/floorl-tests (Files): Likewise. * modules/fprintf-posix-tests (Files): Likewise. * modules/frexp-tests (Files): Likewise. * modules/frexp-nolibm-tests (Files): Likewise. * modules/frexpl-tests (Files): Likewise. * modules/frexpl-nolibm-tests (Files): Likewise. * modules/isfinite-tests (Files): Likewise. * modules/isinf-tests (Files): Likewise. * modules/isnan-tests (Files): Likewise. * modules/isnanf-tests (Files): Likewise. * modules/isnanf-nolibm-tests (Files): Likewise. * modules/isnand-tests (Files): Likewise. * modules/isnand-nolibm-tests (Files): Likewise. * modules/isnanl-tests (Files): Likewise. * modules/isnanl-nolibm-tests (Files): Likewise. * modules/ldexpl-tests (Files): Likewise. * modules/printf-posix-tests (Files): Likewise. * modules/roundf-tests (Files): Likewise. * modules/round-tests (Files): Likewise. * modules/roundl-tests (Files): Likewise. * modules/signbit-tests (Files): Likewise. * modules/snprintf-posix-tests (Files): Likewise. * modules/sprintf-posix-tests (Files): Likewise. * modules/truncf-tests (Files): Likewise. * modules/trunc-tests (Files): Likewise. * modules/truncl-tests (Files): Likewise. * modules/vasnprintf-posix-tests (Files): Likewise. * modules/vasprintf-posix-tests (Files): Likewise. * modules/vdprintf-posix-tests (Files): Likewise. * modules/vfprintf-posix-tests (Files): Likewise. * modules/vprintf-posix-tests (Files): Likewise. * modules/vsnprintf-posix-tests (Files): Likewise. * modules/vsprintf-posix-tests (Files): Likewise. * modules/xprintf-posix-tests (Files): Likewise.
author Bruno Haible <bruno@clisp.org>
date Sun, 11 Sep 2011 17:29:11 +0200
parents
children 8250f2777afc
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.
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 Copyright (C) 2011 Free Software Foundation, Inc.
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
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
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
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #if defined _MSC_VER
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 static float
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 Infinityf ()
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 {
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 static float zero = 0.0f;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 return 1.0f / zero;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 }
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #else
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 # 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
30 #endif
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 /* Infinityd () returns a 'double' +Infinity. */
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 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 #if defined _MSC_VER
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 static double
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 Infinityd ()
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 {
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 static double zero = 0.0;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 return 1.0 / zero;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 }
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 #else
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 # 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
45 #endif
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
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 /* 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
49
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 #if defined _MSC_VER
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 static double
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 Infinityl ()
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 {
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 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
56 return 1.0L / zero;
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 }
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 #else
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 # 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
60 #endif