summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-09-11 17:29:11 +0200
committerBruno Haible <bruno@clisp.org>2011-09-11 17:32:25 +0200
commitcf00d49188ce187174233c0a5e7bd018340a8aab (patch)
treeae93cc9ad18ac78763750925b4c75fc0599409bd /m4
parent0b88a15dca93414df75ff004811c8e2573d593e3 (diff)
downloadgnulib-cf00d49188ce187174233c0a5e7bd018340a8aab.tar.gz
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.
Diffstat (limited to 'm4')
-rw-r--r--m4/frexp.m44
-rw-r--r--m4/printf.m435
2 files changed, 21 insertions, 18 deletions
diff --git a/m4/frexp.m4 b/m4/frexp.m4
index 125edcdc45..f2048f3be3 100644
--- a/m4/frexp.m4
+++ b/m4/frexp.m4
@@ -1,4 +1,4 @@
-# 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);
diff --git a/m4/printf.m4 b/m4/printf.m4
index 0531ad5f2e..d046c11123 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,4 +1,4 @@
-# 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;