Commit e73e42a6 authored by Bruno Haible's avatar Bruno Haible

floor*-ieee, ceil*-ieee, trunc*-ieee, round*-ieee: More robust checks.

* m4/floorf.m4 (gl_FUNC_FLOORF): In the test whether the function is
IEEE compliant, avoid compiler optimizations.
* m4/floor.m4 (gl_FUNC_FLOOR): Likewise.
* m4/ceilf.m4 (gl_FUNC_CEILF): Likewise.
* m4/ceil.m4 (gl_FUNC_CEIL): Likewise.
* m4/ceill.m4 (gl_FUNC_CEILL): Likewise.
* m4/truncf.m4 (gl_FUNC_TRUNCF): Likewise.
* m4/trunc.m4 (gl_FUNC_TRUNC): Likewise.
* m4/truncl.m4 (gl_FUNC_TRUNCL): Likewise.
* m4/roundf.m4 (gl_FUNC_ROUNDF): Likewise.
* m4/round.m4 (gl_FUNC_ROUND): Likewise.
* m4/roundl.m4 (gl_FUNC_ROUNDL): Likewise.
parent b68d5ea2
2011-06-19 Bruno Haible <bruno@clisp.org>
floor*-ieee, ceil*-ieee, trunc*-ieee, round*-ieee: More robust checks.
* m4/floorf.m4 (gl_FUNC_FLOORF): In the test whether the function is
IEEE compliant, avoid compiler optimizations.
* m4/floor.m4 (gl_FUNC_FLOOR): Likewise.
* m4/ceilf.m4 (gl_FUNC_CEILF): Likewise.
* m4/ceil.m4 (gl_FUNC_CEIL): Likewise.
* m4/ceill.m4 (gl_FUNC_CEILL): Likewise.
* m4/truncf.m4 (gl_FUNC_TRUNCF): Likewise.
* m4/trunc.m4 (gl_FUNC_TRUNC): Likewise.
* m4/truncl.m4 (gl_FUNC_TRUNCL): Likewise.
* m4/roundf.m4 (gl_FUNC_ROUNDF): Likewise.
* m4/round.m4 (gl_FUNC_ROUND): Likewise.
* m4/roundl.m4 (gl_FUNC_ROUNDL): Likewise.
2011-06-19 Bruno Haible <bruno@clisp.org>
ceilf-ieee: Work around bug on AIX 7.1.
# ceil.m4 serial 7
# ceil.m4 serial 8
dnl Copyright (C) 2007, 2009-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,
......@@ -28,14 +28,16 @@ AC_DEFUN([gl_FUNC_CEIL],
#include <math.h>
]gl_DOUBLE_MINUS_ZERO_CODE[
]gl_DOUBLE_SIGNBIT_CODE[
int main()
static double dummy (double f) { return 0; }
int main (int argc, char *argv[])
{
double (*my_ceil) (double) = argc ? ceil : dummy;
int result = 0;
/* Test whether ceil (-0.0) is -0.0. */
if (signbitd (minus_zerod) && !signbitd (ceil (minus_zerod)))
if (signbitd (minus_zerod) && !signbitd (my_ceil (minus_zerod)))
result |= 1;
/* Test whether ceil (-0.3) is -0.0. */
if (signbitd (-0.3) && !signbitd (ceil (-0.3)))
if (signbitd (-0.3) && !signbitd (my_ceil (-0.3)))
result |= 2;
return result;
}
......
# ceilf.m4 serial 10
# ceilf.m4 serial 11
dnl Copyright (C) 2007, 2009-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,
......@@ -35,14 +35,16 @@ AC_DEFUN([gl_FUNC_CEILF],
#include <math.h>
]gl_FLOAT_MINUS_ZERO_CODE[
]gl_FLOAT_SIGNBIT_CODE[
int main()
static float dummy (float f) { return 0; }
int main (int argc, char *argv[])
{
float (*my_ceilf) (float) = argc ? ceilf : dummy;
int result = 0;
/* Test whether ceilf (-0.0f) is -0.0f. */
if (signbitf (minus_zerof) && !signbitf (ceilf (minus_zerof)))
if (signbitf (minus_zerof) && !signbitf (my_ceilf (minus_zerof)))
result |= 1;
/* Test whether ceilf (-0.3f) is -0.0f. */
if (signbitf (-0.3f) && !signbitf (ceilf (-0.3f)))
if (signbitf (-0.3f) && !signbitf (my_ceilf (-0.3f)))
result |= 2;
return result;
}
......
# ceill.m4 serial 9
# ceill.m4 serial 10
dnl Copyright (C) 2007, 2009-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,
......@@ -35,10 +35,12 @@ AC_DEFUN([gl_FUNC_CEILL],
#include <math.h>
]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
]gl_LONG_DOUBLE_SIGNBIT_CODE[
int main()
static long double dummy (long double f) { return 0; }
int main (int argc, char *argv[])
{
long double (*my_ceill) (long double) = argc ? ceill : dummy;
/* Test whether ceill (-0.3L) is -0.0L. */
if (signbitl (minus_zerol) && !signbitl (ceill (-0.3L)))
if (signbitl (minus_zerol) && !signbitl (my_ceill (-0.3L)))
return 1;
return 0;
}
......
# floor.m4 serial 6
# floor.m4 serial 7
dnl Copyright (C) 2007, 2009-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,
......@@ -28,10 +28,12 @@ AC_DEFUN([gl_FUNC_FLOOR],
#include <math.h>
]gl_DOUBLE_MINUS_ZERO_CODE[
]gl_DOUBLE_SIGNBIT_CODE[
int main()
static double dummy (double f) { return 0; }
int main (int argc, char *argv[])
{
double (*my_floor) (double) = argc ? floor : dummy;
/* Test whether floor (-0.0) is -0.0. */
if (signbitd (minus_zerod) && !signbitd (floor (minus_zerod)))
if (signbitd (minus_zerod) && !signbitd (my_floor (minus_zerod)))
return 1;
return 0;
}
......
# floorf.m4 serial 9
# floorf.m4 serial 10
dnl Copyright (C) 2007, 2009-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,
......@@ -35,10 +35,12 @@ AC_DEFUN([gl_FUNC_FLOORF],
#include <math.h>
]gl_FLOAT_MINUS_ZERO_CODE[
]gl_FLOAT_SIGNBIT_CODE[
int main()
static float dummy (float f) { return 0; }
int main (int argc, char *argv[])
{
float (*my_floorf) (float) = argc ? floorf : dummy;
/* Test whether floorf (-0.0f) is -0.0f. */
if (signbitf (minus_zerof) && !signbitf (floorf (minus_zerof)))
if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof)))
return 1;
return 0;
}
......
# round.m4 serial 11
# round.m4 serial 12
dnl Copyright (C) 2007, 2009-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,
......@@ -69,10 +69,12 @@ int main()
#include <math.h>
]gl_DOUBLE_MINUS_ZERO_CODE[
]gl_DOUBLE_SIGNBIT_CODE[
int main()
static double dummy (double f) { return 0; }
int main (int argc, char *argv[])
{
double (*my_round) (double) = argc ? round : dummy;
/* Test whether round (-0.0) is -0.0. */
if (signbitd (minus_zerod) && !signbitd (round (minus_zerod)))
if (signbitd (minus_zerod) && !signbitd (my_round (minus_zerod)))
return 1;
return 0;
}
......
# roundf.m4 serial 11
# roundf.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,
......@@ -66,10 +66,12 @@ int main()
#include <math.h>
]gl_FLOAT_MINUS_ZERO_CODE[
]gl_FLOAT_SIGNBIT_CODE[
int main()
static float dummy (float f) { return 0; }
int main (int argc, char *argv[])
{
float (*my_roundf) (float) = argc ? roundf : dummy;
/* Test whether roundf (-0.0f) is -0.0f. */
if (signbitf (minus_zerof) && !signbitf (roundf (minus_zerof)))
if (signbitf (minus_zerof) && !signbitf (my_roundf (minus_zerof)))
return 1;
return 0;
}
......
# roundl.m4 serial 9
# roundl.m4 serial 10
dnl Copyright (C) 2007, 2009-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,
......@@ -31,10 +31,12 @@ AC_DEFUN([gl_FUNC_ROUNDL],
#include <math.h>
]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
]gl_LONG_DOUBLE_SIGNBIT_CODE[
int main()
static long double dummy (long double f) { return 0; }
int main (int argc, char *argv[])
{
long double (*my_roundl) (long double) = argc ? roundl : dummy;
/* Test whether roundl (-0.0L) is -0.0L. */
if (signbitl (minus_zerol) && !signbitl (roundl (minus_zerol)))
if (signbitl (minus_zerol) && !signbitl (my_roundl (minus_zerol)))
return 1;
return 0;
}
......
# trunc.m4 serial 6
# trunc.m4 serial 7
dnl Copyright (C) 2007, 2010-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,
......@@ -56,10 +56,12 @@ AC_DEFUN([gl_FUNC_TRUNC],
#include <math.h>
]gl_DOUBLE_MINUS_ZERO_CODE[
]gl_DOUBLE_SIGNBIT_CODE[
int main()
static double dummy (double f) { return 0; }
int main (int argc, char *argv[])
{
double (*my_trunc) (double) = argc ? trunc : dummy;
/* Test whether trunc (-0.0) is -0.0. */
if (signbitd (minus_zerod) && !signbitd (trunc (minus_zerod)))
if (signbitd (minus_zerod) && !signbitd (my_trunc (minus_zerod)))
return 1;
return 0;
}
......
# truncf.m4 serial 5
# truncf.m4 serial 6
dnl Copyright (C) 2007, 2010-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,
......@@ -56,10 +56,12 @@ AC_DEFUN([gl_FUNC_TRUNCF],
#include <math.h>
]gl_FLOAT_MINUS_ZERO_CODE[
]gl_FLOAT_SIGNBIT_CODE[
int main()
static float dummy (float f) { return 0; }
int main (int argc, char *argv[])
{
float (*my_truncf) (float) = argc ? truncf : dummy;
/* Test whether truncf (-0.0f) is -0.0f. */
if (signbitf (minus_zerof) && !signbitf (truncf (minus_zerof)))
if (signbitf (minus_zerof) && !signbitf (my_truncf (minus_zerof)))
return 1;
return 0;
}
......
# truncl.m4 serial 7
# truncl.m4 serial 8
dnl Copyright (C) 2007-2008, 2010-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,
......@@ -84,10 +84,12 @@ int main()
#include <math.h>
]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
]gl_LONG_DOUBLE_SIGNBIT_CODE[
int main()
static long double dummy (long double f) { return 0; }
int main (int argc, char *argv[])
{
long double (*my_truncl) (long double) = argc ? truncl : dummy;
/* Test whether truncl (-0.3L) is -0.0L. */
if (signbitl (minus_zerol) && !signbitl (truncl (-0.3L)))
if (signbitl (minus_zerol) && !signbitl (my_truncl (-0.3L)))
return 1;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment