From: Bruno Haible Date: Sun, 25 Mar 2007 21:46:38 +0000 (+0000) Subject: Avoid test failures on IRIX MIPS. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a510cdfc2bf7fb0256b35cf6823635511bc3085;p=pspp Avoid test failures on IRIX MIPS. --- diff --git a/ChangeLog b/ChangeLog index 4306d1ecb9..7f2cfe9747 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-03-25 Bruno Haible + + Avoid test failures on IRIX 6.5. + * tests/test-frexpl.c (MIN_NORMAL_EXP): New macro. + (main): Use it. + * tests/test-printf-frexpl.c (MIN_NORMAL_EXP, MIN_SUBNORMAL_EXP): New + macros. + (main): Use them. + 2007-03-25 Bruno Haible * m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS): New macro. diff --git a/tests/test-frexpl.c b/tests/test-frexpl.c index 7c66fc8401..1bcde6e1b6 100644 --- a/tests/test-frexpl.c +++ b/tests/test-frexpl.c @@ -29,6 +29,15 @@ #define ASSERT(expr) if (!(expr)) abort (); +/* On MIPS IRIX machines, LDBL_MIN_EXP is -1021, but the smallest reliable + exponent for 'long double' is -964. For exponents below that, the + precision may be truncated to the precision used for 'double'. */ +#ifdef __sgi +# define MIN_NORMAL_EXP (LDBL_MIN_EXP + 57) +#else +# define MIN_NORMAL_EXP LDBL_MIN_EXP +#endif + static long double my_ldexp (long double x, int d) { @@ -97,7 +106,7 @@ main () ASSERT (exp == i); ASSERT (mantissa == 0.5L); } - for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) + for (i = 1, x = 1.0L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) { int exp = -9999; long double mantissa = frexpl (x, &exp); @@ -119,7 +128,7 @@ main () ASSERT (exp == i); ASSERT (mantissa == -0.5L); } - for (i = 1, x = -1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) + for (i = 1, x = -1.0L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) { int exp = -9999; long double mantissa = frexpl (x, &exp); @@ -141,7 +150,7 @@ main () ASSERT (exp == i); ASSERT (mantissa == 0.505L); } - for (i = 1, x = 1.01L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) + for (i = 1, x = 1.01L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) { int exp = -9999; long double mantissa = frexpl (x, &exp); @@ -165,7 +174,7 @@ main () ASSERT (exp == i); ASSERT (mantissa == 0.866025L); } - for (i = 1, x = 1.73205L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) + for (i = 1, x = 1.73205L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) { int exp = -9999; long double mantissa = frexpl (x, &exp); diff --git a/tests/test-printf-frexpl.c b/tests/test-printf-frexpl.c index 15cd91d85b..c57d2f81ae 100644 --- a/tests/test-printf-frexpl.c +++ b/tests/test-printf-frexpl.c @@ -28,6 +28,17 @@ #define ASSERT(expr) if (!(expr)) abort (); +/* On MIPS IRIX machines, LDBL_MIN_EXP is -1021, but the smallest reliable + exponent for 'long double' is -964. For exponents below that, the + precision may be truncated to the precision used for 'double'. */ +#ifdef __sgi +# define MIN_NORMAL_EXP (LDBL_MIN_EXP + 57) +# define MIN_SUBNORMAL_EXP MIN_NORMAL_EXP +#else +# define MIN_NORMAL_EXP LDBL_MIN_EXP +# define MIN_SUBNORMAL_EXP (LDBL_MIN_EXP - 100) +#endif + static long double my_ldexp (long double x, int d) { @@ -54,14 +65,14 @@ main () ASSERT (exp == i - 1); ASSERT (mantissa == 1.0L); } - for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) + for (i = 1, x = 1.0L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) { int exp = -9999; long double mantissa = printf_frexpl (x, &exp); ASSERT (exp == i - 1); ASSERT (mantissa == 1.0L); } - for (; i >= LDBL_MIN_EXP - 100 && x > 0.0L; i--, x *= 0.5L) + for (; i >= MIN_SUBNORMAL_EXP && x > 0.0L; i--, x *= 0.5L) { int exp = -9999; long double mantissa = printf_frexpl (x, &exp); @@ -76,14 +87,14 @@ main () ASSERT (exp == i - 1); ASSERT (mantissa == 1.01L); } - for (i = 1, x = 1.01L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) + for (i = 1, x = 1.01L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) { int exp = -9999; long double mantissa = printf_frexpl (x, &exp); ASSERT (exp == i - 1); ASSERT (mantissa == 1.01L); } - for (; i >= LDBL_MIN_EXP - 100 && x > 0.0L; i--, x *= 0.5L) + for (; i >= MIN_SUBNORMAL_EXP && x > 0.0L; i--, x *= 0.5L) { int exp = -9999; long double mantissa = printf_frexpl (x, &exp); @@ -100,14 +111,14 @@ main () ASSERT (exp == i - 1); ASSERT (mantissa == 1.73205L); } - for (i = 1, x = 1.73205L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) + for (i = 1, x = 1.73205L; i >= MIN_NORMAL_EXP; i--, x *= 0.5L) { int exp = -9999; long double mantissa = printf_frexpl (x, &exp); ASSERT (exp == i - 1); ASSERT (mantissa == 1.73205L); } - for (; i >= LDBL_MIN_EXP - 100 && x > 0.0L; i--, x *= 0.5L) + for (; i >= MIN_SUBNORMAL_EXP && x > 0.0L; i--, x *= 0.5L) { int exp = -9999; long double mantissa = printf_frexpl (x, &exp);