Commit cf00d491 authored by Bruno Haible's avatar Bruno Haible

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.
parent 0b88a15d
2011-09-11 Bruno Haible <bruno@clisp.org>
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.
2011-09-11 Bruno Haible <bruno@clisp.org>
Ensure pid_t gets defined.
......@@ -75,8 +75,9 @@ _GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \
#if !defined NAN || @REPLACE_NAN@
# if !GNULIB_defined_NAN
# undef NAN
/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
# ifdef __DECC
/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler
choke on the expression 0.0 / 0.0. */
# if defined __DECC || defined _MSC_VER
static float
_NaN ()
{
......
# frexp.m4 serial 11
# frexp.m4 serial 12
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
......@@ -133,7 +133,7 @@ int main()
result |= 1;
}
/* Test on infinite numbers. */
x = 1.0 / 0.0;
x = 1.0 / zero;
{
int exp;
double y = frexp (x, &exp);
......
# printf.m4 serial 44
# printf.m4 serial 45
dnl Copyright (C) 2003, 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
......@@ -178,28 +178,28 @@ static double zero = 0.0;
int main ()
{
int result = 0;
if (sprintf (buf, "%f", 1.0 / 0.0) < 0
if (sprintf (buf, "%f", 1.0 / zero) < 0
|| (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
result |= 1;
if (sprintf (buf, "%f", -1.0 / 0.0) < 0
if (sprintf (buf, "%f", -1.0 / zero) < 0
|| (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
result |= 1;
if (sprintf (buf, "%f", zero / zero) < 0
|| !strisnan (buf, 0, strlen (buf)))
result |= 2;
if (sprintf (buf, "%e", 1.0 / 0.0) < 0
if (sprintf (buf, "%e", 1.0 / zero) < 0
|| (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
result |= 4;
if (sprintf (buf, "%e", -1.0 / 0.0) < 0
if (sprintf (buf, "%e", -1.0 / zero) < 0
|| (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
result |= 4;
if (sprintf (buf, "%e", zero / zero) < 0
|| !strisnan (buf, 0, strlen (buf)))
result |= 8;
if (sprintf (buf, "%g", 1.0 / 0.0) < 0
if (sprintf (buf, "%g", 1.0 / zero) < 0
|| (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
result |= 16;
if (sprintf (buf, "%g", -1.0 / 0.0) < 0
if (sprintf (buf, "%g", -1.0 / zero) < 0
|| (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
result |= 16;
if (sprintf (buf, "%g", zero / zero) < 0
......@@ -294,28 +294,28 @@ int main ()
{
int result = 0;
nocrash_init();
if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0
if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0
|| (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
result |= 1;
if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0
if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0
|| (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
result |= 1;
if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
|| !strisnan (buf, 0, strlen (buf)))
result |= 1;
if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0
if (sprintf (buf, "%Le", 1.0L / zeroL) < 0
|| (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
result |= 1;
if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0
if (sprintf (buf, "%Le", -1.0L / zeroL) < 0
|| (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
result |= 1;
if (sprintf (buf, "%Le", zeroL / zeroL) < 0
|| !strisnan (buf, 0, strlen (buf)))
result |= 1;
if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0
if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0
|| (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
result |= 1;
if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0
if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0
|| (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
result |= 1;
if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
......@@ -478,6 +478,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
#include <stdio.h>
#include <string.h>
static char buf[100];
static double zero = 0.0;
int main ()
{
int result = 0;
......@@ -502,7 +503,7 @@ int main ()
result |= 4;
/* This catches a FreeBSD 6.1 bug. See
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
|| buf[0] == '0')
result |= 8;
/* This catches a MacOS X 10.3.9 (Darwin 7.9) bug. */
......@@ -562,13 +563,14 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
#include <stdio.h>
#include <string.h>
static char buf[100];
static double zero = 0.0;
int main ()
{
int result = 0;
if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
|| strcmp (buf, "1234567.000000 33") != 0)
result |= 1;
if (sprintf (buf, "%F", 1.0 / 0.0) < 0
if (sprintf (buf, "%F", 1.0 / zero) < 0
|| (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
result |= 2;
/* This catches a Cygwin 1.5.x bug. */
......@@ -878,9 +880,10 @@ AC_DEFUN([gl_PRINTF_FLAG_ZERO],
#include <stdio.h>
#include <string.h>
static char buf[100];
static double zero = 0.0;
int main ()
{
if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0
if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
|| (strcmp (buf, " inf") != 0
&& strcmp (buf, " infinity") != 0))
return 1;
......
......@@ -2,6 +2,7 @@ Files:
tests/test-ceil1.c
tests/test-ceil2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-ceilf1.c
tests/test-ceilf2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-ceill.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -4,6 +4,7 @@ tests/test-dprintf-posix.c
tests/test-printf-posix.output
tests/test-dprintf-posix2.sh
tests/test-dprintf-posix2.c
tests/infinity.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-floor1.c
tests/test-floor2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-floorf1.c
tests/test-floorf2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-floorl.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -7,6 +7,7 @@ tests/test-fprintf-posix2.sh
tests/test-fprintf-posix2.c
tests/test-fprintf-posix3.sh
tests/test-fprintf-posix3.c
tests/infinity.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-frexp.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-frexp.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-frexpl.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-frexpl.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-isfinite.c
tests/infinity.h
tests/macros.h
Depends-on:
......
......@@ -3,6 +3,7 @@ m4/exponentf.m4
m4/exponentd.m4
m4/exponentl.m4
tests/test-isinf.c
tests/infinity.h
tests/macros.h
Depends-on:
......
Files:
tests/test-isnan.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-isnand-nolibm.c
tests/test-isnand.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-isnand.c
tests/test-isnand.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-isnanf-nolibm.c
tests/test-isnanf.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-isnanf.c
tests/test-isnanf.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-isnanl-nolibm.c
tests/test-isnanl.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-isnanl.c
tests/test-isnanl.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
Files:
tests/test-ldexpl.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -5,6 +5,7 @@ tests/test-printf-posix.h
tests/test-printf-posix.output
tests/test-printf-posix2.sh
tests/test-printf-posix2.c
tests/infinity.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-round1.c
tests/test-round2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -3,6 +3,7 @@ tests/test-roundf1.c
tests/test-round2.c
tests/test-roundf2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-roundl.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-signbit.c
tests/minus-zero.h
tests/infinity.h
tests/macros.h
m4/exponentf.m4
m4/exponentd.m4
......
......@@ -3,6 +3,7 @@ tests/test-snprintf-posix.c
tests/test-snprintf-posix.h
tests/test-snprintf.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-sprintf-posix.c
tests/test-sprintf-posix.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-trunc1.c
tests/test-trunc2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-truncf1.c
tests/test-truncf2.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
Files:
tests/test-truncl.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -4,6 +4,7 @@ tests/test-vasnprintf-posix2.sh
tests/test-vasnprintf-posix2.c
tests/test-vasnprintf-posix3.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
m4/locale-fr.m4
......
Files:
tests/test-vasprintf-posix.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/macros.h
......
......@@ -3,6 +3,7 @@ tests/test-vdprintf-posix.sh
tests/test-vdprintf-posix.c
tests/test-fprintf-posix.h
tests/test-printf-posix.output
tests/infinity.h
tests/signature.h
tests/macros.h
......
......@@ -3,6 +3,7 @@ tests/test-vfprintf-posix.sh
tests/test-vfprintf-posix.c
tests/test-fprintf-posix.h
tests/test-printf-posix.output
tests/infinity.h
tests/signature.h
tests/macros.h
......
......@@ -3,6 +3,7 @@ tests/test-vprintf-posix.sh
tests/test-vprintf-posix.c
tests/test-printf-posix.h
tests/test-printf-posix.output
tests/infinity.h
tests/signature.h
tests/macros.h
......
......@@ -3,6 +3,7 @@ tests/test-vsnprintf-posix.c
tests/test-snprintf-posix.h
tests/test-vsnprintf.c
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -2,6 +2,7 @@ Files:
tests/test-vsprintf-posix.c
tests/test-sprintf-posix.h
tests/minus-zero.h
tests/infinity.h
tests/nan.h
tests/signature.h
tests/macros.h
......
......@@ -5,6 +5,7 @@ tests/test-xprintf-posix.c
tests/test-fprintf-posix.h
tests/test-printf-posix.h
tests/test-printf-posix.output
tests/infinity.h
tests/macros.h
Depends-on:
......
/* Macros for infinity.
Copyright (C) 2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Infinityf () returns a 'float' +Infinity. */
/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */
#if defined _MSC_VER
static float
Infinityf ()
{
static float zero = 0.0f;
return 1.0f / zero;
}
#else
# define Infinityf() (1.0f / 0.0f)
#endif
/* Infinityd () returns a 'double' +Infinity. */
/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */
#if defined _MSC_VER
static double
Infinityd ()
{
static double zero = 0.0;
return 1.0 / zero;
}
#else
# define Infinityd() (1.0 / 0.0)
#endif
/* Infinityl () returns a 'long double' +Infinity. */
/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */
#if defined _MSC_VER
static double
Infinityl ()
{
static long double zero = 0.0L;
return 1.0L / zero;
}
#else
# define Infinityl() (1.0L / 0.0L)
#endif
......@@ -17,8 +17,9 @@
/* NaNf () returns a 'float' not-a-number. */
/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
#ifdef __DECC
/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
on the expression 0.0 / 0.0. */
#if defined __DECC || defined _MSC_VER
static float
NaNf ()
{
......@@ -32,8 +33,9 @@ NaNf ()
/* NaNd () returns a 'double' not-a-number. */
/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
#ifdef __DECC
/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
on the expression 0.0 / 0.0. */
#if defined __DECC || defined _MSC_VER
static double
NaNd ()
{
......@@ -48,13 +50,21 @@ NaNd ()
/* NaNl () returns a 'long double' not-a-number. */
/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the
runtime type conversion. */
runtime type conversion.
The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L. */
#ifdef __sgi
static long double NaNl ()
{
double zero = 0.0;
return zero / zero;
}
#elif defined _MSC_VER
static long double
NaNl ()
{
static long double zero = 0.0L;
return zero / zero;
}
#else
# define NaNl() (0.0L / 0.0L)
#endif
......@@ -27,6 +27,7 @@ SIGNATURE_CHECK (ceil, double, (double));
#include "isnand-nolibm.h"
#include "minus-zero.h"
#include "infinity.h"
#include "nan.h"
#include "macros.h"
......@@ -58,8 +59,8 @@ main ()
ASSERT (ceil (-65536.0) == -65536.0);
ASSERT (ceil (-2.341e31) == -2.341e31);
/* Infinite numbers. */
ASSERT (ceil (1.0 / 0.0) == 1.0 / 0.0);
ASSERT (ceil (-1.0 / 0.0) == -1.0 / 0.0);
ASSERT (ceil (Infinityd ()) == Infinityd ());
ASSERT (ceil (- Infinityd ()) == - Infinityd ());
/* NaNs. */
ASSERT (isnand (ceil (NaNd ())));
......
......@@ -25,6 +25,7 @@ SIGNATURE_CHECK (ceilf, float, (float));
#include "isnanf-nolibm.h"
#include "minus-zero.h"
#include "infinity.h"
#include "nan.h"
#include "macros.h"
......@@ -69,8 +70,8 @@ main (int argc, char **argv _GL_UNUSED)
ASSERT (my_ceilf (-65536.0f) == -65536.0f);
ASSERT (my_ceilf (-2.341e31f) == -2.341e31f);
/* Infinite numbers. */
ASSERT (my_ceilf (1.0f / 0.0f) == 1.0f / 0.0f);
ASSERT (my_ceilf (-1.0f / 0.0f) == -1.0f / 0.0f);
ASSERT (my_ceilf (Infinityf ()) == Infinityf ());
ASSERT (my_ceilf (- Infinityf ()) == - Infinityf ());
/* NaNs. */
ASSERT (isnanf (my_ceilf (NaNf ())));
......
......@@ -28,6 +28,7 @@ SIGNATURE_CHECK (ceill, long double, (long double));