]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
New <math.h> macro named issignaling to check for a signaling NaN (sNaN).
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 2 Apr 2013 11:51:02 +0000 (13:51 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 2 Apr 2013 11:51:02 +0000 (13:51 +0200)
It is based on draft TS 18661 and currently enabled as a GNU extension.

49 files changed:
ChangeLog
NEWS
Versions.def
include/math.h
manual/arith.texi
manual/libm-err-tab.pl
math/Makefile
math/Versions
math/basic-test.c
math/bits/mathcalls.h
math/gen-libm-test.pl
math/libm-test.inc
math/math.h
math/test-snan.c
ports/ChangeLog.hppa
ports/ChangeLog.mips
ports/sysdeps/hppa/math_private.h [new file with mode: 0644]
ports/sysdeps/mips/math_private.h [new file with mode: 0644]
ports/sysdeps/unix/sysv/linux/aarch64/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/alpha/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/arm/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/ia64/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/m68k/coldfire/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/m68k/m680x0/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/mips/mips64/n32/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/mips/mips64/n64/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/nptl/libm.abilist
ports/sysdeps/unix/sysv/linux/tile/tilepro/nptl/libm.abilist
sysdeps/generic/math-tests.h
sysdeps/ieee754/dbl-64/s_issignaling.c [new file with mode: 0644]
sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c [new file with mode: 0644]
sysdeps/ieee754/flt-32/s_issignalingf.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128/s_issignalingl.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c [new file with mode: 0644]
sysdeps/ieee754/ldbl-96/s_issignalingl.c [new file with mode: 0644]
sysdeps/powerpc/math-tests.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/i386/nptl/libm.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libm.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libm.abilist
sysdeps/unix/sysv/linux/s390/s390-32/nptl/libm.abilist
sysdeps/unix/sysv/linux/s390/s390-64/nptl/libm.abilist
sysdeps/unix/sysv/linux/sh/nptl/libm.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libm.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libm.abilist
sysdeps/unix/sysv/linux/x86_64/64/nptl/libm.abilist
sysdeps/unix/sysv/linux/x86_64/x32/nptl/libm.abilist

index df0291b152c029fd03564d2dc2ccab8a3cb36014..ee4eacfbeab86b278583336771ea9e6c9808c6ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2013-04-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+       * Versions.def (libm): Add GLIBC_2.18.
+       * include/math.h [!_ISOMAC] (__issignaling, __issignalingf): Add
+       hidden libm prototypes.
+       [!_ISOMAC && !__NO_LONG_DOUBLE_MATH] (__issignalingl): Likewise.
+       * math/Makefile (libm-calls): Add s_issignaling.
+       * math/Versions (libm: GLIBC_2.18): Add __issignaling,
+       __issignalingf, __issignalingl.  Adjust all libm.abilist files.
+       * math/bits/mathcalls.h [__USE_GNU] (__issignaling): New prototype
+       declaration.
+       * math/math.h [__USE_GNU] (issignaling): New macro.
+       * sysdeps/ieee754/flt-32/s_issignalingf.c: New file.
+       * sysdeps/ieee754/dbl-64/s_issignaling.c: Likewise.
+       * sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c: Likewise.
+       * sysdeps/ieee754/ldbl-96/s_issignalingl.c: Likewise.
+       * sysdeps/ieee754/ldbl-128/s_issignalingl.c: Likewise.
+       * sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c: Likewise.
+       * manual/arith.texi (issignaling): New section.
+       * manual/libm-err-tab.pl (@all_functions): Update comment.
+       * math/gen-libm-test.pl (parse_args): Apply special handling for
+       issignaling.
+       * math/libm-test.inc (print_float, issignaling_test): New
+       functions.
+       (check_float_internal): Add issignaling checks.
+       * sysdeps/generic/math-tests.h (SNAN_TESTS_TYPE_CAST): Provide
+       default definition.
+       * sysdeps/powerpc/math-tests.h: New file.
+       * math/basic-test.c (TEST_FUNC, TEST_TRUNC): Add issignaling
+       tests.
+       * math/test-snan.c (TEST_FUNC): Likewise.
+
 2013-03-30  David S. Miller  <davem@davemloft.net>
 
        * po/de.po: Update from translation team.
diff --git a/NEWS b/NEWS
index 82e9ed568aac261b2a16d94cc268dff3b29eb585..3bb5cb3e9429f3c85cfaf9ca9310935658456def 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,8 @@ Version 2.18
 
 * Added a benchmark framework to track performance of functions in glibc.
 
+* New <math.h> macro named issignaling to check for a signaling NaN (sNaN).
+  It is based on draft TS 18661 and currently enabled as a GNU extension.
 \f
 Version 2.17
 
index 7c7d1f89d3d179d573d90d02a54a79c0492419f2..04622397fddbee2d168e726fb56374b085c09b56 100644 (file)
@@ -58,6 +58,7 @@ libm {
   GLIBC_2.3.4
   GLIBC_2.4
   GLIBC_2.15
+  GLIBC_2.18
 }
 libnsl {
   GLIBC_2.0
index 2b040c67fd6d54e2e6b060dc35f49f59bd57cc61..cbbce59501d344a75252c9457a8b92288e604326 100644 (file)
@@ -23,11 +23,14 @@ hidden_proto (__isnanl)
 
 libm_hidden_proto (__fpclassify)
 libm_hidden_proto (__fpclassifyf)
+libm_hidden_proto (__issignaling)
+libm_hidden_proto (__issignalingf)
 libm_hidden_proto (__exp)
 libm_hidden_proto (__expf)
 
 # ifndef __NO_LONG_DOUBLE_MATH
 libm_hidden_proto (__fpclassifyl)
+libm_hidden_proto (__issignalingl)
 libm_hidden_proto (__expl)
 libm_hidden_proto (__expm1l)
 # endif
index d060ff94637f021e122c32fcc1a89afa129a93dc..ce8844ec2de311451583cb48763f5e459794fed1 100644 (file)
@@ -387,6 +387,14 @@ to
 @end smallexample
 @end deftypefn
 
+@comment math.h
+@comment GNU
+@deftypefn {Macro} int issignaling (@emph{float-type} @var{x})
+This macro returns a nonzero value if @var{x} is a signaling NaN
+(sNaN).  It is based on draft TS 18661 and currently enabled as a GNU
+extension.
+@end deftypefn
+
 Another set of floating-point classification functions was provided by
 BSD.  @Theglibc{} also supports these functions; however, we
 recommend that you use the ISO C99 macros in new code.  Those are standard
index 5aa26039ac0382242e37ece079662ddd52d7c013..15646693fe43c46646638cb8a999a5f86caf329f 100755 (executable)
@@ -77,7 +77,9 @@ use vars qw (%results @all_floats %suffices @all_functions);
     "remainder", "remquo", "rint", "round", "scalb", "scalbn", "scalbln",
     "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
     "trunc", "y0", "y1", "yn" );
-# "fpclassify", "isfinite", "isnormal", "signbit" are not tabulated
+# fpclassify, isnormal, isfinite, isinf, isnan, issignaling, signbit,
+# isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered
+# are not tabulated.
 
 if ($#ARGV == 0) {
   $sources = $ARGV[0];
index e216dfb96ac83c09b52ca86749a2e4d8f31b363a..f396ba206af5f3c471e235718a258f264919beb0 100644 (file)
@@ -58,7 +58,7 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod        \
             s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos       \
             s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
             s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2   \
-            s_isinf_ns $(calls:s_%=m_%) x2y2m1 k_casinh
+            s_isinf_ns s_issignaling $(calls:s_%=m_%) x2y2m1 k_casinh
 
 include ../Makeconfig
 
index 09888510b1c030ae07bc69a67e5954822069acbc..513ab142441df849b8ce4bfc1c24bfe838d9e47e 100644 (file)
@@ -198,4 +198,7 @@ libm {
     __gamma_r_finite; __gammaf_r_finite; __gammal_r_finite;
     __exp_finite; __expf_finite; __expl_finite;
   }
+  GLIBC_2.18 {
+    __issignaling; __issignalingf; __issignalingl;
+  }
 }
index ffead2ec0f622b43c146635d44761a04af549623..9e9b848ee5633b0326627d2cc6bf2f51d24b79b9 100644 (file)
@@ -20,6 +20,9 @@
 #include <float.h>
 #include <stdio.h>
 
+#include <math-tests.h>
+
+
 static int errors = 0;
 
 
@@ -39,6 +42,10 @@ NAME (void)                                                                \
   /* Variables are declared volatile to forbid some compiler                 \
      optimizations.  */                                                              \
   volatile FLOAT Inf_var, qNaN_var, zero_var, one_var;                       \
+  /* A sNaN is only guaranteed to be representable in variables with */              \
+  /* static (or thread-local) storage duration.  */                          \
+  static volatile FLOAT sNaN_var = __builtin_nans ## SUFFIX ("");            \
+  static volatile FLOAT minus_sNaN_var = -__builtin_nans ## SUFFIX ("");      \
   FLOAT x1, x2;                                                                      \
                                                                              \
   zero_var = 0.0;                                                            \
@@ -49,6 +56,8 @@ NAME (void)                                                                 \
   (void) &zero_var;                                                          \
   (void) &one_var;                                                           \
   (void) &qNaN_var;                                                          \
+  (void) &sNaN_var;                                                          \
+  (void) &minus_sNaN_var;                                                    \
   (void) &Inf_var;                                                           \
                                                                              \
                                                                              \
@@ -56,16 +65,41 @@ NAME (void)                                                               \
   check (#FLOAT " isinf (-inf) == -1", isinf (-Inf_var) == -1);                      \
   check (#FLOAT " !isinf (1)", !(isinf (one_var)));                          \
   check (#FLOAT " !isinf (qNaN)", !(isinf (qNaN_var)));                              \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " !isinf (sNaN)", !(isinf (sNaN_var)));                    \
                                                                              \
   check (#FLOAT " isnan (qNaN)", isnan (qNaN_var));                          \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " isnan (sNaN)", isnan (sNaN_var));                        \
   check (#FLOAT " isnan (-qNaN)", isnan (-qNaN_var));                        \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " isnan (-sNaN)", isnan (minus_sNaN_var));                 \
   check (#FLOAT " !isnan (1)", !(isnan (one_var)));                          \
   check (#FLOAT " !isnan (inf)", !(isnan (Inf_var)));                        \
                                                                              \
+  check (#FLOAT " !issignaling (qNaN)", !(issignaling (qNaN_var)));          \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " issignaling (sNaN)", issignaling (sNaN_var));            \
+  check (#FLOAT " !issignaling (-qNaN)", !(issignaling (-qNaN_var)));        \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " issignaling (-sNaN)", issignaling (minus_sNaN_var));      \
+  check (#FLOAT " !issignaling (1)", !(issignaling (one_var)));                      \
+  check (#FLOAT " !issignaling (inf)", !(issignaling (Inf_var)));            \
+                                                                             \
   check (#FLOAT " inf == inf", Inf_var == Inf_var);                          \
   check (#FLOAT " -inf == -inf", -Inf_var == -Inf_var);                              \
   check (#FLOAT " inf != -inf", Inf_var != -Inf_var);                        \
   check (#FLOAT " qNaN != qNaN", qNaN_var != qNaN_var);                              \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " sNaN != sNaN", sNaN_var != sNaN_var);                    \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " qNaN != sNaN", qNaN_var != sNaN_var);                    \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " -sNaN != -sNaN", minus_sNaN_var != minus_sNaN_var);              \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " sNaN != -sNaN", sNaN_var != minus_sNaN_var);             \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " qNaN != -sNaN", qNaN_var != minus_sNaN_var);             \
                                                                              \
   /*                                                                         \
      the same tests but this time with NAN from <bits/nan.h>                 \
@@ -76,6 +110,11 @@ NAME (void)                                                               \
   check (#FLOAT " !isinf (NAN)", !(isinf (NAN)));                            \
   check (#FLOAT " !isinf (-NAN)", !(isinf (-NAN)));                          \
   check (#FLOAT " NAN != NAN", NAN != NAN);                                  \
+  check (#FLOAT " NAN != qNaN", NAN != qNaN_var);                            \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " NAN != sNaN", NAN != sNaN_var);                          \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " NAN != -sNaN", NAN != minus_sNaN_var);                   \
                                                                              \
   /*                                                                         \
      And again with the value returned by the `nan' function.                \
@@ -86,6 +125,12 @@ NAME (void)                                                               \
   check (#FLOAT " !isinf (-nan (\"\"))", !(isinf (-nan ## SUFFIX (""))));     \
   check (#FLOAT " nan (\"\") != nan (\"\")",                                 \
         nan ## SUFFIX ("") != nan ## SUFFIX (""));                           \
+  check (#FLOAT " nan (\"\") != qNaN", nan ## SUFFIX ("") != qNaN_var);              \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " nan (\"\") != sNaN", nan ## SUFFIX ("") != sNaN_var);     \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    check (#FLOAT " nan (\"\") != -sNaN",                                    \
+          nan ## SUFFIX ("") != minus_sNaN_var);                             \
                                                                              \
   /* test if EPSILON is ok */                                                \
   x1 = 1.0;                                                                  \
@@ -108,6 +153,9 @@ void                                                                              \
 NAME (void)                                                                  \
 {                                                                            \
   volatile DOUBLE Inf_var, qNaN_var, zero_var, one_var;                              \
+  /* A sNaN is only guaranteed to be representable in variables with */              \
+  /* static (or thread-local) storage duration.  */                          \
+  static volatile DOUBLE sNaN_var = __builtin_nans ## SUFFIX ("");           \
   FLOAT x1, x2;                                                                      \
                                                                              \
   zero_var = 0.0;                                                            \
@@ -116,10 +164,25 @@ NAME (void)                                                                     \
   Inf_var = one_var / zero_var;                                                      \
                                                                              \
   (void) &qNaN_var;                                                          \
+  (void) &sNaN_var;                                                          \
   (void) &Inf_var;                                                           \
                                                                              \
   x1 = (FLOAT) qNaN_var;                                                     \
-  check (" "#FLOAT" x = ("#FLOAT") ("#DOUBLE") qNaN", isnan (x1) != 0);              \
+  check (" "#FLOAT" x = ("#FLOAT") ("#DOUBLE") qNaN, isnan", isnan (x1));     \
+  check (" "#FLOAT" x = ("#FLOAT") ("#DOUBLE") qNaN, !issignaling",          \
+        !issignaling (x1));                                                  \
+  if (SNAN_TESTS (FLOAT))                                                    \
+    {                                                                        \
+      x1 = (FLOAT) sNaN_var;                                                 \
+      check (" "#FLOAT" x = ("#FLOAT") ("#DOUBLE") sNaN, isnan", isnan (x1)); \
+      if (SNAN_TESTS_TYPE_CAST)                                                      \
+       {                                                                     \
+         /* Upon type conversion, a sNaN is converted into a qNaN plus an */ \
+         /* INVALID exception (not checked here).  */                        \
+         check (" "#FLOAT" x = ("#FLOAT") ("#DOUBLE") sNaN, !issignaling",   \
+                !issignaling (x1));                                          \
+       }                                                                     \
+      }                                                                              \
   x2 = (FLOAT) Inf_var;                                                              \
   check (" "#FLOAT" x = ("#FLOAT") ("#DOUBLE") Inf", isinf (x2) != 0);       \
 }
index e5af507257bb1019a162f42b4d606e5f8cf0f740..870c54c529d60dd6775a445777ac155baa900019 100644 (file)
@@ -360,6 +360,12 @@ __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
 __END_NAMESPACE_C99
 #endif
 
+#ifdef __USE_GNU
+/* Test for signaling NaN.  */
+__MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value))
+     __attribute__ ((__const__));
+#endif
+
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Return X times (2 to the Nth power).  */
 __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
index f50f1d9e02f9e7acc82ade8079368f87eb7c181f..aa60d9dbae633cc8f70a6309a70689882774d3a5 100755 (executable)
@@ -322,7 +322,7 @@ sub parse_args {
   }
   # Special handling for some macros:
   $cline .= " (\"$str\", ";
-  if ($args[0] =~ /fpclassify|isnormal|isfinite|isinf|isnan|signbit
+  if ($args[0] =~ /fpclassify|isnormal|isfinite|isinf|isnan|issignaling|signbit
       |isgreater|isgreaterequal|isless|islessequal
       |islessgreater|isunordered/x) {
     $c_call = "$args[0] (";
index 3c5e58f39f5bc50cdc75dc45936d367e06a73241..1d3ba48b7da92b0419c54e07fa2ddc263956d716 100644 (file)
@@ -42,7 +42,7 @@
    cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
    fabs, fdim, finite, floor, fma, fmax, fmin, fmod, fpclassify,
    frexp, gamma, hypot,
-   ilogb, isfinite, isinf, isnan, isnormal,
+   ilogb, isfinite, isinf, isnan, isnormal, issignaling,
    isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
    j0, j1, jn,
    ldexp, lgamma, log, log10, log1p, log2, logb,
@@ -87,9 +87,8 @@
    aren't checked at the moment.
 
    NaN values: There exist signalling and quiet NaNs.  This implementation
-   only uses quiet NaN as parameter but does not differentiate
-   between the two kinds of NaNs as result.  Where the sign of a NaN is
-   significant, this is not tested.
+   only uses quiet NaN as parameter.  Where the sign of a NaN is
+   significant, this is not tested.  The payload of NaNs is not examined.
 
    Inline functions: Inlining functions should give an improvement in
    speed - but not in precission.  The inlined functions return
@@ -265,6 +264,19 @@ set_max_error (FLOAT current, FLOAT *curr_max_error)
 }
 
 
+/* Print a FLOAT.  */
+static void
+print_float (FLOAT f)
+{
+  /* As printf doesn't differ between a sNaN and a qNaN, do this manually.  */
+  if (issignaling (f))
+    printf ("sNaN\n");
+  else if (isnan (f))
+    printf ("qNaN\n");
+  else
+    printf ("% .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n", f, f);
+}
+
 /* Should the message print to screen?  This depends on the verbose flag,
    and the test status.  */
 static int
@@ -534,7 +546,11 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
   FLOAT ulp = 0;
 
   test_exceptions (test_name, exceptions);
-  if (isnan (computed) && isnan (expected))
+  if (issignaling (computed) && issignaling (expected))
+    ok = 1;
+  else if (issignaling (computed) || issignaling (expected))
+    ok = 0;
+  else if (isnan (computed) && isnan (expected))
     ok = 1;
   else if (isinf (computed) && isinf (expected))
     {
@@ -548,8 +564,9 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
       else
        ok = 1;
     }
-  /* Don't calc ulp for NaNs or infinities.  */
-  else if (isinf (computed) || isnan (computed) || isinf (expected) || isnan (expected))
+  /* Don't calculate ULPs for infinities or any kind of NaNs.  */
+  else if (isinf (computed) || isnan (computed)
+          || isinf (expected) || isnan (expected))
     ok = 0;
   else
     {
@@ -594,10 +611,10 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
        printf ("Failure: ");
       printf ("Test: %s\n", test_name);
       printf ("Result:\n");
-      printf (" is:         % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n",
-             computed, computed);
-      printf (" should be:  % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n",
-             expected, expected);
+      printf (" is:         ");
+      print_float (computed);
+      printf (" should be:  ");
+      print_float (expected);
       if (print_diff)
        {
          printf (" difference: % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR
@@ -7812,6 +7829,22 @@ isnormal_test (void)
   END (isnormal);
 }
 
+static void
+issignaling_test (void)
+{
+  START (issignaling);
+
+  TEST_f_b (issignaling, 0, 0);
+  TEST_f_b (issignaling, minus_zero, 0);
+  TEST_f_b (issignaling, 10, 0);
+  TEST_f_b (issignaling, min_subnorm_value, 0);
+  TEST_f_b (issignaling, plus_infty, 0);
+  TEST_f_b (issignaling, minus_infty, 0);
+  TEST_f_b (issignaling, qnan_value, 0);
+
+  END (issignaling);
+}
+
 static void
 isunordered_test (void)
 {
@@ -12448,6 +12481,7 @@ main (int argc, char **argv)
   isinf_test ();
   isnan_test ();
   isnormal_test ();
+  issignaling_test ();
   signbit_test ();
 
   /* Trigonometric functions:  */
index 2f25c237d4183f456c6f3859d81ae512b3ea0034..e3adf096ad54e9b83740ed3765c8291e7edd3b4b 100644 (file)
@@ -282,6 +282,20 @@ enum
 
 #endif /* Use ISO C99.  */
 
+#ifdef __USE_GNU
+/* Return nonzero value if X is a signaling NaN.  */
+# ifdef __NO_LONG_DOUBLE_MATH
+#  define issignaling(x) \
+     (sizeof (x) == sizeof (float) ? __issignalingf (x) : __issignaling (x))
+# else
+#  define issignaling(x) \
+     (sizeof (x) == sizeof (float)                                           \
+      ? __issignalingf (x)                                                   \
+      : sizeof (x) == sizeof (double)                                        \
+      ? __issignaling (x) : __issignalingl (x))
+# endif
+#endif /* Use GNU.  */
+
 #ifdef __USE_MISC
 /* Support for various different standard error handling behaviors.  */
 typedef enum
index f185cbb45c19fa50c1023d2d52c81963e0f6079a..82f1dbe2093335c29ba5bdd6302faf675c5e06dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Test signaling NaNs in isnan, isinf, and similar functions.
+/* Test signaling NaNs in issignaling, isnan, isinf, and similar functions.
    Copyright (C) 2008-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Andreas Jaeger <aj@suse.de>, 2005.
@@ -117,6 +117,48 @@ NAME (void)                                                                      \
                                                                              \
   feclearexcept(FE_ALL_EXCEPT);                                                      \
   feenableexcept (FE_ALL_EXCEPT);                                            \
+  if (sigsetjmp(sigfpe_buf, 0))                                                      \
+    {                                                                        \
+      printf (#FLOAT " issignaling (qNaN) raised SIGFPE\n");                 \
+      errors++;                                                                      \
+    } else {                                                                 \
+      check (#FLOAT " issignaling (qNaN)", !issignaling (qNaN_var));         \
+    }                                                                        \
+                                                                             \
+  feclearexcept(FE_ALL_EXCEPT);                                                      \
+  feenableexcept (FE_ALL_EXCEPT);                                            \
+  if (sigsetjmp(sigfpe_buf, 0))                                                      \
+    {                                                                        \
+      printf (#FLOAT " issignaling (-qNaN) raised SIGFPE\n");                \
+      errors++;                                                                      \
+    } else {                                                                 \
+      check (#FLOAT " issignaling (-qNaN)", !issignaling (-qNaN_var));       \
+    }                                                                        \
+                                                                             \
+  feclearexcept(FE_ALL_EXCEPT);                                                      \
+  feenableexcept (FE_ALL_EXCEPT);                                            \
+  if (sigsetjmp(sigfpe_buf, 0))                                                      \
+    {                                                                        \
+      printf (#FLOAT " issignaling (sNaN) raised SIGFPE\n");                 \
+      errors++;                                                                      \
+    } else {                                                                 \
+      check (#FLOAT " issignaling (sNaN)",                                   \
+            SNAN_TESTS (FLOAT) ? issignaling (sNaN_var) : 1);                \
+    }                                                                        \
+                                                                             \
+  feclearexcept(FE_ALL_EXCEPT);                                                      \
+  feenableexcept (FE_ALL_EXCEPT);                                            \
+  if (sigsetjmp(sigfpe_buf, 0))                                                      \
+    {                                                                        \
+      printf (#FLOAT " issignaling (-sNaN) raised SIGFPE\n");                \
+      errors++;                                                                      \
+    } else {                                                                 \
+      check (#FLOAT " issignaling (-sNaN)",                                  \
+            SNAN_TESTS (FLOAT) ? issignaling (minus_sNaN_var) : 1);          \
+    }                                                                        \
+                                                                             \
+  feclearexcept(FE_ALL_EXCEPT);                                                      \
+  feenableexcept (FE_ALL_EXCEPT);                                            \
   if (sigsetjmp(sigfpe_buf, 0))                                                      \
     {                                                                        \
       printf (#FLOAT " isnan (qNaN) raised SIGFPE\n");                       \
index 0610c177d99a853cc49a2e11b6fa68c9b46a21bc..6aa0e9188b4544ac5345ba01212ecc4d6d2bcdcd 100644 (file)
@@ -1,3 +1,7 @@
+2013-04-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+       * sysdeps/hppa/math_private.h: New file.
+
 2013-03-06  Andreas Jaeger  <aj@suse.de>
 
        * sysdeps/unix/sysv/linux/hppa/bits/msq.h (MSG_COPY): Define.
index 539cacf19d49f50c71e2aca393e7f2c81a80dc59..b221512655711735d236780036b858772d9822ac 100644 (file)
@@ -1,3 +1,7 @@
+2013-04-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+       * sysdeps/mips/math_private.h: New file.
+
 2013-03-20  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/unix/sysv/linux/mips/configure.in (default-abi): Set
diff --git a/ports/sysdeps/hppa/math_private.h b/ports/sysdeps/hppa/math_private.h
new file mode 100644 (file)
index 0000000..03b0711
--- /dev/null
@@ -0,0 +1,27 @@
+/* Internal math stuff.  HPPA version.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _MATH_PRIVATE_H
+
+/* One of the few architectures where the meaning of the quiet/signaling bit is
+   inverse to IEEE 754-2008 (as well as common practice for IEEE 754-1985).  */
+#define HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+
+#include_next <math_private.h>
+
+#endif
diff --git a/ports/sysdeps/mips/math_private.h b/ports/sysdeps/mips/math_private.h
new file mode 100644 (file)
index 0000000..f0ba4ee
--- /dev/null
@@ -0,0 +1,27 @@
+/* Internal math stuff.  MIPS version.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _MATH_PRIVATE_H
+
+/* One of the few architectures where the meaning of the quiet/signaling bit is
+   inverse to IEEE 754-2008 (as well as common practice for IEEE 754-1985).  */
+#define HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+
+#include_next <math_private.h>
+
+#endif
index 14b7edfe2e66d91959d6586bb9c5550693583225..0f1cfc8702480b365fb890ae91258c3527c586fa 100644 (file)
@@ -395,3 +395,8 @@ GLIBC_2.17
  yn F
  ynf F
  ynl F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
index 9c4170dbe4ad658e437960169af08b92b4e4fc91..400a851d4de8d3b1d53bc565bd9a809cc6dbae02 100644 (file)
@@ -391,6 +391,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  feclearexcept F
index cee34728d857a8ab3fa4124e7f2fdc30e4c359a1..614e5ebe5c4622688f733f19102ea7858d5ec169 100644 (file)
@@ -54,6 +54,10 @@ GLIBC_2.15
  __y1f_finite F
  __yn_finite F
  __ynf_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
 GLIBC_2.4
  GLIBC_2.4 A
  _LIB_VERSION D 0x4
index 1fb51a118ddd418888710867a18953674589bc82..db8b2791105a59010bb7ff07779859994e241488 100644 (file)
@@ -18,6 +18,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  _LIB_VERSION D 0x4
index cee34728d857a8ab3fa4124e7f2fdc30e4c359a1..614e5ebe5c4622688f733f19102ea7858d5ec169 100644 (file)
@@ -54,6 +54,10 @@ GLIBC_2.15
  __y1f_finite F
  __yn_finite F
  __ynf_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
 GLIBC_2.4
  GLIBC_2.4 A
  _LIB_VERSION D 0x4
index 35fc1e3d72d584dbaf342d8351687fbf6cbb5462..0beecb7246257ffec7ecd8fe331e1c718eefe44c 100644 (file)
@@ -396,6 +396,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  feclearexcept F
index defa1b0b49bea17c187be293229dcf08653564fe..53812463c496f1bcb4dd1dd0abf86b357fdd006d 100644 (file)
@@ -212,6 +212,10 @@ GLIBC_2.15
  __y1f_finite F
  __yn_finite F
  __ynf_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
 GLIBC_2.2
  GLIBC_2.2 A
  __clog10 F
index 064eeba0b1cbcb48bc321ca1ba81b3f5dd6beffa..bb397951797e306f02196c60a2d2033eceee809b 100644 (file)
@@ -239,6 +239,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  __clog10 F
index 064eeba0b1cbcb48bc321ca1ba81b3f5dd6beffa..bb397951797e306f02196c60a2d2033eceee809b 100644 (file)
@@ -239,6 +239,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  __clog10 F
index ddc8576866c0d40fb5e3d0891628f00c8b3b7815..9bd593c0e9ed01eb34ecc4c7ef24c7affb3e7b0f 100644 (file)
@@ -396,6 +396,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  feclearexcept F
index 601b505ead70d0cc99da6ebca3267ee5ef3cdad2..cb0d1a44233e08c288b96b6162c048a6569e3da3 100644 (file)
@@ -367,3 +367,7 @@ GLIBC_2.15
  __y1f_finite F
  __yn_finite F
  __ynf_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
index 601b505ead70d0cc99da6ebca3267ee5ef3cdad2..cb0d1a44233e08c288b96b6162c048a6569e3da3 100644 (file)
@@ -367,3 +367,7 @@ GLIBC_2.15
  __y1f_finite F
  __yn_finite F
  __ynf_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
index 601b505ead70d0cc99da6ebca3267ee5ef3cdad2..cb0d1a44233e08c288b96b6162c048a6569e3da3 100644 (file)
@@ -367,3 +367,7 @@ GLIBC_2.15
  __y1f_finite F
  __yn_finite F
  __ynf_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
index 76f738ee9989dc94eb9993b001180b2065895f22..da8747a9442737c722e2e76b236562735a00891d 100644 (file)
@@ -34,3 +34,9 @@
   (sizeof (x) == sizeof (float) ? SNAN_TESTS_float                     \
    : sizeof (x) == sizeof (double) ? SNAN_TESTS_double                 \
    : SNAN_TESTS_long_double)
+
+/* Indicate whether to run tests involving type casts of sNaN values.  These
+   are run unless overridden.  */
+#ifndef SNAN_TESTS_TYPE_CAST
+# define SNAN_TESTS_TYPE_CAST  1
+#endif
diff --git a/sysdeps/ieee754/dbl-64/s_issignaling.c b/sysdeps/ieee754/dbl-64/s_issignaling.c
new file mode 100644 (file)
index 0000000..f475bc7
--- /dev/null
@@ -0,0 +1,46 @@
+/* Test for signaling NaN.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_private.h>
+
+int
+__issignaling (double x)
+{
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+  u_int32_t hxi;
+  GET_HIGH_WORD (hxi, x);
+  /* We only have to care about the high-order bit of x's significand, because
+     having it set (sNaN) already makes the significand different from that
+     used to designate infinity.  */
+  return (hxi & 0x7ff80000) == 0x7ff80000;
+#else
+  u_int32_t hxi, lxi;
+  EXTRACT_WORDS (hxi, lxi, x);
+  /* To keep the following comparison simple, toggle the quiet/signaling bit,
+     so that it is set for sNaNs.  This is inverse to IEEE 754-2008 (as well as
+     common practice for IEEE 754-1985).  */
+  hxi ^= 0x00080000;
+  /* If lxi != 0, then set any suitable bit of the significand in hxi.  */
+  hxi |= (lxi | -lxi) >> 31;
+  /* We have to compare for greater (instead of greater or equal), because x's
+     significand being all-zero designates infinity not NaN.  */
+  return (hxi & 0x7fffffff) > 0x7ff80000;
+#endif
+}
+libm_hidden_def (__issignaling)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c
new file mode 100644 (file)
index 0000000..3fa0254
--- /dev/null
@@ -0,0 +1,43 @@
+/* Test for signaling NaN.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_private.h>
+
+int
+__issignaling (double x)
+{
+  u_int64_t xi;
+  EXTRACT_WORDS64 (xi, x);
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+# error untested
+  /* We only have to care about the high-order bit of x's significand, because
+     having it set (sNaN) already makes the significand different from that
+     used to designate infinity.  */
+  return (xi & UINT64_C (0x7ff8000000000000)) == UINT64_C (0x7ff8000000000000);
+#else
+  /* To keep the following comparison simple, toggle the quiet/signaling bit,
+     so that it is set for sNaNs.  This is inverse to IEEE 754-2008 (as well as
+     common practice for IEEE 754-1985).  */
+  xi ^= UINT64_C (0x0008000000000000);
+  /* We have to compare for greater (instead of greater or equal), because x's
+     significand being all-zero designates infinity not NaN.  */
+  return (xi & UINT64_C (0x7fffffffffffffff)) > UINT64_C (0x7ff8000000000000);
+#endif
+}
+libm_hidden_def (__issignaling)
diff --git a/sysdeps/ieee754/flt-32/s_issignalingf.c b/sysdeps/ieee754/flt-32/s_issignalingf.c
new file mode 100644 (file)
index 0000000..59a1892
--- /dev/null
@@ -0,0 +1,42 @@
+/* Test for signaling NaN.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_private.h>
+
+int
+__issignalingf (float x)
+{
+  u_int32_t xi;
+  GET_FLOAT_WORD (xi, x);
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+  /* We only have to care about the high-order bit of x's significand, because
+     having it set (sNaN) already makes the significand different from that
+     used to designate infinity.  */
+  return (xi & 0x7fc00000) == 0x7fc00000;
+#else
+  /* To keep the following comparison simple, toggle the quiet/signaling bit,
+     so that it is set for sNaNs.  This is inverse to IEEE 754-2008 (as well as
+     common practice for IEEE 754-1985).  */
+  xi ^= 0x00400000;
+  /* We have to compare for greater (instead of greater or equal), because x's
+     significand being all-zero designates infinity not NaN.  */
+  return (xi & 0x7fffffff) > 0x7fc00000;
+#endif
+}
+libm_hidden_def (__issignalingf)
diff --git a/sysdeps/ieee754/ldbl-128/s_issignalingl.c b/sysdeps/ieee754/ldbl-128/s_issignalingl.c
new file mode 100644 (file)
index 0000000..b69a66d
--- /dev/null
@@ -0,0 +1,45 @@
+/* Test for signaling NaN.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_private.h>
+
+int
+__issignalingl (long double x)
+{
+  u_int64_t hxi, lxi __attribute__ ((unused));
+  GET_LDOUBLE_WORDS64 (hxi, lxi, x);
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+  /* We only have to care about the high-order bit of x's significand, because
+     having it set (sNaN) already makes the significand different from that
+     used to designate infinity.  */
+  return ((hxi & UINT64_C (0x7fff800000000000))
+          == UINT64_C (0x7fff800000000000));
+#else
+  /* To keep the following comparison simple, toggle the quiet/signaling bit,
+     so that it is set for sNaNs.  This is inverse to IEEE 754-2008 (as well as
+     common practice for IEEE 754-1985).  */
+  hxi ^= UINT64_C (0x0000800000000000);
+  /* If lxi != 0, then set any suitable bit of the significand in hxi.  */
+  hxi |= (lxi | -lxi) >> 63;
+  /* We have to compare for greater (instead of greater or equal), because x's
+     significand being all-zero designates infinity not NaN.  */
+  return (hxi & UINT64_C (0x7fffffffffffffff)) > UINT64_C (0x7fff800000000000);
+#endif
+}
+libm_hidden_def (__issignalingl)
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c b/sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c
new file mode 100644 (file)
index 0000000..96fab1a
--- /dev/null
@@ -0,0 +1,45 @@
+/* Test for signaling NaN.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_private.h>
+
+int
+__issignalingl (long double x)
+{
+  u_int64_t xi;
+  /* For inspecting NaN status, we only have to look at the first of the pair
+     of IEEE 754 64-bit precision numbers.  */
+  GET_LDOUBLE_MSW64 (xi, x);
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+# error untested
+  /* We only have to care about the high-order bit of x's significand, because
+     having it set (sNaN) already makes the significand different from that
+     used to designate infinity.  */
+  return (xi & UINT64_C (0x7ff8000000000000)) == UINT64_C (0x7ff8000000000000);
+#else
+  /* To keep the following comparison simple, toggle the quiet/signaling bit,
+     so that it is set for sNaNs.  This is inverse to IEEE 754-2008 (as well as
+     common practice for IEEE 754-1985).  */
+  xi ^= UINT64_C (0x0008000000000000);
+  /* We have to compare for greater (instead of greater or equal), because x's
+     significand being all-zero designates infinity not NaN.  */
+  return (xi & UINT64_C (0x7fffffffffffffff)) > UINT64_C (0x7ff8000000000000);
+#endif
+}
+libm_hidden_def (__issignalingl)
diff --git a/sysdeps/ieee754/ldbl-96/s_issignalingl.c b/sysdeps/ieee754/ldbl-96/s_issignalingl.c
new file mode 100644 (file)
index 0000000..107aff1
--- /dev/null
@@ -0,0 +1,43 @@
+/* Test for signaling NaN.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_private.h>
+
+int
+__issignalingl (long double x)
+{
+  u_int32_t exi, hxi, lxi;
+  GET_LDOUBLE_WORDS (exi, hxi, lxi, x);
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+# error not implemented
+#else
+  /* To keep the following comparison simple, toggle the quiet/signaling bit,
+     so that it is set for sNaNs.  This is inverse to IEEE 754-2008 (as well as
+     common practice for IEEE 754-1985).  */
+  hxi ^= 0x40000000;
+  /* If lxi != 0, then set any suitable bit of the significand in hxi.  */
+  hxi |= (lxi | -lxi) >> 31;
+  /* We do not recognize a pseudo NaN as sNaN; they're invalid on 80387 and
+     later.  */
+  /* We have to compare for greater (instead of greater or equal), because x's
+     significand being all-zero designates infinity not NaN.  */
+  return ((exi & 0x7fff) == 0x7fff) && (hxi > 0xc0000000);
+#endif
+}
+libm_hidden_def (__issignalingl)
diff --git a/sysdeps/powerpc/math-tests.h b/sysdeps/powerpc/math-tests.h
new file mode 100644 (file)
index 0000000..0f09610
--- /dev/null
@@ -0,0 +1,26 @@
+/* Configuration for math tests.  PowerPC version.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* On PowerPC, in versions of GCC up to at least 4.7.2, a type cast -- which is
+   a IEEE 754-2008 general-computational convertFormat operation (IEEE
+   754-2008, 5.4.2) -- does not turn a sNaN into a qNaN (whilst raising an
+   INVALID exception), which is contrary to IEEE 754-2008 5.1 and 7.2.  This
+   renders certain tests infeasible in this scenario.  */
+#define SNAN_TESTS_TYPE_CAST   0
+
+#include_next <math-tests.h>
index 401a2c6ddf022dfa92a48770350db280957fb5c7..c185f0b205d954982a9b0387e909a68009fb3fd6 100644 (file)
@@ -396,6 +396,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  __expl F
index 620aff9e9438f28b0852662cdd8c5eab43dbe79d..76a4ba31db70c7ee417893448541cbcccba5bdf1 100644 (file)
@@ -397,6 +397,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  feclearexcept F
index 89422ab9f4c6f90f5f6b8e6b503240850f176ae9..d309a6fa1a4a0ef605d00e952ca17f8136cf1ad7 100644 (file)
@@ -81,6 +81,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.3
  GLIBC_2.3 A
  _LIB_VERSION D 0x4
index ae8af50eb8666dd5ffa0613881e1bcfcb639854a..f836c90d9478a0a56314a3343c47f19ef0cac884 100644 (file)
@@ -393,6 +393,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  fedisableexcept F
index acf4d68514cff432bc0c169ea95777613891aa1d..a0891ad2526e7a4c6349cc88d641539fddd55fa3 100644 (file)
@@ -81,6 +81,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  _LIB_VERSION D 0x4
index d85192910fa1d618ff30c178c5f1d28e18996d17..92821fdbb9ca36c5378895ff81470aed4c379649 100644 (file)
@@ -54,6 +54,10 @@ GLIBC_2.15
  __y1f_finite F
  __yn_finite F
  __ynf_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
 GLIBC_2.2
  GLIBC_2.2 A
  _LIB_VERSION D 0x4
index 4c6ec6b7127a4e88ffc2c94f890837d9e2c31197..9a1fcb1b4666ca13c4dcda962fb9673c612bf645 100644 (file)
@@ -388,6 +388,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  feclearexcept F
index 22fb92aec5a777bb5b6977b9fd3e46e9c09ada1d..2b41d342256748c7a8609584a603958624f62cad 100644 (file)
@@ -81,6 +81,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2
  GLIBC_2.2 A
  _LIB_VERSION D 0x4
index 7bf568c51c1878ed57acc8905f2970c990262994..2390934678c667626b72ff33f1d8c16e3b9e870e 100644 (file)
@@ -81,6 +81,11 @@ GLIBC_2.15
  __yn_finite F
  __ynf_finite F
  __ynl_finite F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F
 GLIBC_2.2.5
  GLIBC_2.2.5 A
  _LIB_VERSION D 0x4
index 0f3ea4ba4028cfbdf4644f074c1a76f814aa36a1..1825adb1b31cfdb780be3621571265d96de56985 100644 (file)
@@ -395,3 +395,8 @@ GLIBC_2.16
  yn F
  ynf F
  ynl F
+GLIBC_2.18
+ GLIBC_2.18 A
+ __issignaling F
+ __issignalingf F
+ __issignalingl F