public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 13:03   ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Zack Weinberg
@ 2017-02-20 13:03     ` Zack Weinberg
  2017-02-20 13:04       ` [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes Zack Weinberg
                         ` (3 more replies)
  2017-02-20 13:58     ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Carlos O'Donell
  1 sibling, 4 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-20 13:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: carlos, joseph, adhemerval.zanella

These are a grab bag of changes where the testsuite was using internal
symbols of some variety, but this was straightforward to fix, and the
fixed code should work with or without the change to compile the
testsuite under _ISOMAC.  They are, however, not *quite* obvious and I
would appreciate a second pair of eyes.

math/test-misc.c was using #ifndef NO_LONG_DOUBLE, which is an internal
configuration macro, to decide whether to do certain tests involving
'long double'.  I changed the test to #if LDBL_MANT_DIG > DBL_MANT_DIG
instead, which uses only public float.h macros and is equivalent on
all supported platforms.  (Note that NO_LONG_DOUBLE doesn't mean 'the
compiler doesn't support long double', it means 'long double is the
same as double'.)  It's possible that instead we should just do these
tests unconditionally on all platforms.

atomic.h cannot be used by code compiled under _ISOMAC, but
stdatomic.h can.  There are quite a few tests that use atomic.h; most
of them were not straightforward to change to stdatomic.h, but
nptl/tst-join7.c was, so I did that.

posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; I
duplicated the definition into the .c file, which is not ideal, but
since this didn't come up anywhere else, inventing a new header for it
seems like excessive polish.

string/strcasestr.c had an explicit #include <config.h> - this appears
originally to have been externally maintained code.  Removed.

sysdeps/powerpc/fpu/tst-setcontext-fpscr.c appears to have been
written before the advent of sys/auxv.h; it was using sysdep.h
instead, which is obviously a no-go in _ISOMAC mode.  I made the
minimal change; I think a big chunk of this file could be replaced by
a simple call to getauxval but I'll let someone who actually has a
powerpc machine to test on do that.

tst-writev.c has a configuration macro 'ARTIFICIAL_LIMIT' that the
Makefiles are expected to define, and sysdeps/unix/sysv/linux/Makefile
was using the internal __getpagesize in the definition; changed to
sysconf(_SC_PAGESIZE) which is the POSIX equivalent.

ia64-linux doesn't supply 'clone', only '__clone2', which is not
defined in the public headers(!)  All the other clone tests have local
extern declarations of __clone2, but tst-clone.c doesn't; it was
getting away with this because include/sched.h does declare __clone2.

Finally, tst-setgetname.c was using kernel-features.h (also a no-go in
_ISOMAC mode) just for one __ASSUME macro which it doesn't really need.

zw

	* math/test-misc.c: Instead of testing NO_LONG_DOUBLE, test
	whether LDBL_MANT_DIG is greater than DBL_MANT_DIG.
	* nptl/tst-join7.c: Include stdlib.h. Include stdatomic.h instead of
	atomic.h.  Use C11 atomics instead of libc-internal atomics.
	* posix/wordexp-test.c: Include stdint.h. Don't include
	libc-internal.h. Define PTR_ALIGN_DOWN here.
	* string/strcasestr.c: No need to include config.h.
	* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c: Include
	sys/auxv.h. Don't include sysdep.h.
        * sysdeps/unix/sysv/linux/tst-clone.c [__ia64__]: Add extern
        declaration of __clone2.
	* sysdeps/unix/sysv/linux/Makefile (CFLAGS-tst-writev.c):
	Use sysconf (_SC_PAGESIZE) instead of __getpagesize in definition of
	ARTIFICIAL_LIMIT.
	* sysdeps/unix/sysv/linux/tst-setgetname.c:
	Don't include kernel-features.h. Don't #ifndef out anything
	based on __ASSUME macros.
---
 math/test-misc.c                           | 23 +++++++++++------------
 nptl/tst-join7mod.c                        |  9 +++++----
 posix/wordexp-test.c                       |  6 +++++-
 string/strcasestr.c                        |  4 ----
 sysdeps/powerpc/fpu/tst-setcontext-fpscr.c |  2 +-
 sysdeps/unix/sysv/linux/Makefile           |  2 +-
 sysdeps/unix/sysv/linux/tst-clone.c        |  5 +++++
 sysdeps/unix/sysv/linux/tst-setgetname.c   |  3 ---
 8 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/math/test-misc.c b/math/test-misc.c
index 8968b80662..09812a3ccf 100644
--- a/math/test-misc.c
+++ b/math/test-misc.c
@@ -30,7 +30,7 @@ do_test (void)
 {
   int result = 0;
 
-#ifndef NO_LONG_DOUBLE
+#if LDBL_MANT_DIG > DBL_MANT_DIG
   {
     long double x = 0x100000001ll + (long double) 0.5;
     long double q;
@@ -60,7 +60,7 @@ do_test (void)
 # elif LDBL_MANT_DIG == 113
     m = 0x1.ffffffffffffffffffffffffffffp-1L;
 # else
-#  error "Please adjust"
+#  error "Unsupported LDBL_MANT_DIG, please adjust"
 # endif
 
     for (i = LDBL_MAX_EXP, x = LDBL_MAX; i >= LDBL_MIN_EXP; --i, x /= 2.0L)
@@ -720,7 +720,7 @@ do_test (void)
       }
   }
 
-#ifndef NO_LONG_DOUBLE
+#if LDBL_MANT_DIG > DBL_MANT_DIG
   {
     long double v1, v2;
 
@@ -910,7 +910,7 @@ do_test (void)
       puts ("isnormal (DBL_MIN) failed");
       result = 1;
     }
-#ifndef NO_LONG_DOUBLE
+#if LDBL_MANT_DIG > DBL_MANT_DIG
   if (! isnormal (LDBL_MIN))
     {
       puts ("isnormal (LDBL_MIN) failed");
@@ -960,7 +960,7 @@ do_test (void)
   }
 #endif
 
-#ifndef NO_LONG_DOUBLE
+#if LDBL_MANT_DIG > DBL_MANT_DIG
   {
     long double r;
 
@@ -1027,7 +1027,7 @@ do_test (void)
       puts ("nextafter -DBL_MIN test failed");
       result = 1;
     }
-#ifndef NO_LONG_DOUBLE
+#if LDBL_MANT_DIG > DBL_MANT_DIG
   if (nextafterl (nextafterl (LDBL_MIN, LDBL_MIN / 2.0), LDBL_MIN)
       != LDBL_MIN)
     {
@@ -1072,7 +1072,7 @@ do_test (void)
     }
 #endif
 
-#ifndef NO_LONG_DOUBLE
+#if LDBL_MANT_DIG > DBL_MANT_DIG
   volatile long double ld1 = LDBL_MAX;
   volatile long double ld2 = LDBL_MAX / 2;
   (void) &ld1;
@@ -1087,9 +1087,8 @@ do_test (void)
       result = 1;
     }
 # endif
-#endif
 
-#if !defined NO_LONG_DOUBLE && LDBL_MANT_DIG == 113
+# if LDBL_MANT_DIG == 113
   volatile long double ld3 = 0x1.0000000000010000000100000001p+1;
   volatile long double ld4 = 0x1.0000000000000000000000000001p+1;
   (void) &ld3;
@@ -1100,14 +1099,13 @@ do_test (void)
       printf ("long double subtraction test failed %.28La\n", ld3);
       result = 1;
     }
-#endif
+# endif
 
 /* Skip testing IBM long double format, for 2 reasons:
    1) it only supports FE_TONEAREST
    2) nextafter (0.0, 1.0) == nextafterl (0.0L, 1.0L), so
       nextafter (0.0, 1.0) / 16.0L will be 0.0L.  */
-#if !defined NO_LONG_DOUBLE && LDBL_MANT_DIG >= DBL_MANT_DIG + 4 \
-    && LDBL_MANT_DIG != 106
+# if LDBL_MANT_DIG >= DBL_MANT_DIG + 4 && LDBL_MANT_DIG != 106
   int oldmode = fegetround ();
   int j;
   for (j = 0; j < 4; j++)
@@ -1197,6 +1195,7 @@ do_test (void)
       else
 	puts ("ignoring this failure");
     }
+# endif
 #endif
 
   return result;
diff --git a/nptl/tst-join7mod.c b/nptl/tst-join7mod.c
index 1d9c95d418..5a43404571 100644
--- a/nptl/tst-join7mod.c
+++ b/nptl/tst-join7mod.c
@@ -18,17 +18,18 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <pthread.h>
-#include <atomic.h>
+#include <stdatomic.h>
 
 static pthread_t th;
-static int running = 1;
+static atomic_int running = 1;
 
 static void *
 test_run (void *p)
 {
-  while (atomic_load_relaxed (&running))
+  while (atomic_load_explicit (&running, memory_order_relaxed))
     printf ("Test running\n");
   printf ("Test finished\n");
   return NULL;
@@ -49,7 +50,7 @@ do_init (void)
 static void __attribute__ ((destructor))
 do_end (void)
 {
-  atomic_store_relaxed (&running, 0);
+  atomic_store_explicit (&running, 0, memory_order_relaxed);
   int ret = pthread_join (th, NULL);
 
   if (ret != 0)
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
index 15eb233001..af174cf7d0 100644
--- a/posix/wordexp-test.c
+++ b/posix/wordexp-test.c
@@ -22,10 +22,14 @@
 #include <unistd.h>
 #include <pwd.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <wordexp.h>
-#include <libc-internal.h>
+
+#define ALIGN_DOWN(base, size)	((base) & -((__typeof__ (base)) (size)))
+#define PTR_ALIGN_DOWN(base, size) \
+  ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size)))
 
 #define IFS " \n\t"
 
diff --git a/string/strcasestr.c b/string/strcasestr.c
index a9ff18c7f5..2acf003155 100644
--- a/string/strcasestr.c
+++ b/string/strcasestr.c
@@ -25,10 +25,6 @@
  *
  * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de	*/
 
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
 /* Specification.  */
 #include <string.h>
 
diff --git a/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c b/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c
index 3a8d699b9a..4e3f90d4d3 100644
--- a/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c
+++ b/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c
@@ -26,8 +26,8 @@
 #include <malloc.h>
 #include <link.h>
 #include <elf.h>
-#include <sysdep.h>
 #include <fpu_control.h>
+#include <sys/auxv.h>
 
 static ucontext_t ctx[3];
 
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index b3d68665f9..fc29c54c86 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -20,7 +20,7 @@ sysdep_routines += clone umount umount2 readahead \
 		   personality
 
 CFLAGS-gethostid.c = -fexceptions
-CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=0x80000000-__getpagesize()"
+CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"
 
 # Note that bits/mman-linux.h is listed here though the file lives in the
 # top-level bits/ subdirectory instead of here in sysdeps/.../linux/bits/.
diff --git a/sysdeps/unix/sysv/linux/tst-clone.c b/sysdeps/unix/sysv/linux/tst-clone.c
index c4e6fbe48b..1da749db8d 100644
--- a/sysdeps/unix/sysv/linux/tst-clone.c
+++ b/sysdeps/unix/sysv/linux/tst-clone.c
@@ -23,6 +23,11 @@
 #include <unistd.h>
 #include <sched.h>
 
+#ifdef __ia64__
+extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
+		     size_t __child_stack_size, int __flags, void *__arg, ...);
+#endif
+
 int child_fn(void *arg)
 {
   puts ("FAIL: in child_fn(); should not be here");
diff --git a/sysdeps/unix/sysv/linux/tst-setgetname.c b/sysdeps/unix/sysv/linux/tst-setgetname.c
index 5acd614117..b1010f0446 100644
--- a/sysdeps/unix/sysv/linux/tst-setgetname.c
+++ b/sysdeps/unix/sysv/linux/tst-setgetname.c
@@ -23,7 +23,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <kernel-features.h>
 
 /* New name of process.  */
 #define NEW_NAME "setname"
@@ -101,7 +100,6 @@ do_test (int argc, char **argv)
     {
       res = get_self_comm (gettid (), name_check, TASK_COMM_LEN);
 
-#ifndef __ASSUME_PROC_PID_TASK_COMM
       /* On this first test we look for ENOENT to be returned from
          get_self_comm to indicate that the kernel is older than
          2.6.33 and doesn't contain comm within the proc structure.
@@ -111,7 +109,6 @@ do_test (int argc, char **argv)
 	  printf ("SKIP: The kernel does not have /proc/self/task/%%lu/comm.\n");
 	  return 0;
 	}
-#endif
 
       if (res == 0)
        {
-- 
2.11.0

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite.
  2017-02-20 13:03 ` [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h Zack Weinberg
@ 2017-02-20 13:03   ` Zack Weinberg
  2017-02-20 13:03     ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Zack Weinberg
  2017-02-20 13:58     ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Carlos O'Donell
  2017-02-20 13:52   ` [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h Carlos O'Donell
  1 sibling, 2 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-20 13:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: carlos, joseph, adhemerval.zanella

A few 'long double'-related tests include math_private.h just for
their variety of math_ldbl.h, which contains macros for assembling and
disassembling the binary representation of 'long double'.  math_ldbl.h
insists on being included from math_private.h, but if we relax this
restriction (and fix some portability sloppiness) we can use it
directly and not have to expose all of math_private.h to the
testsuite.

The only bit of this that I'm not 100% happy with is,
ldbl-128ibm/math_ldbl.h was using EXTRACT_WORDS64 from math_private.h.
I replicated the logic of EXTRACT_WORDS64 into the function that
needed it, which is the expeditious local fix.  It seems abstractly
better to add similar functionality to all varieties of ieee754.h, but
that would change a public API so I wasn't comfortable doing it in
this patch series.

zw

	* sysdeps/generic/math_private.h: Use __BIG_ENDIAN and
	__LITTLE_ENDIAN, not BIG_ENDIAN and LITTLE_ENDIAN.

	* sysdeps/generic/math_ldbl.h
	* sysdeps/ia64/fpu/math_ldbl.h
	* sysdeps/ieee754/ldbl-128/math_ldbl.h
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
	* sysdeps/ieee754/ldbl-96/math_ldbl.h
	* sysdeps/powerpc/fpu/math_ldbl.h
	* sysdeps/x86_64/fpu/math_ldbl.h:
	Allow direct inclusion.  Use uintNN_t instead of u_intNN_t.
	Use __BIG_ENDIAN and __LITTLE_ENDIAN, not BIG_ENDIAN and
	LITTLE_ENDIAN.  Include endian.h and/or stdint.h if necessary.

	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h: Don't use EXTRACT_WORDS64.

	* sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
	* sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
	* sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
	* sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c:
	Include math_ldbl.h, not math_private.h.
---
 sysdeps/generic/math_ldbl.h                        | 10 +++++----
 sysdeps/generic/math_private.h                     |  4 ++--
 sysdeps/ia64/fpu/math_ldbl.h                       | 22 ++++++++++--------
 sysdeps/ieee754/ldbl-128/math_ldbl.h               | 26 +++++++++++++---------
 sysdeps/ieee754/ldbl-128ibm/math_ldbl.h            | 18 ++++++++++-----
 .../ldbl-128ibm/test-canonical-ldbl-128ibm.c       |  2 +-
 .../ldbl-128ibm/test-totalorderl-ldbl-128ibm.c     |  2 +-
 sysdeps/ieee754/ldbl-96/math_ldbl.h                | 22 ++++++++++--------
 sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c   |  2 +-
 sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c |  2 +-
 sysdeps/powerpc/fpu/math_ldbl.h                    |  7 +++---
 sysdeps/x86_64/fpu/math_ldbl.h                     | 13 ++++++-----
 12 files changed, 77 insertions(+), 53 deletions(-)

diff --git a/sysdeps/generic/math_ldbl.h b/sysdeps/generic/math_ldbl.h
index f0b97ef8f9..4e7ee7912e 100644
--- a/sysdeps/generic/math_ldbl.h
+++ b/sysdeps/generic/math_ldbl.h
@@ -1,5 +1,7 @@
-#ifndef _MATH_PRIVATE_H_
-#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
-#endif
+#ifndef _MATH_LDBL_H_
+#define _MATH_LDBL_H_ 1
 
-/* This is empty.  Any machine using long double type will override this header.  */
+/* Any machine with a 'long double' distinct from 'double' must
+   override this header.  */
+
+#endif
diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h
index c0d4e3dbcd..be65b9487b 100644
--- a/sysdeps/generic/math_private.h
+++ b/sysdeps/generic/math_private.h
@@ -37,7 +37,7 @@
 /* A union which permits us to convert between a double and two 32 bit
    ints.  */
 
-#if __FLOAT_WORD_ORDER == BIG_ENDIAN
+#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
 
 typedef union
 {
@@ -52,7 +52,7 @@ typedef union
 
 #endif
 
-#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
+#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
 
 typedef union
 {
diff --git a/sysdeps/ia64/fpu/math_ldbl.h b/sysdeps/ia64/fpu/math_ldbl.h
index 475ca795fa..748e9aff5a 100644
--- a/sysdeps/ia64/fpu/math_ldbl.h
+++ b/sysdeps/ia64/fpu/math_ldbl.h
@@ -1,11 +1,13 @@
-#ifndef _MATH_PRIVATE_H_
-#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
-#endif
+#ifndef _MATH_LDBL_H_
+#define _MATH_LDBL_H_ 1
+
+#include <stdint.h>
+#include <endian.h>
 
 /* A union which permits us to convert between a long double and
    three 32 bit ints.  */
 
-#if __FLOAT_WORD_ORDER == BIG_ENDIAN
+#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
 
 typedef union
 {
@@ -15,22 +17,22 @@ typedef union
     unsigned int empty0:32;
     int sign_exponent:16;
     unsigned int empty1:16;
-    u_int32_t msw;
-    u_int32_t lsw;
+    uint32_t msw;
+    uint32_t lsw;
   } parts;
 } ieee_long_double_shape_type;
 
 #endif
 
-#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
+#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
 
 typedef union
 {
   long double value;
   struct
   {
-    u_int32_t lsw;
-    u_int32_t msw;
+    uint32_t lsw;
+    uint32_t msw;
     int sign_exponent:16;
     unsigned int empty1:16;
     unsigned int empty0:32;
@@ -98,3 +100,5 @@ do {								\
   se_u.parts.sign_exponent = (exp);				\
   (d) = se_u.value;						\
 } while (0)
+
+#endif /* math_ldbl.h */
diff --git a/sysdeps/ieee754/ldbl-128/math_ldbl.h b/sysdeps/ieee754/ldbl-128/math_ldbl.h
index c1980c9401..6ea2c385df 100644
--- a/sysdeps/ieee754/ldbl-128/math_ldbl.h
+++ b/sysdeps/ieee754/ldbl-128/math_ldbl.h
@@ -1,41 +1,43 @@
-#ifndef _MATH_PRIVATE_H_
-#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
-#endif
+#ifndef _MATH_LDBL_H_
+#define _MATH_LDBL_H_ 1
+
+#include <stdint.h>
+#include <endian.h>
 
 /* A union which permits us to convert between a long double and
    four 32 bit ints or two 64 bit ints.  */
 
-#if __FLOAT_WORD_ORDER == BIG_ENDIAN
+#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
 
 typedef union
 {
   long double value;
   struct
   {
-    u_int64_t msw;
-    u_int64_t lsw;
+    uint64_t msw;
+    uint64_t lsw;
   } parts64;
   struct
   {
-    u_int32_t w0, w1, w2, w3;
+    uint32_t w0, w1, w2, w3;
   } parts32;
 } ieee854_long_double_shape_type;
 
 #endif
 
-#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
+#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
 
 typedef union
 {
   long double value;
   struct
   {
-    u_int64_t lsw;
-    u_int64_t msw;
+    uint64_t lsw;
+    uint64_t msw;
   } parts64;
   struct
   {
-    u_int32_t w3, w2, w1, w0;
+    uint32_t w3, w2, w1, w0;
   } parts32;
 } ieee854_long_double_shape_type;
 
@@ -96,3 +98,5 @@ do {								\
 */
 #define _Float128 long double
 #define L(x) x##L
+
+#endif /* math_ldbl.h */
diff --git a/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
index 625ce00e13..5420fb27af 100644
--- a/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
+++ b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
@@ -1,6 +1,5 @@
-#ifndef _MATH_PRIVATE_H_
-#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
-#endif
+#ifndef _MATH_LDBL_H_
+#define _MATH_LDBL_H_ 1
 
 #include <ieee754.h>
 #include <stdint.h>
@@ -239,9 +238,14 @@ ldbl_nearbyint (double a)
 static inline void
 ldbl_canonicalize_int (double *a, double *aa)
 {
-  int64_t ax, aax;
-  EXTRACT_WORDS64 (ax, *a);
-  EXTRACT_WORDS64 (aax, *aa);
+  /* We can't use math_private.h macros in this file.  */
+  uint64_t ax, aax;
+  union { double value; uint64_t word; } extractor;
+  extractor.value = *a;
+  ax = extractor.word;
+  extractor.value = *aa;
+  aax = extractor.word;
+
   int expdiff = ((ax >> 52) & 0x7ff) - ((aax >> 52) & 0x7ff);
   if (expdiff <= 53)
     {
@@ -263,3 +267,5 @@ ldbl_canonicalize_int (double *a, double *aa)
 	}
     }
 }
+
+#endif /* math_ldbl.h */
diff --git a/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c b/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
index 8be4499bd5..75735db18e 100644
--- a/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
+++ b/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
@@ -18,7 +18,7 @@
 
 #include <float.h>
 #include <math.h>
-#include <math_private.h>
+#include <math_ldbl.h>
 #include <stdbool.h>
 #include <stdio.h>
 
diff --git a/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c b/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
index 86869aceda..eaada2f848 100644
--- a/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
+++ b/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
@@ -17,7 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
-#include <math_private.h>
+#include <math_ldbl.h>
 #include <stdbool.h>
 #include <stdio.h>
 
diff --git a/sysdeps/ieee754/ldbl-96/math_ldbl.h b/sysdeps/ieee754/ldbl-96/math_ldbl.h
index cca30657ce..74fbad6374 100644
--- a/sysdeps/ieee754/ldbl-96/math_ldbl.h
+++ b/sysdeps/ieee754/ldbl-96/math_ldbl.h
@@ -1,11 +1,13 @@
-#ifndef _MATH_PRIVATE_H_
-#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
-#endif
+#ifndef _MATH_LDBL_H_
+#define _MATH_LDBL_H_ 1
+
+#include <stdint.h>
+#include <endian.h>
 
 /* A union which permits us to convert between a long double and
    three 32 bit ints.  */
 
-#if __FLOAT_WORD_ORDER == BIG_ENDIAN
+#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
 
 typedef union
 {
@@ -14,22 +16,22 @@ typedef union
   {
     int sign_exponent:16;
     unsigned int empty:16;
-    u_int32_t msw;
-    u_int32_t lsw;
+    uint32_t msw;
+    uint32_t lsw;
   } parts;
 } ieee_long_double_shape_type;
 
 #endif
 
-#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
+#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
 
 typedef union
 {
   long double value;
   struct
   {
-    u_int32_t lsw;
-    u_int32_t msw;
+    uint32_t lsw;
+    uint32_t msw;
     int sign_exponent:16;
     unsigned int empty:16;
   } parts;
@@ -96,3 +98,5 @@ do {								\
   se_u.parts.sign_exponent = (exp);				\
   (d) = se_u.value;						\
 } while (0)
+
+#endif /* math_ldbl.h */
diff --git a/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c b/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
index db9db04367..3254097754 100644
--- a/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
+++ b/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
@@ -18,7 +18,7 @@
 
 #include <float.h>
 #include <math.h>
-#include <math_private.h>
+#include <math_ldbl.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c b/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
index eb21956e4f..4e01f15aa9 100644
--- a/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
+++ b/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
@@ -18,7 +18,7 @@
 
 #include <float.h>
 #include <math.h>
-#include <math_private.h>
+#include <math_ldbl.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/sysdeps/powerpc/fpu/math_ldbl.h b/sysdeps/powerpc/fpu/math_ldbl.h
index 36378c0239..597d216a07 100644
--- a/sysdeps/powerpc/fpu/math_ldbl.h
+++ b/sysdeps/powerpc/fpu/math_ldbl.h
@@ -1,6 +1,5 @@
-#ifndef _MATH_PRIVATE_H_
-#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
-#endif
+#ifndef _MATH_LDBL_H_PPC_
+#define _MATH_LDBL_H_PPC_ 1
 
 /* GCC does not optimize the default ldbl_pack code to not spill register
    in the stack. The following optimization tells gcc that pack/unpack
@@ -34,3 +33,5 @@ ldbl_unpack_ppc (long double l, double *a, double *aa)
 #define ldbl_unpack ldbl_unpack_ppc
 
 #include <sysdeps/ieee754/ldbl-128ibm/math_ldbl.h>
+
+#endif /* math_ldbl.h */
diff --git a/sysdeps/x86_64/fpu/math_ldbl.h b/sysdeps/x86_64/fpu/math_ldbl.h
index b9ff8dadaf..cbc47c2935 100644
--- a/sysdeps/x86_64/fpu/math_ldbl.h
+++ b/sysdeps/x86_64/fpu/math_ldbl.h
@@ -1,6 +1,7 @@
-#ifndef _MATH_PRIVATE_H_
-#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
-#endif
+#ifndef _MATH_LDBL_H_
+#define _MATH_LDBL_H_ 1
+
+#include <stdint.h>
 
 /* A union which permits us to convert between a long double and
    three 32 bit ints.  */
@@ -10,8 +11,8 @@ typedef union
   long double value;
   struct
   {
-    u_int32_t lsw;
-    u_int32_t msw;
+    uint32_t lsw;
+    uint32_t msw;
     int sign_exponent:16;
     unsigned int empty1:16;
     unsigned int empty0:32;
@@ -77,3 +78,5 @@ do {								\
   se_u.parts.sign_exponent = (exp);				\
   (d) = se_u.value;						\
 } while (0)
+
+#endif /* math_ldbl.h */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h.
  2017-02-20 13:03 [PATCH 0/4] Suppress internal declarations for most of the testsuite Zack Weinberg
@ 2017-02-20 13:03 ` Zack Weinberg
  2017-02-20 13:03   ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Zack Weinberg
  2017-02-20 13:52   ` [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h Carlos O'Donell
  0 siblings, 2 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-20 13:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: carlos, joseph, adhemerval.zanella

Quite a few tests include libc-internal.h just for the DIAG_* macros.
Split those macros to their own file, which can be included safely in
_ISOMAC mode.  I also moved ignore_value, since it seems logically
related, even though I didn't notice any tests needing it.

Compiling the testsuite in _ISOMAC mode revealed that somehow the
__nonnull annotations on pthread_mutexattr_destroy and unsetenv, in
the public headers, are ignored for internal code; because of this,
two tests need, but do not have, a -Wnonnull suppression.  Those
additions are also included in this patch, to keep everything
involving libc-diag.h together.

(Query, should libc-diag.h have a copyright header? libc-internal.h
doesn't.  (Should it?))

zw

	* include/libc-diag.h: New file which defines ignore_value,
	DIAG_PUSH_NEEDS_COMMENT, DIAG_POP_NEEDS_COMMENT,
	DIAG_IGNORE_NEEDS_COMMENT, and DIAG_IGNORE_Os_NEEDS_COMMENT...
	* include/libc-internal.h: ...moved from here; include libc-diag.h.

	* malloc/tst-malloc.c, malloc/tst-memcheck.c, malloc/tst-realloc.c
	* misc/tst-error1.c, posix/tst-dir.c, stdio-common/bug21.c
	* stdio-common/scanf14.c, stdio-common/scanf4.c, stdio-common/scanf7.c
	* stdio-common/test-vfprintf.c, stdio-common/tst-printf.c
	* stdio-common/tst-printfsz.c, stdio-common/tst-sprintf.c
	* stdio-common/tst-unlockedio.c, stdio-common/tstdiomisc.c
	* stdlib/bug-getcontext.c, string/tester.c, string/tst-endian.c
        * time/tst-strptime2.c, wcsmbs/tst-wcstof.c:
        Include libc-diag.h instead of libc-internal.h.

	* stdlib/tst-environ.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to unsetenv (NULL).
	* nptl/tst-mutex1.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to pthread_mutexattr_destroy (NULL).
---
 include/libc-diag.h           | 57 +++++++++++++++++++++++++++++++++++++++++++
 include/libc-internal.h       | 52 +--------------------------------------
 malloc/tst-malloc.c           |  2 +-
 malloc/tst-mcheck.c           |  2 +-
 malloc/tst-realloc.c          |  2 +-
 misc/tst-error1.c             |  2 +-
 nptl/tst-mutex1.c             |  7 +++++-
 posix/tst-dir.c               |  2 +-
 stdio-common/bug21.c          |  2 +-
 stdio-common/scanf14.c        |  2 +-
 stdio-common/scanf4.c         |  2 +-
 stdio-common/scanf7.c         |  2 +-
 stdio-common/test-vfprintf.c  |  2 +-
 stdio-common/tst-printf.c     |  2 +-
 stdio-common/tst-printfsz.c   |  2 +-
 stdio-common/tst-sprintf.c    |  2 +-
 stdio-common/tst-unlockedio.c |  2 +-
 stdio-common/tstdiomisc.c     |  2 +-
 stdlib/bug-getcontext.c       |  2 +-
 stdlib/tst-environ.c          |  7 +++++-
 string/tester.c               |  2 +-
 string/tst-endian.c           |  2 +-
 time/tst-strptime2.c          |  2 +-
 wcsmbs/tst-wcstof.c           |  2 +-
 24 files changed, 90 insertions(+), 73 deletions(-)
 create mode 100644 include/libc-diag.h

diff --git a/include/libc-diag.h b/include/libc-diag.h
new file mode 100644
index 0000000000..a6a413c567
--- /dev/null
+++ b/include/libc-diag.h
@@ -0,0 +1,57 @@
+/* Macros for controlling diagnostic output from the compiler.  */
+#ifndef _LIBC_DIAG_H
+#define _LIBC_DIAG_H 1
+
+/* Ignore the value of an expression when a cast to void does not
+   suffice (in particular, for a call to a function declared with
+   attribute warn_unused_result).  */
+#define ignore_value(x) \
+  ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; })
+
+/* The macros to control diagnostics are structured like this, rather
+   than a single macro that both pushes and pops diagnostic state and
+   takes the affected code as an argument, because the GCC pragmas
+   work by disabling the diagnostic for a range of source locations
+   and do not work when all the pragmas and the affected code are in a
+   single macro expansion.  */
+
+/* Push diagnostic state.  */
+#define DIAG_PUSH_NEEDS_COMMENT _Pragma ("GCC diagnostic push")
+
+/* Pop diagnostic state.  */
+#define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop")
+
+#define _DIAG_STR1(s) #s
+#define _DIAG_STR(s) _DIAG_STR1(s)
+
+/* Ignore the diagnostic OPTION.  VERSION is the most recent GCC
+   version for which the diagnostic has been confirmed to appear in
+   the absence of the pragma (in the form MAJOR.MINOR for GCC 4.x,
+   just MAJOR for GCC 5 and later).  Uses of this pragma should be
+   reviewed when the GCC version given is no longer supported for
+   building glibc; the version number should always be on the same
+   source line as the macro name, so such uses can be found with grep.
+   Uses should come with a comment giving more details of the
+   diagnostic, and an architecture on which it is seen if possibly
+   optimization-related and not in architecture-specific code.  This
+   macro should only be used if the diagnostic seems hard to fix (for
+   example, optimization-related false positives).  */
+#define DIAG_IGNORE_NEEDS_COMMENT(version, option)     \
+  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
+
+/* Similar to DIAG_IGNORE_NEEDS_COMMENT the following macro ignores the
+   diagnostic OPTION but only if optimizations for size are enabled.
+   This is required because different warnings may be generated for
+   different optimization levels.  For example a key piece of code may
+   only generate a warning when compiled at -Os, but at -O2 you could
+   still want the warning to be enabled to catch errors.  In this case
+   you would use DIAG_IGNORE_Os_NEEDS_COMMENT to disable the warning
+   only for -Os.  */
+#ifdef __OPTIMIZE_SIZE__
+# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option) \
+  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
+#else
+# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)
+#endif
+
+#endif /* libc-diag.h */
diff --git a/include/libc-internal.h b/include/libc-internal.h
index e4395dd5c5..a38a35d87c 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -74,56 +74,6 @@ extern __typeof (__profile_frequency) __profile_frequency attribute_hidden;
 #define PTR_ALIGN_UP(base, size) \
   ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size)))
 
-/* Ignore the value of an expression when a cast to void does not
-   suffice (in particular, for a call to a function declared with
-   attribute warn_unused_result).  */
-#define ignore_value(x) \
-  ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; })
-
-/* The macros to control diagnostics are structured like this, rather
-   than a single macro that both pushes and pops diagnostic state and
-   takes the affected code as an argument, because the GCC pragmas
-   work by disabling the diagnostic for a range of source locations
-   and do not work when all the pragmas and the affected code are in a
-   single macro expansion.  */
-
-/* Push diagnostic state.  */
-#define DIAG_PUSH_NEEDS_COMMENT _Pragma ("GCC diagnostic push")
-
-/* Pop diagnostic state.  */
-#define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop")
-
-#define _DIAG_STR1(s) #s
-#define _DIAG_STR(s) _DIAG_STR1(s)
-
-/* Ignore the diagnostic OPTION.  VERSION is the most recent GCC
-   version for which the diagnostic has been confirmed to appear in
-   the absence of the pragma (in the form MAJOR.MINOR for GCC 4.x,
-   just MAJOR for GCC 5 and later).  Uses of this pragma should be
-   reviewed when the GCC version given is no longer supported for
-   building glibc; the version number should always be on the same
-   source line as the macro name, so such uses can be found with grep.
-   Uses should come with a comment giving more details of the
-   diagnostic, and an architecture on which it is seen if possibly
-   optimization-related and not in architecture-specific code.  This
-   macro should only be used if the diagnostic seems hard to fix (for
-   example, optimization-related false positives).  */
-#define DIAG_IGNORE_NEEDS_COMMENT(version, option)	\
-  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
-
-/* Similar to DIAG_IGNORE_NEEDS_COMMENT the following macro ignores the
-   diagnostic OPTION but only if optimizations for size are enabled.
-   This is required because different warnings may be generated for
-   different optimization levels.  For example a key piece of code may
-   only generate a warning when compiled at -Os, but at -O2 you could
-   still want the warning to be enabled to catch errors.  In this case
-   you would use DIAG_IGNORE_Os_NEEDS_COMMENT to disable the warning
-   only for -Os.  */
-#ifdef __OPTIMIZE_SIZE__
-# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)	\
-  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
-#else
-# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)
-#endif
+#include <libc-diag.h>
 
 #endif /* _LIBC_INTERNAL  */
diff --git a/malloc/tst-malloc.c b/malloc/tst-malloc.c
index 740ac6ce31..dbc8d4ab56 100644
--- a/malloc/tst-malloc.c
+++ b/malloc/tst-malloc.c
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <malloc.h>
 #include <stdio.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int errors = 0;
 
diff --git a/malloc/tst-mcheck.c b/malloc/tst-mcheck.c
index 2e3cba96b8..5a66bab331 100644
--- a/malloc/tst-mcheck.c
+++ b/malloc/tst-mcheck.c
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int errors = 0;
 
diff --git a/malloc/tst-realloc.c b/malloc/tst-realloc.c
index 7f1f228c06..31a58bd026 100644
--- a/malloc/tst-realloc.c
+++ b/malloc/tst-realloc.c
@@ -19,7 +19,7 @@
 #include <malloc.h>
 #include <stdio.h>
 #include <string.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int errors = 0;
 
diff --git a/misc/tst-error1.c b/misc/tst-error1.c
index a97a22ce9d..9c4a62fbd0 100644
--- a/misc/tst-error1.c
+++ b/misc/tst-error1.c
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <wchar.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int
 do_test (int argc, char *argv[])
diff --git a/nptl/tst-mutex1.c b/nptl/tst-mutex1.c
index 8a4f2e6e4e..b2a4b5492a 100644
--- a/nptl/tst-mutex1.c
+++ b/nptl/tst-mutex1.c
@@ -20,7 +20,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdbool.h>
-
+#include <libc-diag.h>
 
 #ifndef ATTR
 # define ATTR NULL
@@ -45,11 +45,16 @@ do_test (void)
       return 1;
     }
 
+  /* This deliberately tests supplying a null pointer to a function whose
+     argument is marked __attribute__ ((nonnull)). */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (5, "-Wnonnull");
   if (!ATTR_NULL && pthread_mutexattr_destroy (ATTR) != 0)
     {
       puts ("mutexattr_destroy failed");
       return 1;
     }
+  DIAG_POP_NEEDS_COMMENT;
 
   if (pthread_mutex_lock (&m) != 0)
     {
diff --git a/posix/tst-dir.c b/posix/tst-dir.c
index 1a9c7dfe97..fee79b32a0 100644
--- a/posix/tst-dir.c
+++ b/posix/tst-dir.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* We expect four arguments:
    - source directory name
diff --git a/stdio-common/bug21.c b/stdio-common/bug21.c
index ca27272ba1..7a8c6a3542 100644
--- a/stdio-common/bug21.c
+++ b/stdio-common/bug21.c
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int
 do_test (void)
diff --git a/stdio-common/scanf14.c b/stdio-common/scanf14.c
index cffccb0b19..2bcd9c9893 100644
--- a/stdio-common/scanf14.c
+++ b/stdio-common/scanf14.c
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 #define FAIL() \
   do {							\
diff --git a/stdio-common/scanf4.c b/stdio-common/scanf4.c
index 9bb14bb16b..7a2abec89b 100644
--- a/stdio-common/scanf4.c
+++ b/stdio-common/scanf4.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 int
 main(int arc, char *argv[])
diff --git a/stdio-common/scanf7.c b/stdio-common/scanf7.c
index 53ddf4cb09..f568738d7e 100644
--- a/stdio-common/scanf7.c
+++ b/stdio-common/scanf7.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
diff --git a/stdio-common/test-vfprintf.c b/stdio-common/test-vfprintf.c
index f1805d5d00..f8bb9cee58 100644
--- a/stdio-common/test-vfprintf.c
+++ b/stdio-common/test-vfprintf.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 
 const char *locs[] =
diff --git a/stdio-common/tst-printf.c b/stdio-common/tst-printf.c
index 719b3eb08c..b6d62a5a2f 100644
--- a/stdio-common/tst-printf.c
+++ b/stdio-common/tst-printf.c
@@ -26,7 +26,7 @@
 #endif
 
 #include <float.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* This whole file is picayune tests of corner cases of printf format strings.
    The compiler warnings are not useful here.  */
diff --git a/stdio-common/tst-printfsz.c b/stdio-common/tst-printfsz.c
index 8a3385f94d..47aa8536b3 100644
--- a/stdio-common/tst-printfsz.c
+++ b/stdio-common/tst-printfsz.c
@@ -2,7 +2,7 @@
 #include <printf.h>
 #include <stdio.h>
 #include <string.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 #define V       12345678.12345678
 
diff --git a/stdio-common/tst-sprintf.c b/stdio-common/tst-sprintf.c
index d5284b9697..cbd35447a9 100644
--- a/stdio-common/tst-sprintf.c
+++ b/stdio-common/tst-sprintf.c
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <locale.h>
 #include <string.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 
 static int
diff --git a/stdio-common/tst-unlockedio.c b/stdio-common/tst-unlockedio.c
index 6eec6fdbac..35652ce772 100644
--- a/stdio-common/tst-unlockedio.c
+++ b/stdio-common/tst-unlockedio.c
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 int fd;
 static void do_prepare (void);
diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c
index 9c7342d55f..89009e0549 100644
--- a/stdio-common/tstdiomisc.c
+++ b/stdio-common/tstdiomisc.c
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <wchar.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int
 t1 (void)
diff --git a/stdlib/bug-getcontext.c b/stdlib/bug-getcontext.c
index c4072129a6..163400acba 100644
--- a/stdlib/bug-getcontext.c
+++ b/stdlib/bug-getcontext.c
@@ -5,7 +5,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ucontext.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int
 do_test (void)
diff --git a/stdlib/tst-environ.c b/stdlib/tst-environ.c
index 6a29fed62a..b2301641f5 100644
--- a/stdlib/tst-environ.c
+++ b/stdlib/tst-environ.c
@@ -19,7 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
+#include <libc-diag.h>
 
 #define VAR "FOOBAR"
 
@@ -196,12 +196,17 @@ do_test (void)
       result = 1;
     }
 
+  /* This deliberately tests supplying a null pointer to a function whose
+     argument is marked __attribute__ ((nonnull)). */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT(5, "-Wnonnull");
   errno = 0;
   if (unsetenv (NULL) >= 0 || errno != EINVAL)
     {
       puts ("unsetenv #1 failed");
       result = 1;
     }
+  DIAG_POP_NEEDS_COMMENT;
 
   errno = 0;
   if (unsetenv ("") >= 0 || errno != EINVAL)
diff --git a/string/tester.c b/string/tester.c
index ec350243eb..4b928b4f5e 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -32,7 +32,7 @@
 #include <string.h>
 #include <strings.h>
 #include <fcntl.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 
 #define	STREQ(a, b)	(strcmp((a), (b)) == 0)
diff --git a/string/tst-endian.c b/string/tst-endian.c
index 7d39131a68..d3c7c2c4c5 100644
--- a/string/tst-endian.c
+++ b/string/tst-endian.c
@@ -3,7 +3,7 @@
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 #if __GNUC_PREREQ (6, 0)
 /* GCC 6.0 warns on big endian systems about:
diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
index 9273568b6f..8019e7f5d8 100644
--- a/time/tst-strptime2.c
+++ b/time/tst-strptime2.c
@@ -4,7 +4,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <time.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* Dummy string is used to match strptime's %s specifier.  */
 
diff --git a/wcsmbs/tst-wcstof.c b/wcsmbs/tst-wcstof.c
index 861f65905a..d3d75f8f60 100644
--- a/wcsmbs/tst-wcstof.c
+++ b/wcsmbs/tst-wcstof.c
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <wctype.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static int
 do_test (void)
-- 
2.11.0

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 0/4] Suppress internal declarations for most of the testsuite.
@ 2017-02-20 13:03 Zack Weinberg
  2017-02-20 13:03 ` [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h Zack Weinberg
  0 siblings, 1 reply; 30+ messages in thread
From: Zack Weinberg @ 2017-02-20 13:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: carlos, joseph, adhemerval.zanella

This patch series arranges to compile most of the testsuite under
_ISOMAC, i.e. nearly all internal declarations from the wrapper
headers are suppressed, as are nearly all declarations from
libc-symbols.h itself.  This is a step towards compiling the testsuite
against *installed* headers.  It's still different in significant
ways: libc-modules.h and the IS_IN family of macros are still visible,
everything gets _GNU_SOURCE whether it likes it or not, and tests can
still include non-installed non-wrapper headers if they want.  Of course,
many of those assume the full libc-symbols.h is visible, so they won't
work---the bulk of the changes to C sources in these patches is
dealing with that.

(I don't have any plans to continue working toward the goal of
compiling the testsuite against installed headers.  I did this because
it also smooths the way toward getting rid of all __need_foo macros.)

Patches 1-3 are 'safe' changes in the testsuite: they aren't
*necessary* in the absence of patch 4, but they do no harm, and they
are conceptually separate and can be reviewed as such.  Patch 4
introduces a new IS_IN module for the testsuite, arranges for that to
imply _ISOMAC, and separates out the tests that actually *need*
to see internal declarations.

I tested these with two build-many-glibcs cycles, one with patches 1-3
applied and one with patches 1-4 applied.  (1-3 are independent of
each other at the file level, so this should be sufficient.)  There
were no new failures.  However, what with HPPA, Coldfire, and
Microblaze not being buildable at the moment due to unrelated bugs, I
think there's a good chance that their arch-specific tests will need
some adjustments for this patchset.  I propose to leave that to the
people who are working on those architectures already.

Patches 1-3 can be applied in any order, but 4 will break the build in
the absence of the other three.  4 also requires my patch to clean up
the macros controlling whether gets is visible
(https://sourceware.org/ml/libc-alpha/2017-02/msg00284.html).

zw

Zack Weinberg (4):
  Split DIAG_* macros to new header libc-diag.h.
  Allow direct use of math_ldbl.h in testsuite.
  Miscellaneous 'safe' testsuite changes.
  Add IS_IN (testsuite) and remaining fixes.

 Makeconfig                                         |  3 +-
 Makefile                                           |  4 +-
 Makerules                                          | 55 ++++++++++----
 Rules                                              | 18 ++---
 benchtests/strcoll-inputs/filelist#en_US.UTF-8     |  1 -
 config.h.in                                        | 11 ---
 dlfcn/Makefile                                     |  3 +-
 elf/Makefile                                       | 58 ++++++++-------
 elf/tst-env-setuid-tunables.c                      |  6 ++
 extra-modules.mk                                   |  9 ---
 include/errno.h                                    |  2 +-
 include/libc-diag.h                                | 57 +++++++++++++++
 include/libc-internal.h                            | 52 +-------------
 include/libc-symbols.h                             | 62 +++++++++++-----
 include/math.h                                     |  5 ++
 include/stdio.h                                    | 10 ++-
 include/stdlib.h                                   |  4 --
 include/string.h                                   | 10 +--
 include/time.h                                     |  4 --
 include/unistd.h                                   |  3 -
 include/wchar.h                                    |  2 -
 inet/Makefile                                      |  4 +-
 inet/tst-checks-posix.c                            |  1 -
 intl/tst-gettext2.c                                |  2 +
 malloc/Makefile                                    |  6 +-
 malloc/tst-malloc.c                                |  2 +-
 malloc/tst-mcheck.c                                |  2 +-
 malloc/tst-realloc.c                               |  2 +-
 math/test-misc.c                                   | 23 +++---
 math/test-signgam-finite-c99.c                     |  1 -
 math/test-signgam-main.c                           |  1 -
 misc/Makefile                                      |  5 +-
 misc/sys/cdefs.h                                   |  3 +
 misc/tst-error1.c                                  |  2 +-
 nptl/Makefile                                      | 31 ++++----
 nptl/tst-join7mod.c                                |  9 +--
 nptl/tst-mutex1.c                                  |  7 +-
 nss/Makefile                                       |  6 +-
 posix/Makefile                                     | 11 +--
 posix/tst-dir.c                                    |  2 +-
 posix/wordexp-test.c                               |  6 +-
 stdio-common/bug21.c                               |  2 +-
 stdio-common/scanf14.c                             |  2 +-
 stdio-common/scanf4.c                              |  2 +-
 stdio-common/scanf7.c                              |  2 +-
 stdio-common/test-vfprintf.c                       |  2 +-
 stdio-common/tst-printf.c                          |  2 +-
 stdio-common/tst-printfsz.c                        |  2 +-
 stdio-common/tst-sprintf.c                         |  2 +-
 stdio-common/tst-unlockedio.c                      |  2 +-
 stdio-common/tstdiomisc.c                          |  2 +-
 stdlib/Makefile                                    | 17 +++--
 stdlib/bug-getcontext.c                            |  2 +-
 stdlib/tst-environ.c                               |  7 +-
 stdlib/tst-strtod.c                                | 60 ----------------
 stdlib/tst-strtod1i.c                              | 84 ++++++++++++++++++++++
 stdlib/tst-strtod5.c                               | 54 +++++---------
 stdlib/tst-strtod5i.c                              | 83 +++++++++++++++++++++
 string/strcasestr.c                                |  4 --
 string/test-string.h                               | 12 ++++
 string/test-strstr.c                               |  1 +
 string/tester.c                                    |  2 +-
 string/tst-endian.c                                |  2 +-
 sysdeps/generic/math_ldbl.h                        | 10 +--
 sysdeps/generic/math_private.h                     |  4 +-
 sysdeps/ia64/fpu/libm-symbols.h                    |  2 +-
 sysdeps/ia64/fpu/math_ldbl.h                       | 22 +++---
 sysdeps/ieee754/ldbl-128/math_ldbl.h               | 26 ++++---
 sysdeps/ieee754/ldbl-128ibm/math_ldbl.h            | 18 +++--
 .../ldbl-128ibm/test-canonical-ldbl-128ibm.c       |  2 +-
 .../ldbl-128ibm/test-totalorderl-ldbl-128ibm.c     |  2 +-
 sysdeps/ieee754/ldbl-96/math_ldbl.h                | 22 +++---
 sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c   |  2 +-
 sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c |  2 +-
 sysdeps/m68k/m680x0/fpu/bits/mathinline.h          | 15 ++--
 sysdeps/powerpc/Makefile                           |  2 +-
 sysdeps/powerpc/fpu/math_ldbl.h                    |  7 +-
 sysdeps/powerpc/fpu/tst-setcontext-fpscr.c         |  2 +-
 sysdeps/unix/sysv/linux/Makefile                   |  2 +-
 sysdeps/unix/sysv/linux/tst-clone.c                |  5 ++
 sysdeps/unix/sysv/linux/tst-setgetname.c           |  3 -
 sysdeps/x86_64/fpu/Makefile                        |  8 +++
 sysdeps/x86_64/fpu/math-tests-arch.h               |  8 +--
 sysdeps/x86_64/fpu/math_ldbl.h                     | 13 ++--
 sysdeps/x86_64/multiarch/test-multiarch.c          |  2 +-
 time/tst-strptime2.c                               |  2 +-
 wcsmbs/tst-wcstof.c                                |  2 +-
 87 files changed, 624 insertions(+), 412 deletions(-)
 delete mode 100644 extra-modules.mk
 create mode 100644 include/libc-diag.h
 create mode 100644 stdlib/tst-strtod1i.c
 create mode 100644 stdlib/tst-strtod5i.c

-- 
2.11.0

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes.
  2017-02-20 13:03     ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Zack Weinberg
@ 2017-02-20 13:04       ` Zack Weinberg
  2017-02-20 15:13         ` Carlos O'Donell
  2017-02-20 14:11       ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Carlos O'Donell
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 30+ messages in thread
From: Zack Weinberg @ 2017-02-20 13:04 UTC (permalink / raw)
  To: libc-alpha; +Cc: carlos, joseph, adhemerval.zanella

This is the main change, adding a new build module called 'testsuite'.
IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
(which means several ad-hoc tests for __cplusplus can go away).
libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
defined; in particular, _ISOMAC mode does not get config.h
automatically anymore.  And there's a third mode for when
libc-symbols.h is included without MODULE_NAME being defined at all
(this happens when preprocessing Versions files, for instance)---IS_IN
always evaluates to false but _ISOMAC is *not* defined.  This is the
way it has always worked, but now it's explicit.

There are still quite a few tests that need to see internal gunk of
one variety or another.  There are three new Makefile variables to
allow that.  'tests-internal' is the most straightforward: move a file
from 'tests' to 'tests-internal' if it needs to be compiled as it
always has (MODULE_NAME=nonlib).  'test-internal-extras' is the same
thing, but for files formerly in 'test-extras'.  Finally,
'modules-names-tests' is for files in 'modules-names' that *should* be
compiled with MODULE_NAME=testsuite (most of the things in
'modules-names' are *not* tests).  Unlike the other two, you need to
list a test module in *both* modules-names and modules-names-tests.

The remaining changes to C source files in this patch seemed likely to
cause problems in the absence of the main change:

 * tst-env-setuid-tunables.c needs to see HAVE_TUNABLES but no other
   internal goo, so rather than put it in tests-internal I made it
   include config.h itself
 * similarly, tst-gettext2.c can define N_() itself instead of
   expecting libc-symbols.h to do it
 * some tests were defining _ISOMAC themselves; this is no longer
   necessary (note that definitions of _ISOMAC by test scripts like
   conform-test.pl are usually still necessary, since they don't use
   libc-modules.h/libc-symbols.h at all)
 * tst-strtod.c and tst-strtod5.c were testing both strtod and
   __strtod_internal, so they got chopped in half
 * ia64/fpu/libm-symbols.h is suppressed in _ISOMAC mode
   (see discussion from last year about this file)
 * string/test-strstr.c includes strstr.c, which uses
   libc_hidden_builtin_def; it can be dummied out in this context
 * several files that include string/test-string.h require
   inhibit_loop_to_libcall but no other definitions from
   libc-symbols.h/config.h; I chose to duplicate the definition of
   inhibit_loop_to_libcall rather than make them internal tests

 * x86_64/fpu/math-tests-arch.h and x86_64/multiarch/test-multiarch.h
   change from including init-arch.h to including cpu-features.h.
   This is the change that I committed last week that had to be backed
   out.  What's going on is, they actually *use* stuff from
   x86/cpu-features.h, which is a non-installed non-wrapper header
   whose contents vary depending on _LIBC and IS_IN.  It depends on
   init-arch.h when it's used the way the test suite is currently
   being compiled, hence the bustage, but with this patch init-arch.h
   becomes unnecessary, and init-arch.h itself depends on the full
   libc-symbols.h.  So the change comes back and is safe now.

N.B. extra-modules.mk was almost identical to cppflags-iterator.mk; the
only differences were that it used a different input variable and it
didn't let the caller control the module.  So I have removed it and
changed the sole use to use cppflags-iterator.mk instead.

zw

	* Makerules: New subdir configuration variables 'tests-internal'
	and 'test-internal-extras'.  Test files in these categories will
	still be compiled with MODULE_NAME=nonlib.  Test files in the
	existing categories (tests, xtests, test-srcs, test-extras) are
	now compiled with MODULE_NAME=testsuite.
	New subdir configuration variable 'modules-names-tests'.  Files
	which are in both 'modules-names' and 'modules-names-tests' will
	be compiled with MODULE_NAME=testsuite instead of
	MODULE_NAME=extramodules.
	Use cppflags-iterator.mk instead of extra-modules.mk for the
	files in $(modules-names).
	(gen-as-const-headers): Move to tests-internal.
	(do-tests-clean, common-mostlyclean): Support tests-internal.
	* Makeconfig (built-modules): Add testsuite.
	* Makefile: Change libof-check-installed-headers-c and
	libof-check-installed-headers-cxx to 'testsuite'.
	* Rules: Likewise.  Support tests-internal.
	* extra-modules.mk: Removed.
	* benchtests/strcoll-inputs/filelist#en_US.UTF-8:
	Remove extra-modules.mk.

	* config.h.in: Don't check for __OPTIMIZE__ or __FAST_MATH__ here.
	* include/libc-symbols.h: Move definitions of _GNU_SOURCE,
	PASTE_NAME, PASTE_NAME1, IN_MODULE, IS_IN, and IS_IN_LIB to the
	very top of the file and rationalize their order.
	If MODULE_NAME is not defined at all, define IS_IN to always be
	false, and don't define _ISOMAC.
	If any of IS_IN (testsuite), IS_IN_build, or __cplusplus are
	true, define _ISOMAC and suppress everything else in this file,
	starting with the inclusion of config.h.
	Do check for inappropriate definitions of __OPTIMIZE__ and
	__FAST_MATH__ here, but only if _ISOMAC is not defined.
        Correct some out-of-date commentary.

	* include/math.h: If _ISOMAC is defined, undefine NO_LONG_DOUBLE
	and _Mlong_double_ before including math.h.
	* include/stdio.h: If _ISOMAC is defined, undefine _IO_MTSAFE_IO
	before including libio/stdio.h (this causes the external version of
	_IO_lock_t to be visible).
	* include/string.h: If _ISOMAC is defined, don't expose
	_STRING_ARCH_unaligned. Move a comment to a more appropriate
	location.

	* include/errno.h, include/stdio.h, include/stdlib.h, include/string.h
	* include/time.h, include/unistd.h, include/wchar.h: No need to
	check __cplusplus nor use __BEGIN_DECLS/__END_DECLS.

	* dlfcn/Makefile: Move tst-dladdr to tests-internal.
	* elf/Makefile: Move tst-ptrguard1-static, tst-stackguard1-static,
	tst-tls1-static, tst-tls2-static, tst-tls3-static, loadtest,
	unload, unload2, circleload1, neededtest, neededtest2,
	neededtest3, neededtest4, tst-tls1, tst-tls2, tst-tls3,
	tst-tls6, tst-tls7, tst-tls8, tst-dlmopen2, tst-ptrguard1,
	tst-stackguard1, tst-_dl_addr_inside_object, and all of the
	ifunc tests to tests-internal.
	Don't add $(modules-names) to test-extras.
	* inet/Makefile: Move tst-inet6_scopeid_pton to tests-internal.
	* malloc/Makefile: Move tst-mallocstate and tst-scratch_buffer to
	tests-internal.
	* misc/Makefile: Move tst-atomic and tst-atomic-long to tests-internal.
	* nptl/Makefile: Move tst-typesizes, tst-rwlock19, tst-sem11,
	tst-sem12, tst-sem13, tst-barrier5, tst-signal7, tst-tls3,
	tst-tls3-malloc, tst-tls5, tst-stackguard1, tst-sem11-static,
	tst-sem12-static, and tst-stackguard1-static to tests-internal.
        Link tests-internal with libpthread also.
	Don't add $(modules-names) to test-extras.
	* nss/Makefile: Move tst-field and tst-cancel-getpwuid_r to
	tests-internal.
	* posix/Makefile: Move bug-regex5, bug-regex20, bug-regex33,
	tst-rfc3484, tst-rfc3484-2, and tst-rfc3484-3 to tests-internal.
	* stdlib/Makefile: Move tst-strtod1i, tst-strtod3, tst-strtod4,
	tst-strtod5i, tst-tls-atexit, and tst-tls-atexit-nodelete to
	tests-internal.
	* sysdeps/powerpc/Makefile: Move test-get_hwcap and
	test-get_hwcap-static to tests-internal.
	* sysdeps/x86_64/fpu/Makefile: Add all libmvec test modules to
	modules-names-tests.

	* elf/tst-env-setuid-tunables.c: Include config.h with _LIBC
	defined, for HAVE_TUNABLES.
	* inet/tst-checks-posix.c: No need to define _ISOMAC.
	* intl/tst-gettext2.c: Provide own definition of N_.
	* math/test-signgam-finite-c99.c: No need to define _ISOMAC.
	* math/test-signgam-main.c: No need to define _ISOMAC.
	* stdlib/tst-strtod.c: Split locale_test to...
	* stdlib/tst-strtod1i.c: ...this new file.
	* stdlib/tst-strtod5.c: Split tests of __strtod_internal to...
	* stdlib/tst-strtod5i.c: ...this new file.
	* string/test-string.h: Include stdint.h. Duplicate definition of
	inhibit_loop_to_libcall here (from libc-symbols.h).
	* string/test-strstr.c: Provide dummy definition of
	libc_hidden_builtin_def when including strstr.c.
	* sysdeps/ia64/fpu/libm-symbols.h: Suppress entire file in _ISOMAC
	mode; no need to test __STRICT_ANSI__ nor __cplusplus as well.
	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
	Don't include init-arch.h.

	* misc/sys/cdefs.h (__NTHNL): New macro.
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h
	(__m81_defun): Use __NTHNL to avoid errors with GCC 6.
---
 Makeconfig                                     |  3 +-
 Makefile                                       |  4 +-
 Makerules                                      | 55 +++++++++++++----
 Rules                                          | 18 +++---
 benchtests/strcoll-inputs/filelist#en_US.UTF-8 |  1 -
 config.h.in                                    | 11 ----
 dlfcn/Makefile                                 |  3 +-
 elf/Makefile                                   | 58 ++++++++++--------
 elf/tst-env-setuid-tunables.c                  |  6 ++
 extra-modules.mk                               |  9 ---
 include/errno.h                                |  2 +-
 include/libc-symbols.h                         | 62 ++++++++++++++-----
 include/math.h                                 |  5 ++
 include/stdio.h                                | 10 ++-
 include/stdlib.h                               |  4 --
 include/string.h                               | 10 +--
 include/time.h                                 |  4 --
 include/unistd.h                               |  3 -
 include/wchar.h                                |  2 -
 inet/Makefile                                  |  4 +-
 inet/tst-checks-posix.c                        |  1 -
 intl/tst-gettext2.c                            |  2 +
 malloc/Makefile                                |  6 +-
 math/test-signgam-finite-c99.c                 |  1 -
 math/test-signgam-main.c                       |  1 -
 misc/Makefile                                  |  5 +-
 misc/sys/cdefs.h                               |  3 +
 nptl/Makefile                                  | 31 +++++-----
 nss/Makefile                                   |  6 +-
 posix/Makefile                                 | 11 ++--
 stdlib/Makefile                                | 17 +++---
 stdlib/tst-strtod.c                            | 60 ------------------
 stdlib/tst-strtod1i.c                          | 84 ++++++++++++++++++++++++++
 stdlib/tst-strtod5.c                           | 54 ++++++-----------
 stdlib/tst-strtod5i.c                          | 83 +++++++++++++++++++++++++
 string/test-string.h                           | 12 ++++
 string/test-strstr.c                           |  1 +
 sysdeps/ia64/fpu/libm-symbols.h                |  2 +-
 sysdeps/m68k/m680x0/fpu/bits/mathinline.h      | 15 ++---
 sysdeps/powerpc/Makefile                       |  2 +-
 sysdeps/x86_64/fpu/Makefile                    |  8 +++
 sysdeps/x86_64/fpu/math-tests-arch.h           |  8 +--
 sysdeps/x86_64/multiarch/test-multiarch.c      |  2 +-
 43 files changed, 429 insertions(+), 260 deletions(-)
 delete mode 100644 extra-modules.mk
 create mode 100644 stdlib/tst-strtod1i.c
 create mode 100644 stdlib/tst-strtod5i.c

diff --git a/Makeconfig b/Makeconfig
index 97a15b569e..f4c4fb4f7b 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -901,7 +901,8 @@ libio-include = -I$(..)libio
 # List of non-library modules that we build.
 built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
 		libSegFault libpcprofile librpcsvc locale-programs \
-		memusagestat nonlib nscd extramodules libnldbl libsupport
+		memusagestat nonlib nscd extramodules libnldbl libsupport \
+		testsuite
 
 in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
 				    $(libof-$(<F)) \
diff --git a/Makefile b/Makefile
index 425cb796db..0ce12e9377 100644
--- a/Makefile
+++ b/Makefile
@@ -321,7 +321,7 @@ endif
 ifneq "$(headers)" ""
 # Special test of all the installed headers in this directory.
 tests-special += $(objpfx)check-installed-headers-c.out
-libof-check-installed-headers-c := nonlib
+libof-check-installed-headers-c := testsuite
 $(objpfx)check-installed-headers-c.out: \
     scripts/check-installed-headers.sh $(headers)
 	$(SHELL) $(..)scripts/check-installed-headers.sh c \
@@ -331,7 +331,7 @@ $(objpfx)check-installed-headers-c.out: \
 
 ifneq "$(CXX)" ""
 tests-special += $(objpfx)check-installed-headers-cxx.out
-libof-check-installed-headers-cxx := nonlib
+libof-check-installed-headers-cxx := testsuite
 $(objpfx)check-installed-headers-cxx.out: \
     scripts/check-installed-headers.sh $(headers)
 	$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
diff --git a/Makerules b/Makerules
index e9194e54cf..69ab1a3a7c 100644
--- a/Makerules
+++ b/Makerules
@@ -277,7 +277,7 @@ $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
 vpath %.sym $(sysdirs)
 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
 
-tests += $(gen-as-const-headers:%.sym=test-as-const-%)
+tests-internal += $(gen-as-const-headers:%.sym=test-as-const-%)
 generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
 $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
 			    %.sym $(common-objpfx)%.h
@@ -797,12 +797,21 @@ endif
 
 # The makefile may define $(modules-names) to build additional modules.
 # These are built with $(build-module), except any in $(modules-names-nobuild).
+# MODULE_NAME=extramodules, except any in $(modules-names-tests).
 ifdef modules-names
-# extra-lib.mk is included once for each extra lib to define rules
-# to build it, and to add its objects to the various variables.
-# During its evaluation, $(lib) is set to the name of the library.
-extra-modules-left := $(modules-names)
-include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
+cpp-srcs-left := $(filter-out $(modules-names-tests),$(modules-names))
+ifneq (,$(cpp-srcs-left))
+lib := extramodules
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+endif
+
+ifdef modules-names-tests
+cpp-srcs-left := $(filter $(modules-names-tests),$(modules-names))
+ifneq (,$(cpp-srcs-left))
+lib := testsuite
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+endif
+endif
 
 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
@@ -814,7 +823,7 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1326,7 +1335,17 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
-all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
+# The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
+# that almost all internal declarations from config.h, libc-symbols.h, and
+# include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
+all-testsuite := $(strip $(tests) $(xtests) $(test-srcs) $(test-extras))
+ifneq (,$(all-testsuite))
+cpp-srcs-left = $(all-testsuite)
+lib := testsuite
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+endif
+
+all-nonlib := $(strip $(tests-internal) $(test-internal-extras) $(others))
 ifneq (,$(all-nonlib))
 cpp-srcs-left = $(all-nonlib)
 lib := nonlib
@@ -1540,22 +1559,32 @@ clean: common-clean
 mostlyclean: common-mostlyclean
 
 do-tests-clean:
-	-rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
+	-rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) \
+						      $(tests-internal) \
+						      $(xtests) \
 						      $(test-srcs)) \
 				     $(addsuffix .test-result,$(tests) \
+							      $(tests-internal) \
 							      $(xtests) \
 							      $(test-srcs)))
 
 # Remove the object files.
 common-mostlyclean:
-	-rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
+	-rm -f $(addprefix $(objpfx),$(tests) $(tests-internal) $(xtests) \
+				     $(test-srcs) \
 				     $(others) $(sysdep-others) stubs \
-				     $(addsuffix .o,$(tests) $(xtests) \
-						    $(test-srcs) $(others) \
+				     $(addsuffix .o,$(tests) \
+						    $(tests-internal) \
+						    $(xtests) \
+						    $(test-srcs) \
+						    $(others) \
 						    $(sysdep-others)) \
-				     $(addsuffix .out,$(tests) $(xtests) \
+				     $(addsuffix .out,$(tests) \
+						      $(tests-internal) \
+						      $(xtests) \
 						      $(test-srcs)) \
 				     $(addsuffix .test-result,$(tests) \
+							      $(tests-internal) \
 							      $(xtests) \
 							      $(test-srcs)))
 	-rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
diff --git a/Rules b/Rules
index 917bc969b5..168cf508d7 100644
--- a/Rules
+++ b/Rules
@@ -84,7 +84,7 @@ common-generated += dummy.o dummy.c
 ifneq "$(headers)" ""
 # Special test of all the installed headers in this directory.
 tests-special += $(objpfx)check-installed-headers-c.out
-libof-check-installed-headers-c := nonlib
+libof-check-installed-headers-c := testsuite
 $(objpfx)check-installed-headers-c.out: \
     $(..)scripts/check-installed-headers.sh $(headers)
 	$(SHELL) $(..)scripts/check-installed-headers.sh c \
@@ -94,7 +94,7 @@ $(objpfx)check-installed-headers-c.out: \
 
 ifneq "$(CXX)" ""
 tests-special += $(objpfx)check-installed-headers-cxx.out
-libof-check-installed-headers-cxx := nonlib
+libof-check-installed-headers-cxx := testsuite
 $(objpfx)check-installed-headers-cxx.out: \
     $(..)scripts/check-installed-headers.sh $(headers)
 	$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
@@ -129,12 +129,14 @@ endif
 others: $(py-const)
 
 ifeq ($(run-built-tests),no)
-tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported),$(tests)) \
+tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
+                                          $(tests) $(tests-internal)) \
 			     $(test-srcs)) $(tests-special) \
 			     $(tests-printers-programs)
 xtests: tests $(xtests-special)
 else
-tests: $(tests:%=$(objpfx)%.out) $(tests-special) $(tests-printers-out)
+tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \
+       $(tests-special) $(tests-printers-out)
 xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special)
 endif
 
@@ -143,7 +145,7 @@ xtests-special-notdir = $(patsubst $(objpfx)%, %, $(xtests-special))
 ifeq ($(run-built-tests),no)
 tests-expected =
 else
-tests-expected = $(tests) $(tests-printers)
+tests-expected = $(tests) $(tests-internal) $(tests-printers)
 endif
 tests:
 	$(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \
@@ -156,7 +158,7 @@ xtests:
 
 ifeq ($(build-programs),yes)
 binaries-all-notests = $(others) $(sysdep-others)
-binaries-all-tests = $(tests) $(xtests) $(test-srcs)
+binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)
 binaries-all = $(binaries-all-notests) $(binaries-all-tests)
 binaries-static-notests = $(others-static)
 binaries-static-tests = $(tests-static) $(xtests-static)
@@ -170,7 +172,7 @@ binaries-pie-notests =
 endif
 else
 binaries-all-notests =
-binaries-all-tests = $(tests) $(xtests) $(test-srcs)
+binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)
 binaries-all = $(binaries-all-tests)
 binaries-static-notests =
 binaries-static-tests =
@@ -230,7 +232,7 @@ $(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
 	$(+link-static-tests)
 endif
 
-ifneq "$(strip $(tests) $(xtests) $(test-srcs))" ""
+ifneq "$(strip $(tests) $(tests-internal) $(xtests) $(test-srcs))" ""
 # These are the implicit rules for making test outputs
 # from the test programs and whatever input files are present.
 
diff --git a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
index b7b38017d8..eb23b47484 100644
--- a/benchtests/strcoll-inputs/filelist#en_US.UTF-8
+++ b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
@@ -9667,7 +9667,6 @@ hr.po
 libc.pot
 ko.po
 ru.po
-extra-modules.mk
 intl
 tst-gettext4-fr.po
 tstcodeset.po
diff --git a/config.h.in b/config.h.in
index fb2cc51c03..50f03c0cd8 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,14 +1,3 @@
-#if !defined IS_IN_build && !defined __ASSEMBLER__ && !defined _ISOMAC \
-    && !defined __OPTIMIZE__
-# error "glibc cannot be compiled without optimization"
-#endif
-
-/* Another evil option when it comes to compiling the C library is
-   --ffast-math since it alters the ABI.  */
-#if defined __FAST_MATH__ && !defined TEST_FAST_MATH
-# error "glibc must not be compiled with -ffast-math"
-#endif
-
 /* Define if building with SELinux support.  Set by --with-selinux.  */
 #undef	HAVE_SELINUX
 
diff --git a/dlfcn/Makefile b/dlfcn/Makefile
index 94f511d828..8e4f9d1241 100644
--- a/dlfcn/Makefile
+++ b/dlfcn/Makefile
@@ -34,9 +34,10 @@ libdl-shared-only-routines := dlopenold dlfcn
 endif
 
 ifeq (yes,$(build-shared))
-tests = glrefmain failtest tst-dladdr default errmsg1 tstcxaatexit \
+tests = glrefmain failtest default errmsg1 tstcxaatexit \
 	bug-dlopen1 bug-dlsym1 tst-dlinfo bug-atexit1 bug-atexit2 \
 	bug-atexit3 tstatexit bug-dl-leaf tst-rec-dlopen
+tests-internal = tst-dladdr
 endif
 modules-names = glreflib1 glreflib2 glreflib3 failtestmod defaultmod1 \
 		defaultmod2 errmsg1mod modatexit modcxaatexit \
diff --git a/elf/Makefile b/elf/Makefile
index 61abeb59ee..876641aa57 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -142,43 +142,49 @@ $(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
 	$(do-install-program)
 endif
 
-tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1 \
-	tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
-	tst-auxv
-tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static \
-	       tst-leaks1-static tst-array1-static tst-array5-static \
-	       tst-ptrguard1-static tst-dl-iter-static \
+tests-static-normal := tst-leaks1-static tst-array1-static tst-array5-static \
+	       tst-dl-iter-static \
 	       tst-tlsalign-static tst-tlsalign-extern-static \
 	       tst-linkall-static tst-env-setuid tst-env-setuid-tunables
+tests-static-internal := tst-tls1-static tst-tls2-static \
+	       tst-ptrguard1-static tst-stackguard1-static
+
+tests := tst-tls9 tst-leaks1 \
+	tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
+	tst-auxv
+tests-internal := tst-tls1 tst-tls2 $(tests-static-internal)
+tests-static := $(tests-static-normal) $(tests-static-internal)
+
 ifeq (yes,$(build-shared))
 tests-static += tst-tls9-static
 tst-tls9-static-ENV = \
        LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
-endif
-tests += $(tests-static)
-ifeq (yes,$(build-shared))
-tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
-	 constload1 order noload filter unload \
+
+tests += restest1 preloadtest loadfail multiload origtest resolvfail \
+	 constload1 order noload filter \
 	 reldep reldep2 reldep3 reldep4 nodelete nodelete2 \
-	 nodlopen nodlopen2 neededtest neededtest2 \
-	 neededtest3 neededtest4 unload2 lateglobal initfirst global \
+	 nodlopen nodlopen2 lateglobal initfirst global \
 	 restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \
-	 circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \
+	 tst-tls4 tst-tls5 \
 	 tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 \
 	 tst-tls16 tst-tls17 tst-tls18 tst-tls19 tst-tls-dlinfo \
 	 tst-align tst-align2 $(tests-execstack-$(have-z-execstack)) \
 	 tst-dlmodcount tst-dlopenrpath tst-deep1 \
-	 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
+	 tst-dlmopen1 tst-dlmopen3 \
 	 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
 	 tst-audit1 tst-audit2 tst-audit8 tst-audit9 \
-	 tst-stackguard1 tst-addr1 tst-thrlock \
+	 tst-addr1 tst-thrlock \
 	 tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
 	 tst-nodelete) \
 	 tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
-	 tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
+	 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
 	 tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-noload \
 	 tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose
 #	 reldep9
+tests-internal += loadtest unload unload2 circleload1 \
+	 neededtest neededtest2 neededtest3 neededtest4 \
+	 tst-tls3 tst-tls6 tst-tls7 tst-tls8 tst-dlmopen2 \
+	 tst-ptrguard1 tst-stackguard1
 ifeq ($(build-hardcoded-path-in-tests),yes)
 tests += tst-dlopen-aout
 LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
@@ -289,21 +295,23 @@ CFLAGS-vismain.c = $(PIE-ccflag)
 endif
 modules-execstack-yes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
-# We need this variable to be sure the test modules get the right CPPFLAGS.
-test-extras += $(modules-names)
 
 # filtmod1.so has a special rule
 modules-names-nobuild := filtmod1
 
+tests += $(tests-static)
+
 ifneq (no,$(multi-arch))
-tests-static += ifuncmain1static ifuncmain1picstatic \
+tests-ifuncstatic := ifuncmain1static ifuncmain1picstatic \
 		ifuncmain2static ifuncmain2picstatic \
 		ifuncmain4static ifuncmain4picstatic \
 		ifuncmain5static ifuncmain5picstatic \
 		ifuncmain7static ifuncmain7picstatic
-
+tests-static += $(tests-ifuncstatic)
+tests-internal += $(tests-ifuncstatic)
 ifeq (yes,$(build-shared))
-tests += ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
+tests-internal += \
+	 ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
 	 ifuncmain1staticpic \
 	 ifuncmain2 ifuncmain2pic ifuncmain3 ifuncmain4 \
 	 ifuncmain5 ifuncmain5pic ifuncmain5staticpic \
@@ -311,11 +319,11 @@ tests += ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
 ifunc-test-modules = ifuncdep1 ifuncdep1pic ifuncdep2 ifuncdep2pic \
 		     ifuncdep5 ifuncdep5pic
 extra-test-objs += $(ifunc-test-modules:=.o)
-test-extras += $(ifunc-test-modules)
+test-internal-extras += $(ifunc-test-modules)
 ifeq (yes,$(have-fpie))
 ifunc-pie-tests = ifuncmain1pie ifuncmain1vispie ifuncmain1staticpie \
 		  ifuncmain5pie ifuncmain6pie ifuncmain7pie
-tests += $(ifunc-pie-tests)
+tests-internal += $(ifunc-pie-tests)
 tests-pie += $(ifunc-pie-tests)
 endif
 modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
@@ -357,7 +365,7 @@ endif
 # unit test driver must be able to link with the shared object
 # that is going to eventually go into an installed DSO.
 ifeq (yesyes,$(have-fpie)$(build-shared))
-tests += tst-_dl_addr_inside_object
+tests-internal += tst-_dl_addr_inside_object
 tests-pie += tst-_dl_addr_inside_object
 $(objpfx)tst-_dl_addr_inside_object: $(objpfx)dl-addr-obj.os
 CFLAGS-tst-_dl_addr_inside_object.c += $(PIE-ccflag)
diff --git a/elf/tst-env-setuid-tunables.c b/elf/tst-env-setuid-tunables.c
index a5f0a81ef3..afcb146e6d 100644
--- a/elf/tst-env-setuid-tunables.c
+++ b/elf/tst-env-setuid-tunables.c
@@ -19,6 +19,12 @@
    glibc.malloc.check and glibc.malloc.mmap_threshold but also retain
    glibc.malloc.mmap_threshold in an unprivileged child.  */
 
+/* This is compiled as part of the testsuite but needs to see
+   HAVE_TUNABLES. */
+#define _LIBC 1
+#include "config.h"
+#undef _LIBC
+
 #define test_parent test_parent_tunables
 #define test_child test_child_tunables
 
diff --git a/extra-modules.mk b/extra-modules.mk
deleted file mode 100644
index 5f8e693b15..0000000000
--- a/extra-modules.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-# This file is included several times in a row, once
-# for each element of $(modules-names).  $(extra-modules-left)
-# is initialized first to $(modules-names) so that with each
-# inclusion, we advance $(module) to the next name.
-
-module := $(firstword $(extra-modules-left))
-extra-modules-left := $(filter-out $(module),$(extra-modules-left))
-
-libof-$(notdir $(module)) := extramodules
diff --git a/include/errno.h b/include/errno.h
index 7df41dfc31..73fc32e5e0 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -2,7 +2,7 @@
 
 #include <stdlib/errno.h>
 
-#if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus
+#if defined _ERRNO_H && !defined _ISOMAC
 
 # if IS_IN (rtld)
 #  include <dl-sysdep.h>
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 775d8af84e..922e4b638c 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -20,26 +20,46 @@
 #ifndef _LIBC_SYMBOLS_H
 #define _LIBC_SYMBOLS_H	1
 
-#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME)
-#define IS_IN(lib) (IN_MODULE == MODULE_##lib)
+/* This file is included implicitly in the compilation of every source file,
+   using -include.  It includes config.h.  */
 
-/* Returns true if the current module is a versioned library.  Versioned
-   library names culled from shlib-versions files are assigned a MODULE_*
-   value lower than MODULE_LIBS_BEGIN.  */
-#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN)
+/* Enable declarations of GNU extensions, since we are compiling them.  */
+#define _GNU_SOURCE 1
 
-#define PASTE_NAME(a,b)      PASTE_NAME1 (a,b)
-#define PASTE_NAME1(a,b)     a##b
+#ifdef MODULE_NAME
 
-/* This file's macros are included implicitly in the compilation of every
-   file in the C library by -imacros.
+/* Use `#if IS_IN (module)` to detect what component is being compiled.  */
+#define PASTE_NAME1(a,b) a##b
+#define PASTE_NAME(a,b)	 PASTE_NAME1 (a,b)
+#define IN_MODULE	 PASTE_NAME (MODULE_, MODULE_NAME)
+#define IS_IN(lib)	 (IN_MODULE == MODULE_##lib)
 
-   We include config.h which is generated by configure.
-   It should define for us the following symbol:
+/* True if the current module is a versioned library.  Versioned
+   library names culled from shlib-versions files are assigned a
+   MODULE_* value greater than MODULE_LIBS_BEGIN.  */
+#define IS_IN_LIB	 (IN_MODULE > MODULE_LIBS_BEGIN)
 
-   * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
+/* The testsuite, and some other ancillary code, should be compiled against
+   as close an approximation to the installed headers as possible.
+   Defining this symbol disables most internal-use-only declarations
+   provided by this header, and all those provided by other internal
+   wrapper headers.  */
+#if IS_IN (testsuite) || defined IS_IN_build || defined __cplusplus
+# define _ISOMAC 1
+#endif
 
-   */
+#else
+/* The generation process for a few files created very early in the
+   build (notably libc-modules.h itself) involves preprocessing this
+   header without defining MODULE_NAME.  Under these conditions,
+   internal declarations (especially from config.h) must be visible,
+   but IS_IN should always evaluate as false.  */
+# define IS_IN(lib) 0
+# define IS_IN_LIB 0
+# define IN_MODULE (-1)
+#endif
+
+#ifndef _ISOMAC
 
 /* This is defined for the compilation of all C library code.  features.h
    tests this to avoid inclusion of stubs.h while compiling the library,
@@ -50,8 +70,17 @@
    itself is being compiled, or just some generator program.  */
 #define _LIBC	1
 
-/* Enable declarations of GNU extensions, since we are compiling them.  */
-#define _GNU_SOURCE	1
+/* Some files must be compiled with optimization on.  */
+#if !defined __ASSEMBLER__ && !defined __OPTIMIZE__
+# error "glibc cannot be compiled without optimization"
+#endif
+
+/* -ffast-math cannot be applied to the C library, as it alters the ABI.
+   Some test components that use -ffast-math are currently not part of
+   IS_IN (testsuite) for technical reasons, so we have a secondary override.  */
+#if defined __FAST_MATH__ && !defined TEST_FAST_MATH
+# error "glibc must not be compiled with -ffast-math"
+#endif
 
 #include <config.h>
 
@@ -887,4 +916,5 @@ for linking")
 # define inhibit_loop_to_libcall
 #endif
 
+#endif /* !_ISOMAC */
 #endif /* libc-symbols.h */
diff --git a/include/math.h b/include/math.h
index a4f556263a..6ff67830f8 100644
--- a/include/math.h
+++ b/include/math.h
@@ -1,5 +1,10 @@
 #ifndef	_MATH_H
 
+#ifdef _ISOMAC
+# undef NO_LONG_DOUBLE
+# undef _Mlong_double_
+#endif
+
 #include <math/math.h>
 
 #ifndef _ISOMAC
diff --git a/include/stdio.h b/include/stdio.h
index 17b5a05076..6c84dffdeb 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -1,11 +1,13 @@
 #ifndef _STDIO_H
-# if defined __need_FILE || defined __need___FILE || defined _ISOMAC
+# if defined _ISOMAC
+#  undef _IO_MTSAFE_IO
+#  include <libio/stdio.h>
+# elif defined __need_FILE || defined __need___FILE
 #  include <libio/stdio.h>
 # else
 #  include <libio/stdio.h>
 
 /* Now define the internal interfaces.  */
-__BEGIN_DECLS
 
 extern int __fcloseall (void);
 extern int __snprintf (char *__restrict __s, size_t __maxlen,
@@ -30,7 +32,6 @@ extern int __vsscanf (const char *__restrict __s,
 		      _G_va_list __arg)
      __attribute__ ((__format__ (__scanf__, 2, 0)));
 
-#  ifndef __cplusplus
 extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
 extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
      __THROW;
@@ -52,7 +53,6 @@ extern int __obstack_printf_chk (struct obstack *, int, const char *, ...)
      __THROW;
 extern int __obstack_vprintf_chk (struct obstack *, int, const char *,
 				  _G_va_list) __THROW;
-#  endif
 
 extern int __isoc99_fscanf (FILE *__restrict __stream,
 			    const char *__restrict __format, ...) __wur;
@@ -184,7 +184,5 @@ libc_hidden_proto (__obstack_vprintf_chk)
 extern FILE * __fmemopen (void *buf, size_t len, const char *mode);
 libc_hidden_proto (__fmemopen)
 
-__END_DECLS
 # endif
-
 #endif
diff --git a/include/stdlib.h b/include/stdlib.h
index 352339e859..8039876017 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -13,8 +13,6 @@
 #if !defined __Need_M_And_C && !defined _ISOMAC
 # include <sys/stat.h>
 
-__BEGIN_DECLS
-
 extern __typeof (strtol_l) __strtol_l;
 extern __typeof (strtoul_l) __strtoul_l;
 extern __typeof (strtoll_l) __strtoll_l;
@@ -265,8 +263,6 @@ extern __typeof (unsetenv) unsetenv attribute_hidden;
 extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
 # endif
 
-__END_DECLS
-
 #endif
 
 #undef __Need_M_And_C
diff --git a/include/string.h b/include/string.h
index f166de9c43..ce71674086 100644
--- a/include/string.h
+++ b/include/string.h
@@ -1,6 +1,8 @@
 #ifndef _STRING_H
 
-#if !defined _ISOMAC && !defined __cplusplus
+#ifndef _ISOMAC
+/* Some of these are defined as macros in the real string.h, so we must
+   prototype them before including it.  */
 #include <sys/types.h>
 
 extern void *__memccpy (void *__dest, const void *__src,
@@ -46,16 +48,14 @@ extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
 extern int __ffs (int __i) __attribute__ ((const));
 
 extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
-#endif
 
 /* Get _STRING_ARCH_unaligned.  */
 #include <string_private.h>
+#endif
 
-/* Now the real definitions.  We do this here since some of the functions
-   above are defined as macros in the headers.  */
 #include <string/string.h>
 
-#if !defined _ISOMAC && !defined __cplusplus
+#ifndef _ISOMAC
 extern __typeof (strcoll_l) __strcoll_l;
 extern __typeof (strxfrm_l) __strxfrm_l;
 extern __typeof (strcasecmp_l) __strcasecmp_l;
diff --git a/include/time.h b/include/time.h
index 684ceb812f..8fe18185ed 100644
--- a/include/time.h
+++ b/include/time.h
@@ -4,8 +4,6 @@
 #ifndef _ISOMAC
 # include <xlocale.h>
 
-__BEGIN_DECLS
-
 extern __typeof (strftime_l) __strftime_l;
 libc_hidden_proto (__strftime_l)
 extern __typeof (strptime_l) __strptime_l;
@@ -112,7 +110,5 @@ extern double __difftime (time_t time1, time_t time0);
    actual clock ID.  */
 #define CLOCK_IDFIELD_SIZE	3
 
-__END_DECLS
-
 #endif
 #endif
diff --git a/include/unistd.h b/include/unistd.h
index 16d68a1505..fbcea1b92d 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -2,7 +2,6 @@
 # include <posix/unistd.h>
 
 # ifndef _ISOMAC
-__BEGIN_DECLS
 
 libc_hidden_proto (_exit, __noreturn__)
 rtld_hidden_proto (_exit, __noreturn__)
@@ -188,7 +187,5 @@ extern int __getlogin_r_loginuid (char *name, size_t namesize)
 extern __typeof (__access) __access_noerrno attribute_hidden;
 #  endif
 
-__END_DECLS
 # endif
-
 #endif
diff --git a/include/wchar.h b/include/wchar.h
index 6272130e24..e2579a176a 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -172,7 +172,6 @@ extern int __vfwprintf (__FILE *__restrict __s,
 			const wchar_t *__restrict __format,
 			__gnuc_va_list __arg)
      /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
-#ifndef __cplusplus
 extern int __vfwprintf_chk (FILE *__restrict __s, int __flag,
 			    const wchar_t *__restrict __format,
 			    __gnuc_va_list __arg)
@@ -184,7 +183,6 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
      /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
 libc_hidden_proto (__vfwprintf_chk)
 libc_hidden_proto (__vswprintf_chk)
-#endif
 
 extern int __isoc99_fwscanf (__FILE *__restrict __stream,
 			     const wchar_t *__restrict __format, ...);
diff --git a/inet/Makefile b/inet/Makefile
index 010792af8f..b33355602e 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -52,7 +52,9 @@ aux := check_pf check_native ifreq
 tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
 	 tst-gethnm test-ifaddrs bug-if1 test-inet6_opt tst-ether_line \
 	 tst-getni1 tst-getni2 tst-inet6_rth tst-checks tst-checks-posix \
-	 tst-sockaddr tst-inet6_scopeid_pton test-hnto-types
+	 tst-sockaddr test-hnto-types
+
+tests-internal := tst-inet6_scopeid_pton
 
 include ../Rules
 
diff --git a/inet/tst-checks-posix.c b/inet/tst-checks-posix.c
index e46b6a2a69..cdcb5cb3aa 100644
--- a/inet/tst-checks-posix.c
+++ b/inet/tst-checks-posix.c
@@ -19,6 +19,5 @@
 /* Process tst-checks.c in POSIX mode.  */
 #undef _GNU_SOURCE
 #define _POSIX_C_SOURCE 200112L
-#define _ISOMAC
 
 #include "tst-checks.c"
diff --git a/intl/tst-gettext2.c b/intl/tst-gettext2.c
index bdfe76de66..894e09e41e 100644
--- a/intl/tst-gettext2.c
+++ b/intl/tst-gettext2.c
@@ -24,6 +24,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#define N_(msgid) msgid
+
 struct data_t
 {
   const char *selection;
diff --git a/malloc/Makefile b/malloc/Makefile
index e93b83b57d..ca83228b1c 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -25,9 +25,9 @@ include ../Makeconfig
 dist-headers := malloc.h
 headers := $(dist-headers) obstack.h mcheck.h
 tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
-	 tst-mallocstate tst-mcheck tst-mallocfork tst-trim1 \
+	 tst-mcheck tst-mallocfork tst-trim1 \
 	 tst-malloc-usable tst-realloc tst-posix_memalign \
-	 tst-pvalloc tst-memalign tst-mallopt tst-scratch_buffer \
+	 tst-pvalloc tst-memalign tst-mallopt \
 	 tst-malloc-backtrace tst-malloc-thread-exit \
 	 tst-malloc-thread-fail tst-malloc-fork-deadlock \
 	 tst-mallocfork2 \
@@ -39,6 +39,8 @@ tests-static := \
 	 tst-interpose-static-thread \
 	 tst-malloc-usable-static \
 
+tests-internal := tst-mallocstate tst-scratch_buffer
+
 ifneq (no,$(have-tunables))
 tests += tst-malloc-usable-tunables
 tests-static += tst-malloc-usable-static-tunables
diff --git a/math/test-signgam-finite-c99.c b/math/test-signgam-finite-c99.c
index a67a803c99..3dacef5147 100644
--- a/math/test-signgam-finite-c99.c
+++ b/math/test-signgam-finite-c99.c
@@ -20,7 +20,6 @@
 #undef __LIBC_INTERNAL_MATH_INLINES
 #undef _GNU_SOURCE
 #undef _Mlong_double_
-#define _ISOMAC
 
 #include <math.h>
 #include <stdio.h>
diff --git a/math/test-signgam-main.c b/math/test-signgam-main.c
index 11ebbe3628..e3cecf7fa1 100644
--- a/math/test-signgam-main.c
+++ b/math/test-signgam-main.c
@@ -19,7 +19,6 @@
 #undef _LIBC
 #undef __LIBC_INTERNAL_MATH_INLINES
 #undef _GNU_SOURCE
-#define _ISOMAC
 
 #include <math.h>
 #include <stdio.h>
diff --git a/misc/Makefile b/misc/Makefile
index ed988c3967..bd88253c26 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -79,8 +79,9 @@ gpl2lgpl := error.c error.h
 tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
 	 tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \
 	 tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 \
-	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \
-	 tst-atomic tst-atomic-long
+	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty
+
+tests-internal := tst-atomic tst-atomic-long
 tests-static := tst-empty
 
 ifeq ($(run-built-tests),yes)
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index e5fe4f89d9..39c91e1225 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -55,15 +55,18 @@
 #  define __THROW	__attribute__ ((__nothrow__ __LEAF))
 #  define __THROWNL	__attribute__ ((__nothrow__))
 #  define __NTH(fct)	__attribute__ ((__nothrow__ __LEAF)) fct
+#  define __NTHNL(fct)  __attribute__ ((__nothrow__)) fct
 # else
 #  if defined __cplusplus && __GNUC_PREREQ (2,8)
 #   define __THROW	throw ()
 #   define __THROWNL	throw ()
 #   define __NTH(fct)	__LEAF_ATTR fct throw ()
+#   define __NTHNL(fct) fct throw ()
 #  else
 #   define __THROW
 #   define __THROWNL
 #   define __NTH(fct)	fct
+#   define __NTHNL(fct) fct
 #  endif
 # endif
 
diff --git a/nptl/Makefile b/nptl/Makefile
index 6d48c0cfc8..edffb66272 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -220,8 +220,7 @@ LDLIBS-tst-once5 = -lstdc++
 CFLAGS-tst-thread_local1.o = -std=gnu++11
 LDLIBS-tst-thread_local1 = -lstdc++
 
-tests = tst-typesizes \
-	tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
+tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
 	tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
 	tst-mutex7 tst-mutex8 tst-mutex9 tst-mutex5a tst-mutex7a \
 	tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 tst-mutexpi5 \
@@ -241,13 +240,12 @@ tests = tst-typesizes \
 	tst-rwlock4 tst-rwlock5 tst-rwlock6 tst-rwlock7 tst-rwlock8 \
 	tst-rwlock9 tst-rwlock10 tst-rwlock11 tst-rwlock12 tst-rwlock13 \
 	tst-rwlock14 tst-rwlock15 tst-rwlock16 tst-rwlock17 tst-rwlock18 \
-	tst-rwlock19 \
 	tst-once1 tst-once2 tst-once3 tst-once4 tst-once5 \
 	tst-key1 tst-key2 tst-key3 tst-key4 \
 	tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
-	tst-sem8 tst-sem9 tst-sem10 tst-sem11 tst-sem12 tst-sem13 tst-sem14 \
+	tst-sem8 tst-sem9 tst-sem10 tst-sem14 \
 	tst-sem15 tst-sem16 \
-	tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 tst-barrier5 \
+	tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
 	tst-align tst-align3 \
 	tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
 	tst-basic7 \
@@ -272,7 +270,7 @@ tests = tst-typesizes \
 	tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \
 	tst-flock1 tst-flock2 \
 	tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
-	tst-signal6 tst-signal7 \
+	tst-signal6 \
 	tst-exec1 tst-exec2 tst-exec3 tst-exec4 tst-exec5 \
 	tst-exit1 tst-exit2 tst-exit3 \
 	tst-stdio1 tst-stdio2 \
@@ -297,6 +295,10 @@ tests = tst-typesizes \
 	tst-bad-schedattr \
 	tst-thread_local1 tst-mutex-errorcheck tst-robust10 \
 	tst-robust-fork tst-create-detached
+
+tests-internal := tst-typesizes tst-rwlock19 tst-sem11 tst-sem12 tst-sem13 \
+		  tst-barrier5 tst-signal7
+
 xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
 test-srcs = tst-oddstacklimit
@@ -354,8 +356,8 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
 	 tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 \
 	 tst-oncex3 tst-oncex4
 ifeq ($(build-shared),yes)
-tests += tst-atfork2 tst-tls3 tst-tls3-malloc tst-tls4 tst-tls5 tst-_res1 \
-	 tst-fini1 tst-stackguard1
+tests += tst-atfork2 tst-tls4 tst-_res1 tst-fini1
+tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
 tests-nolibpthread += tst-fini1
 ifeq ($(have-z-execstack),yes)
 tests += tst-execstack
@@ -369,7 +371,7 @@ modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \
 		tst-join7mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
-test-extras += $(modules-names) tst-cleanup4aux tst-cleanupx4aux
+test-extras += tst-cleanup4aux tst-cleanupx4aux
 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
 
 tst-atfork2mod.so-no-z-defs = yes
@@ -422,9 +424,9 @@ tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
 		tst-cancel21-static tst-cancel24-static tst-cond8-static \
 		tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
 		tst-sem12-static
-tests += tst-stackguard1-static tst-cancel21-static tst-cancel24-static \
-	 tst-cond8-static tst-mutex8-static tst-mutexpi8-static \
-	 tst-sem11-static tst-sem12-static
+tests += tst-cancel21-static tst-cancel24-static \
+	 tst-cond8-static tst-mutex8-static tst-mutexpi8-static
+tests-internal += tst-sem11-static tst-sem12-static tst-stackguard1-static
 xtests-static += tst-setuid1-static
 
 # These tests are linked with libc before libpthread
@@ -619,8 +621,9 @@ ifeq ($(build-shared),yes)
 $(addprefix $(objpfx), \
   $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
     $(tests-nolibpthread), \
-    $(tests) $(xtests) $(test-srcs))): $(objpfx)libpthread.so \
-				       $(objpfx)libpthread_nonshared.a
+    $(tests) $(tests-internal) $(xtests) $(test-srcs))): \
+	$(objpfx)libpthread.so \
+	$(objpfx)libpthread_nonshared.a
 $(objpfx)tst-unload: $(libdl)
 # $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
 # since otherwise libpthread.so comes before libc.so when linking.
diff --git a/nss/Makefile b/nss/Makefile
index de6c47a1db..6d165f2734 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -49,15 +49,15 @@ makedb-modules = xmalloc hash-string
 extra-objs		+= $(makedb-modules:=.o)
 
 tests-static            = tst-field
+tests-internal		= tst-field
 tests			= test-netdb tst-nss-test1 test-digits-dots \
-			  tst-nss-getpwent bug17079 \
-			  $(tests-static)
+			  tst-nss-getpwent bug17079
 xtests			= bug-erange
 
 # If we have a thread library then we can test cancellation against
 # some routines like getpwuid_r.
 ifeq (yes,$(have-thread-library))
-tests += tst-cancel-getpwuid_r
+tests-internal += tst-cancel-getpwuid_r
 endif
 
 # Specify rules for the nss_* modules.  We have some services.
diff --git a/posix/Makefile b/posix/Makefile
index 8f23d647c8..e07aae58eb 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -67,24 +67,23 @@ tests		:= tstgetopt testfnm runtests runptests	     \
 		   tst-mmap tst-mmap-offset tst-getaddrinfo tst-truncate \
 		   tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
 		   tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
-		   tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
+		   tst-gnuglob tst-regex bug-regex6 bug-regex7 \
 		   bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
 		   bug-regex13 bug-regex14 bug-regex15 bug-regex16 \
-		   bug-regex17 bug-regex18 bug-regex19 bug-regex20 \
+		   bug-regex17 bug-regex18 bug-regex19 \
 		   bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
 		   bug-regex25 bug-regex26 bug-regex27 bug-regex28 \
 		   bug-regex29 bug-regex30 bug-regex31 bug-regex32 \
-		   bug-regex33 tst-nice tst-nanosleep tst-regex2 \
+		   tst-nice tst-nanosleep tst-regex2 \
 		   transbug tst-rxspencer tst-pcre tst-boost \
 		   bug-ga1 tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \
 		   tst-getaddrinfo2 bug-glob1 bug-glob2 bug-glob3 tst-sysconf \
 		   tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
 		   tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
 		   tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
-		   tst-execvp3 tst-execvp4 tst-rfc3484 tst-rfc3484-2 \
+		   tst-execvp3 tst-execvp4 \
 		   tst-execvpe1 tst-execvpe2 tst-execvpe3 tst-execvpe4 \
 		   tst-execvpe5 tst-execvpe6 \
-		   tst-rfc3484-3 \
 		   tst-getaddrinfo3 tst-fnmatch2 tst-cpucount tst-cpuset \
 		   bug-getopt1 bug-getopt2 bug-getopt3 bug-getopt4 \
 		   bug-getopt5 tst-getopt_long1 bug-regex34 bug-regex35 \
@@ -92,6 +91,8 @@ tests		:= tstgetopt testfnm runtests runptests	     \
 		   tst-fnmatch3 bug-regex36 tst-getaddrinfo5 \
 		   tst-posix_spawn-fd \
 		   tst-posix_fadvise tst-posix_fadvise64
+tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
+		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3
 xtests		:= bug-ga2
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 5751b5d600..d4edcf8eef 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -68,23 +68,26 @@ test-srcs	:= tst-fmtmsg
 tests		:= tst-strtol tst-strtod testmb testrand testsort testdiv   \
 		   test-canon test-canon2 tst-strtoll tst-environ	    \
 		   tst-xpg-basename tst-random tst-random2 tst-bsearch	    \
-		   tst-limits tst-rand48 bug-strtod tst-setcontext          \
+		   tst-limits tst-rand48 bug-strtod tst-setcontext	    \
 		   tst-setcontext2 test-a64l tst-qsort tst-system testmb2   \
-		   bug-strtod2 tst-atof1 tst-atof2 tst-strtod2 tst-strtod3  \
-		   tst-rand48-2 tst-makecontext tst-strtod4 tst-strtod5     \
+		   bug-strtod2 tst-atof1 tst-atof2 tst-strtod2		    \
+		   tst-rand48-2 tst-makecontext tst-strtod5		    \
 		   tst-qsort2 tst-makecontext2 tst-strtod6 tst-unsetenv1    \
 		   tst-makecontext3 bug-getcontext bug-fmtmsg1		    \
 		   tst-secure-getenv tst-strtod-overflow tst-strtod-round   \
-		   tst-tininess tst-strtod-underflow tst-tls-atexit	    \
-		   tst-setcontext3 tst-tls-atexit-nodelete		    \
+		   tst-tininess tst-strtod-underflow tst-setcontext3	    \
 		   tst-strtol-locale tst-strtod-nan-locale tst-strfmon_l    \
 		   tst-quick_exit tst-thread-quick_exit tst-width	    \
-		   tst-width-stdint tst-strfrom tst-strfrom-locale \
+		   tst-width-stdint tst-strfrom tst-strfrom-locale	    \
 		   tst-getrandom
+tests-internal	:= tst-strtod1i tst-strtod3 tst-strtod4 tst-strtod5i \
+		   tst-tls-atexit tst-tls-atexit-nodelete
+tests-static	:= tst-secure-getenv
+
 ifeq ($(build-hardcoded-path-in-tests),yes)
 tests += tst-empty-env
 endif
-tests-static	:= tst-secure-getenv
+
 ifeq ($(have-cxx-thread_local),yes)
 CFLAGS-tst-quick_exit.o = -std=c++11
 LDLIBS-tst-quick_exit = -lstdc++
diff --git a/stdlib/tst-strtod.c b/stdlib/tst-strtod.c
index ced6d8a351..e0f096c325 100644
--- a/stdlib/tst-strtod.c
+++ b/stdlib/tst-strtod.c
@@ -79,7 +79,6 @@ static const struct ltest tests[] =
 
 static void expand (char *dst, int c);
 static int long_dbl (void);
-static int locale_test (void);
 
 static int
 do_test (void)
@@ -176,8 +175,6 @@ do_test (void)
 
   status |= long_dbl ();
 
-  status |= locale_test ();
-
   return status ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
@@ -217,63 +214,6 @@ long_dbl (void)
   return 0;
 }
 
-/* Perform a few tests in a locale with thousands separators.  */
-static int
-locale_test (void)
-{
-  static const struct
-  {
-    const char *loc;
-    const char *str;
-    double exp;
-    ptrdiff_t nread;
-  } tests[] =
-    {
-      { "de_DE.UTF-8", "1,5", 1.5, 3 },
-      { "de_DE.UTF-8", "1.5", 1.0, 1 },
-      { "de_DE.UTF-8", "1.500", 1500.0, 5 },
-      { "de_DE.UTF-8", "36.893.488.147.419.103.232", 0x1.0p65, 26 }
-    };
-#define ntests (sizeof (tests) / sizeof (tests[0]))
-  size_t n;
-  int result = 0;
-
-  puts ("\nLocale tests");
-
-  for (n = 0; n < ntests; ++n)
-    {
-      double d;
-      char *endp;
-
-      if (setlocale (LC_ALL, tests[n].loc) == NULL)
-	{
-	  printf ("cannot set locale %s\n", tests[n].loc);
-	  result = 1;
-	  continue;
-	}
-
-      /* We call __strtod_interal here instead of strtod to tests the
-	 handling of grouping.  */
-      d = __strtod_internal (tests[n].str, &endp, 1);
-      if (d != tests[n].exp)
-	{
-	  printf ("strtod(\"%s\") returns %g and not %g\n",
-		  tests[n].str, d, tests[n].exp);
-	  result = 1;
-	}
-      else if (endp - tests[n].str != tests[n].nread)
-	{
-	  printf ("strtod(\"%s\") read %td bytes and not %td\n",
-		  tests[n].str, endp - tests[n].str, tests[n].nread);
-	  result = 1;
-	}
-    }
-
-  if (result == 0)
-    puts ("all OK");
-
-  return result;
-}
 
 #define TEST_FUNCTION do_test ()
 #include "../test-skeleton.c"
diff --git a/stdlib/tst-strtod1i.c b/stdlib/tst-strtod1i.c
new file mode 100644
index 0000000000..5c2ba9981d
--- /dev/null
+++ b/stdlib/tst-strtod1i.c
@@ -0,0 +1,84 @@
+/* Copyright (C) 1991-2017 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 <ctype.h>
+#include <locale.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <math.h>
+
+/* Perform a few tests in a locale with thousands separators.  */
+static int
+do_test (void)
+{
+  static const struct
+  {
+    const char *loc;
+    const char *str;
+    double exp;
+    ptrdiff_t nread;
+  } tests[] =
+    {
+      { "de_DE.UTF-8", "1,5", 1.5, 3 },
+      { "de_DE.UTF-8", "1.5", 1.0, 1 },
+      { "de_DE.UTF-8", "1.500", 1500.0, 5 },
+      { "de_DE.UTF-8", "36.893.488.147.419.103.232", 0x1.0p65, 26 }
+    };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+  size_t n;
+  int result = 0;
+
+  puts ("\nLocale tests");
+
+  for (n = 0; n < ntests; ++n)
+    {
+      double d;
+      char *endp;
+
+      if (setlocale (LC_ALL, tests[n].loc) == NULL)
+	{
+	  printf ("cannot set locale %s\n", tests[n].loc);
+	  result = 1;
+	  continue;
+	}
+
+      d = __strtod_internal (tests[n].str, &endp, 1);
+      if (d != tests[n].exp)
+	{
+	  printf ("strtod(\"%s\") returns %g and not %g\n",
+		  tests[n].str, d, tests[n].exp);
+	  result = 1;
+	}
+      else if (endp - tests[n].str != tests[n].nread)
+	{
+	  printf ("strtod(\"%s\") read %td bytes and not %td\n",
+		  tests[n].str, endp - tests[n].str, tests[n].nread);
+	  result = 1;
+	}
+    }
+
+  if (result == 0)
+    puts ("all OK");
+
+  return result ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/stdlib/tst-strtod5.c b/stdlib/tst-strtod5.c
index 337c746989..691759e366 100644
--- a/stdlib/tst-strtod5.c
+++ b/stdlib/tst-strtod5.c
@@ -9,38 +9,27 @@
 static const struct
 {
   const char *in;
-  int group;
   double expected;
 } tests[] =
   {
-    { "0", 0, 0.0 },
-    { "000", 0, 0.0 },
-    { "-0", 0, -0.0 },
-    { "-000", 0, -0.0 },
-    { "0,", 0, 0.0 },
-    { "-0,", 0, -0.0 },
-    { "0,0", 0, 0.0 },
-    { "-0,0", 0, -0.0 },
-    { "0e-10", 0, 0.0 },
-    { "-0e-10", 0, -0.0 },
-    { "0,e-10", 0, 0.0 },
-    { "-0,e-10", 0, -0.0 },
-    { "0,0e-10", 0, 0.0 },
-    { "-0,0e-10", 0, -0.0 },
-    { "0e-1000000", 0, 0.0 },
-    { "-0e-1000000", 0, -0.0 },
-    { "0,0e-1000000", 0, 0.0 },
-    { "-0,0e-1000000", 0, -0.0 },
-    { "0", 1, 0.0 },
-    { "000", 1, 0.0 },
-    { "-0", 1, -0.0 },
-    { "-000", 1, -0.0 },
-    { "0e-10", 1, 0.0 },
-    { "-0e-10", 1, -0.0 },
-    { "0e-1000000", 1, 0.0 },
-    { "-0e-1000000", 1, -0.0 },
-    { "000"NBSP"000"NBSP"000", 1, 0.0 },
-    { "-000"NBSP"000"NBSP"000", 1, -0.0 }
+    { "0", 0.0 },
+    { "000", 0.0 },
+    { "-0", -0.0 },
+    { "-000", -0.0 },
+    { "0,", 0.0 },
+    { "-0,", -0.0 },
+    { "0,0", 0.0 },
+    { "-0,0", -0.0 },
+    { "0e-10", 0.0 },
+    { "-0e-10", -0.0 },
+    { "0,e-10", 0.0 },
+    { "-0,e-10", -0.0 },
+    { "0,0e-10", 0.0 },
+    { "-0,0e-10", -0.0 },
+    { "0e-1000000", 0.0 },
+    { "-0e-1000000", -0.0 },
+    { "0,0e-1000000", 0.0 },
+    { "-0,0e-1000000", -0.0 },
   };
 #define NTESTS (sizeof (tests) / sizeof (tests[0]))
 
@@ -59,12 +48,7 @@ do_test (void)
   for (int i = 0; i < NTESTS; ++i)
     {
       char *ep;
-      double r;
-
-      if (tests[i].group)
-	r = __strtod_internal (tests[i].in, &ep, 1);
-      else
-	r = strtod (tests[i].in, &ep);
+      double r = strtod (tests[i].in, &ep);
 
       if (*ep != '\0')
 	{
diff --git a/stdlib/tst-strtod5i.c b/stdlib/tst-strtod5i.c
new file mode 100644
index 0000000000..92ed983141
--- /dev/null
+++ b/stdlib/tst-strtod5i.c
@@ -0,0 +1,83 @@
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#define NBSP "\xc2\xa0"
+
+static const struct
+{
+  const char *in;
+  int group;
+  double expected;
+} tests[] =
+  {
+    { "0", 0, 0.0 },
+    { "000", 0, 0.0 },
+    { "-0", 0, -0.0 },
+    { "-000", 0, -0.0 },
+    { "0,", 0, 0.0 },
+    { "-0,", 0, -0.0 },
+    { "0,0", 0, 0.0 },
+    { "-0,0", 0, -0.0 },
+    { "0e-10", 0, 0.0 },
+    { "-0e-10", 0, -0.0 },
+    { "0,e-10", 0, 0.0 },
+    { "-0,e-10", 0, -0.0 },
+    { "0,0e-10", 0, 0.0 },
+    { "-0,0e-10", 0, -0.0 },
+    { "0e-1000000", 0, 0.0 },
+    { "-0e-1000000", 0, -0.0 },
+    { "0,0e-1000000", 0, 0.0 },
+    { "-0,0e-1000000", 0, -0.0 },
+    { "0", 1, 0.0 },
+    { "000", 1, 0.0 },
+    { "-0", 1, -0.0 },
+    { "-000", 1, -0.0 },
+    { "0e-10", 1, 0.0 },
+    { "-0e-10", 1, -0.0 },
+    { "0e-1000000", 1, 0.0 },
+    { "-0e-1000000", 1, -0.0 },
+    { "000"NBSP"000"NBSP"000", 1, 0.0 },
+    { "-000"NBSP"000"NBSP"000", 1, -0.0 }
+  };
+#define NTESTS (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
+    {
+      puts ("could not set locale");
+      return 1;
+    }
+
+  int status = 0;
+
+  for (int i = 0; i < NTESTS; ++i)
+    {
+      char *ep;
+      double r = __strtod_internal (tests[i].in, &ep, tests[i].group);
+
+      if (*ep != '\0')
+	{
+	  printf ("%d: got rest string \"%s\", expected \"\"\n", i, ep);
+	  status = 1;
+	}
+
+      if (r != tests[i].expected
+	  || copysign (10.0, r) != copysign (10.0, tests[i].expected))
+	{
+	  printf ("%d: got wrong results %g, expected %g\n",
+		  i, r, tests[i].expected);
+	  status = 1;
+	}
+    }
+
+  return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/string/test-string.h b/string/test-string.h
index 2c36b44c22..9f45898238 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -40,6 +40,18 @@ extern impl_t __start_impls[], __stop_impls[];
 
 #undef __USE_STRING_INLINES
 
+/* We are compiled under _ISOMAC, so libc-symbols.h does not do this
+   for us.  */
+#include "config.h"
+#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
+# define inhibit_loop_to_libcall \
+    __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
+#else
+# define inhibit_loop_to_libcall
+#endif
+
+
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/string/test-strstr.c b/string/test-strstr.c
index c29d37446c..404c374331 100644
--- a/string/test-strstr.c
+++ b/string/test-strstr.c
@@ -23,6 +23,7 @@
 
 
 #define STRSTR simple_strstr
+#define libc_hidden_builtin_def(arg) /* nothing */
 #include "strstr.c"
 
 
diff --git a/sysdeps/ia64/fpu/libm-symbols.h b/sysdeps/ia64/fpu/libm-symbols.h
index 31d6f36de9..505131b813 100644
--- a/sysdeps/ia64/fpu/libm-symbols.h
+++ b/sysdeps/ia64/fpu/libm-symbols.h
@@ -1,4 +1,4 @@
-#if !defined __STRICT_ANSI__ && !defined __cplusplus
+#ifndef _ISOMAC
 # include <sysdep.h>
 # undef ret	/* get rid of the stupid "ret" macro; it breaks br.ret */
 
diff --git a/sysdeps/m68k/m680x0/fpu/bits/mathinline.h b/sysdeps/m68k/m680x0/fpu/bits/mathinline.h
index c2dca317f4..8e6bdc4e27 100644
--- a/sysdeps/m68k/m680x0/fpu/bits/mathinline.h
+++ b/sysdeps/m68k/m680x0/fpu/bits/mathinline.h
@@ -112,19 +112,22 @@ __NTH (__signbitl (long double __x))
 #ifdef	__LIBC_INTERNAL_MATH_INLINES
 /* This is used when defining the functions themselves.  Define them with
    __ names, and with `static inline' instead of `extern inline' so the
-   bodies will always be used, never an external function call.  */
+   bodies will always be used, never an external function call.
+   Note: GCC 6 objects to __attribute__ ((__leaf__)) on static functions.  */
 # define __m81_u(x)		__CONCAT(__,x)
 # define __m81_inline		static __inline
+# define __m81_nth(fn)		__NTHNL (fn)
 #else
 # define __m81_u(x)		x
-# define __m81_inline __MATH_INLINE
+# define __m81_inline		__MATH_INLINE
+# define __m81_nth(fn)		__NTH (fn)
 # define __M81_MATH_INLINES	1
 #endif
 
 /* Define a const math function.  */
 #define __m81_defun(rettype, func, args)				      \
   __m81_inline rettype __attribute__((__const__))			      \
-  __NTH (__m81_u(func) args)
+  __m81_nth (__m81_u(func) args)
 
 /* Define the three variants of a math function that has a direct
    implementation in the m68k fpu.  FUNC is the name for C (which will be
@@ -335,8 +338,8 @@ __inline_functions (long double,l)
 
 # define __inline_functions(float_type, s)				\
 __m81_inline void							\
-__NTH (__m81_u(__CONCAT(__sincos,s))(float_type __x, float_type *__sinx, \
-				     float_type *__cosx))		\
+__m81_nth (__m81_u(__CONCAT(__sincos,s))				\
+	   (float_type __x, float_type *__sinx, float_type *__cosx))	\
 {									\
   __asm __volatile__ ("fsincos%.x %2,%1:%0"				\
 		      : "=f" (*__sinx), "=f" (*__cosx) : "f" (__x));	\
@@ -353,8 +356,6 @@ __inline_functions (long double,l)
 
 /* Define inline versions of the user visible functions.  */
 
-/* Note that there must be no whitespace before the argument passed for
-   NAME, to make token pasting work correctly with -traditional.  */
 # define __inline_forward_c(rettype, name, args1, args2)	\
 __MATH_INLINE rettype __attribute__((__const__))		\
 __NTH (name args1)						\
diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
index 099fbf68cd..aafa226f7f 100644
--- a/sysdeps/powerpc/Makefile
+++ b/sysdeps/powerpc/Makefile
@@ -27,7 +27,7 @@ gen-as-const-headers += locale-defines.sym
 endif
 
 ifeq ($(subdir),nptl)
-tests += test-get_hwcap test-get_hwcap-static
+tests-internal += test-get_hwcap test-get_hwcap-static
 tests-static += test-get_hwcap-static
 endif
 
diff --git a/sysdeps/x86_64/fpu/Makefile b/sysdeps/x86_64/fpu/Makefile
index fad605a841..e4462b9337 100644
--- a/sysdeps/x86_64/fpu/Makefile
+++ b/sysdeps/x86_64/fpu/Makefile
@@ -45,6 +45,12 @@ modules-names += test-double-libmvec-alias-mod \
 		 test-float-libmvec-alias-mod \
 		 test-float-libmvec-alias-avx-mod \
 		 test-float-libmvec-alias-avx2-mod
+modules-names-tests += test-double-libmvec-alias-mod \
+		 test-double-libmvec-alias-avx-mod \
+		 test-double-libmvec-alias-avx2-mod \
+		 test-float-libmvec-alias-mod \
+		 test-float-libmvec-alias-avx-mod \
+		 test-float-libmvec-alias-avx2-mod
 extra-test-objs += test-double-libmvec-sincos-avx-main.o \
 		   test-double-libmvec-sincos-avx2-main.o \
 		   test-double-libmvec-sincos-main.o \
@@ -146,6 +152,8 @@ tests += test-double-libmvec-alias-avx512 \
 	 test-float-libmvec-sincosf-avx512
 modules-names += test-double-libmvec-alias-avx512-mod \
 		 test-float-libmvec-alias-avx512-mod
+modules-names-tests += test-double-libmvec-alias-avx512-mod \
+		 test-float-libmvec-alias-avx512-mod
 extra-test-objs += test-double-libmvec-sincos-avx512-main.o \
 		   test-float-libmvec-sincosf-avx512-main.o
 test-double-libmvec-alias-avx512-mod.so-no-z-defs = yes
diff --git a/sysdeps/x86_64/fpu/math-tests-arch.h b/sysdeps/x86_64/fpu/math-tests-arch.h
index 98f7cf6548..9278e3440b 100644
--- a/sysdeps/x86_64/fpu/math-tests-arch.h
+++ b/sysdeps/x86_64/fpu/math-tests-arch.h
@@ -16,11 +16,11 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <cpu-features.h>
+
 #if defined REQUIRE_AVX
-# include <init-arch.h>
 
 # define INIT_ARCH_EXT
-
 # define CHECK_ARCH_EXT                                        \
   do                                                           \
     {                                                          \
@@ -29,10 +29,8 @@
   while (0)
 
 #elif defined REQUIRE_AVX2
-# include <init-arch.h>
 
 # define INIT_ARCH_EXT
-
 # define CHECK_ARCH_EXT                                        \
   do                                                           \
     {                                                          \
@@ -41,10 +39,8 @@
   while (0)
 
 #elif defined REQUIRE_AVX512F
-# include <init-arch.h>
 
 # define INIT_ARCH_EXT
-
 # define CHECK_ARCH_EXT                                        \
   do                                                           \
     {                                                          \
diff --git a/sysdeps/x86_64/multiarch/test-multiarch.c b/sysdeps/x86_64/multiarch/test-multiarch.c
index 3974842c19..597d64e1e8 100644
--- a/sysdeps/x86_64/multiarch/test-multiarch.c
+++ b/sysdeps/x86_64/multiarch/test-multiarch.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <init-arch.h>
+#include <cpu-features.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-- 
2.11.0

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h.
  2017-02-20 13:03 ` [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h Zack Weinberg
  2017-02-20 13:03   ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Zack Weinberg
@ 2017-02-20 13:52   ` Carlos O'Donell
  1 sibling, 0 replies; 30+ messages in thread
From: Carlos O'Donell @ 2017-02-20 13:52 UTC (permalink / raw)
  To: Zack Weinberg, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/20/2017 08:03 AM, Zack Weinberg wrote:
> Quite a few tests include libc-internal.h just for the DIAG_* macros.
> Split those macros to their own file, which can be included safely in
> _ISOMAC mode.  I also moved ignore_value, since it seems logically
> related, even though I didn't notice any tests needing it.
> 
> Compiling the testsuite in _ISOMAC mode revealed that somehow the
> __nonnull annotations on pthread_mutexattr_destroy and unsetenv, in
> the public headers, are ignored for internal code; because of this,
> two tests need, but do not have, a -Wnonnull suppression.  Those
> additions are also included in this patch, to keep everything
> involving libc-diag.h together.
> 
> (Query, should libc-diag.h have a copyright header? libc-internal.h
> doesn't.  (Should it?))
 
This patch looks good to me.

Yes, libc-diag.h should have a copyright header.

Yes, libc-internal.h should have a copyright header.

> zw
> 
> 	* include/libc-diag.h: New file which defines ignore_value,
> 	DIAG_PUSH_NEEDS_COMMENT, DIAG_POP_NEEDS_COMMENT,
> 	DIAG_IGNORE_NEEDS_COMMENT, and DIAG_IGNORE_Os_NEEDS_COMMENT...
> 	* include/libc-internal.h: ...moved from here; include libc-diag.h.
> 
> 	* malloc/tst-malloc.c, malloc/tst-memcheck.c, malloc/tst-realloc.c
> 	* misc/tst-error1.c, posix/tst-dir.c, stdio-common/bug21.c
> 	* stdio-common/scanf14.c, stdio-common/scanf4.c, stdio-common/scanf7.c
> 	* stdio-common/test-vfprintf.c, stdio-common/tst-printf.c
> 	* stdio-common/tst-printfsz.c, stdio-common/tst-sprintf.c
> 	* stdio-common/tst-unlockedio.c, stdio-common/tstdiomisc.c
> 	* stdlib/bug-getcontext.c, string/tester.c, string/tst-endian.c
>         * time/tst-strptime2.c, wcsmbs/tst-wcstof.c:
>         Include libc-diag.h instead of libc-internal.h.
> 
> 	* stdlib/tst-environ.c: Include libc-diag.h.  Suppress -Wnonnull for
> 	call to unsetenv (NULL).
> 	* nptl/tst-mutex1.c: Include libc-diag.h.  Suppress -Wnonnull for
> 	call to pthread_mutexattr_destroy (NULL).
> ---
>  include/libc-diag.h           | 57 +++++++++++++++++++++++++++++++++++++++++++
>  include/libc-internal.h       | 52 +--------------------------------------
>  malloc/tst-malloc.c           |  2 +-
>  malloc/tst-mcheck.c           |  2 +-
>  malloc/tst-realloc.c          |  2 +-
>  misc/tst-error1.c             |  2 +-
>  nptl/tst-mutex1.c             |  7 +++++-
>  posix/tst-dir.c               |  2 +-
>  stdio-common/bug21.c          |  2 +-
>  stdio-common/scanf14.c        |  2 +-
>  stdio-common/scanf4.c         |  2 +-
>  stdio-common/scanf7.c         |  2 +-
>  stdio-common/test-vfprintf.c  |  2 +-
>  stdio-common/tst-printf.c     |  2 +-
>  stdio-common/tst-printfsz.c   |  2 +-
>  stdio-common/tst-sprintf.c    |  2 +-
>  stdio-common/tst-unlockedio.c |  2 +-
>  stdio-common/tstdiomisc.c     |  2 +-
>  stdlib/bug-getcontext.c       |  2 +-
>  stdlib/tst-environ.c          |  7 +++++-
>  string/tester.c               |  2 +-
>  string/tst-endian.c           |  2 +-
>  time/tst-strptime2.c          |  2 +-
>  wcsmbs/tst-wcstof.c           |  2 +-
>  24 files changed, 90 insertions(+), 73 deletions(-)
>  create mode 100644 include/libc-diag.h
> 
> diff --git a/include/libc-diag.h b/include/libc-diag.h
> new file mode 100644
> index 0000000000..a6a413c567
> --- /dev/null
> +++ b/include/libc-diag.h
> @@ -0,0 +1,57 @@
> +/* Macros for controlling diagnostic output from the compiler.  */
> +#ifndef _LIBC_DIAG_H
> +#define _LIBC_DIAG_H 1
> +
> +/* Ignore the value of an expression when a cast to void does not
> +   suffice (in particular, for a call to a function declared with
> +   attribute warn_unused_result).  */
> +#define ignore_value(x) \
> +  ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; })
> +
> +/* The macros to control diagnostics are structured like this, rather
> +   than a single macro that both pushes and pops diagnostic state and
> +   takes the affected code as an argument, because the GCC pragmas
> +   work by disabling the diagnostic for a range of source locations
> +   and do not work when all the pragmas and the affected code are in a
> +   single macro expansion.  */
> +
> +/* Push diagnostic state.  */
> +#define DIAG_PUSH_NEEDS_COMMENT _Pragma ("GCC diagnostic push")
> +
> +/* Pop diagnostic state.  */
> +#define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop")
> +
> +#define _DIAG_STR1(s) #s
> +#define _DIAG_STR(s) _DIAG_STR1(s)
> +
> +/* Ignore the diagnostic OPTION.  VERSION is the most recent GCC
> +   version for which the diagnostic has been confirmed to appear in
> +   the absence of the pragma (in the form MAJOR.MINOR for GCC 4.x,
> +   just MAJOR for GCC 5 and later).  Uses of this pragma should be
> +   reviewed when the GCC version given is no longer supported for
> +   building glibc; the version number should always be on the same
> +   source line as the macro name, so such uses can be found with grep.
> +   Uses should come with a comment giving more details of the
> +   diagnostic, and an architecture on which it is seen if possibly
> +   optimization-related and not in architecture-specific code.  This
> +   macro should only be used if the diagnostic seems hard to fix (for
> +   example, optimization-related false positives).  */
> +#define DIAG_IGNORE_NEEDS_COMMENT(version, option)     \
> +  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
> +
> +/* Similar to DIAG_IGNORE_NEEDS_COMMENT the following macro ignores the
> +   diagnostic OPTION but only if optimizations for size are enabled.
> +   This is required because different warnings may be generated for
> +   different optimization levels.  For example a key piece of code may
> +   only generate a warning when compiled at -Os, but at -O2 you could
> +   still want the warning to be enabled to catch errors.  In this case
> +   you would use DIAG_IGNORE_Os_NEEDS_COMMENT to disable the warning
> +   only for -Os.  */
> +#ifdef __OPTIMIZE_SIZE__
> +# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option) \
> +  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
> +#else
> +# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)
> +#endif
> +
> +#endif /* libc-diag.h */
> diff --git a/include/libc-internal.h b/include/libc-internal.h
> index e4395dd5c5..a38a35d87c 100644
> --- a/include/libc-internal.h
> +++ b/include/libc-internal.h
> @@ -74,56 +74,6 @@ extern __typeof (__profile_frequency) __profile_frequency attribute_hidden;
>  #define PTR_ALIGN_UP(base, size) \
>    ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size)))
>  
> -/* Ignore the value of an expression when a cast to void does not
> -   suffice (in particular, for a call to a function declared with
> -   attribute warn_unused_result).  */
> -#define ignore_value(x) \
> -  ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; })
> -
> -/* The macros to control diagnostics are structured like this, rather
> -   than a single macro that both pushes and pops diagnostic state and
> -   takes the affected code as an argument, because the GCC pragmas
> -   work by disabling the diagnostic for a range of source locations
> -   and do not work when all the pragmas and the affected code are in a
> -   single macro expansion.  */
> -
> -/* Push diagnostic state.  */
> -#define DIAG_PUSH_NEEDS_COMMENT _Pragma ("GCC diagnostic push")
> -
> -/* Pop diagnostic state.  */
> -#define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop")
> -
> -#define _DIAG_STR1(s) #s
> -#define _DIAG_STR(s) _DIAG_STR1(s)
> -
> -/* Ignore the diagnostic OPTION.  VERSION is the most recent GCC
> -   version for which the diagnostic has been confirmed to appear in
> -   the absence of the pragma (in the form MAJOR.MINOR for GCC 4.x,
> -   just MAJOR for GCC 5 and later).  Uses of this pragma should be
> -   reviewed when the GCC version given is no longer supported for
> -   building glibc; the version number should always be on the same
> -   source line as the macro name, so such uses can be found with grep.
> -   Uses should come with a comment giving more details of the
> -   diagnostic, and an architecture on which it is seen if possibly
> -   optimization-related and not in architecture-specific code.  This
> -   macro should only be used if the diagnostic seems hard to fix (for
> -   example, optimization-related false positives).  */
> -#define DIAG_IGNORE_NEEDS_COMMENT(version, option)	\
> -  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
> -
> -/* Similar to DIAG_IGNORE_NEEDS_COMMENT the following macro ignores the
> -   diagnostic OPTION but only if optimizations for size are enabled.
> -   This is required because different warnings may be generated for
> -   different optimization levels.  For example a key piece of code may
> -   only generate a warning when compiled at -Os, but at -O2 you could
> -   still want the warning to be enabled to catch errors.  In this case
> -   you would use DIAG_IGNORE_Os_NEEDS_COMMENT to disable the warning
> -   only for -Os.  */
> -#ifdef __OPTIMIZE_SIZE__
> -# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)	\
> -  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
> -#else
> -# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)
> -#endif
> +#include <libc-diag.h>
>  
>  #endif /* _LIBC_INTERNAL  */
> diff --git a/malloc/tst-malloc.c b/malloc/tst-malloc.c
> index 740ac6ce31..dbc8d4ab56 100644
> --- a/malloc/tst-malloc.c
> +++ b/malloc/tst-malloc.c
> @@ -19,7 +19,7 @@
>  #include <errno.h>
>  #include <malloc.h>
>  #include <stdio.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int errors = 0;
>  
> diff --git a/malloc/tst-mcheck.c b/malloc/tst-mcheck.c
> index 2e3cba96b8..5a66bab331 100644
> --- a/malloc/tst-mcheck.c
> +++ b/malloc/tst-mcheck.c
> @@ -19,7 +19,7 @@
>  #include <errno.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int errors = 0;
>  
> diff --git a/malloc/tst-realloc.c b/malloc/tst-realloc.c
> index 7f1f228c06..31a58bd026 100644
> --- a/malloc/tst-realloc.c
> +++ b/malloc/tst-realloc.c
> @@ -19,7 +19,7 @@
>  #include <malloc.h>
>  #include <stdio.h>
>  #include <string.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int errors = 0;
>  
> diff --git a/misc/tst-error1.c b/misc/tst-error1.c
> index a97a22ce9d..9c4a62fbd0 100644
> --- a/misc/tst-error1.c
> +++ b/misc/tst-error1.c
> @@ -3,7 +3,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <wchar.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int
>  do_test (int argc, char *argv[])
> diff --git a/nptl/tst-mutex1.c b/nptl/tst-mutex1.c
> index 8a4f2e6e4e..b2a4b5492a 100644
> --- a/nptl/tst-mutex1.c
> +++ b/nptl/tst-mutex1.c
> @@ -20,7 +20,7 @@
>  #include <stdio.h>
>  #include <errno.h>
>  #include <stdbool.h>
> -
> +#include <libc-diag.h>
>  
>  #ifndef ATTR
>  # define ATTR NULL
> @@ -45,11 +45,16 @@ do_test (void)
>        return 1;
>      }
>  
> +  /* This deliberately tests supplying a null pointer to a function whose
> +     argument is marked __attribute__ ((nonnull)). */
> +  DIAG_PUSH_NEEDS_COMMENT;
> +  DIAG_IGNORE_NEEDS_COMMENT (5, "-Wnonnull");
>    if (!ATTR_NULL && pthread_mutexattr_destroy (ATTR) != 0)
>      {
>        puts ("mutexattr_destroy failed");
>        return 1;
>      }
> +  DIAG_POP_NEEDS_COMMENT;
>  
>    if (pthread_mutex_lock (&m) != 0)
>      {
> diff --git a/posix/tst-dir.c b/posix/tst-dir.c
> index 1a9c7dfe97..fee79b32a0 100644
> --- a/posix/tst-dir.c
> +++ b/posix/tst-dir.c
> @@ -26,7 +26,7 @@
>  #include <string.h>
>  #include <unistd.h>
>  #include <sys/stat.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  /* We expect four arguments:
>     - source directory name
> diff --git a/stdio-common/bug21.c b/stdio-common/bug21.c
> index ca27272ba1..7a8c6a3542 100644
> --- a/stdio-common/bug21.c
> +++ b/stdio-common/bug21.c
> @@ -1,5 +1,5 @@
>  #include <stdio.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int
>  do_test (void)
> diff --git a/stdio-common/scanf14.c b/stdio-common/scanf14.c
> index cffccb0b19..2bcd9c9893 100644
> --- a/stdio-common/scanf14.c
> +++ b/stdio-common/scanf14.c
> @@ -2,7 +2,7 @@
>  #include <stdlib.h>
>  #include <string.h>
>  #include <wchar.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  #define FAIL() \
>    do {							\
> diff --git a/stdio-common/scanf4.c b/stdio-common/scanf4.c
> index 9bb14bb16b..7a2abec89b 100644
> --- a/stdio-common/scanf4.c
> +++ b/stdio-common/scanf4.c
> @@ -1,6 +1,6 @@
>  #include <stdio.h>
>  #include <stdlib.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  int
>  main(int arc, char *argv[])
> diff --git a/stdio-common/scanf7.c b/stdio-common/scanf7.c
> index 53ddf4cb09..f568738d7e 100644
> --- a/stdio-common/scanf7.c
> +++ b/stdio-common/scanf7.c
> @@ -1,6 +1,6 @@
>  #include <stdio.h>
>  #include <stdlib.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  int
>  main (int argc, char *argv[])
> diff --git a/stdio-common/test-vfprintf.c b/stdio-common/test-vfprintf.c
> index f1805d5d00..f8bb9cee58 100644
> --- a/stdio-common/test-vfprintf.c
> +++ b/stdio-common/test-vfprintf.c
> @@ -25,7 +25,7 @@
>  #include <string.h>
>  #include <unistd.h>
>  #include <sys/stat.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  
>  const char *locs[] =
> diff --git a/stdio-common/tst-printf.c b/stdio-common/tst-printf.c
> index 719b3eb08c..b6d62a5a2f 100644
> --- a/stdio-common/tst-printf.c
> +++ b/stdio-common/tst-printf.c
> @@ -26,7 +26,7 @@
>  #endif
>  
>  #include <float.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  /* This whole file is picayune tests of corner cases of printf format strings.
>     The compiler warnings are not useful here.  */
> diff --git a/stdio-common/tst-printfsz.c b/stdio-common/tst-printfsz.c
> index 8a3385f94d..47aa8536b3 100644
> --- a/stdio-common/tst-printfsz.c
> +++ b/stdio-common/tst-printfsz.c
> @@ -2,7 +2,7 @@
>  #include <printf.h>
>  #include <stdio.h>
>  #include <string.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  #define V       12345678.12345678
>  
> diff --git a/stdio-common/tst-sprintf.c b/stdio-common/tst-sprintf.c
> index d5284b9697..cbd35447a9 100644
> --- a/stdio-common/tst-sprintf.c
> +++ b/stdio-common/tst-sprintf.c
> @@ -2,7 +2,7 @@
>  #include <stdlib.h>
>  #include <locale.h>
>  #include <string.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  
>  static int
> diff --git a/stdio-common/tst-unlockedio.c b/stdio-common/tst-unlockedio.c
> index 6eec6fdbac..35652ce772 100644
> --- a/stdio-common/tst-unlockedio.c
> +++ b/stdio-common/tst-unlockedio.c
> @@ -20,7 +20,7 @@
>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <string.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  int fd;
>  static void do_prepare (void);
> diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c
> index 9c7342d55f..89009e0549 100644
> --- a/stdio-common/tstdiomisc.c
> +++ b/stdio-common/tstdiomisc.c
> @@ -3,7 +3,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <wchar.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int
>  t1 (void)
> diff --git a/stdlib/bug-getcontext.c b/stdlib/bug-getcontext.c
> index c4072129a6..163400acba 100644
> --- a/stdlib/bug-getcontext.c
> +++ b/stdlib/bug-getcontext.c
> @@ -5,7 +5,7 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <ucontext.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int
>  do_test (void)
> diff --git a/stdlib/tst-environ.c b/stdlib/tst-environ.c
> index 6a29fed62a..b2301641f5 100644
> --- a/stdlib/tst-environ.c
> +++ b/stdlib/tst-environ.c
> @@ -19,7 +19,7 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> -
> +#include <libc-diag.h>
>  
>  #define VAR "FOOBAR"
>  
> @@ -196,12 +196,17 @@ do_test (void)
>        result = 1;
>      }
>  
> +  /* This deliberately tests supplying a null pointer to a function whose
> +     argument is marked __attribute__ ((nonnull)). */
> +  DIAG_PUSH_NEEDS_COMMENT;
> +  DIAG_IGNORE_NEEDS_COMMENT(5, "-Wnonnull");
>    errno = 0;
>    if (unsetenv (NULL) >= 0 || errno != EINVAL)
>      {
>        puts ("unsetenv #1 failed");
>        result = 1;
>      }
> +  DIAG_POP_NEEDS_COMMENT;
>  
>    errno = 0;
>    if (unsetenv ("") >= 0 || errno != EINVAL)
> diff --git a/string/tester.c b/string/tester.c
> index ec350243eb..4b928b4f5e 100644
> --- a/string/tester.c
> +++ b/string/tester.c
> @@ -32,7 +32,7 @@
>  #include <string.h>
>  #include <strings.h>
>  #include <fcntl.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  
>  #define	STREQ(a, b)	(strcmp((a), (b)) == 0)
> diff --git a/string/tst-endian.c b/string/tst-endian.c
> index 7d39131a68..d3c7c2c4c5 100644
> --- a/string/tst-endian.c
> +++ b/string/tst-endian.c
> @@ -3,7 +3,7 @@
>  #include <inttypes.h>
>  #include <stdio.h>
>  #include <stdint.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  #if __GNUC_PREREQ (6, 0)
>  /* GCC 6.0 warns on big endian systems about:
> diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
> index 9273568b6f..8019e7f5d8 100644
> --- a/time/tst-strptime2.c
> +++ b/time/tst-strptime2.c
> @@ -4,7 +4,7 @@
>  #include <stdbool.h>
>  #include <stdio.h>
>  #include <time.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  /* Dummy string is used to match strptime's %s specifier.  */
>  
> diff --git a/wcsmbs/tst-wcstof.c b/wcsmbs/tst-wcstof.c
> index 861f65905a..d3d75f8f60 100644
> --- a/wcsmbs/tst-wcstof.c
> +++ b/wcsmbs/tst-wcstof.c
> @@ -3,7 +3,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <wctype.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  static int
>  do_test (void)
> 


-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite.
  2017-02-20 13:03   ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Zack Weinberg
  2017-02-20 13:03     ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Zack Weinberg
@ 2017-02-20 13:58     ` Carlos O'Donell
  2017-02-25 15:28       ` Zack Weinberg
  1 sibling, 1 reply; 30+ messages in thread
From: Carlos O'Donell @ 2017-02-20 13:58 UTC (permalink / raw)
  To: Zack Weinberg, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/20/2017 08:03 AM, Zack Weinberg wrote:
> A few 'long double'-related tests include math_private.h just for
> their variety of math_ldbl.h, which contains macros for assembling and
> disassembling the binary representation of 'long double'.  math_ldbl.h
> insists on being included from math_private.h, but if we relax this
> restriction (and fix some portability sloppiness) we can use it
> directly and not have to expose all of math_private.h to the
> testsuite.
> 
> The only bit of this that I'm not 100% happy with is,
> ldbl-128ibm/math_ldbl.h was using EXTRACT_WORDS64 from math_private.h.
> I replicated the logic of EXTRACT_WORDS64 into the function that
> needed it, which is the expeditious local fix.  It seems abstractly
> better to add similar functionality to all varieties of ieee754.h, but
> that would change a public API so I wasn't comfortable doing it in
> this patch series.

Looks good to me with the expansion of the comment for 
the ldbl-128ibm/math_ldbl.h changes.

> zw
> 
> 	* sysdeps/generic/math_private.h: Use __BIG_ENDIAN and
> 	__LITTLE_ENDIAN, not BIG_ENDIAN and LITTLE_ENDIAN.
> 
> 	* sysdeps/generic/math_ldbl.h
> 	* sysdeps/ia64/fpu/math_ldbl.h
> 	* sysdeps/ieee754/ldbl-128/math_ldbl.h
> 	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
> 	* sysdeps/ieee754/ldbl-96/math_ldbl.h
> 	* sysdeps/powerpc/fpu/math_ldbl.h
> 	* sysdeps/x86_64/fpu/math_ldbl.h:
> 	Allow direct inclusion.  Use uintNN_t instead of u_intNN_t.
> 	Use __BIG_ENDIAN and __LITTLE_ENDIAN, not BIG_ENDIAN and
> 	LITTLE_ENDIAN.  Include endian.h and/or stdint.h if necessary.
> 
> 	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h: Don't use EXTRACT_WORDS64.
> 
> 	* sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
> 	* sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
> 	* sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
> 	* sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c:
> 	Include math_ldbl.h, not math_private.h.
> ---
>  sysdeps/generic/math_ldbl.h                        | 10 +++++----
>  sysdeps/generic/math_private.h                     |  4 ++--
>  sysdeps/ia64/fpu/math_ldbl.h                       | 22 ++++++++++--------
>  sysdeps/ieee754/ldbl-128/math_ldbl.h               | 26 +++++++++++++---------
>  sysdeps/ieee754/ldbl-128ibm/math_ldbl.h            | 18 ++++++++++-----
>  .../ldbl-128ibm/test-canonical-ldbl-128ibm.c       |  2 +-
>  .../ldbl-128ibm/test-totalorderl-ldbl-128ibm.c     |  2 +-
>  sysdeps/ieee754/ldbl-96/math_ldbl.h                | 22 ++++++++++--------
>  sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c   |  2 +-
>  sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c |  2 +-
>  sysdeps/powerpc/fpu/math_ldbl.h                    |  7 +++---
>  sysdeps/x86_64/fpu/math_ldbl.h                     | 13 ++++++-----
>  12 files changed, 77 insertions(+), 53 deletions(-)
> 
> diff --git a/sysdeps/generic/math_ldbl.h b/sysdeps/generic/math_ldbl.h
> index f0b97ef8f9..4e7ee7912e 100644
> --- a/sysdeps/generic/math_ldbl.h
> +++ b/sysdeps/generic/math_ldbl.h
> @@ -1,5 +1,7 @@
> -#ifndef _MATH_PRIVATE_H_
> -#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
> -#endif
> +#ifndef _MATH_LDBL_H_
> +#define _MATH_LDBL_H_ 1
>  
> -/* This is empty.  Any machine using long double type will override this header.  */
> +/* Any machine with a 'long double' distinct from 'double' must
> +   override this header.  */
> +
> +#endif
> diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h
> index c0d4e3dbcd..be65b9487b 100644
> --- a/sysdeps/generic/math_private.h
> +++ b/sysdeps/generic/math_private.h
> @@ -37,7 +37,7 @@
>  /* A union which permits us to convert between a double and two 32 bit
>     ints.  */
>  
> -#if __FLOAT_WORD_ORDER == BIG_ENDIAN
> +#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
>  
>  typedef union
>  {
> @@ -52,7 +52,7 @@ typedef union
>  
>  #endif
>  
> -#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
> +#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
>  
>  typedef union
>  {
> diff --git a/sysdeps/ia64/fpu/math_ldbl.h b/sysdeps/ia64/fpu/math_ldbl.h
> index 475ca795fa..748e9aff5a 100644
> --- a/sysdeps/ia64/fpu/math_ldbl.h
> +++ b/sysdeps/ia64/fpu/math_ldbl.h
> @@ -1,11 +1,13 @@
> -#ifndef _MATH_PRIVATE_H_
> -#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
> -#endif
> +#ifndef _MATH_LDBL_H_
> +#define _MATH_LDBL_H_ 1
> +
> +#include <stdint.h>
> +#include <endian.h>
>  
>  /* A union which permits us to convert between a long double and
>     three 32 bit ints.  */
>  
> -#if __FLOAT_WORD_ORDER == BIG_ENDIAN
> +#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
>  
>  typedef union
>  {
> @@ -15,22 +17,22 @@ typedef union
>      unsigned int empty0:32;
>      int sign_exponent:16;
>      unsigned int empty1:16;
> -    u_int32_t msw;
> -    u_int32_t lsw;
> +    uint32_t msw;
> +    uint32_t lsw;
>    } parts;
>  } ieee_long_double_shape_type;
>  
>  #endif
>  
> -#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
> +#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
>  
>  typedef union
>  {
>    long double value;
>    struct
>    {
> -    u_int32_t lsw;
> -    u_int32_t msw;
> +    uint32_t lsw;
> +    uint32_t msw;
>      int sign_exponent:16;
>      unsigned int empty1:16;
>      unsigned int empty0:32;
> @@ -98,3 +100,5 @@ do {								\
>    se_u.parts.sign_exponent = (exp);				\
>    (d) = se_u.value;						\
>  } while (0)
> +
> +#endif /* math_ldbl.h */
> diff --git a/sysdeps/ieee754/ldbl-128/math_ldbl.h b/sysdeps/ieee754/ldbl-128/math_ldbl.h
> index c1980c9401..6ea2c385df 100644
> --- a/sysdeps/ieee754/ldbl-128/math_ldbl.h
> +++ b/sysdeps/ieee754/ldbl-128/math_ldbl.h
> @@ -1,41 +1,43 @@
> -#ifndef _MATH_PRIVATE_H_
> -#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
> -#endif
> +#ifndef _MATH_LDBL_H_
> +#define _MATH_LDBL_H_ 1
> +
> +#include <stdint.h>
> +#include <endian.h>
>  
>  /* A union which permits us to convert between a long double and
>     four 32 bit ints or two 64 bit ints.  */
>  
> -#if __FLOAT_WORD_ORDER == BIG_ENDIAN
> +#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
>  
>  typedef union
>  {
>    long double value;
>    struct
>    {
> -    u_int64_t msw;
> -    u_int64_t lsw;
> +    uint64_t msw;
> +    uint64_t lsw;
>    } parts64;
>    struct
>    {
> -    u_int32_t w0, w1, w2, w3;
> +    uint32_t w0, w1, w2, w3;
>    } parts32;
>  } ieee854_long_double_shape_type;
>  
>  #endif
>  
> -#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
> +#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
>  
>  typedef union
>  {
>    long double value;
>    struct
>    {
> -    u_int64_t lsw;
> -    u_int64_t msw;
> +    uint64_t lsw;
> +    uint64_t msw;
>    } parts64;
>    struct
>    {
> -    u_int32_t w3, w2, w1, w0;
> +    uint32_t w3, w2, w1, w0;
>    } parts32;
>  } ieee854_long_double_shape_type;
>  
> @@ -96,3 +98,5 @@ do {								\
>  */
>  #define _Float128 long double
>  #define L(x) x##L
> +
> +#endif /* math_ldbl.h */
> diff --git a/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
> index 625ce00e13..5420fb27af 100644
> --- a/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
> +++ b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
> @@ -1,6 +1,5 @@
> -#ifndef _MATH_PRIVATE_H_
> -#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
> -#endif
> +#ifndef _MATH_LDBL_H_
> +#define _MATH_LDBL_H_ 1
>  
>  #include <ieee754.h>
>  #include <stdint.h>
> @@ -239,9 +238,14 @@ ldbl_nearbyint (double a)
>  static inline void
>  ldbl_canonicalize_int (double *a, double *aa)
>  {
> -  int64_t ax, aax;
> -  EXTRACT_WORDS64 (ax, *a);
> -  EXTRACT_WORDS64 (aax, *aa);
> +  /* We can't use math_private.h macros in this file.  */

Suggest:

/* Previously we used EXTRACT_WORDS64 from math_private.h, but in order
   to avoid including internal headers we duplicate that code here.  */

> +  uint64_t ax, aax;
> +  union { double value; uint64_t word; } extractor;
> +  extractor.value = *a;
> +  ax = extractor.word;
> +  extractor.value = *aa;
> +  aax = extractor.word;
> +
>    int expdiff = ((ax >> 52) & 0x7ff) - ((aax >> 52) & 0x7ff);
>    if (expdiff <= 53)
>      {
> @@ -263,3 +267,5 @@ ldbl_canonicalize_int (double *a, double *aa)
>  	}
>      }
>  }
> +
> +#endif /* math_ldbl.h */
> diff --git a/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c b/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
> index 8be4499bd5..75735db18e 100644
> --- a/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
> +++ b/sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
> @@ -18,7 +18,7 @@
>  
>  #include <float.h>
>  #include <math.h>
> -#include <math_private.h>
> +#include <math_ldbl.h>
>  #include <stdbool.h>
>  #include <stdio.h>
>  
> diff --git a/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c b/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
> index 86869aceda..eaada2f848 100644
> --- a/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
> +++ b/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
> @@ -17,7 +17,7 @@
>     <http://www.gnu.org/licenses/>.  */
>  
>  #include <math.h>
> -#include <math_private.h>
> +#include <math_ldbl.h>
>  #include <stdbool.h>
>  #include <stdio.h>
>  
> diff --git a/sysdeps/ieee754/ldbl-96/math_ldbl.h b/sysdeps/ieee754/ldbl-96/math_ldbl.h
> index cca30657ce..74fbad6374 100644
> --- a/sysdeps/ieee754/ldbl-96/math_ldbl.h
> +++ b/sysdeps/ieee754/ldbl-96/math_ldbl.h
> @@ -1,11 +1,13 @@
> -#ifndef _MATH_PRIVATE_H_
> -#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
> -#endif
> +#ifndef _MATH_LDBL_H_
> +#define _MATH_LDBL_H_ 1
> +
> +#include <stdint.h>
> +#include <endian.h>
>  
>  /* A union which permits us to convert between a long double and
>     three 32 bit ints.  */
>  
> -#if __FLOAT_WORD_ORDER == BIG_ENDIAN
> +#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
>  
>  typedef union
>  {
> @@ -14,22 +16,22 @@ typedef union
>    {
>      int sign_exponent:16;
>      unsigned int empty:16;
> -    u_int32_t msw;
> -    u_int32_t lsw;
> +    uint32_t msw;
> +    uint32_t lsw;
>    } parts;
>  } ieee_long_double_shape_type;
>  
>  #endif
>  
> -#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
> +#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
>  
>  typedef union
>  {
>    long double value;
>    struct
>    {
> -    u_int32_t lsw;
> -    u_int32_t msw;
> +    uint32_t lsw;
> +    uint32_t msw;
>      int sign_exponent:16;
>      unsigned int empty:16;
>    } parts;
> @@ -96,3 +98,5 @@ do {								\
>    se_u.parts.sign_exponent = (exp);				\
>    (d) = se_u.value;						\
>  } while (0)
> +
> +#endif /* math_ldbl.h */
> diff --git a/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c b/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
> index db9db04367..3254097754 100644
> --- a/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
> +++ b/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
> @@ -18,7 +18,7 @@
>  
>  #include <float.h>
>  #include <math.h>
> -#include <math_private.h>
> +#include <math_ldbl.h>
>  #include <stdbool.h>
>  #include <stdint.h>
>  #include <stdio.h>
> diff --git a/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c b/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
> index eb21956e4f..4e01f15aa9 100644
> --- a/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
> +++ b/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
> @@ -18,7 +18,7 @@
>  
>  #include <float.h>
>  #include <math.h>
> -#include <math_private.h>
> +#include <math_ldbl.h>
>  #include <stdbool.h>
>  #include <stdint.h>
>  #include <stdio.h>
> diff --git a/sysdeps/powerpc/fpu/math_ldbl.h b/sysdeps/powerpc/fpu/math_ldbl.h
> index 36378c0239..597d216a07 100644
> --- a/sysdeps/powerpc/fpu/math_ldbl.h
> +++ b/sysdeps/powerpc/fpu/math_ldbl.h
> @@ -1,6 +1,5 @@
> -#ifndef _MATH_PRIVATE_H_
> -#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
> -#endif
> +#ifndef _MATH_LDBL_H_PPC_
> +#define _MATH_LDBL_H_PPC_ 1
>  
>  /* GCC does not optimize the default ldbl_pack code to not spill register
>     in the stack. The following optimization tells gcc that pack/unpack
> @@ -34,3 +33,5 @@ ldbl_unpack_ppc (long double l, double *a, double *aa)
>  #define ldbl_unpack ldbl_unpack_ppc
>  
>  #include <sysdeps/ieee754/ldbl-128ibm/math_ldbl.h>
> +
> +#endif /* math_ldbl.h */
> diff --git a/sysdeps/x86_64/fpu/math_ldbl.h b/sysdeps/x86_64/fpu/math_ldbl.h
> index b9ff8dadaf..cbc47c2935 100644
> --- a/sysdeps/x86_64/fpu/math_ldbl.h
> +++ b/sysdeps/x86_64/fpu/math_ldbl.h
> @@ -1,6 +1,7 @@
> -#ifndef _MATH_PRIVATE_H_
> -#error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
> -#endif
> +#ifndef _MATH_LDBL_H_
> +#define _MATH_LDBL_H_ 1
> +
> +#include <stdint.h>
>  
>  /* A union which permits us to convert between a long double and
>     three 32 bit ints.  */
> @@ -10,8 +11,8 @@ typedef union
>    long double value;
>    struct
>    {
> -    u_int32_t lsw;
> -    u_int32_t msw;
> +    uint32_t lsw;
> +    uint32_t msw;
>      int sign_exponent:16;
>      unsigned int empty1:16;
>      unsigned int empty0:32;
> @@ -77,3 +78,5 @@ do {								\
>    se_u.parts.sign_exponent = (exp);				\
>    (d) = se_u.value;						\
>  } while (0)
> +
> +#endif /* math_ldbl.h */
> 


-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 13:03     ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Zack Weinberg
  2017-02-20 13:04       ` [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes Zack Weinberg
@ 2017-02-20 14:11       ` Carlos O'Donell
  2017-02-20 16:26         ` Joseph Myers
  2017-02-25 16:34         ` Zack Weinberg
  2017-02-20 14:52       ` Joseph Myers
  2017-02-20 16:15       ` Joseph Myers
  3 siblings, 2 replies; 30+ messages in thread
From: Carlos O'Donell @ 2017-02-20 14:11 UTC (permalink / raw)
  To: Zack Weinberg, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/20/2017 08:03 AM, Zack Weinberg wrote:
> These are a grab bag of changes where the testsuite was using internal
> symbols of some variety, but this was straightforward to fix, and the
> fixed code should work with or without the change to compile the
> testsuite under _ISOMAC.  They are, however, not *quite* obvious and I
> would appreciate a second pair of eyes.

OK to checkin if you make copies of PTR_ALIGN_DOWN and ALIGN_DOWN for
support/ and convert the one test that uses them. That way all future
tests can use this code without needing to duplicate it. Also that way
glibc developers can use these functions like they would in ineternal
code.

> math/test-misc.c was using #ifndef NO_LONG_DOUBLE, which is an internal
> configuration macro, to decide whether to do certain tests involving
> 'long double'.  I changed the test to #if LDBL_MANT_DIG > DBL_MANT_DIG
> instead, which uses only public float.h macros and is equivalent on
> all supported platforms.  (Note that NO_LONG_DOUBLE doesn't mean 'the
> compiler doesn't support long double', it means 'long double is the
> same as double'.)  It's possible that instead we should just do these
> tests unconditionally on all platforms.

Doing all the tests on all platforms is what we should have done from the
start to verify everything works as expected. However, your changes are
the right minimal fix for math/test-misc.c.

> atomic.h cannot be used by code compiled under _ISOMAC, but
> stdatomic.h can.  There are quite a few tests that use atomic.h; most
> of them were not straightforward to change to stdatomic.h, but
> nptl/tst-join7.c was, so I did that.

These are going to be old tests, because where possible all the tests
should be using C11 atomics per our new policy of moving everything towards
C11 atomics. Therefore because they are old tests there aren't going to be
any more of them added like that so converting them is valuable and makes
the most sense.

> posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; I
> duplicated the definition into the .c file, which is not ideal, but
> since this didn't come up anywhere else, inventing a new header for it
> seems like excessive polish.

Please add PTR_ALIGN_DOWN to the support/ subsystem for testing and port
the test to support/.

We will conceivably need similar macros for other tests and as a glibc
developer I like to have access to the same helper macros I use in glib.

> string/strcasestr.c had an explicit #include <config.h> - this appears
> originally to have been externally maintained code.  Removed.

OK.

> sysdeps/powerpc/fpu/tst-setcontext-fpscr.c appears to have been
> written before the advent of sys/auxv.h; it was using sysdep.h
> instead, which is obviously a no-go in _ISOMAC mode.  I made the
> minimal change; I think a big chunk of this file could be replaced by
> a simple call to getauxval but I'll let someone who actually has a
> powerpc machine to test on do that.

OK.

> tst-writev.c has a configuration macro 'ARTIFICIAL_LIMIT' that the
> Makefiles are expected to define, and sysdeps/unix/sysv/linux/Makefile
> was using the internal __getpagesize in the definition; changed to
> sysconf(_SC_PAGESIZE) which is the POSIX equivalent.

OK.

> ia64-linux doesn't supply 'clone', only '__clone2', which is not
> defined in the public headers(!)  All the other clone tests have local
> extern declarations of __clone2, but tst-clone.c doesn't; it was
> getting away with this because include/sched.h does declare __clone2.
> 
> Finally, tst-setgetname.c was using kernel-features.h (also a no-go in
> _ISOMAC mode) just for one __ASSUME macro which it doesn't really need.

OK.

> zw
> 
> 	* math/test-misc.c: Instead of testing NO_LONG_DOUBLE, test
> 	whether LDBL_MANT_DIG is greater than DBL_MANT_DIG.
> 	* nptl/tst-join7.c: Include stdlib.h. Include stdatomic.h instead of
> 	atomic.h.  Use C11 atomics instead of libc-internal atomics.
> 	* posix/wordexp-test.c: Include stdint.h. Don't include
> 	libc-internal.h. Define PTR_ALIGN_DOWN here.
> 	* string/strcasestr.c: No need to include config.h.
> 	* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c: Include
> 	sys/auxv.h. Don't include sysdep.h.
>         * sysdeps/unix/sysv/linux/tst-clone.c [__ia64__]: Add extern
>         declaration of __clone2.
> 	* sysdeps/unix/sysv/linux/Makefile (CFLAGS-tst-writev.c):
> 	Use sysconf (_SC_PAGESIZE) instead of __getpagesize in definition of
> 	ARTIFICIAL_LIMIT.
> 	* sysdeps/unix/sysv/linux/tst-setgetname.c:
> 	Don't include kernel-features.h. Don't #ifndef out anything
> 	based on __ASSUME macros.
> ---
>  math/test-misc.c                           | 23 +++++++++++------------
>  nptl/tst-join7mod.c                        |  9 +++++----
>  posix/wordexp-test.c                       |  6 +++++-
>  string/strcasestr.c                        |  4 ----
>  sysdeps/powerpc/fpu/tst-setcontext-fpscr.c |  2 +-
>  sysdeps/unix/sysv/linux/Makefile           |  2 +-
>  sysdeps/unix/sysv/linux/tst-clone.c        |  5 +++++
>  sysdeps/unix/sysv/linux/tst-setgetname.c   |  3 ---
>  8 files changed, 28 insertions(+), 26 deletions(-)
> 
> diff --git a/math/test-misc.c b/math/test-misc.c
> index 8968b80662..09812a3ccf 100644
> --- a/math/test-misc.c
> +++ b/math/test-misc.c
> @@ -30,7 +30,7 @@ do_test (void)
>  {
>    int result = 0;
>  
> -#ifndef NO_LONG_DOUBLE
> +#if LDBL_MANT_DIG > DBL_MANT_DIG

OK.

>    {
>      long double x = 0x100000001ll + (long double) 0.5;
>      long double q;
> @@ -60,7 +60,7 @@ do_test (void)
>  # elif LDBL_MANT_DIG == 113
>      m = 0x1.ffffffffffffffffffffffffffffp-1L;
>  # else
> -#  error "Please adjust"
> +#  error "Unsupported LDBL_MANT_DIG, please adjust"

OK.

>  # endif
>  
>      for (i = LDBL_MAX_EXP, x = LDBL_MAX; i >= LDBL_MIN_EXP; --i, x /= 2.0L)
> @@ -720,7 +720,7 @@ do_test (void)
>        }
>    }
>  
> -#ifndef NO_LONG_DOUBLE
> +#if LDBL_MANT_DIG > DBL_MANT_DIG

OK.

>    {
>      long double v1, v2;
>  
> @@ -910,7 +910,7 @@ do_test (void)
>        puts ("isnormal (DBL_MIN) failed");
>        result = 1;
>      }
> -#ifndef NO_LONG_DOUBLE
> +#if LDBL_MANT_DIG > DBL_MANT_DIG

OK.

>    if (! isnormal (LDBL_MIN))
>      {
>        puts ("isnormal (LDBL_MIN) failed");
> @@ -960,7 +960,7 @@ do_test (void)
>    }
>  #endif
>  
> -#ifndef NO_LONG_DOUBLE
> +#if LDBL_MANT_DIG > DBL_MANT_DIG

OK.

>    {
>      long double r;
>  
> @@ -1027,7 +1027,7 @@ do_test (void)
>        puts ("nextafter -DBL_MIN test failed");
>        result = 1;
>      }
> -#ifndef NO_LONG_DOUBLE
> +#if LDBL_MANT_DIG > DBL_MANT_DIG

OK.

>    if (nextafterl (nextafterl (LDBL_MIN, LDBL_MIN / 2.0), LDBL_MIN)
>        != LDBL_MIN)
>      {
> @@ -1072,7 +1072,7 @@ do_test (void)
>      }
>  #endif
>  
> -#ifndef NO_LONG_DOUBLE
> +#if LDBL_MANT_DIG > DBL_MANT_DIG

OK.

>    volatile long double ld1 = LDBL_MAX;
>    volatile long double ld2 = LDBL_MAX / 2;
>    (void) &ld1;
> @@ -1087,9 +1087,8 @@ do_test (void)
>        result = 1;
>      }
>  # endif
> -#endif
>  
> -#if !defined NO_LONG_DOUBLE && LDBL_MANT_DIG == 113
> +# if LDBL_MANT_DIG == 113

OK.

The check above for 'LDBL_MANT_DIG > DBL_MANT_DIG' covers 
the old NO_LONG_DOUBLE check.

>    volatile long double ld3 = 0x1.0000000000010000000100000001p+1;
>    volatile long double ld4 = 0x1.0000000000000000000000000001p+1;
>    (void) &ld3;
> @@ -1100,14 +1099,13 @@ do_test (void)
>        printf ("long double subtraction test failed %.28La\n", ld3);
>        result = 1;
>      }
> -#endif
> +# endif

OK.

>  
>  /* Skip testing IBM long double format, for 2 reasons:
>     1) it only supports FE_TONEAREST
>     2) nextafter (0.0, 1.0) == nextafterl (0.0L, 1.0L), so
>        nextafter (0.0, 1.0) / 16.0L will be 0.0L.  */
> -#if !defined NO_LONG_DOUBLE && LDBL_MANT_DIG >= DBL_MANT_DIG + 4 \
> -    && LDBL_MANT_DIG != 106
> +# if LDBL_MANT_DIG >= DBL_MANT_DIG + 4 && LDBL_MANT_DIG != 106

OK.

Likewise.

>    int oldmode = fegetround ();
>    int j;
>    for (j = 0; j < 4; j++)
> @@ -1197,6 +1195,7 @@ do_test (void)
>        else
>  	puts ("ignoring this failure");
>      }
> +# endif

OK.

>  #endif
>  
>    return result;
> diff --git a/nptl/tst-join7mod.c b/nptl/tst-join7mod.c
> index 1d9c95d418..5a43404571 100644
> --- a/nptl/tst-join7mod.c
> +++ b/nptl/tst-join7mod.c
> @@ -18,17 +18,18 @@
>     <http://www.gnu.org/licenses/>.  */
>  
>  #include <stdio.h>
> +#include <stdlib.h>
>  #include <string.h>
>  #include <pthread.h>
> -#include <atomic.h>
> +#include <stdatomic.h>
>  
>  static pthread_t th;
> -static int running = 1;
> +static atomic_int running = 1;
>  
>  static void *
>  test_run (void *p)
>  {
> -  while (atomic_load_relaxed (&running))
> +  while (atomic_load_explicit (&running, memory_order_relaxed))

OK.

>      printf ("Test running\n");
>    printf ("Test finished\n");
>    return NULL;
> @@ -49,7 +50,7 @@ do_init (void)
>  static void __attribute__ ((destructor))
>  do_end (void)
>  {
> -  atomic_store_relaxed (&running, 0);
> +  atomic_store_explicit (&running, 0, memory_order_relaxed);

OK.

>    int ret = pthread_join (th, NULL);
>  
>    if (ret != 0)
> diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
> index 15eb233001..af174cf7d0 100644
> --- a/posix/wordexp-test.c
> +++ b/posix/wordexp-test.c
> @@ -22,10 +22,14 @@
>  #include <unistd.h>
>  #include <pwd.h>
>  #include <stdio.h>
> +#include <stdint.h>
>  #include <stdlib.h>
>  #include <string.h>
>  #include <wordexp.h>
> -#include <libc-internal.h>
> +
> +#define ALIGN_DOWN(base, size)	((base) & -((__typeof__ (base)) (size)))
> +#define PTR_ALIGN_DOWN(base, size) \
> +  ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size)))

These should go into support/ and the test should be converted to use that.

>  
>  #define IFS " \n\t"
>  
> diff --git a/string/strcasestr.c b/string/strcasestr.c
> index a9ff18c7f5..2acf003155 100644
> --- a/string/strcasestr.c
> +++ b/string/strcasestr.c
> @@ -25,10 +25,6 @@
>   *
>   * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de	*/
>  
> -#if HAVE_CONFIG_H
> -# include <config.h>
> -#endif
> -

OK.

>  /* Specification.  */
>  #include <string.h>
>  
> diff --git a/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c b/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c
> index 3a8d699b9a..4e3f90d4d3 100644
> --- a/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c
> +++ b/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c
> @@ -26,8 +26,8 @@
>  #include <malloc.h>
>  #include <link.h>
>  #include <elf.h>
> -#include <sysdep.h>
>  #include <fpu_control.h>
> +#include <sys/auxv.h>
>  
>  static ucontext_t ctx[3];
>  
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index b3d68665f9..fc29c54c86 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -20,7 +20,7 @@ sysdep_routines += clone umount umount2 readahead \
>  		   personality
>  
>  CFLAGS-gethostid.c = -fexceptions
> -CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=0x80000000-__getpagesize()"
> +CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"

OK.

>  
>  # Note that bits/mman-linux.h is listed here though the file lives in the
>  # top-level bits/ subdirectory instead of here in sysdeps/.../linux/bits/.
> diff --git a/sysdeps/unix/sysv/linux/tst-clone.c b/sysdeps/unix/sysv/linux/tst-clone.c
> index c4e6fbe48b..1da749db8d 100644
> --- a/sysdeps/unix/sysv/linux/tst-clone.c
> +++ b/sysdeps/unix/sysv/linux/tst-clone.c
> @@ -23,6 +23,11 @@
>  #include <unistd.h>
>  #include <sched.h>
>  
> +#ifdef __ia64__
> +extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
> +		     size_t __child_stack_size, int __flags, void *__arg, ...);
> +#endif

OK.

> +
>  int child_fn(void *arg)
>  {
>    puts ("FAIL: in child_fn(); should not be here");
> diff --git a/sysdeps/unix/sysv/linux/tst-setgetname.c b/sysdeps/unix/sysv/linux/tst-setgetname.c
> index 5acd614117..b1010f0446 100644
> --- a/sysdeps/unix/sysv/linux/tst-setgetname.c
> +++ b/sysdeps/unix/sysv/linux/tst-setgetname.c
> @@ -23,7 +23,6 @@
>  #include <unistd.h>
>  #include <fcntl.h>
>  #include <errno.h>
> -#include <kernel-features.h>
>  
>  /* New name of process.  */
>  #define NEW_NAME "setname"
> @@ -101,7 +100,6 @@ do_test (int argc, char **argv)
>      {
>        res = get_self_comm (gettid (), name_check, TASK_COMM_LEN);
>  
> -#ifndef __ASSUME_PROC_PID_TASK_COMM
>        /* On this first test we look for ENOENT to be returned from
>           get_self_comm to indicate that the kernel is older than
>           2.6.33 and doesn't contain comm within the proc structure.
> @@ -111,7 +109,6 @@ do_test (int argc, char **argv)
>  	  printf ("SKIP: The kernel does not have /proc/self/task/%%lu/comm.\n");
>  	  return 0;
>  	}
> -#endif

OK. We should just run this test, no need to cut it out.

>  
>        if (res == 0)
>         {
> 


-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 13:03     ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Zack Weinberg
  2017-02-20 13:04       ` [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes Zack Weinberg
  2017-02-20 14:11       ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Carlos O'Donell
@ 2017-02-20 14:52       ` Joseph Myers
  2017-02-20 15:34         ` Zack Weinberg
  2017-02-25 16:14         ` Zack Weinberg
  2017-02-20 16:15       ` Joseph Myers
  3 siblings, 2 replies; 30+ messages in thread
From: Joseph Myers @ 2017-02-20 14:52 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: libc-alpha, carlos, adhemerval.zanella

On Mon, 20 Feb 2017, Zack Weinberg wrote:

> atomic.h cannot be used by code compiled under _ISOMAC, but
> stdatomic.h can.  There are quite a few tests that use atomic.h; most
> of them were not straightforward to change to stdatomic.h, but
> nptl/tst-join7.c was, so I did that.

stdatomic.h is not available before GCC 4.9, and our minimum version for 
building glibc is 4.7 (although you can't use build-many-glibcs.py with 
versions before 4.9 because of missing features for bootstrapping cross 
compilers with glibc, in particular --with-glibc-version).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes.
  2017-02-20 13:04       ` [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes Zack Weinberg
@ 2017-02-20 15:13         ` Carlos O'Donell
  2017-02-20 15:32           ` Zack Weinberg
  2017-02-27 13:34           ` Zack Weinberg
  0 siblings, 2 replies; 30+ messages in thread
From: Carlos O'Donell @ 2017-02-20 15:13 UTC (permalink / raw)
  To: Zack Weinberg, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/20/2017 08:03 AM, Zack Weinberg wrote:
> This is the main change, adding a new build module called 'testsuite'.
> IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
> (which means several ad-hoc tests for __cplusplus can go away).
> libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
> defined; in particular, _ISOMAC mode does not get config.h
> automatically anymore.  And there's a third mode for when
> libc-symbols.h is included without MODULE_NAME being defined at all
> (this happens when preprocessing Versions files, for instance)---IS_IN
> always evaluates to false but _ISOMAC is *not* defined.  This is the
> way it has always worked, but now it's explicit.
> 
> There are still quite a few tests that need to see internal gunk of
> one variety or another.  There are three new Makefile variables to
> allow that.  'tests-internal' is the most straightforward: move a file
> from 'tests' to 'tests-internal' if it needs to be compiled as it
> always has (MODULE_NAME=nonlib).  'test-internal-extras' is the same
> thing, but for files formerly in 'test-extras'.  Finally,
> 'modules-names-tests' is for files in 'modules-names' that *should* be
> compiled with MODULE_NAME=testsuite (most of the things in
> 'modules-names' are *not* tests).  Unlike the other two, you need to
> list a test module in *both* modules-names and modules-names-tests.
> 
> The remaining changes to C source files in this patch seemed likely to
> cause problems in the absence of the main change:
> 
>  * tst-env-setuid-tunables.c needs to see HAVE_TUNABLES but no other
>    internal goo, so rather than put it in tests-internal I made it
>    include config.h itself
>  * similarly, tst-gettext2.c can define N_() itself instead of
>    expecting libc-symbols.h to do it
>  * some tests were defining _ISOMAC themselves; this is no longer
>    necessary (note that definitions of _ISOMAC by test scripts like
>    conform-test.pl are usually still necessary, since they don't use
>    libc-modules.h/libc-symbols.h at all)
>  * tst-strtod.c and tst-strtod5.c were testing both strtod and
>    __strtod_internal, so they got chopped in half
>  * ia64/fpu/libm-symbols.h is suppressed in _ISOMAC mode
>    (see discussion from last year about this file)
>  * string/test-strstr.c includes strstr.c, which uses
>    libc_hidden_builtin_def; it can be dummied out in this context
>  * several files that include string/test-string.h require
>    inhibit_loop_to_libcall but no other definitions from
>    libc-symbols.h/config.h; I chose to duplicate the definition of
>    inhibit_loop_to_libcall rather than make them internal tests
> 
>  * x86_64/fpu/math-tests-arch.h and x86_64/multiarch/test-multiarch.h
>    change from including init-arch.h to including cpu-features.h.
>    This is the change that I committed last week that had to be backed
>    out.  What's going on is, they actually *use* stuff from
>    x86/cpu-features.h, which is a non-installed non-wrapper header
>    whose contents vary depending on _LIBC and IS_IN.  It depends on
>    init-arch.h when it's used the way the test suite is currently
>    being compiled, hence the bustage, but with this patch init-arch.h
>    becomes unnecessary, and init-arch.h itself depends on the full
>    libc-symbols.h.  So the change comes back and is safe now.
> 
> N.B. extra-modules.mk was almost identical to cppflags-iterator.mk; the
> only differences were that it used a different input variable and it
> didn't let the caller control the module.  So I have removed it and
> changed the sole use to use cppflags-iterator.mk instead.

This change is looking good, it is a step in the right direction, and the
addition of '*-internal' markup is useful.

I still think we need a few improvements.

I'd like two senior developers to review this.

Here goes one review.

High level:

- This is a step in the right direction. My instinct is to want to move
  all the internal dependencies into functions in support/, but that's
  quite a bit of work. Either way they would have to be identified before
  being moved and your work does just that. Eventually I would hope that
  all the tests go back to being compiled with tests, we remove tests-internal,
  and only support/ functions can view the glibc internals through a well
  defined API.

Low level:

- Fix tst-dladdr by removing DL_LOOKUP_ADDRESS usage and keeping it in
  tests instead of tests-internal. I think this test should be as close
  to a real application as possible.

- Please carry out a built artifact comparison to ensure the IS_IN
  changes did not change any code generation in the library. Minimally
  x86_64 and one other architecture of your choice.

- The include/stdio.h change needs a detailed comment about why we undef 
  _IO_MTSAFE_IO.

- Why is tst-cancel-getpwuid_r in tests-internal? It was designed to be
  a standalone cancellation test.

- New test stdlib/tst-strtod1i.c should use new support/ test infrastructure.

- New test stdlib/tst-strtod5i.c needs a copyright header and should use
  new support/ test infrastructure.

> zw
> 
> 	* Makerules: New subdir configuration variables 'tests-internal'
> 	and 'test-internal-extras'.  Test files in these categories will
> 	still be compiled with MODULE_NAME=nonlib.  Test files in the
> 	existing categories (tests, xtests, test-srcs, test-extras) are
> 	now compiled with MODULE_NAME=testsuite.
> 	New subdir configuration variable 'modules-names-tests'.  Files
> 	which are in both 'modules-names' and 'modules-names-tests' will
> 	be compiled with MODULE_NAME=testsuite instead of
> 	MODULE_NAME=extramodules.
> 	Use cppflags-iterator.mk instead of extra-modules.mk for the
> 	files in $(modules-names).
> 	(gen-as-const-headers): Move to tests-internal.
> 	(do-tests-clean, common-mostlyclean): Support tests-internal.
> 	* Makeconfig (built-modules): Add testsuite.
> 	* Makefile: Change libof-check-installed-headers-c and
> 	libof-check-installed-headers-cxx to 'testsuite'.
> 	* Rules: Likewise.  Support tests-internal.
> 	* extra-modules.mk: Removed.
> 	* benchtests/strcoll-inputs/filelist#en_US.UTF-8:
> 	Remove extra-modules.mk.
> 
> 	* config.h.in: Don't check for __OPTIMIZE__ or __FAST_MATH__ here.
> 	* include/libc-symbols.h: Move definitions of _GNU_SOURCE,
> 	PASTE_NAME, PASTE_NAME1, IN_MODULE, IS_IN, and IS_IN_LIB to the
> 	very top of the file and rationalize their order.
> 	If MODULE_NAME is not defined at all, define IS_IN to always be
> 	false, and don't define _ISOMAC.
> 	If any of IS_IN (testsuite), IS_IN_build, or __cplusplus are
> 	true, define _ISOMAC and suppress everything else in this file,
> 	starting with the inclusion of config.h.
> 	Do check for inappropriate definitions of __OPTIMIZE__ and
> 	__FAST_MATH__ here, but only if _ISOMAC is not defined.
>         Correct some out-of-date commentary.
> 
> 	* include/math.h: If _ISOMAC is defined, undefine NO_LONG_DOUBLE
> 	and _Mlong_double_ before including math.h.
> 	* include/stdio.h: If _ISOMAC is defined, undefine _IO_MTSAFE_IO
> 	before including libio/stdio.h (this causes the external version of
> 	_IO_lock_t to be visible).
> 	* include/string.h: If _ISOMAC is defined, don't expose
> 	_STRING_ARCH_unaligned. Move a comment to a more appropriate
> 	location.
> 
> 	* include/errno.h, include/stdio.h, include/stdlib.h, include/string.h
> 	* include/time.h, include/unistd.h, include/wchar.h: No need to
> 	check __cplusplus nor use __BEGIN_DECLS/__END_DECLS.
> 
> 	* dlfcn/Makefile: Move tst-dladdr to tests-internal.
> 	* elf/Makefile: Move tst-ptrguard1-static, tst-stackguard1-static,
> 	tst-tls1-static, tst-tls2-static, tst-tls3-static, loadtest,
> 	unload, unload2, circleload1, neededtest, neededtest2,
> 	neededtest3, neededtest4, tst-tls1, tst-tls2, tst-tls3,
> 	tst-tls6, tst-tls7, tst-tls8, tst-dlmopen2, tst-ptrguard1,
> 	tst-stackguard1, tst-_dl_addr_inside_object, and all of the
> 	ifunc tests to tests-internal.
> 	Don't add $(modules-names) to test-extras.
> 	* inet/Makefile: Move tst-inet6_scopeid_pton to tests-internal.
> 	* malloc/Makefile: Move tst-mallocstate and tst-scratch_buffer to
> 	tests-internal.
> 	* misc/Makefile: Move tst-atomic and tst-atomic-long to tests-internal.
> 	* nptl/Makefile: Move tst-typesizes, tst-rwlock19, tst-sem11,
> 	tst-sem12, tst-sem13, tst-barrier5, tst-signal7, tst-tls3,
> 	tst-tls3-malloc, tst-tls5, tst-stackguard1, tst-sem11-static,
> 	tst-sem12-static, and tst-stackguard1-static to tests-internal.
>         Link tests-internal with libpthread also.
> 	Don't add $(modules-names) to test-extras.
> 	* nss/Makefile: Move tst-field and tst-cancel-getpwuid_r to
> 	tests-internal.
> 	* posix/Makefile: Move bug-regex5, bug-regex20, bug-regex33,
> 	tst-rfc3484, tst-rfc3484-2, and tst-rfc3484-3 to tests-internal.
> 	* stdlib/Makefile: Move tst-strtod1i, tst-strtod3, tst-strtod4,
> 	tst-strtod5i, tst-tls-atexit, and tst-tls-atexit-nodelete to
> 	tests-internal.
> 	* sysdeps/powerpc/Makefile: Move test-get_hwcap and
> 	test-get_hwcap-static to tests-internal.
> 	* sysdeps/x86_64/fpu/Makefile: Add all libmvec test modules to
> 	modules-names-tests.
> 
> 	* elf/tst-env-setuid-tunables.c: Include config.h with _LIBC
> 	defined, for HAVE_TUNABLES.
> 	* inet/tst-checks-posix.c: No need to define _ISOMAC.
> 	* intl/tst-gettext2.c: Provide own definition of N_.
> 	* math/test-signgam-finite-c99.c: No need to define _ISOMAC.
> 	* math/test-signgam-main.c: No need to define _ISOMAC.
> 	* stdlib/tst-strtod.c: Split locale_test to...
> 	* stdlib/tst-strtod1i.c: ...this new file.
> 	* stdlib/tst-strtod5.c: Split tests of __strtod_internal to...
> 	* stdlib/tst-strtod5i.c: ...this new file.
> 	* string/test-string.h: Include stdint.h. Duplicate definition of
> 	inhibit_loop_to_libcall here (from libc-symbols.h).
> 	* string/test-strstr.c: Provide dummy definition of
> 	libc_hidden_builtin_def when including strstr.c.
> 	* sysdeps/ia64/fpu/libm-symbols.h: Suppress entire file in _ISOMAC
> 	mode; no need to test __STRICT_ANSI__ nor __cplusplus as well.
> 	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
> 	Don't include init-arch.h.
> 	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
> 	Don't include init-arch.h.
> 
> 	* misc/sys/cdefs.h (__NTHNL): New macro.
> 	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h
> 	(__m81_defun): Use __NTHNL to avoid errors with GCC 6.
> ---
>  Makeconfig                                     |  3 +-
>  Makefile                                       |  4 +-
>  Makerules                                      | 55 +++++++++++++----
>  Rules                                          | 18 +++---
>  benchtests/strcoll-inputs/filelist#en_US.UTF-8 |  1 -
>  config.h.in                                    | 11 ----
>  dlfcn/Makefile                                 |  3 +-
>  elf/Makefile                                   | 58 ++++++++++--------
>  elf/tst-env-setuid-tunables.c                  |  6 ++
>  extra-modules.mk                               |  9 ---
>  include/errno.h                                |  2 +-
>  include/libc-symbols.h                         | 62 ++++++++++++++-----
>  include/math.h                                 |  5 ++
>  include/stdio.h                                | 10 ++-
>  include/stdlib.h                               |  4 --
>  include/string.h                               | 10 +--
>  include/time.h                                 |  4 --
>  include/unistd.h                               |  3 -
>  include/wchar.h                                |  2 -
>  inet/Makefile                                  |  4 +-
>  inet/tst-checks-posix.c                        |  1 -
>  intl/tst-gettext2.c                            |  2 +
>  malloc/Makefile                                |  6 +-
>  math/test-signgam-finite-c99.c                 |  1 -
>  math/test-signgam-main.c                       |  1 -
>  misc/Makefile                                  |  5 +-
>  misc/sys/cdefs.h                               |  3 +
>  nptl/Makefile                                  | 31 +++++-----
>  nss/Makefile                                   |  6 +-
>  posix/Makefile                                 | 11 ++--
>  stdlib/Makefile                                | 17 +++---
>  stdlib/tst-strtod.c                            | 60 ------------------
>  stdlib/tst-strtod1i.c                          | 84 ++++++++++++++++++++++++++
>  stdlib/tst-strtod5.c                           | 54 ++++++-----------
>  stdlib/tst-strtod5i.c                          | 83 +++++++++++++++++++++++++
>  string/test-string.h                           | 12 ++++
>  string/test-strstr.c                           |  1 +
>  sysdeps/ia64/fpu/libm-symbols.h                |  2 +-
>  sysdeps/m68k/m680x0/fpu/bits/mathinline.h      | 15 ++---
>  sysdeps/powerpc/Makefile                       |  2 +-
>  sysdeps/x86_64/fpu/Makefile                    |  8 +++
>  sysdeps/x86_64/fpu/math-tests-arch.h           |  8 +--
>  sysdeps/x86_64/multiarch/test-multiarch.c      |  2 +-
>  43 files changed, 429 insertions(+), 260 deletions(-)
>  delete mode 100644 extra-modules.mk
>  create mode 100644 stdlib/tst-strtod1i.c
>  create mode 100644 stdlib/tst-strtod5i.c
> 
> diff --git a/Makeconfig b/Makeconfig
> index 97a15b569e..f4c4fb4f7b 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -901,7 +901,8 @@ libio-include = -I$(..)libio
>  # List of non-library modules that we build.
>  built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
>  		libSegFault libpcprofile librpcsvc locale-programs \
> -		memusagestat nonlib nscd extramodules libnldbl libsupport
> +		memusagestat nonlib nscd extramodules libnldbl libsupport \
> +		testsuite

OK.

>  
>  in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
>  				    $(libof-$(<F)) \
> diff --git a/Makefile b/Makefile
> index 425cb796db..0ce12e9377 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -321,7 +321,7 @@ endif
>  ifneq "$(headers)" ""
>  # Special test of all the installed headers in this directory.
>  tests-special += $(objpfx)check-installed-headers-c.out
> -libof-check-installed-headers-c := nonlib
> +libof-check-installed-headers-c := testsuite

OK.

>  $(objpfx)check-installed-headers-c.out: \
>      scripts/check-installed-headers.sh $(headers)
>  	$(SHELL) $(..)scripts/check-installed-headers.sh c \
> @@ -331,7 +331,7 @@ $(objpfx)check-installed-headers-c.out: \
>  
>  ifneq "$(CXX)" ""
>  tests-special += $(objpfx)check-installed-headers-cxx.out
> -libof-check-installed-headers-cxx := nonlib
> +libof-check-installed-headers-cxx := testsuite

OK.

>  $(objpfx)check-installed-headers-cxx.out: \
>      scripts/check-installed-headers.sh $(headers)
>  	$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
> diff --git a/Makerules b/Makerules
> index e9194e54cf..69ab1a3a7c 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -277,7 +277,7 @@ $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
>  vpath %.sym $(sysdirs)
>  before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
>  
> -tests += $(gen-as-const-headers:%.sym=test-as-const-%)
> +tests-internal += $(gen-as-const-headers:%.sym=test-as-const-%)

OK.

>  generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
>  $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
>  			    %.sym $(common-objpfx)%.h
> @@ -797,12 +797,21 @@ endif
>  
>  # The makefile may define $(modules-names) to build additional modules.
>  # These are built with $(build-module), except any in $(modules-names-nobuild).
> +# MODULE_NAME=extramodules, except any in $(modules-names-tests).
>  ifdef modules-names
> -# extra-lib.mk is included once for each extra lib to define rules
> -# to build it, and to add its objects to the various variables.
> -# During its evaluation, $(lib) is set to the name of the library.
> -extra-modules-left := $(modules-names)
> -include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
> +cpp-srcs-left := $(filter-out $(modules-names-tests),$(modules-names))
> +ifneq (,$(cpp-srcs-left))
> +lib := extramodules
> +include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
> +endif
> +
> +ifdef modules-names-tests
> +cpp-srcs-left := $(filter $(modules-names-tests),$(modules-names))
> +ifneq (,$(cpp-srcs-left))
> +lib := testsuite
> +include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
> +endif
> +endif
>  
>  extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
>  $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
> @@ -814,7 +823,7 @@ endif
>  	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
>  	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
>  	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
> -	     $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
> +	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))

OK.

>  ifeq ($(build-programs),yes)
>  +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
>  endif
> @@ -1326,7 +1335,17 @@ check: tests
>  .PHONY: xcheck
>  xcheck: xtests
>  
> -all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
> +# The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
> +# that almost all internal declarations from config.h, libc-symbols.h, and
> +# include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
> +all-testsuite := $(strip $(tests) $(xtests) $(test-srcs) $(test-extras))
> +ifneq (,$(all-testsuite))
> +cpp-srcs-left = $(all-testsuite)
> +lib := testsuite
> +include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
> +endif
> +
> +all-nonlib := $(strip $(tests-internal) $(test-internal-extras) $(others))

OK.

>  ifneq (,$(all-nonlib))
>  cpp-srcs-left = $(all-nonlib)
>  lib := nonlib
> @@ -1540,22 +1559,32 @@ clean: common-clean
>  mostlyclean: common-mostlyclean
>  
>  do-tests-clean:
> -	-rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
> +	-rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) \
> +						      $(tests-internal) \
> +						      $(xtests) \

OK.

>  						      $(test-srcs)) \
>  				     $(addsuffix .test-result,$(tests) \
> +							      $(tests-internal) \

OK.

>  							      $(xtests) \
>  							      $(test-srcs)))
>  
>  # Remove the object files.
>  common-mostlyclean:
> -	-rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
> +	-rm -f $(addprefix $(objpfx),$(tests) $(tests-internal) $(xtests) \

OK.

> +				     $(test-srcs) \
>  				     $(others) $(sysdep-others) stubs \
> -				     $(addsuffix .o,$(tests) $(xtests) \
> -						    $(test-srcs) $(others) \
> +				     $(addsuffix .o,$(tests) \
> +						    $(tests-internal) \

OK.

> +						    $(xtests) \
> +						    $(test-srcs) \
> +						    $(others) \
>  						    $(sysdep-others)) \
> -				     $(addsuffix .out,$(tests) $(xtests) \
> +				     $(addsuffix .out,$(tests) \
> +						      $(tests-internal) \

OK.

> +						      $(xtests) \
>  						      $(test-srcs)) \
>  				     $(addsuffix .test-result,$(tests) \
> +							      $(tests-internal) \

OK.

>  							      $(xtests) \
>  							      $(test-srcs)))
>  	-rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
> diff --git a/Rules b/Rules
> index 917bc969b5..168cf508d7 100644
> --- a/Rules
> +++ b/Rules
> @@ -84,7 +84,7 @@ common-generated += dummy.o dummy.c
>  ifneq "$(headers)" ""
>  # Special test of all the installed headers in this directory.
>  tests-special += $(objpfx)check-installed-headers-c.out
> -libof-check-installed-headers-c := nonlib
> +libof-check-installed-headers-c := testsuite

OK.

>  $(objpfx)check-installed-headers-c.out: \
>      $(..)scripts/check-installed-headers.sh $(headers)
>  	$(SHELL) $(..)scripts/check-installed-headers.sh c \
> @@ -94,7 +94,7 @@ $(objpfx)check-installed-headers-c.out: \
>  
>  ifneq "$(CXX)" ""
>  tests-special += $(objpfx)check-installed-headers-cxx.out
> -libof-check-installed-headers-cxx := nonlib
> +libof-check-installed-headers-cxx := testsuite

OK.

>  $(objpfx)check-installed-headers-cxx.out: \
>      $(..)scripts/check-installed-headers.sh $(headers)
>  	$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
> @@ -129,12 +129,14 @@ endif
>  others: $(py-const)
>  
>  ifeq ($(run-built-tests),no)
> -tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported),$(tests)) \
> +tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
> +                                          $(tests) $(tests-internal)) \

OK.

>  			     $(test-srcs)) $(tests-special) \
>  			     $(tests-printers-programs)
>  xtests: tests $(xtests-special)
>  else
> -tests: $(tests:%=$(objpfx)%.out) $(tests-special) $(tests-printers-out)
> +tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \
> +       $(tests-special) $(tests-printers-out)

OK.

>  xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special)
>  endif
>  
> @@ -143,7 +145,7 @@ xtests-special-notdir = $(patsubst $(objpfx)%, %, $(xtests-special))
>  ifeq ($(run-built-tests),no)
>  tests-expected =
>  else
> -tests-expected = $(tests) $(tests-printers)
> +tests-expected = $(tests) $(tests-internal) $(tests-printers)

OK.

>  endif
>  tests:
>  	$(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \
> @@ -156,7 +158,7 @@ xtests:
>  
>  ifeq ($(build-programs),yes)
>  binaries-all-notests = $(others) $(sysdep-others)
> -binaries-all-tests = $(tests) $(xtests) $(test-srcs)
> +binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)

OK.

>  binaries-all = $(binaries-all-notests) $(binaries-all-tests)
>  binaries-static-notests = $(others-static)
>  binaries-static-tests = $(tests-static) $(xtests-static)
> @@ -170,7 +172,7 @@ binaries-pie-notests =
>  endif
>  else
>  binaries-all-notests =
> -binaries-all-tests = $(tests) $(xtests) $(test-srcs)
> +binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)

Ok.

>  binaries-all = $(binaries-all-tests)
>  binaries-static-notests =
>  binaries-static-tests =
> @@ -230,7 +232,7 @@ $(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
>  	$(+link-static-tests)
>  endif
>  
> -ifneq "$(strip $(tests) $(xtests) $(test-srcs))" ""
> +ifneq "$(strip $(tests) $(tests-internal) $(xtests) $(test-srcs))" ""

OK.

>  # These are the implicit rules for making test outputs
>  # from the test programs and whatever input files are present.
>  
> diff --git a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
> index b7b38017d8..eb23b47484 100644
> --- a/benchtests/strcoll-inputs/filelist#en_US.UTF-8
> +++ b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
> @@ -9667,7 +9667,6 @@ hr.po
>  libc.pot
>  ko.po
>  ru.po
> -extra-modules.mk

OK.

>  intl
>  tst-gettext4-fr.po
>  tstcodeset.po
> diff --git a/config.h.in b/config.h.in
> index fb2cc51c03..50f03c0cd8 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -1,14 +1,3 @@
> -#if !defined IS_IN_build && !defined __ASSEMBLER__ && !defined _ISOMAC \
> -    && !defined __OPTIMIZE__
> -# error "glibc cannot be compiled without optimization"
> -#endif
> -
> -/* Another evil option when it comes to compiling the C library is
> -   --ffast-math since it alters the ABI.  */
> -#if defined __FAST_MATH__ && !defined TEST_FAST_MATH
> -# error "glibc must not be compiled with -ffast-math"
> -#endif
> -

OK. Moved to libc-symbols.h.

>  /* Define if building with SELinux support.  Set by --with-selinux.  */
>  #undef	HAVE_SELINUX
>  
> diff --git a/dlfcn/Makefile b/dlfcn/Makefile
> index 94f511d828..8e4f9d1241 100644
> --- a/dlfcn/Makefile
> +++ b/dlfcn/Makefile
> @@ -34,9 +34,10 @@ libdl-shared-only-routines := dlopenold dlfcn
>  endif
>  
>  ifeq (yes,$(build-shared))
> -tests = glrefmain failtest tst-dladdr default errmsg1 tstcxaatexit \
> +tests = glrefmain failtest default errmsg1 tstcxaatexit \

No.

>  	bug-dlopen1 bug-dlsym1 tst-dlinfo bug-atexit1 bug-atexit2 \
>  	bug-atexit3 tstatexit bug-dl-leaf tst-rec-dlopen

Please fix tst-dladdr by removing the use of DL_LOOKUP_ADDRESS, it is
not needed and only informative, worse it forces non-lazy resolution of
the particular symbol which other arches don't do and so modifies what
is being tested because of the side-effects.

> +tests-internal = tst-dladdr
>  endif
>  modules-names = glreflib1 glreflib2 glreflib3 failtestmod defaultmod1 \
>  		defaultmod2 errmsg1mod modatexit modcxaatexit \
> diff --git a/elf/Makefile b/elf/Makefile
> index 61abeb59ee..876641aa57 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -142,43 +142,49 @@ $(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
>  	$(do-install-program)
>  endif
>  
> -tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1 \
> -	tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
> -	tst-auxv
> -tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static \
> -	       tst-leaks1-static tst-array1-static tst-array5-static \
> -	       tst-ptrguard1-static tst-dl-iter-static \
> +tests-static-normal := tst-leaks1-static tst-array1-static tst-array5-static \
> +	       tst-dl-iter-static \
>  	       tst-tlsalign-static tst-tlsalign-extern-static \
>  	       tst-linkall-static tst-env-setuid tst-env-setuid-tunables
> +tests-static-internal := tst-tls1-static tst-tls2-static \
> +	       tst-ptrguard1-static tst-stackguard1-static

OK.

All of these require internal headers for special reasons.

> +
> +tests := tst-tls9 tst-leaks1 \
> +	tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
> +	tst-auxv
> +tests-internal := tst-tls1 tst-tls2 $(tests-static-internal)
> +tests-static := $(tests-static-normal) $(tests-static-internal)
> +
>  ifeq (yes,$(build-shared))
>  tests-static += tst-tls9-static
>  tst-tls9-static-ENV = \
>         LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
> -endif
> -tests += $(tests-static)
> -ifeq (yes,$(build-shared))
> -tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
> -	 constload1 order noload filter unload \
> +
> +tests += restest1 preloadtest loadfail multiload origtest resolvfail \
> +	 constload1 order noload filter \
>  	 reldep reldep2 reldep3 reldep4 nodelete nodelete2 \
> -	 nodlopen nodlopen2 neededtest neededtest2 \
> -	 neededtest3 neededtest4 unload2 lateglobal initfirst global \
> +	 nodlopen nodlopen2 lateglobal initfirst global \
>  	 restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \
> -	 circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \
> +	 tst-tls4 tst-tls5 \
>  	 tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 \
>  	 tst-tls16 tst-tls17 tst-tls18 tst-tls19 tst-tls-dlinfo \
>  	 tst-align tst-align2 $(tests-execstack-$(have-z-execstack)) \
>  	 tst-dlmodcount tst-dlopenrpath tst-deep1 \
> -	 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
> +	 tst-dlmopen1 tst-dlmopen3 \
>  	 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
>  	 tst-audit1 tst-audit2 tst-audit8 tst-audit9 \
> -	 tst-stackguard1 tst-addr1 tst-thrlock \
> +	 tst-addr1 tst-thrlock \
>  	 tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
>  	 tst-nodelete) \
>  	 tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
> -	 tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
> +	 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
>  	 tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-noload \
>  	 tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose
>  #	 reldep9
> +tests-internal += loadtest unload unload2 circleload1 \
> +	 neededtest neededtest2 neededtest3 neededtest4 \
> +	 tst-tls3 tst-tls6 tst-tls7 tst-tls8 tst-dlmopen2 \
> +	 tst-ptrguard1 tst-stackguard1

OK.

>  ifeq ($(build-hardcoded-path-in-tests),yes)
>  tests += tst-dlopen-aout
>  LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
> @@ -289,21 +295,23 @@ CFLAGS-vismain.c = $(PIE-ccflag)
>  endif
>  modules-execstack-yes = tst-execstack-mod
>  extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
> -# We need this variable to be sure the test modules get the right CPPFLAGS.
> -test-extras += $(modules-names)
>  
>  # filtmod1.so has a special rule
>  modules-names-nobuild := filtmod1
>  
> +tests += $(tests-static)
> +

OK.

>  ifneq (no,$(multi-arch))
> -tests-static += ifuncmain1static ifuncmain1picstatic \
> +tests-ifuncstatic := ifuncmain1static ifuncmain1picstatic \
>  		ifuncmain2static ifuncmain2picstatic \
>  		ifuncmain4static ifuncmain4picstatic \
>  		ifuncmain5static ifuncmain5picstatic \
>  		ifuncmain7static ifuncmain7picstatic
> -
> +tests-static += $(tests-ifuncstatic)
> +tests-internal += $(tests-ifuncstatic)

OK.

>  ifeq (yes,$(build-shared))
> -tests += ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
> +tests-internal += \
> +	 ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \

OK.

>  	 ifuncmain1staticpic \
>  	 ifuncmain2 ifuncmain2pic ifuncmain3 ifuncmain4 \
>  	 ifuncmain5 ifuncmain5pic ifuncmain5staticpic \
> @@ -311,11 +319,11 @@ tests += ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
>  ifunc-test-modules = ifuncdep1 ifuncdep1pic ifuncdep2 ifuncdep2pic \
>  		     ifuncdep5 ifuncdep5pic
>  extra-test-objs += $(ifunc-test-modules:=.o)
> -test-extras += $(ifunc-test-modules)
> +test-internal-extras += $(ifunc-test-modules)

OK.

>  ifeq (yes,$(have-fpie))
>  ifunc-pie-tests = ifuncmain1pie ifuncmain1vispie ifuncmain1staticpie \
>  		  ifuncmain5pie ifuncmain6pie ifuncmain7pie
> -tests += $(ifunc-pie-tests)
> +tests-internal += $(ifunc-pie-tests)

OK.

>  tests-pie += $(ifunc-pie-tests)
>  endif
>  modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
> @@ -357,7 +365,7 @@ endif
>  # unit test driver must be able to link with the shared object
>  # that is going to eventually go into an installed DSO.
>  ifeq (yesyes,$(have-fpie)$(build-shared))
> -tests += tst-_dl_addr_inside_object
> +tests-internal += tst-_dl_addr_inside_object

OK.

>  tests-pie += tst-_dl_addr_inside_object
>  $(objpfx)tst-_dl_addr_inside_object: $(objpfx)dl-addr-obj.os
>  CFLAGS-tst-_dl_addr_inside_object.c += $(PIE-ccflag)
> diff --git a/elf/tst-env-setuid-tunables.c b/elf/tst-env-setuid-tunables.c
> index a5f0a81ef3..afcb146e6d 100644
> --- a/elf/tst-env-setuid-tunables.c
> +++ b/elf/tst-env-setuid-tunables.c
> @@ -19,6 +19,12 @@
>     glibc.malloc.check and glibc.malloc.mmap_threshold but also retain
>     glibc.malloc.mmap_threshold in an unprivileged child.  */
>  
> +/* This is compiled as part of the testsuite but needs to see
> +   HAVE_TUNABLES. */
> +#define _LIBC 1
> +#include "config.h"
> +#undef _LIBC

OK.

> +
>  #define test_parent test_parent_tunables
>  #define test_child test_child_tunables
>  
> diff --git a/extra-modules.mk b/extra-modules.mk
> deleted file mode 100644
> index 5f8e693b15..0000000000
> --- a/extra-modules.mk
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -# This file is included several times in a row, once
> -# for each element of $(modules-names).  $(extra-modules-left)
> -# is initialized first to $(modules-names) so that with each
> -# inclusion, we advance $(module) to the next name.
> -
> -module := $(firstword $(extra-modules-left))
> -extra-modules-left := $(filter-out $(module),$(extra-modules-left))
> -
> -libof-$(notdir $(module)) := extramodules

OK.

> diff --git a/include/errno.h b/include/errno.h
> index 7df41dfc31..73fc32e5e0 100644
> --- a/include/errno.h
> +++ b/include/errno.h
> @@ -2,7 +2,7 @@
>  
>  #include <stdlib/errno.h>
>  
> -#if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus
> +#if defined _ERRNO_H && !defined _ISOMAC

OK.

>  # if IS_IN (rtld)
>  #  include <dl-sysdep.h>
> diff --git a/include/libc-symbols.h b/include/libc-symbols.h
> index 775d8af84e..922e4b638c 100644
> --- a/include/libc-symbols.h
> +++ b/include/libc-symbols.h

These changes to libc-symbols.h worry me the most, which is why I noted above
that you need to carry out a built artifact test to make sure you didn't change
any of the generated library code when you didn't mean to.

They look logically correct, and fixes up what I thought was ugly when I ported
this work into RHEL 7.2 (no offense to Siddhesh the work did a lot of good).

> @@ -20,26 +20,46 @@
>  #ifndef _LIBC_SYMBOLS_H
>  #define _LIBC_SYMBOLS_H	1
>  
> -#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME)
> -#define IS_IN(lib) (IN_MODULE == MODULE_##lib)
> +/* This file is included implicitly in the compilation of every source file,
> +   using -include.  It includes config.h.  */
>  
> -/* Returns true if the current module is a versioned library.  Versioned
> -   library names culled from shlib-versions files are assigned a MODULE_*
> -   value lower than MODULE_LIBS_BEGIN.  */
> -#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN)
> +/* Enable declarations of GNU extensions, since we are compiling them.  */
> +#define _GNU_SOURCE 1
>  
> -#define PASTE_NAME(a,b)      PASTE_NAME1 (a,b)
> -#define PASTE_NAME1(a,b)     a##b
> +#ifdef MODULE_NAME
>  
> -/* This file's macros are included implicitly in the compilation of every
> -   file in the C library by -imacros.
> +/* Use `#if IS_IN (module)` to detect what component is being compiled.  */
> +#define PASTE_NAME1(a,b) a##b
> +#define PASTE_NAME(a,b)	 PASTE_NAME1 (a,b)
> +#define IN_MODULE	 PASTE_NAME (MODULE_, MODULE_NAME)
> +#define IS_IN(lib)	 (IN_MODULE == MODULE_##lib)
>  
> -   We include config.h which is generated by configure.
> -   It should define for us the following symbol:
> +/* True if the current module is a versioned library.  Versioned
> +   library names culled from shlib-versions files are assigned a
> +   MODULE_* value greater than MODULE_LIBS_BEGIN.  */
> +#define IS_IN_LIB	 (IN_MODULE > MODULE_LIBS_BEGIN)
>  
> -   * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
> +/* The testsuite, and some other ancillary code, should be compiled against
> +   as close an approximation to the installed headers as possible.
> +   Defining this symbol disables most internal-use-only declarations
> +   provided by this header, and all those provided by other internal
> +   wrapper headers.  */
> +#if IS_IN (testsuite) || defined IS_IN_build || defined __cplusplus
> +# define _ISOMAC 1
> +#endif
>  
> -   */
> +#else
> +/* The generation process for a few files created very early in the
> +   build (notably libc-modules.h itself) involves preprocessing this
> +   header without defining MODULE_NAME.  Under these conditions,
> +   internal declarations (especially from config.h) must be visible,
> +   but IS_IN should always evaluate as false.  */
> +# define IS_IN(lib) 0
> +# define IS_IN_LIB 0
> +# define IN_MODULE (-1)

OK.

> +#endif
> +
> +#ifndef _ISOMAC
>  
>  /* This is defined for the compilation of all C library code.  features.h
>     tests this to avoid inclusion of stubs.h while compiling the library,
> @@ -50,8 +70,17 @@
>     itself is being compiled, or just some generator program.  */
>  #define _LIBC	1
>  
> -/* Enable declarations of GNU extensions, since we are compiling them.  */
> -#define _GNU_SOURCE	1
> +/* Some files must be compiled with optimization on.  */
> +#if !defined __ASSEMBLER__ && !defined __OPTIMIZE__
> +# error "glibc cannot be compiled without optimization"
> +#endif
> +
> +/* -ffast-math cannot be applied to the C library, as it alters the ABI.
> +   Some test components that use -ffast-math are currently not part of
> +   IS_IN (testsuite) for technical reasons, so we have a secondary override.  */
> +#if defined __FAST_MATH__ && !defined TEST_FAST_MATH
> +# error "glibc must not be compiled with -ffast-math"
> +#endif
>  

OK.

>  #include <config.h>
>  
> @@ -887,4 +916,5 @@ for linking")
>  # define inhibit_loop_to_libcall
>  #endif
>  
> +#endif /* !_ISOMAC */

OK.

>  #endif /* libc-symbols.h */
> diff --git a/include/math.h b/include/math.h
> index a4f556263a..6ff67830f8 100644
> --- a/include/math.h
> +++ b/include/math.h
> @@ -1,5 +1,10 @@
>  #ifndef	_MATH_H
>  
> +#ifdef _ISOMAC
> +# undef NO_LONG_DOUBLE
> +# undef _Mlong_double_
> +#endif

OK.

> +
>  #include <math/math.h>
>  
>  #ifndef _ISOMAC
> diff --git a/include/stdio.h b/include/stdio.h
> index 17b5a05076..6c84dffdeb 100644
> --- a/include/stdio.h
> +++ b/include/stdio.h
> @@ -1,11 +1,13 @@
>  #ifndef _STDIO_H
> -# if defined __need_FILE || defined __need___FILE || defined _ISOMAC
> +# if defined _ISOMAC
> +#  undef _IO_MTSAFE_IO
> +#  include <libio/stdio.h>

Needs a detailed comment about why we undef _IO_MTSAFE_IO.

> +# elif defined __need_FILE || defined __need___FILE

OK.

>  #  include <libio/stdio.h>
>  # else
>  #  include <libio/stdio.h>
>  
>  /* Now define the internal interfaces.  */
> -__BEGIN_DECLS
>  
>  extern int __fcloseall (void);
>  extern int __snprintf (char *__restrict __s, size_t __maxlen,
> @@ -30,7 +32,6 @@ extern int __vsscanf (const char *__restrict __s,
>  		      _G_va_list __arg)
>       __attribute__ ((__format__ (__scanf__, 2, 0)));
>  
> -#  ifndef __cplusplus
>  extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
>  extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
>       __THROW;
> @@ -52,7 +53,6 @@ extern int __obstack_printf_chk (struct obstack *, int, const char *, ...)
>       __THROW;
>  extern int __obstack_vprintf_chk (struct obstack *, int, const char *,
>  				  _G_va_list) __THROW;
> -#  endif
>  
>  extern int __isoc99_fscanf (FILE *__restrict __stream,
>  			    const char *__restrict __format, ...) __wur;
> @@ -184,7 +184,5 @@ libc_hidden_proto (__obstack_vprintf_chk)
>  extern FILE * __fmemopen (void *buf, size_t len, const char *mode);
>  libc_hidden_proto (__fmemopen)
>  
> -__END_DECLS
>  # endif
> -

OK.

>  #endif
> diff --git a/include/stdlib.h b/include/stdlib.h
> index 352339e859..8039876017 100644
> --- a/include/stdlib.h
> +++ b/include/stdlib.h
> @@ -13,8 +13,6 @@
>  #if !defined __Need_M_And_C && !defined _ISOMAC
>  # include <sys/stat.h>
>  
> -__BEGIN_DECLS
> -
>  extern __typeof (strtol_l) __strtol_l;
>  extern __typeof (strtoul_l) __strtoul_l;
>  extern __typeof (strtoll_l) __strtoll_l;
> @@ -265,8 +263,6 @@ extern __typeof (unsetenv) unsetenv attribute_hidden;
>  extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
>  # endif
>  
> -__END_DECLS
> -
>  #endif
>  

OK.

>  #undef __Need_M_And_C
> diff --git a/include/string.h b/include/string.h
> index f166de9c43..ce71674086 100644
> --- a/include/string.h
> +++ b/include/string.h
> @@ -1,6 +1,8 @@
>  #ifndef _STRING_H
>  
> -#if !defined _ISOMAC && !defined __cplusplus
> +#ifndef _ISOMAC
> +/* Some of these are defined as macros in the real string.h, so we must
> +   prototype them before including it.  */

OK.

>  #include <sys/types.h>
>  
>  extern void *__memccpy (void *__dest, const void *__src,
> @@ -46,16 +48,14 @@ extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
>  extern int __ffs (int __i) __attribute__ ((const));
>  
>  extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
> -#endif
>  
>  /* Get _STRING_ARCH_unaligned.  */
>  #include <string_private.h>
> +#endif
>  
> -/* Now the real definitions.  We do this here since some of the functions
> -   above are defined as macros in the headers.  */
>  #include <string/string.h>
>  
> -#if !defined _ISOMAC && !defined __cplusplus
> +#ifndef _ISOMAC

Ok.

>  extern __typeof (strcoll_l) __strcoll_l;
>  extern __typeof (strxfrm_l) __strxfrm_l;
>  extern __typeof (strcasecmp_l) __strcasecmp_l;
> diff --git a/include/time.h b/include/time.h
> index 684ceb812f..8fe18185ed 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -4,8 +4,6 @@
>  #ifndef _ISOMAC
>  # include <xlocale.h>
>  
> -__BEGIN_DECLS
> -
>  extern __typeof (strftime_l) __strftime_l;
>  libc_hidden_proto (__strftime_l)
>  extern __typeof (strptime_l) __strptime_l;
> @@ -112,7 +110,5 @@ extern double __difftime (time_t time1, time_t time0);
>     actual clock ID.  */
>  #define CLOCK_IDFIELD_SIZE	3
>  
> -__END_DECLS
> -

OK.

>  #endif
>  #endif
> diff --git a/include/unistd.h b/include/unistd.h
> index 16d68a1505..fbcea1b92d 100644
> --- a/include/unistd.h
> +++ b/include/unistd.h
> @@ -2,7 +2,6 @@
>  # include <posix/unistd.h>
>  
>  # ifndef _ISOMAC
> -__BEGIN_DECLS
>  
>  libc_hidden_proto (_exit, __noreturn__)
>  rtld_hidden_proto (_exit, __noreturn__)
> @@ -188,7 +187,5 @@ extern int __getlogin_r_loginuid (char *name, size_t namesize)
>  extern __typeof (__access) __access_noerrno attribute_hidden;
>  #  endif
>  
> -__END_DECLS
>  # endif
> -

Ok.

>  #endif
> diff --git a/include/wchar.h b/include/wchar.h
> index 6272130e24..e2579a176a 100644
> --- a/include/wchar.h
> +++ b/include/wchar.h
> @@ -172,7 +172,6 @@ extern int __vfwprintf (__FILE *__restrict __s,
>  			const wchar_t *__restrict __format,
>  			__gnuc_va_list __arg)
>       /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
> -#ifndef __cplusplus
>  extern int __vfwprintf_chk (FILE *__restrict __s, int __flag,
>  			    const wchar_t *__restrict __format,
>  			    __gnuc_va_list __arg)
> @@ -184,7 +183,6 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
>       /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
>  libc_hidden_proto (__vfwprintf_chk)
>  libc_hidden_proto (__vswprintf_chk)
> -#endif

OK.

>  
>  extern int __isoc99_fwscanf (__FILE *__restrict __stream,
>  			     const wchar_t *__restrict __format, ...);
> diff --git a/inet/Makefile b/inet/Makefile
> index 010792af8f..b33355602e 100644
> --- a/inet/Makefile
> +++ b/inet/Makefile
> @@ -52,7 +52,9 @@ aux := check_pf check_native ifreq
>  tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
>  	 tst-gethnm test-ifaddrs bug-if1 test-inet6_opt tst-ether_line \
>  	 tst-getni1 tst-getni2 tst-inet6_rth tst-checks tst-checks-posix \
> -	 tst-sockaddr tst-inet6_scopeid_pton test-hnto-types
> +	 tst-sockaddr test-hnto-types
> +
> +tests-internal := tst-inet6_scopeid_pton

OK. Begrudingly because there really should be a standard API to get the
scopeid from the ipv6 address, but there isn't, so we use an internal
helper to print an error message when the test fails.

>  
>  include ../Rules
>  
> diff --git a/inet/tst-checks-posix.c b/inet/tst-checks-posix.c
> index e46b6a2a69..cdcb5cb3aa 100644
> --- a/inet/tst-checks-posix.c
> +++ b/inet/tst-checks-posix.c
> @@ -19,6 +19,5 @@
>  /* Process tst-checks.c in POSIX mode.  */
>  #undef _GNU_SOURCE
>  #define _POSIX_C_SOURCE 200112L
> -#define _ISOMAC

OK.

>  
>  #include "tst-checks.c"
> diff --git a/intl/tst-gettext2.c b/intl/tst-gettext2.c
> index bdfe76de66..894e09e41e 100644
> --- a/intl/tst-gettext2.c
> +++ b/intl/tst-gettext2.c
> @@ -24,6 +24,8 @@
>  #include <stdlib.h>
>  #include <stdio.h>
>  
> +#define N_(msgid) msgid
> +

OK.

>  struct data_t
>  {
>    const char *selection;
> diff --git a/malloc/Makefile b/malloc/Makefile
> index e93b83b57d..ca83228b1c 100644
> --- a/malloc/Makefile
> +++ b/malloc/Makefile
> @@ -25,9 +25,9 @@ include ../Makeconfig
>  dist-headers := malloc.h
>  headers := $(dist-headers) obstack.h mcheck.h
>  tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
> -	 tst-mallocstate tst-mcheck tst-mallocfork tst-trim1 \
> +	 tst-mcheck tst-mallocfork tst-trim1 \
>  	 tst-malloc-usable tst-realloc tst-posix_memalign \
> -	 tst-pvalloc tst-memalign tst-mallopt tst-scratch_buffer \
> +	 tst-pvalloc tst-memalign tst-mallopt \
>  	 tst-malloc-backtrace tst-malloc-thread-exit \
>  	 tst-malloc-thread-fail tst-malloc-fork-deadlock \
>  	 tst-mallocfork2 \
> @@ -39,6 +39,8 @@ tests-static := \
>  	 tst-interpose-static-thread \
>  	 tst-malloc-usable-static \
>  
> +tests-internal := tst-mallocstate tst-scratch_buffer

OK.

> +
>  ifneq (no,$(have-tunables))
>  tests += tst-malloc-usable-tunables
>  tests-static += tst-malloc-usable-static-tunables
> diff --git a/math/test-signgam-finite-c99.c b/math/test-signgam-finite-c99.c
> index a67a803c99..3dacef5147 100644
> --- a/math/test-signgam-finite-c99.c
> +++ b/math/test-signgam-finite-c99.c
> @@ -20,7 +20,6 @@
>  #undef __LIBC_INTERNAL_MATH_INLINES
>  #undef _GNU_SOURCE
>  #undef _Mlong_double_
> -#define _ISOMAC
>  

OK.

>  #include <math.h>
>  #include <stdio.h>
> diff --git a/math/test-signgam-main.c b/math/test-signgam-main.c
> index 11ebbe3628..e3cecf7fa1 100644
> --- a/math/test-signgam-main.c
> +++ b/math/test-signgam-main.c
> @@ -19,7 +19,6 @@
>  #undef _LIBC
>  #undef __LIBC_INTERNAL_MATH_INLINES
>  #undef _GNU_SOURCE
> -#define _ISOMAC

OK.

>  
>  #include <math.h>
>  #include <stdio.h>
> diff --git a/misc/Makefile b/misc/Makefile
> index ed988c3967..bd88253c26 100644
> --- a/misc/Makefile
> +++ b/misc/Makefile
> @@ -79,8 +79,9 @@ gpl2lgpl := error.c error.h
>  tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
>  	 tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \
>  	 tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 \
> -	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \
> -	 tst-atomic tst-atomic-long
> +	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty
> +
> +tests-internal := tst-atomic tst-atomic-long

OK.

>  tests-static := tst-empty
>  
>  ifeq ($(run-built-tests),yes)
> diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
> index e5fe4f89d9..39c91e1225 100644
> --- a/misc/sys/cdefs.h
> +++ b/misc/sys/cdefs.h
> @@ -55,15 +55,18 @@
>  #  define __THROW	__attribute__ ((__nothrow__ __LEAF))
>  #  define __THROWNL	__attribute__ ((__nothrow__))
>  #  define __NTH(fct)	__attribute__ ((__nothrow__ __LEAF)) fct
> +#  define __NTHNL(fct)  __attribute__ ((__nothrow__)) fct
>  # else
>  #  if defined __cplusplus && __GNUC_PREREQ (2,8)
>  #   define __THROW	throw ()
>  #   define __THROWNL	throw ()
>  #   define __NTH(fct)	__LEAF_ATTR fct throw ()
> +#   define __NTHNL(fct) fct throw ()
>  #  else
>  #   define __THROW
>  #   define __THROWNL
>  #   define __NTH(fct)	fct
> +#   define __NTHNL(fct) fct
>  #  endif
>  # endif
>  

OK.

> diff --git a/nptl/Makefile b/nptl/Makefile
> index 6d48c0cfc8..edffb66272 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -220,8 +220,7 @@ LDLIBS-tst-once5 = -lstdc++
>  CFLAGS-tst-thread_local1.o = -std=gnu++11
>  LDLIBS-tst-thread_local1 = -lstdc++
>  
> -tests = tst-typesizes \
> -	tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
> +tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
>  	tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
>  	tst-mutex7 tst-mutex8 tst-mutex9 tst-mutex5a tst-mutex7a \
>  	tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 tst-mutexpi5 \
> @@ -241,13 +240,12 @@ tests = tst-typesizes \
>  	tst-rwlock4 tst-rwlock5 tst-rwlock6 tst-rwlock7 tst-rwlock8 \
>  	tst-rwlock9 tst-rwlock10 tst-rwlock11 tst-rwlock12 tst-rwlock13 \
>  	tst-rwlock14 tst-rwlock15 tst-rwlock16 tst-rwlock17 tst-rwlock18 \
> -	tst-rwlock19 \
>  	tst-once1 tst-once2 tst-once3 tst-once4 tst-once5 \
>  	tst-key1 tst-key2 tst-key3 tst-key4 \
>  	tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
> -	tst-sem8 tst-sem9 tst-sem10 tst-sem11 tst-sem12 tst-sem13 tst-sem14 \
> +	tst-sem8 tst-sem9 tst-sem10 tst-sem14 \
>  	tst-sem15 tst-sem16 \
> -	tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 tst-barrier5 \
> +	tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
>  	tst-align tst-align3 \
>  	tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
>  	tst-basic7 \
> @@ -272,7 +270,7 @@ tests = tst-typesizes \
>  	tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \
>  	tst-flock1 tst-flock2 \
>  	tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
> -	tst-signal6 tst-signal7 \
> +	tst-signal6 \
>  	tst-exec1 tst-exec2 tst-exec3 tst-exec4 tst-exec5 \
>  	tst-exit1 tst-exit2 tst-exit3 \
>  	tst-stdio1 tst-stdio2 \
> @@ -297,6 +295,10 @@ tests = tst-typesizes \
>  	tst-bad-schedattr \
>  	tst-thread_local1 tst-mutex-errorcheck tst-robust10 \
>  	tst-robust-fork tst-create-detached
> +
> +tests-internal := tst-typesizes tst-rwlock19 tst-sem11 tst-sem12 tst-sem13 \
> +		  tst-barrier5 tst-signal7

OK.

> +
>  xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
>  	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
>  test-srcs = tst-oddstacklimit
> @@ -354,8 +356,8 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
>  	 tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 \
>  	 tst-oncex3 tst-oncex4
>  ifeq ($(build-shared),yes)
> -tests += tst-atfork2 tst-tls3 tst-tls3-malloc tst-tls4 tst-tls5 tst-_res1 \
> -	 tst-fini1 tst-stackguard1
> +tests += tst-atfork2 tst-tls4 tst-_res1 tst-fini1
> +tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1

OK.

>  tests-nolibpthread += tst-fini1
>  ifeq ($(have-z-execstack),yes)
>  tests += tst-execstack
> @@ -369,7 +371,7 @@ modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \
>  		tst-join7mod
>  extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
>  		   tst-cleanup4aux.o tst-cleanupx4aux.o
> -test-extras += $(modules-names) tst-cleanup4aux tst-cleanupx4aux
> +test-extras += tst-cleanup4aux tst-cleanupx4aux
>  test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
>  
>  tst-atfork2mod.so-no-z-defs = yes
> @@ -422,9 +424,9 @@ tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
>  		tst-cancel21-static tst-cancel24-static tst-cond8-static \
>  		tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
>  		tst-sem12-static
> -tests += tst-stackguard1-static tst-cancel21-static tst-cancel24-static \
> -	 tst-cond8-static tst-mutex8-static tst-mutexpi8-static \
> -	 tst-sem11-static tst-sem12-static
> +tests += tst-cancel21-static tst-cancel24-static \
> +	 tst-cond8-static tst-mutex8-static tst-mutexpi8-static
> +tests-internal += tst-sem11-static tst-sem12-static tst-stackguard1-static

OK.

>  xtests-static += tst-setuid1-static
>  
>  # These tests are linked with libc before libpthread
> @@ -619,8 +621,9 @@ ifeq ($(build-shared),yes)
>  $(addprefix $(objpfx), \
>    $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
>      $(tests-nolibpthread), \
> -    $(tests) $(xtests) $(test-srcs))): $(objpfx)libpthread.so \
> -				       $(objpfx)libpthread_nonshared.a
> +    $(tests) $(tests-internal) $(xtests) $(test-srcs))): \
> +	$(objpfx)libpthread.so \
> +	$(objpfx)libpthread_nonshared.a

Why doesn't this use $(shared-thread-library)?

>  $(objpfx)tst-unload: $(libdl)
>  # $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
>  # since otherwise libpthread.so comes before libc.so when linking.
> diff --git a/nss/Makefile b/nss/Makefile
> index de6c47a1db..6d165f2734 100644
> --- a/nss/Makefile
> +++ b/nss/Makefile
> @@ -49,15 +49,15 @@ makedb-modules = xmalloc hash-string
>  extra-objs		+= $(makedb-modules:=.o)
>  
>  tests-static            = tst-field
> +tests-internal		= tst-field
>  tests			= test-netdb tst-nss-test1 test-digits-dots \
> -			  tst-nss-getpwent bug17079 \
> -			  $(tests-static)
> +			  tst-nss-getpwent bug17079
>  xtests			= bug-erange
>  
>  # If we have a thread library then we can test cancellation against
>  # some routines like getpwuid_r.
>  ifeq (yes,$(have-thread-library))
> -tests += tst-cancel-getpwuid_r
> +tests-internal += tst-cancel-getpwuid_r

Why is this in tests-internal? It should have no internal header dependencies.

>  endif
>  
>  # Specify rules for the nss_* modules.  We have some services.
> diff --git a/posix/Makefile b/posix/Makefile
> index 8f23d647c8..e07aae58eb 100644
> --- a/posix/Makefile
> +++ b/posix/Makefile
> @@ -67,24 +67,23 @@ tests		:= tstgetopt testfnm runtests runptests	     \
>  		   tst-mmap tst-mmap-offset tst-getaddrinfo tst-truncate \
>  		   tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
>  		   tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
> -		   tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
> +		   tst-gnuglob tst-regex bug-regex6 bug-regex7 \
>  		   bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
>  		   bug-regex13 bug-regex14 bug-regex15 bug-regex16 \
> -		   bug-regex17 bug-regex18 bug-regex19 bug-regex20 \
> +		   bug-regex17 bug-regex18 bug-regex19 \
>  		   bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
>  		   bug-regex25 bug-regex26 bug-regex27 bug-regex28 \
>  		   bug-regex29 bug-regex30 bug-regex31 bug-regex32 \
> -		   bug-regex33 tst-nice tst-nanosleep tst-regex2 \
> +		   tst-nice tst-nanosleep tst-regex2 \
>  		   transbug tst-rxspencer tst-pcre tst-boost \
>  		   bug-ga1 tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \
>  		   tst-getaddrinfo2 bug-glob1 bug-glob2 bug-glob3 tst-sysconf \
>  		   tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
>  		   tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
>  		   tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
> -		   tst-execvp3 tst-execvp4 tst-rfc3484 tst-rfc3484-2 \
> +		   tst-execvp3 tst-execvp4 \
>  		   tst-execvpe1 tst-execvpe2 tst-execvpe3 tst-execvpe4 \
>  		   tst-execvpe5 tst-execvpe6 \
> -		   tst-rfc3484-3 \
>  		   tst-getaddrinfo3 tst-fnmatch2 tst-cpucount tst-cpuset \
>  		   bug-getopt1 bug-getopt2 bug-getopt3 bug-getopt4 \
>  		   bug-getopt5 tst-getopt_long1 bug-regex34 bug-regex35 \
> @@ -92,6 +91,8 @@ tests		:= tstgetopt testfnm runtests runptests	     \
>  		   tst-fnmatch3 bug-regex36 tst-getaddrinfo5 \
>  		   tst-posix_spawn-fd \
>  		   tst-posix_fadvise tst-posix_fadvise64
> +tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
> +		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3

OK.

>  xtests		:= bug-ga2
>  ifeq (yes,$(build-shared))
>  test-srcs	:= globtest
> diff --git a/stdlib/Makefile b/stdlib/Makefile
> index 5751b5d600..d4edcf8eef 100644
> --- a/stdlib/Makefile
> +++ b/stdlib/Makefile
> @@ -68,23 +68,26 @@ test-srcs	:= tst-fmtmsg
>  tests		:= tst-strtol tst-strtod testmb testrand testsort testdiv   \
>  		   test-canon test-canon2 tst-strtoll tst-environ	    \
>  		   tst-xpg-basename tst-random tst-random2 tst-bsearch	    \
> -		   tst-limits tst-rand48 bug-strtod tst-setcontext          \
> +		   tst-limits tst-rand48 bug-strtod tst-setcontext	    \
>  		   tst-setcontext2 test-a64l tst-qsort tst-system testmb2   \
> -		   bug-strtod2 tst-atof1 tst-atof2 tst-strtod2 tst-strtod3  \
> -		   tst-rand48-2 tst-makecontext tst-strtod4 tst-strtod5     \
> +		   bug-strtod2 tst-atof1 tst-atof2 tst-strtod2		    \
> +		   tst-rand48-2 tst-makecontext tst-strtod5		    \
>  		   tst-qsort2 tst-makecontext2 tst-strtod6 tst-unsetenv1    \
>  		   tst-makecontext3 bug-getcontext bug-fmtmsg1		    \
>  		   tst-secure-getenv tst-strtod-overflow tst-strtod-round   \
> -		   tst-tininess tst-strtod-underflow tst-tls-atexit	    \
> -		   tst-setcontext3 tst-tls-atexit-nodelete		    \
> +		   tst-tininess tst-strtod-underflow tst-setcontext3	    \
>  		   tst-strtol-locale tst-strtod-nan-locale tst-strfmon_l    \
>  		   tst-quick_exit tst-thread-quick_exit tst-width	    \
> -		   tst-width-stdint tst-strfrom tst-strfrom-locale \
> +		   tst-width-stdint tst-strfrom tst-strfrom-locale	    \
>  		   tst-getrandom
> +tests-internal	:= tst-strtod1i tst-strtod3 tst-strtod4 tst-strtod5i \
> +		   tst-tls-atexit tst-tls-atexit-nodelete
> +tests-static	:= tst-secure-getenv
> +

OK.

>  ifeq ($(build-hardcoded-path-in-tests),yes)
>  tests += tst-empty-env
>  endif
> -tests-static	:= tst-secure-getenv
> +

OK.

>  ifeq ($(have-cxx-thread_local),yes)
>  CFLAGS-tst-quick_exit.o = -std=c++11
>  LDLIBS-tst-quick_exit = -lstdc++
> diff --git a/stdlib/tst-strtod.c b/stdlib/tst-strtod.c
> index ced6d8a351..e0f096c325 100644
> --- a/stdlib/tst-strtod.c
> +++ b/stdlib/tst-strtod.c
> @@ -79,7 +79,6 @@ static const struct ltest tests[] =
>  
>  static void expand (char *dst, int c);
>  static int long_dbl (void);
> -static int locale_test (void);
>  
>  static int
>  do_test (void)
> @@ -176,8 +175,6 @@ do_test (void)
>  
>    status |= long_dbl ();
>  
> -  status |= locale_test ();
> -
>    return status ? EXIT_FAILURE : EXIT_SUCCESS;
>  }
>  
> @@ -217,63 +214,6 @@ long_dbl (void)
>    return 0;
>  }
>  
> -/* Perform a few tests in a locale with thousands separators.  */
> -static int
> -locale_test (void)
> -{
> -  static const struct
> -  {
> -    const char *loc;
> -    const char *str;
> -    double exp;
> -    ptrdiff_t nread;
> -  } tests[] =
> -    {
> -      { "de_DE.UTF-8", "1,5", 1.5, 3 },
> -      { "de_DE.UTF-8", "1.5", 1.0, 1 },
> -      { "de_DE.UTF-8", "1.500", 1500.0, 5 },
> -      { "de_DE.UTF-8", "36.893.488.147.419.103.232", 0x1.0p65, 26 }
> -    };
> -#define ntests (sizeof (tests) / sizeof (tests[0]))
> -  size_t n;
> -  int result = 0;
> -
> -  puts ("\nLocale tests");
> -
> -  for (n = 0; n < ntests; ++n)
> -    {
> -      double d;
> -      char *endp;
> -
> -      if (setlocale (LC_ALL, tests[n].loc) == NULL)
> -	{
> -	  printf ("cannot set locale %s\n", tests[n].loc);
> -	  result = 1;
> -	  continue;
> -	}
> -
> -      /* We call __strtod_interal here instead of strtod to tests the
> -	 handling of grouping.  */
> -      d = __strtod_internal (tests[n].str, &endp, 1);
> -      if (d != tests[n].exp)
> -	{
> -	  printf ("strtod(\"%s\") returns %g and not %g\n",
> -		  tests[n].str, d, tests[n].exp);
> -	  result = 1;
> -	}
> -      else if (endp - tests[n].str != tests[n].nread)
> -	{
> -	  printf ("strtod(\"%s\") read %td bytes and not %td\n",
> -		  tests[n].str, endp - tests[n].str, tests[n].nread);
> -	  result = 1;
> -	}
> -    }
> -
> -  if (result == 0)
> -    puts ("all OK");
> -
> -  return result;
> -}

OK.

>  
>  #define TEST_FUNCTION do_test ()
>  #include "../test-skeleton.c"
> diff --git a/stdlib/tst-strtod1i.c b/stdlib/tst-strtod1i.c
> new file mode 100644
> index 0000000000..5c2ba9981d
> --- /dev/null
> +++ b/stdlib/tst-strtod1i.c
> @@ -0,0 +1,84 @@
> +/* Copyright (C) 1991-2017 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 <ctype.h>
> +#include <locale.h>
> +#include <stddef.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <string.h>
> +#include <math.h>
> +
> +/* Perform a few tests in a locale with thousands separators.  */
> +static int
> +do_test (void)
> +{
> +  static const struct
> +  {
> +    const char *loc;
> +    const char *str;
> +    double exp;
> +    ptrdiff_t nread;
> +  } tests[] =
> +    {
> +      { "de_DE.UTF-8", "1,5", 1.5, 3 },
> +      { "de_DE.UTF-8", "1.5", 1.0, 1 },
> +      { "de_DE.UTF-8", "1.500", 1500.0, 5 },
> +      { "de_DE.UTF-8", "36.893.488.147.419.103.232", 0x1.0p65, 26 }
> +    };
> +#define ntests (sizeof (tests) / sizeof (tests[0]))
> +  size_t n;
> +  int result = 0;
> +
> +  puts ("\nLocale tests");
> +
> +  for (n = 0; n < ntests; ++n)
> +    {
> +      double d;
> +      char *endp;
> +
> +      if (setlocale (LC_ALL, tests[n].loc) == NULL)
> +	{
> +	  printf ("cannot set locale %s\n", tests[n].loc);
> +	  result = 1;
> +	  continue;
> +	}
> +
> +      d = __strtod_internal (tests[n].str, &endp, 1);
> +      if (d != tests[n].exp)
> +	{
> +	  printf ("strtod(\"%s\") returns %g and not %g\n",
> +		  tests[n].str, d, tests[n].exp);
> +	  result = 1;
> +	}
> +      else if (endp - tests[n].str != tests[n].nread)
> +	{
> +	  printf ("strtod(\"%s\") read %td bytes and not %td\n",
> +		  tests[n].str, endp - tests[n].str, tests[n].nread);
> +	  result = 1;
> +	}
> +    }
> +
> +  if (result == 0)
> +    puts ("all OK");
> +
> +  return result ? EXIT_FAILURE : EXIT_SUCCESS;
> +}
> +
> +#define TEST_FUNCTION do_test ()
> +#include "../test-skeleton.c"

This should use the new support/ test infrastructure.

> diff --git a/stdlib/tst-strtod5.c b/stdlib/tst-strtod5.c
> index 337c746989..691759e366 100644
> --- a/stdlib/tst-strtod5.c
> +++ b/stdlib/tst-strtod5.c
> @@ -9,38 +9,27 @@
>  static const struct
>  {
>    const char *in;
> -  int group;
>    double expected;
>  } tests[] =
>    {
> -    { "0", 0, 0.0 },
> -    { "000", 0, 0.0 },
> -    { "-0", 0, -0.0 },
> -    { "-000", 0, -0.0 },
> -    { "0,", 0, 0.0 },
> -    { "-0,", 0, -0.0 },
> -    { "0,0", 0, 0.0 },
> -    { "-0,0", 0, -0.0 },
> -    { "0e-10", 0, 0.0 },
> -    { "-0e-10", 0, -0.0 },
> -    { "0,e-10", 0, 0.0 },
> -    { "-0,e-10", 0, -0.0 },
> -    { "0,0e-10", 0, 0.0 },
> -    { "-0,0e-10", 0, -0.0 },
> -    { "0e-1000000", 0, 0.0 },
> -    { "-0e-1000000", 0, -0.0 },
> -    { "0,0e-1000000", 0, 0.0 },
> -    { "-0,0e-1000000", 0, -0.0 },
> -    { "0", 1, 0.0 },
> -    { "000", 1, 0.0 },
> -    { "-0", 1, -0.0 },
> -    { "-000", 1, -0.0 },
> -    { "0e-10", 1, 0.0 },
> -    { "-0e-10", 1, -0.0 },
> -    { "0e-1000000", 1, 0.0 },
> -    { "-0e-1000000", 1, -0.0 },
> -    { "000"NBSP"000"NBSP"000", 1, 0.0 },
> -    { "-000"NBSP"000"NBSP"000", 1, -0.0 }
> +    { "0", 0.0 },
> +    { "000", 0.0 },
> +    { "-0", -0.0 },
> +    { "-000", -0.0 },
> +    { "0,", 0.0 },
> +    { "-0,", -0.0 },
> +    { "0,0", 0.0 },
> +    { "-0,0", -0.0 },
> +    { "0e-10", 0.0 },
> +    { "-0e-10", -0.0 },
> +    { "0,e-10", 0.0 },
> +    { "-0,e-10", -0.0 },
> +    { "0,0e-10", 0.0 },
> +    { "-0,0e-10", -0.0 },
> +    { "0e-1000000", 0.0 },
> +    { "-0e-1000000", -0.0 },
> +    { "0,0e-1000000", 0.0 },
> +    { "-0,0e-1000000", -0.0 },
>    };
>  #define NTESTS (sizeof (tests) / sizeof (tests[0]))
>  
> @@ -59,12 +48,7 @@ do_test (void)
>    for (int i = 0; i < NTESTS; ++i)
>      {
>        char *ep;
> -      double r;
> -
> -      if (tests[i].group)
> -	r = __strtod_internal (tests[i].in, &ep, 1);
> -      else
> -	r = strtod (tests[i].in, &ep);
> +      double r = strtod (tests[i].in, &ep);
>  
>        if (*ep != '\0')
>  	{
> diff --git a/stdlib/tst-strtod5i.c b/stdlib/tst-strtod5i.c
> new file mode 100644
> index 0000000000..92ed983141
> --- /dev/null
> +++ b/stdlib/tst-strtod5i.c
> @@ -0,0 +1,83 @@

Needs a copyright header.

> +#include <locale.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <math.h>
> +
> +#define NBSP "\xc2\xa0"
> +
> +static const struct
> +{
> +  const char *in;
> +  int group;
> +  double expected;
> +} tests[] =
> +  {
> +    { "0", 0, 0.0 },
> +    { "000", 0, 0.0 },
> +    { "-0", 0, -0.0 },
> +    { "-000", 0, -0.0 },
> +    { "0,", 0, 0.0 },
> +    { "-0,", 0, -0.0 },
> +    { "0,0", 0, 0.0 },
> +    { "-0,0", 0, -0.0 },
> +    { "0e-10", 0, 0.0 },
> +    { "-0e-10", 0, -0.0 },
> +    { "0,e-10", 0, 0.0 },
> +    { "-0,e-10", 0, -0.0 },
> +    { "0,0e-10", 0, 0.0 },
> +    { "-0,0e-10", 0, -0.0 },
> +    { "0e-1000000", 0, 0.0 },
> +    { "-0e-1000000", 0, -0.0 },
> +    { "0,0e-1000000", 0, 0.0 },
> +    { "-0,0e-1000000", 0, -0.0 },
> +    { "0", 1, 0.0 },
> +    { "000", 1, 0.0 },
> +    { "-0", 1, -0.0 },
> +    { "-000", 1, -0.0 },
> +    { "0e-10", 1, 0.0 },
> +    { "-0e-10", 1, -0.0 },
> +    { "0e-1000000", 1, 0.0 },
> +    { "-0e-1000000", 1, -0.0 },
> +    { "000"NBSP"000"NBSP"000", 1, 0.0 },
> +    { "-000"NBSP"000"NBSP"000", 1, -0.0 }
> +  };
> +#define NTESTS (sizeof (tests) / sizeof (tests[0]))
> +
> +
> +static int
> +do_test (void)
> +{
> +  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
> +    {
> +      puts ("could not set locale");
> +      return 1;
> +    }
> +
> +  int status = 0;
> +
> +  for (int i = 0; i < NTESTS; ++i)
> +    {
> +      char *ep;
> +      double r = __strtod_internal (tests[i].in, &ep, tests[i].group);
> +
> +      if (*ep != '\0')
> +	{
> +	  printf ("%d: got rest string \"%s\", expected \"\"\n", i, ep);
> +	  status = 1;
> +	}
> +
> +      if (r != tests[i].expected
> +	  || copysign (10.0, r) != copysign (10.0, tests[i].expected))
> +	{
> +	  printf ("%d: got wrong results %g, expected %g\n",
> +		  i, r, tests[i].expected);
> +	  status = 1;
> +	}
> +    }
> +
> +  return status;
> +}
> +
> +#define TEST_FUNCTION do_test ()
> +#include "../test-skeleton.c"

New tests should use new support/ infrastructure.

> diff --git a/string/test-string.h b/string/test-string.h
> index 2c36b44c22..9f45898238 100644
> --- a/string/test-string.h
> +++ b/string/test-string.h
> @@ -40,6 +40,18 @@ extern impl_t __start_impls[], __stop_impls[];
>  
>  #undef __USE_STRING_INLINES
>  
> +/* We are compiled under _ISOMAC, so libc-symbols.h does not do this
> +   for us.  */
> +#include "config.h"
> +#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
> +# define inhibit_loop_to_libcall \
> +    __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
> +#else
> +# define inhibit_loop_to_libcall
> +#endif

OK.

> +
> +
> +#include <stdint.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> diff --git a/string/test-strstr.c b/string/test-strstr.c
> index c29d37446c..404c374331 100644
> --- a/string/test-strstr.c
> +++ b/string/test-strstr.c
> @@ -23,6 +23,7 @@
>  
>  
>  #define STRSTR simple_strstr
> +#define libc_hidden_builtin_def(arg) /* nothing */

OK.

>  #include "strstr.c"
>  
>  
> diff --git a/sysdeps/ia64/fpu/libm-symbols.h b/sysdeps/ia64/fpu/libm-symbols.h
> index 31d6f36de9..505131b813 100644
> --- a/sysdeps/ia64/fpu/libm-symbols.h
> +++ b/sysdeps/ia64/fpu/libm-symbols.h
> @@ -1,4 +1,4 @@
> -#if !defined __STRICT_ANSI__ && !defined __cplusplus
> +#ifndef _ISOMAC

OK.

>  # include <sysdep.h>
>  # undef ret	/* get rid of the stupid "ret" macro; it breaks br.ret */
>  
> diff --git a/sysdeps/m68k/m680x0/fpu/bits/mathinline.h b/sysdeps/m68k/m680x0/fpu/bits/mathinline.h
> index c2dca317f4..8e6bdc4e27 100644
> --- a/sysdeps/m68k/m680x0/fpu/bits/mathinline.h
> +++ b/sysdeps/m68k/m680x0/fpu/bits/mathinline.h
> @@ -112,19 +112,22 @@ __NTH (__signbitl (long double __x))
>  #ifdef	__LIBC_INTERNAL_MATH_INLINES
>  /* This is used when defining the functions themselves.  Define them with
>     __ names, and with `static inline' instead of `extern inline' so the
> -   bodies will always be used, never an external function call.  */
> +   bodies will always be used, never an external function call.
> +   Note: GCC 6 objects to __attribute__ ((__leaf__)) on static functions.  */
>  # define __m81_u(x)		__CONCAT(__,x)
>  # define __m81_inline		static __inline
> +# define __m81_nth(fn)		__NTHNL (fn)
>  #else
>  # define __m81_u(x)		x
> -# define __m81_inline __MATH_INLINE
> +# define __m81_inline		__MATH_INLINE
> +# define __m81_nth(fn)		__NTH (fn)

OK.

>  # define __M81_MATH_INLINES	1
>  #endif
>  
>  /* Define a const math function.  */
>  #define __m81_defun(rettype, func, args)				      \
>    __m81_inline rettype __attribute__((__const__))			      \
> -  __NTH (__m81_u(func) args)
> +  __m81_nth (__m81_u(func) args)
>  
>  /* Define the three variants of a math function that has a direct
>     implementation in the m68k fpu.  FUNC is the name for C (which will be
> @@ -335,8 +338,8 @@ __inline_functions (long double,l)
>  
>  # define __inline_functions(float_type, s)				\
>  __m81_inline void							\
> -__NTH (__m81_u(__CONCAT(__sincos,s))(float_type __x, float_type *__sinx, \
> -				     float_type *__cosx))		\
> +__m81_nth (__m81_u(__CONCAT(__sincos,s))				\
> +	   (float_type __x, float_type *__sinx, float_type *__cosx))	\
>  {									\
>    __asm __volatile__ ("fsincos%.x %2,%1:%0"				\
>  		      : "=f" (*__sinx), "=f" (*__cosx) : "f" (__x));	\
> @@ -353,8 +356,6 @@ __inline_functions (long double,l)
>  
>  /* Define inline versions of the user visible functions.  */
>  
> -/* Note that there must be no whitespace before the argument passed for
> -   NAME, to make token pasting work correctly with -traditional.  */
>  # define __inline_forward_c(rettype, name, args1, args2)	\
>  __MATH_INLINE rettype __attribute__((__const__))		\
>  __NTH (name args1)						\
> diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
> index 099fbf68cd..aafa226f7f 100644
> --- a/sysdeps/powerpc/Makefile
> +++ b/sysdeps/powerpc/Makefile
> @@ -27,7 +27,7 @@ gen-as-const-headers += locale-defines.sym
>  endif
>  
>  ifeq ($(subdir),nptl)
> -tests += test-get_hwcap test-get_hwcap-static
> +tests-internal += test-get_hwcap test-get_hwcap-static

OK.

>  tests-static += test-get_hwcap-static
>  endif
>  
> diff --git a/sysdeps/x86_64/fpu/Makefile b/sysdeps/x86_64/fpu/Makefile
> index fad605a841..e4462b9337 100644
> --- a/sysdeps/x86_64/fpu/Makefile
> +++ b/sysdeps/x86_64/fpu/Makefile
> @@ -45,6 +45,12 @@ modules-names += test-double-libmvec-alias-mod \
>  		 test-float-libmvec-alias-mod \
>  		 test-float-libmvec-alias-avx-mod \
>  		 test-float-libmvec-alias-avx2-mod
> +modules-names-tests += test-double-libmvec-alias-mod \
> +		 test-double-libmvec-alias-avx-mod \
> +		 test-double-libmvec-alias-avx2-mod \
> +		 test-float-libmvec-alias-mod \
> +		 test-float-libmvec-alias-avx-mod \
> +		 test-float-libmvec-alias-avx2-mod

OK.

>  extra-test-objs += test-double-libmvec-sincos-avx-main.o \
>  		   test-double-libmvec-sincos-avx2-main.o \
>  		   test-double-libmvec-sincos-main.o \
> @@ -146,6 +152,8 @@ tests += test-double-libmvec-alias-avx512 \
>  	 test-float-libmvec-sincosf-avx512
>  modules-names += test-double-libmvec-alias-avx512-mod \
>  		 test-float-libmvec-alias-avx512-mod
> +modules-names-tests += test-double-libmvec-alias-avx512-mod \
> +		 test-float-libmvec-alias-avx512-mod

OK.

>  extra-test-objs += test-double-libmvec-sincos-avx512-main.o \
>  		   test-float-libmvec-sincosf-avx512-main.o
>  test-double-libmvec-alias-avx512-mod.so-no-z-defs = yes
> diff --git a/sysdeps/x86_64/fpu/math-tests-arch.h b/sysdeps/x86_64/fpu/math-tests-arch.h
> index 98f7cf6548..9278e3440b 100644
> --- a/sysdeps/x86_64/fpu/math-tests-arch.h
> +++ b/sysdeps/x86_64/fpu/math-tests-arch.h
> @@ -16,11 +16,11 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> +#include <cpu-features.h>
> +
>  #if defined REQUIRE_AVX
> -# include <init-arch.h>
>  
>  # define INIT_ARCH_EXT
> -
>  # define CHECK_ARCH_EXT                                        \
>    do                                                           \
>      {                                                          \
> @@ -29,10 +29,8 @@
>    while (0)
>  
>  #elif defined REQUIRE_AVX2
> -# include <init-arch.h>
>  
>  # define INIT_ARCH_EXT
> -
>  # define CHECK_ARCH_EXT                                        \
>    do                                                           \
>      {                                                          \
> @@ -41,10 +39,8 @@
>    while (0)
>  
>  #elif defined REQUIRE_AVX512F
> -# include <init-arch.h>
>  
>  # define INIT_ARCH_EXT
> -

OK.

>  # define CHECK_ARCH_EXT                                        \
>    do                                                           \
>      {                                                          \
> diff --git a/sysdeps/x86_64/multiarch/test-multiarch.c b/sysdeps/x86_64/multiarch/test-multiarch.c
> index 3974842c19..597d64e1e8 100644
> --- a/sysdeps/x86_64/multiarch/test-multiarch.c
> +++ b/sysdeps/x86_64/multiarch/test-multiarch.c
> @@ -16,7 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> -#include <init-arch.h>
> +#include <cpu-features.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> 

OK.

-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes.
  2017-02-20 15:13         ` Carlos O'Donell
@ 2017-02-20 15:32           ` Zack Weinberg
  2017-02-27 13:34           ` Zack Weinberg
  1 sibling, 0 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-20 15:32 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: GNU C Library, Joseph Myers, Adhemerval Zanella

On Mon, Feb 20, 2017 at 10:13 AM, Carlos O'Donell <carlos@redhat.com> wrote:
>
> This change is looking good, it is a step in the right direction, and the
> addition of '*-internal' markup is useful.
>
> I still think we need a few improvements.
>
> I'd like two senior developers to review this.

That seems fair.  I expect not to have time to do any further work on
this until the weekend, so I want to say thank you now for the quick
reviews.

> - This is a step in the right direction. My instinct is to want to move
>   all the internal dependencies into functions in support/, but that's
>   quite a bit of work. Either way they would have to be identified before
>   being moved and your work does just that. Eventually I would hope that
>   all the tests go back to being compiled with tests, we remove tests-internal,
>   and only support/ functions can view the glibc internals through a well
>   defined API.

I agree with this in principle but I suspect it may be hard,
especially for the tests which are digging around inside the guts of
the dynamic linker.  And I want to be clear that I don't plan to do
any of it.  I don't have the time or the expertise.

zw

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 14:52       ` Joseph Myers
@ 2017-02-20 15:34         ` Zack Weinberg
  2017-02-20 16:05           ` Carlos O'Donell
  2017-02-20 16:30           ` Joseph Myers
  2017-02-25 16:14         ` Zack Weinberg
  1 sibling, 2 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-20 15:34 UTC (permalink / raw)
  To: Joseph Myers; +Cc: GNU C Library, Carlos O'Donell, Adhemerval Zanella

On Mon, Feb 20, 2017 at 9:52 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Mon, 20 Feb 2017, Zack Weinberg wrote:
>> atomic.h cannot be used by code compiled under _ISOMAC, but
>> stdatomic.h can.  There are quite a few tests that use atomic.h; most
>> of them were not straightforward to change to stdatomic.h, but
>> nptl/tst-join7.c was, so I did that.
>
> stdatomic.h is not available before GCC 4.9, and our minimum version for
> building glibc is 4.7 (although you can't use build-many-glibcs.py with
> versions before 4.9 because of missing features for bootstrapping cross
> compilers with glibc, in particular --with-glibc-version).

I don't recall exactly what was wrong with atomic.h in _ISOMAC mode
but I suspect it is not trivial to fix.  I *could* just give up here
and move tst-join7 to tests-internal, but if the "new policy" is to
use C11 atomics, perhaps that is sufficient reason to bump the minimum
version requirement to 4.9??

zw

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 15:34         ` Zack Weinberg
@ 2017-02-20 16:05           ` Carlos O'Donell
  2017-02-20 16:30           ` Joseph Myers
  1 sibling, 0 replies; 30+ messages in thread
From: Carlos O'Donell @ 2017-02-20 16:05 UTC (permalink / raw)
  To: Zack Weinberg, Joseph Myers; +Cc: GNU C Library, Adhemerval Zanella

On 02/20/2017 10:34 AM, Zack Weinberg wrote:
> On Mon, Feb 20, 2017 at 9:52 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>> On Mon, 20 Feb 2017, Zack Weinberg wrote:
>>> atomic.h cannot be used by code compiled under _ISOMAC, but
>>> stdatomic.h can.  There are quite a few tests that use atomic.h; most
>>> of them were not straightforward to change to stdatomic.h, but
>>> nptl/tst-join7.c was, so I did that.
>>
>> stdatomic.h is not available before GCC 4.9, and our minimum version for
>> building glibc is 4.7 (although you can't use build-many-glibcs.py with
>> versions before 4.9 because of missing features for bootstrapping cross
>> compilers with glibc, in particular --with-glibc-version).
> 
> I don't recall exactly what was wrong with atomic.h in _ISOMAC mode
> but I suspect it is not trivial to fix.  I *could* just give up here
> and move tst-join7 to tests-internal, but if the "new policy" is to
> use C11 atomics, perhaps that is sufficient reason to bump the minimum
> version requirement to 4.9??

Please restart this in a different thread, for context:

C11 (internally, not exposed via headers):
https://sourceware.org/glibc/wiki/Consensus#Standards_we_use

RFC: requiring GCC >= 4.7 to build glibc
https://sourceware.org/ml/libc-alpha/2015-08/msg00851.html

Google developers appeared to be blockers here because of Ubuntu 14.04LTS
using gcc 4.8, and that should be verified again, include Mike Frysinger
to answer that question.

Paul Eggart recommended gcc 4.9.

Upstream GCC has no FSF supported 4x. branches, they are all 5/6/7 support.

Therefore if we are going to move the minimum required build compiler it
should be to some supported FSF branch e.g. gcc 5.4.

I think that users expecting new new glibc to build with old old gcc have
their expectations set wrong. They should be using old glibc branches and
working on backports if they need ABI/API-neutral fixes.

This has nothing to do with the compiler used to build the applications
though, there we need to continue to support very old gcc's.

-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 13:03     ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Zack Weinberg
                         ` (2 preceding siblings ...)
  2017-02-20 14:52       ` Joseph Myers
@ 2017-02-20 16:15       ` Joseph Myers
  3 siblings, 0 replies; 30+ messages in thread
From: Joseph Myers @ 2017-02-20 16:15 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: libc-alpha, carlos, adhemerval.zanella

On Mon, 20 Feb 2017, Zack Weinberg wrote:

> Finally, tst-setgetname.c was using kernel-features.h (also a no-go in
> _ISOMAC mode) just for one __ASSUME macro which it doesn't really need.

That macros is only used there.  Effectively, its function is to say "when 
we remove support for 2.6.32 kernels this code can be removed".  So if we 
remove the conditional we should also remove the macro definition and find 
some other way to track that this code should be removed when we increase 
the minimum kernel version for x86_64 / x86.  (Or we could decide that an 
extra year of support for 2.6.32 kernels on those architectures, compared 
to other architectures having required 3.2 in glibc 2.24, is enough, and 
just increase the minimum version so the conditional code is no longer 
needed.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 14:11       ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Carlos O'Donell
@ 2017-02-20 16:26         ` Joseph Myers
  2017-02-25 16:34         ` Zack Weinberg
  1 sibling, 0 replies; 30+ messages in thread
From: Joseph Myers @ 2017-02-20 16:26 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: Zack Weinberg, libc-alpha, adhemerval.zanella

On Mon, 20 Feb 2017, Carlos O'Donell wrote:

> > math/test-misc.c was using #ifndef NO_LONG_DOUBLE, which is an internal
> > configuration macro, to decide whether to do certain tests involving
> > 'long double'.  I changed the test to #if LDBL_MANT_DIG > DBL_MANT_DIG
> > instead, which uses only public float.h macros and is equivalent on
> > all supported platforms.  (Note that NO_LONG_DOUBLE doesn't mean 'the
> > compiler doesn't support long double', it means 'long double is the
> > same as double'.)  It's possible that instead we should just do these
> > tests unconditionally on all platforms.
> 
> Doing all the tests on all platforms is what we should have done from the
> start to verify everything works as expected. However, your changes are
> the right minimal fix for math/test-misc.c.

I agree the tests of long double functions should be run even when long 
double functions alias the double ones.  But that depends on patch 4 
(which stops most tests from being built with _LIBC defined) to do cleanly 
(as in the case where they are aliases, the long double functions aren't 
declared when _LIBC is defined, since the code defining them as aliases 
wouldn't work if they were declared - you can't define aliases when 
declarations with different types are visible).  The changes to use 
LDBL_MANT_DIG > DBL_MANT_DIG seem clearly the right thing for patch 3 in 
this series.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 15:34         ` Zack Weinberg
  2017-02-20 16:05           ` Carlos O'Donell
@ 2017-02-20 16:30           ` Joseph Myers
  1 sibling, 0 replies; 30+ messages in thread
From: Joseph Myers @ 2017-02-20 16:30 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: GNU C Library, Carlos O'Donell, Adhemerval Zanella

On Mon, 20 Feb 2017, Zack Weinberg wrote:

> I don't recall exactly what was wrong with atomic.h in _ISOMAC mode
> but I suspect it is not trivial to fix.  I *could* just give up here
> and move tst-join7 to tests-internal, but if the "new policy" is to
> use C11 atomics, perhaps that is sufficient reason to bump the minimum
> version requirement to 4.9??

Policy for internal operations is to use operations matched to C11 
semantics as far as possible; not necessarily the public <stdatomic.h> 
interfaces or the __atomic_* built-in functions (in cases where that 
brings in a libatomic dependency, that's not suitable for use in glibc, 
but __atomic_*, which were introduced in GCC 4.7, may be used on 
architectures where they don't involve problematic dependencies, and may 
well be a sensible default to use on architectures where there isn't a 
reason to do something different).

I'd be fine with increasing the minimum GCC version, although I don't 
think there's that much conditional code to remove with an increase to 
4.9.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite.
  2017-02-20 13:58     ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Carlos O'Donell
@ 2017-02-25 15:28       ` Zack Weinberg
  0 siblings, 0 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-25 15:28 UTC (permalink / raw)
  To: libc-alpha

On 02/20/2017 08:58 AM, Carlos O'Donell wrote:
>> +  /* We can't use math_private.h macros in this file.  */
> Suggest:
> 
> /* Previously we used EXTRACT_WORDS64 from math_private.h, but in order
>    to avoid including internal headers we duplicate that code here.  */

Done.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 14:52       ` Joseph Myers
  2017-02-20 15:34         ` Zack Weinberg
@ 2017-02-25 16:14         ` Zack Weinberg
  1 sibling, 0 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-25 16:14 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, carlos, adhemerval.zanella

On 02/20/2017 09:52 AM, Joseph Myers wrote:
> On Mon, 20 Feb 2017, Zack Weinberg wrote:
> 
>> atomic.h cannot be used by code compiled under _ISOMAC, but 
>> stdatomic.h can.  There are quite a few tests that use atomic.h; 
>> most of them were not straightforward to change to stdatomic.h,
>> but nptl/tst-join7.c was, so I did that.
> 
> stdatomic.h is not available before GCC 4.9, and our minimum version
>  for building glibc is 4.7 (although you can't use 
> build-many-glibcs.py with versions before 4.9 because of missing 
> features for bootstrapping cross compilers with glibc, in particular
>  --with-glibc-version).
...
>> Finally, tst-setgetname.c was using kernel-features.h (also a no-go
>> in _ISOMAC mode) just for one __ASSUME macro which it doesn't
>> really need.
> 
> That macros is only used there.  Effectively, its function is to say 
> "when we remove support for 2.6.32 kernels this code can be 
> removed".

Rather than hold up this patch on questions of whether we can bump the
minimum compiler or kernel requirement, I am going to drop these changes
and move the affected tests to tests-internal.

zw

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-20 14:11       ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Carlos O'Donell
  2017-02-20 16:26         ` Joseph Myers
@ 2017-02-25 16:34         ` Zack Weinberg
  2017-02-25 21:06           ` Florian Weimer
  2017-03-01 20:19           ` Carlos O'Donell
  1 sibling, 2 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-25 16:34 UTC (permalink / raw)
  To: Carlos O'Donell, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/20/2017 09:11 AM, Carlos O'Donell wrote:
> On 02/20/2017 08:03 AM, Zack Weinberg wrote:
>>
>> posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; I
>> duplicated the definition into the .c file, which is not ideal, but
>> since this didn't come up anywhere else, inventing a new header for it
>> seems like excessive polish.
> 
> Please add PTR_ALIGN_DOWN to the support/ subsystem for testing and port
> the test to support/.
> 
> We will conceivably need similar macros for other tests and as a glibc
> developer I like to have access to the same helper macros I use in glib.

wordexp-test.c is currently not even using the old test skeleton, and
does some fairly hairy things with fork handlers.  I would prefer not to
go down a rabbit hole.  Instead I propose to do something similar to
what I did for the DIAG_* macros: introduce a new header in include/
called libc-pointer-arith.h; move cast_to_integer, ALIGN_UP, ALIGN_DOWN,
PTR_ALIGN_UP, and PTR_ALIGN_DOWN there; have libc-internal.h include it;
have wordexp-test.c include it instead of libc-internal.h; and call that
good enough for now.  OK?

zw

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-25 16:34         ` Zack Weinberg
@ 2017-02-25 21:06           ` Florian Weimer
  2017-02-27  1:38             ` Zack Weinberg
  2017-03-01 20:19           ` Carlos O'Donell
  1 sibling, 1 reply; 30+ messages in thread
From: Florian Weimer @ 2017-02-25 21:06 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: Carlos O'Donell, libc-alpha, joseph, adhemerval.zanella

* Zack Weinberg:

> wordexp-test.c is currently not even using the old test skeleton, and
> does some fairly hairy things with fork handlers.  I would prefer not to
> go down a rabbit hole.  Instead I propose to do something similar to
> what I did for the DIAG_* macros: introduce a new header in include/
> called libc-pointer-arith.h; move cast_to_integer, ALIGN_UP, ALIGN_DOWN,
> PTR_ALIGN_UP, and PTR_ALIGN_DOWN there; have libc-internal.h include it;
> have wordexp-test.c include it instead of libc-internal.h; and call that
> good enough for now.  OK?

If we move into that direction, can we also replace #include
<libc-internal.h> in sysdeps/x86_64/nptl/tls.h?

I think this is one major cause why things compile on x86-64, but not
other architectures.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-25 21:06           ` Florian Weimer
@ 2017-02-27  1:38             ` Zack Weinberg
  2017-03-01 18:22               ` Carlos O'Donell
  2017-03-02 13:57               ` Andreas Schwab
  0 siblings, 2 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-02-27  1:38 UTC (permalink / raw)
  To: Florian Weimer
  Cc: Carlos O'Donell, GNU C Library, Joseph Myers, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]

On Sat, Feb 25, 2017 at 4:06 PM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * Zack Weinberg:
>
>> wordexp-test.c is currently not even using the old test skeleton, and
>> does some fairly hairy things with fork handlers.  I would prefer not to
>> go down a rabbit hole.  Instead I propose to do something similar to
>> what I did for the DIAG_* macros: introduce a new header in include/
>> called libc-pointer-arith.h; move cast_to_integer, ALIGN_UP, ALIGN_DOWN,
>> PTR_ALIGN_UP, and PTR_ALIGN_DOWN there; have libc-internal.h include it;
>> have wordexp-test.c include it instead of libc-internal.h; and call that
>> good enough for now.  OK?
>
> If we move into that direction, can we also replace #include
> <libc-internal.h> in sysdeps/x86_64/nptl/tls.h?
>
> I think this is one major cause why things compile on x86-64, but not
> other architectures.

I looked into that, and it turns out that the users of libc-internal.h
divide neatly into four classes: those that want the DIAG_* macros,
those that want the ALIGN macros, those that want the other stuff
(mostly early init), and those that don't need it at all.  See
attached - not quite fully baked but does pass many-glibcs tests.  I'm
not sure you're going to get your wish, because x86/nptl/tls.h does
need to keep including libc-pointer-arith.h, and the #1 cause of
failures in many-glibcs that I didn't see in a regular x86-64 build
was ... needing to include libc-pointer-arith.h.  But this still seems
like a good cleanup.

zw

[-- Attachment #2: 0001-Narrowing-the-visibility-of-libc-internal.h-even-fur.patch --]
[-- Type: text/x-patch, Size: 32834 bytes --]

From 8baa3eb75e49d167c286873e1fc9e24d4596b238 Mon Sep 17 00:00:00 2001
From: Zack Weinberg <zackw@panix.com>
Date: Sun, 26 Feb 2017 20:17:52 -0500
Subject: [PATCH 1/3] Narrowing the visibility of libc-internal.h even further.

posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; similar
to what was done with libc-diag.h, I have split the definitions of
cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and PTR_ALIGN_DOWN
to a new header, libc-pointer-arith.h.

It then occurred to me that the remaining declarations in libc-internal.h
are mostly to do with early initialization, and probably most of the
files including it, even in the core code, don't need it anymore.  Indeed,
only 19 files actually need what remains of libc-internal.h.  23 others
need libc-diag.h instead, and 12 need libc-pointer-arith.h instead.
No file needs more than one of them, and 16 don't need any of them!

So, with this patch, libc-internal.h stops including libc-diag.h as
well as losing the pointer arithmetic macros, and all including files
are adjusted.

        * include/libc-pointer-arith.h: New file.  Define
	cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and
        PTR_ALIGN_DOWN here.
        * include/libc-internal.h: Definitions of above macros
	moved from here.  Don't include libc-diag.h anymore either.
	* posix/wordexp-test.c: Include stdint.h and libc-pointer-arith.h.
        Don't include libc-internal.h.

	* debug/pcprofile.c, elf/dl-tunables.c, elf/soinit.c, io/openat.c
	* io/openat64.c, misc/ptrace.c, nptl/pthread_clock_gettime.c
	* nptl/pthread_clock_settime.c, nptl/pthread_cond_common.c
	* string/strcoll_l.c, sysdeps/nacl/brk.c
	* sysdeps/unix/clock_settime.c
	* sysdeps/unix/sysv/linux/i386/get_clockfreq.c
	* sysdeps/unix/sysv/linux/ia64/get_clockfreq.c
	* sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
	* sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c:
	Don't include libc-internal.h.

	* elf/get-dynamic-info.h, iconv/loop.c
	* iconvdata/iso-2022-cn-ext.c, locale/weight.h, locale/weightwc.h
	* misc/reboot.c, nis/nis_table.c, nptl_db/thread_dbP.h
	* nscd/connections.c, resolv/res_send.c, soft-fp/fmadf4.c
	* soft-fp/fmasf4.c, soft-fp/fmatf4.c, stdio-common/vfscanf.c
	* sysdeps/ieee754/dbl-64/e_lgamma_r.c
	* sysdeps/ieee754/dbl-64/k_rem_pio2.c
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c
	* sysdeps/ieee754/ldbl-128/k_tanl.c
	* sysdeps/ieee754/ldbl-128ibm/k_tanl.c
	* sysdeps/ieee754/ldbl-96/e_lgammal_r.c
	* sysdeps/ieee754/ldbl-96/k_tanl.c, sysdeps/nptl/futex-internal.h:
	Include libc-diag.h instead of libc-internal.h.

        * elf/dl-load.c, elf/dl-reloc.c, locale/programs/locarchive.c
        * nptl/nptl-init.c, string/strcspn.c, string/strspn.c
	* malloc/malloc.c, sysdeps/i386/nptl/tls.h
	* sysdeps/nacl/dl-map-segments.h, sysdeps/x86_64/atomic-machine.h
	* sysdeps/unix/sysv/linux/spawni.c
        * sysdeps/x86_64/nptl/tls.h:
        Include libc-pointer-arith.h instead of libc-internal.h.

	* elf/get-dynamic-info.h, sysdeps/nacl/dl-map-segments.h
	* sysdeps/x86_64/atomic-machine.h:
        Add multiple include guard.
---
 debug/pcprofile.c                                  |  1 -
 elf/dl-load.c                                      |  2 +-
 elf/dl-reloc.c                                     |  2 +-
 elf/dl-tunables.c                                  |  1 -
 elf/get-dynamic-info.h                             |  7 ++-
 elf/soinit.c                                       |  1 -
 iconv/loop.c                                       |  2 +-
 iconvdata/iso-2022-cn-ext.c                        |  2 +-
 include/libc-internal.h                            | 38 --------------
 include/libc-pointer-arith.h                       | 60 ++++++++++++++++++++++
 io/openat.c                                        |  1 -
 io/openat64.c                                      |  1 -
 locale/programs/locarchive.c                       |  2 +-
 locale/weight.h                                    |  2 +-
 locale/weightwc.h                                  |  2 +-
 malloc/malloc.c                                    |  2 +-
 misc/ptrace.c                                      |  1 -
 misc/reboot.c                                      |  2 +-
 nis/nis_table.c                                    |  2 +-
 nptl/nptl-init.c                                   |  2 +-
 nptl/pthread_clock_gettime.c                       |  1 -
 nptl/pthread_clock_settime.c                       |  1 -
 nptl/pthread_cond_common.c                         |  1 -
 nptl_db/thread_dbP.h                               |  2 +-
 nscd/connections.c                                 |  2 +-
 posix/wordexp-test.c                               |  3 +-
 resolv/res_send.c                                  |  2 +-
 soft-fp/fmadf4.c                                   |  7 +--
 soft-fp/fmasf4.c                                   |  7 +--
 soft-fp/fmatf4.c                                   |  7 +--
 stdio-common/vfscanf.c                             |  2 +-
 string/strcoll_l.c                                 |  1 -
 string/strcspn.c                                   |  2 +-
 string/strspn.c                                    |  2 +-
 sysdeps/i386/nptl/tls.h                            |  2 +-
 sysdeps/ieee754/dbl-64/e_lgamma_r.c                |  2 +-
 sysdeps/ieee754/dbl-64/k_rem_pio2.c                |  2 +-
 sysdeps/ieee754/flt-32/e_lgammaf_r.c               |  2 +-
 sysdeps/ieee754/flt-32/k_rem_pio2f.c               |  2 +-
 sysdeps/ieee754/ldbl-128/k_tanl.c                  |  3 +-
 sysdeps/ieee754/ldbl-128ibm/k_tanl.c               |  3 +-
 sysdeps/ieee754/ldbl-96/e_lgammal_r.c              |  2 +-
 sysdeps/ieee754/ldbl-96/k_tanl.c                   |  3 +-
 sysdeps/nacl/brk.c                                 |  1 -
 sysdeps/nacl/dl-map-segments.h                     |  7 ++-
 sysdeps/nptl/futex-internal.h                      |  2 +-
 sysdeps/unix/clock_settime.c                       |  1 -
 sysdeps/unix/sysv/linux/i386/get_clockfreq.c       |  2 -
 sysdeps/unix/sysv/linux/ia64/get_clockfreq.c       |  1 -
 sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c    |  1 -
 .../unix/sysv/linux/sparc/sparc64/get_clockfreq.c  |  1 -
 sysdeps/unix/sysv/linux/spawni.c                   |  2 +-
 sysdeps/x86_64/atomic-machine.h                    | 10 ++--
 sysdeps/x86_64/nptl/tls.h                          |  2 +-
 54 files changed, 125 insertions(+), 99 deletions(-)
 create mode 100644 include/libc-pointer-arith.h

diff --git a/debug/pcprofile.c b/debug/pcprofile.c
index 1643ef652f..b6402ef63b 100644
--- a/debug/pcprofile.c
+++ b/debug/pcprofile.c
@@ -22,7 +22,6 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <libc-internal.h>
 
 /* Nonzero if we are actually doing something.  */
 static int active;
diff --git a/elf/dl-load.c b/elf/dl-load.c
index a5318f9c8d..c1b6d4ba0f 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -36,7 +36,7 @@
 #include <caller.h>
 #include <sysdep.h>
 #include <stap-probe.h>
-#include <libc-internal.h>
+#include <libc-pointer-arith.h>
 
 #include <dl-dst.h>
 #include <dl-load.h>
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 4ac558df52..b3c3a9bbf9 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -25,8 +25,8 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <_itoa.h>
+#include <libc-pointer-arith.h>
 #include "dynamic-link.h"
-#include <libc-internal.h>
 
 /* Statistics function.  */
 #ifdef SHARED
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index e42aa67003..ebf48bb389 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -22,7 +22,6 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <libc-internal.h>
 #include <sysdep.h>
 #include <fcntl.h>
 #include <ldsodefs.h>
diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
index 86760d8844..6413558975 100644
--- a/elf/get-dynamic-info.h
+++ b/elf/get-dynamic-info.h
@@ -16,8 +16,11 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _GET_DYNAMIC_INFO_H
+#define _GET_DYNAMIC_INFO_H 1
+
 #include <assert.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 #ifndef RESOLVE_MAP
 static
@@ -179,3 +182,5 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
     info[DT_RPATH] = NULL;
 #endif
 }
+
+#endif /* get-dynamic-info.h */
diff --git a/elf/soinit.c b/elf/soinit.c
index 71398308d2..fe9935732b 100644
--- a/elf/soinit.c
+++ b/elf/soinit.c
@@ -4,7 +4,6 @@
    calling those lists of functions.  */
 
 #ifndef NO_CTORS_DTORS_SECTIONS
-# include <libc-internal.h>
 # include <stdlib.h>
 
 static void (*const __CTOR_LIST__[1]) (void)
diff --git a/iconv/loop.c b/iconv/loop.c
index 42a03e79b0..0160f72cd6 100644
--- a/iconv/loop.c
+++ b/iconv/loop.c
@@ -56,7 +56,7 @@
 #include <sys/param.h>		/* For MIN.  */
 #define __need_size_t
 #include <stddef.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* We have to provide support for machines which are not able to handled
    unaligned memory accesses.  Some of the character encodings have
diff --git a/iconvdata/iso-2022-cn-ext.c b/iconvdata/iso-2022-cn-ext.c
index c9c698ee85..919524f001 100644
--- a/iconvdata/iso-2022-cn-ext.c
+++ b/iconvdata/iso-2022-cn-ext.c
@@ -27,7 +27,7 @@
 #include "cns11643.h"
 #include "cns11643l1.h"
 #include "cns11643l2.h"
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 #include <assert.h>
 
diff --git a/include/libc-internal.h b/include/libc-internal.h
index be6c02186f..cd2f2622ed 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -53,42 +53,4 @@ extern void __init_misc (int, char **, char **);
 extern __typeof (__profile_frequency) __profile_frequency attribute_hidden;
 # endif
 
-/* 1 if 'type' is a pointer type, 0 otherwise.  */
-# define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5)
-
-/* __intptr_t if P is true, or T if P is false.  */
-# define __integer_if_pointer_type_sub(T, P) \
-  __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \
-		  : (__typeof__ (0 ? (__intptr_t *) 0 : (void *) (!(P)))) 0))
-
-/* __intptr_t if EXPR has a pointer type, or the type of EXPR otherwise.  */
-# define __integer_if_pointer_type(expr) \
-  __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \
-				__pointer_type (__typeof__ (expr)))
-
-/* Cast an integer or a pointer VAL to integer with proper type.  */
-# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
-
-/* Align a value by rounding down to closest size.
-   e.g. Using size of 4096, we get this behavior:
-	{4095, 4096, 4097} = {0, 4096, 4096}.  */
-#define ALIGN_DOWN(base, size)	((base) & -((__typeof__ (base)) (size)))
-
-/* Align a value by rounding up to closest size.
-   e.g. Using size of 4096, we get this behavior:
-	{4095, 4096, 4097} = {4096, 4096, 8192}.
-
-  Note: The size argument has side effects (expanded multiple times).  */
-#define ALIGN_UP(base, size)	ALIGN_DOWN ((base) + (size) - 1, (size))
-
-/* Same as ALIGN_DOWN(), but automatically casts when base is a pointer.  */
-#define PTR_ALIGN_DOWN(base, size) \
-  ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size)))
-
-/* Same as ALIGN_UP(), but automatically casts when base is a pointer.  */
-#define PTR_ALIGN_UP(base, size) \
-  ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size)))
-
-#include <libc-diag.h>
-
 #endif /* _LIBC_INTERNAL  */
diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h
new file mode 100644
index 0000000000..715cbc1bbe
--- /dev/null
+++ b/include/libc-pointer-arith.h
@@ -0,0 +1,60 @@
+/* Helper macros for pointer arithmetic.
+   Copyright (C) 2012-2017 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 _LIBC_POINTER_ARITH_H
+#define _LIBC_POINTER_ARITH_H 1
+
+#include <stdint.h>
+
+/* 1 if 'type' is a pointer type, 0 otherwise.  */
+# define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5)
+
+/* intptr_t if P is true, or T if P is false.  */
+# define __integer_if_pointer_type_sub(T, P) \
+  __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \
+		  : (__typeof__ (0 ? (intptr_t *) 0 : (void *) (!(P)))) 0))
+
+/* intptr_t if EXPR has a pointer type, or the type of EXPR otherwise.  */
+# define __integer_if_pointer_type(expr) \
+  __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \
+				__pointer_type (__typeof__ (expr)))
+
+/* Cast an integer or a pointer VAL to integer with proper type.  */
+# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
+
+/* Align a value by rounding down to closest size.
+   e.g. Using size of 4096, we get this behavior:
+	{4095, 4096, 4097} = {0, 4096, 4096}.  */
+#define ALIGN_DOWN(base, size)	((base) & -((__typeof__ (base)) (size)))
+
+/* Align a value by rounding up to closest size.
+   e.g. Using size of 4096, we get this behavior:
+	{4095, 4096, 4097} = {4096, 4096, 8192}.
+
+  Note: The size argument has side effects (expanded multiple times).  */
+#define ALIGN_UP(base, size)	ALIGN_DOWN ((base) + (size) - 1, (size))
+
+/* Same as ALIGN_DOWN(), but automatically casts when base is a pointer.  */
+#define PTR_ALIGN_DOWN(base, size) \
+  ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size)))
+
+/* Same as ALIGN_UP(), but automatically casts when base is a pointer.  */
+#define PTR_ALIGN_UP(base, size) \
+  ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size)))
+
+#endif
diff --git a/io/openat.c b/io/openat.c
index c54ee34678..529f418da2 100644
--- a/io/openat.c
+++ b/io/openat.c
@@ -22,7 +22,6 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <kernel-features.h>
-#include <libc-internal.h>
 
 /* Some mostly-generic code (e.g. sysdeps/posix/getcwd.c) uses this variable
    if __ASSUME_ATFCTS is not defined.  */
diff --git a/io/openat64.c b/io/openat64.c
index 2f564b51f0..116becda98 100644
--- a/io/openat64.c
+++ b/io/openat64.c
@@ -21,7 +21,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <sys/stat.h>
-#include <libc-internal.h>
 
 /* Open FILE with access OFLAG.  Interpret relative paths relative to
    the directory associated with FD.  If O_CREAT or O_TMPFILE is in OFLAG, a
diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
index 13c4e9ee42..f67b7b8d99 100644
--- a/locale/programs/locarchive.c
+++ b/locale/programs/locarchive.c
@@ -40,8 +40,8 @@
 #include <sys/shm.h>
 #include <sys/stat.h>
 
-#include <libc-internal.h>
 #include <libc-mmap.h>
+#include <libc-pointer-arith.h>
 #include "../../crypt/md5.h"
 #include "../localeinfo.h"
 #include "../locarchive.h"
diff --git a/locale/weight.h b/locale/weight.h
index f4797180d1..0558123f34 100644
--- a/locale/weight.h
+++ b/locale/weight.h
@@ -19,7 +19,7 @@
 #ifndef _WEIGHT_H_
 #define _WEIGHT_H_	1
 
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* Find index of weight.  */
 static inline int32_t __attribute__ ((always_inline))
diff --git a/locale/weightwc.h b/locale/weightwc.h
index 6a726aa86b..97ce2b3dec 100644
--- a/locale/weightwc.h
+++ b/locale/weightwc.h
@@ -19,7 +19,7 @@
 #ifndef _WEIGHTWC_H_
 #define _WEIGHTWC_H_	1
 
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* Find index of weight.  */
 static inline int32_t __attribute__ ((always_inline))
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 4885793905..e29105c372 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -237,7 +237,7 @@
 #include <sys/param.h>
 
 /* For ALIGN_UP et. al.  */
-#include <libc-internal.h>
+#include <libc-pointer-arith.h>
 
 #include <malloc/malloc-internal.h>
 
diff --git a/misc/ptrace.c b/misc/ptrace.c
index 06356c9c92..aace1b5a34 100644
--- a/misc/ptrace.c
+++ b/misc/ptrace.c
@@ -19,7 +19,6 @@
 #include <sys/ptrace.h>
 #include <sys/types.h>
 #include <stdarg.h>
-#include <libc-internal.h>
 
 /* Perform process tracing functions.  REQUEST is one of the values
    in <sys/ptrace.h>, and determines the action to be taken.
diff --git a/misc/reboot.c b/misc/reboot.c
index 86b0a50d65..70549c41b7 100644
--- a/misc/reboot.c
+++ b/misc/reboot.c
@@ -18,7 +18,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <sys/reboot.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* Reboot the system.  */
 int
diff --git a/nis/nis_table.c b/nis/nis_table.c
index c0b05db819..caf3e6af43 100644
--- a/nis/nis_table.c
+++ b/nis/nis_table.c
@@ -19,7 +19,7 @@
 #include <assert.h>
 #include <string.h>
 #include <rpcsvc/nis.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 #include "nis_xdr.h"
 #include "nis_intern.h"
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 2f8599b391..29216077a2 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -36,7 +36,7 @@
 #include <lowlevellock.h>
 #include <futex-internal.h>
 #include <kernel-features.h>
-#include <libc-internal.h>
+#include <libc-pointer-arith.h>
 #include <pthread-pids.h>
 
 #ifndef TLS_MULTIPLE_THREADS_IN_TCB
diff --git a/nptl/pthread_clock_gettime.c b/nptl/pthread_clock_gettime.c
index e3a82f7e6a..c9abb61540 100644
--- a/nptl/pthread_clock_gettime.c
+++ b/nptl/pthread_clock_gettime.c
@@ -18,7 +18,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <time.h>
-#include <libc-internal.h>
 #include "pthreadP.h"
 
 
diff --git a/nptl/pthread_clock_settime.c b/nptl/pthread_clock_settime.c
index 6aeb3bece0..f2722d9635 100644
--- a/nptl/pthread_clock_settime.c
+++ b/nptl/pthread_clock_settime.c
@@ -18,7 +18,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <time.h>
-#include <libc-internal.h>
 #include "pthreadP.h"
 
 
diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c
index 7c63ef9b89..ffbbde4106 100644
--- a/nptl/pthread_cond_common.c
+++ b/nptl/pthread_cond_common.c
@@ -19,7 +19,6 @@
 #include <atomic.h>
 #include <stdint.h>
 #include <pthread.h>
-#include <libc-internal.h>
 
 /* We need 3 least-significant bits on __wrefs for something else.  */
 #define __PTHREAD_COND_MAX_GROUP_SIZE ((unsigned) 1 << 29)
diff --git a/nptl_db/thread_dbP.h b/nptl_db/thread_dbP.h
index d359e79f72..c88ee2923f 100644
--- a/nptl_db/thread_dbP.h
+++ b/nptl_db/thread_dbP.h
@@ -30,7 +30,7 @@
 #include "../nptl/pthreadP.h"  	/* This is for *_BITMASK only.  */
 #include <list.h>
 #include <gnu/lib-names.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* Indeces for the symbol names.  */
 enum
diff --git a/nscd/connections.c b/nscd/connections.c
index 26d2c0091b..205ff423de 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -59,7 +59,7 @@
 #include <resolv/resolv.h>
 
 #include <kernel-features.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 
 /* Support to run nscd as an unprivileged user */
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
index 15eb233001..17ae812346 100644
--- a/posix/wordexp-test.c
+++ b/posix/wordexp-test.c
@@ -22,10 +22,11 @@
 #include <unistd.h>
 #include <pwd.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <wordexp.h>
-#include <libc-internal.h>
+#include <libc-pointer-arith.h>
 
 #define IFS " \n\t"
 
diff --git a/resolv/res_send.c b/resolv/res_send.c
index 93db5b9a61..28c4cabfcb 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -108,7 +108,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <kernel-features.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 #if PACKETSZ > 65536
 #define MAXPACKET       PACKETSZ
diff --git a/soft-fp/fmadf4.c b/soft-fp/fmadf4.c
index 7b7342b2e2..74e2360eb7 100644
--- a/soft-fp/fmadf4.c
+++ b/soft-fp/fmadf4.c
@@ -25,8 +25,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <libc-internal.h>
-#include <sys/cdefs.h>
+#include <math.h>
+#include <libc-diag.h>
+
 /* R_e is not set in cases where it is not used in packing, but the
    compiler does not see that it is set in all cases where it is
    used, resulting in warnings that it may be used uninitialized.
@@ -35,7 +36,7 @@
    macro is defined.  */
 DIAG_PUSH_NEEDS_COMMENT;
 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmaybe-uninitialized");
-#include <math.h>
+
 #include "soft-fp.h"
 #include "double.h"
 
diff --git a/soft-fp/fmasf4.c b/soft-fp/fmasf4.c
index 20c0ca8f5a..2d3120eda9 100644
--- a/soft-fp/fmasf4.c
+++ b/soft-fp/fmasf4.c
@@ -25,8 +25,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <libc-internal.h>
-#include <sys/cdefs.h>
+#include <math.h>
+#include <libc-diag.h>
+
 /* R_e is not set in cases where it is not used in packing, but the
    compiler does not see that it is set in all cases where it is
    used, resulting in warnings that it may be used uninitialized.
@@ -35,7 +36,7 @@
    macro is defined.  */
 DIAG_PUSH_NEEDS_COMMENT;
 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmaybe-uninitialized");
-#include <math.h>
+
 #include "soft-fp.h"
 #include "single.h"
 
diff --git a/soft-fp/fmatf4.c b/soft-fp/fmatf4.c
index d3a4ee4dc0..553a7ad3f8 100644
--- a/soft-fp/fmatf4.c
+++ b/soft-fp/fmatf4.c
@@ -25,8 +25,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <libc-internal.h>
-#include <sys/cdefs.h>
+#include <math.h>
+#include <libc-diag.h>
+
 /* R_e is not set in cases where it is not used in packing, but the
    compiler does not see that it is set in all cases where it is
    used, resulting in warnings that it may be used uninitialized.
@@ -35,7 +36,7 @@
    macro is defined.  */
 DIAG_PUSH_NEEDS_COMMENT;
 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmaybe-uninitialized");
-#include <math.h>
+
 #include "soft-fp.h"
 #include "quad.h"
 
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 214dab469d..1adf27e11b 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <wchar.h>
 #include <wctype.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 #include <libc-lock.h>
 #include <locale/localeinfo.h>
 #include <scratch_buffer.h>
diff --git a/string/strcoll_l.c b/string/strcoll_l.c
index 7e8fbf3895..8fd55b000a 100644
--- a/string/strcoll_l.c
+++ b/string/strcoll_l.c
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <string.h>
 #include <sys/param.h>
-#include <libc-internal.h>
 
 #ifndef STRING_TYPE
 # define STRING_TYPE char
diff --git a/string/strcspn.c b/string/strcspn.c
index 06299e2098..1035552a8e 100644
--- a/string/strcspn.c
+++ b/string/strcspn.c
@@ -17,7 +17,7 @@
 
 #include <string.h>
 #include <stdint.h>
-#include <libc-internal.h>
+#include <libc-pointer-arith.h>
 
 #undef strcspn
 
diff --git a/string/strspn.c b/string/strspn.c
index a7fec70c65..c63197cdf0 100644
--- a/string/strspn.c
+++ b/string/strspn.c
@@ -17,7 +17,7 @@
 
 #include <string.h>
 #include <stdint.h>
-#include <libc-internal.h>
+#include <libc-pointer-arith.h>
 
 #undef strspn
 #ifndef STRSPN
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
index 2500c82305..04dc6aef91 100644
--- a/sysdeps/i386/nptl/tls.h
+++ b/sysdeps/i386/nptl/tls.h
@@ -26,7 +26,7 @@
 # include <stdint.h>
 # include <stdlib.h>
 # include <sysdep.h>
-# include <libc-internal.h>
+# include <libc-pointer-arith.h> /* For cast_to_integer. */
 # include <kernel-features.h>
 # include <dl-dtv.h>
 
diff --git a/sysdeps/ieee754/dbl-64/e_lgamma_r.c b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
index c337679f7c..b5860d8a24 100644
--- a/sysdeps/ieee754/dbl-64/e_lgamma_r.c
+++ b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
@@ -77,9 +77,9 @@
  *
  */
 
-#include <libc-internal.h>
 #include <math.h>
 #include <math_private.h>
+#include <libc-diag.h>
 
 static const double
 two52=  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index d853b65a05..2b5add6976 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -132,7 +132,7 @@ static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $
 
 #include <math.h>
 #include <math_private.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
 
diff --git a/sysdeps/ieee754/flt-32/e_lgammaf_r.c b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
index 1bd2122663..1b30dcd84d 100644
--- a/sysdeps/ieee754/flt-32/e_lgammaf_r.c
+++ b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
@@ -13,9 +13,9 @@
  * ====================================================
  */
 
-#include <libc-internal.h>
 #include <math.h>
 #include <math_private.h>
+#include <libc-diag.h>
 
 static const float
 two23=  8.3886080000e+06, /* 0x4b000000 */
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 52ffb09f0e..a8d5b216e6 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -19,7 +19,7 @@ static char rcsid[] = "$NetBSD: k_rem_pio2f.c,v 1.4 1995/05/10 20:46:28 jtc Exp
 
 #include <math.h>
 #include <math_private.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* In the float version, the input parameter x contains 8 bit
    integers, not 24 bit integers.  113 bit precision is not supported.  */
diff --git a/sysdeps/ieee754/ldbl-128/k_tanl.c b/sysdeps/ieee754/ldbl-128/k_tanl.c
index dc9c457f6a..e79023c69a 100644
--- a/sysdeps/ieee754/ldbl-128/k_tanl.c
+++ b/sysdeps/ieee754/ldbl-128/k_tanl.c
@@ -57,9 +57,10 @@
  */
 
 #include <float.h>
-#include <libc-internal.h>
 #include <math.h>
 #include <math_private.h>
+#include <libc-diag.h>
+
 static const _Float128
   one = 1,
   pio4hi = L(7.8539816339744830961566084581987569936977E-1),
diff --git a/sysdeps/ieee754/ldbl-128ibm/k_tanl.c b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c
index 3c1bf32af9..232e00c345 100644
--- a/sysdeps/ieee754/ldbl-128ibm/k_tanl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c
@@ -57,9 +57,10 @@
  */
 
 #include <float.h>
-#include <libc-internal.h>
 #include <math.h>
 #include <math_private.h>
+#include <libc-diag.h>
+
 static const long double
   one = 1.0L,
   pio4hi = 7.8539816339744830961566084581987569936977E-1L,
diff --git a/sysdeps/ieee754/ldbl-96/e_lgammal_r.c b/sysdeps/ieee754/ldbl-96/e_lgammal_r.c
index 9862fe8d5c..4ecd63045f 100644
--- a/sysdeps/ieee754/ldbl-96/e_lgammal_r.c
+++ b/sysdeps/ieee754/ldbl-96/e_lgammal_r.c
@@ -91,9 +91,9 @@
  *
  */
 
-#include <libc-internal.h>
 #include <math.h>
 #include <math_private.h>
+#include <libc-diag.h>
 
 static const long double
   half = 0.5L,
diff --git a/sysdeps/ieee754/ldbl-96/k_tanl.c b/sysdeps/ieee754/ldbl-96/k_tanl.c
index 0c050c112f..f8641d5ce4 100644
--- a/sysdeps/ieee754/ldbl-96/k_tanl.c
+++ b/sysdeps/ieee754/ldbl-96/k_tanl.c
@@ -57,9 +57,10 @@
  */
 
 #include <float.h>
-#include <libc-internal.h>
 #include <math.h>
 #include <math_private.h>
+#include <libc-diag.h>
+
 static const long double
   one = 1.0L,
   pio4hi = 0xc.90fdaa22168c235p-4L,
diff --git a/sysdeps/nacl/brk.c b/sysdeps/nacl/brk.c
index 15e0c4fdfe..c96c66f3b8 100644
--- a/sysdeps/nacl/brk.c
+++ b/sysdeps/nacl/brk.c
@@ -17,7 +17,6 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <libc-internal.h>
 #include <stdint.h>
 #include <sys/mman.h>
 #include <sys/param.h>
diff --git a/sysdeps/nacl/dl-map-segments.h b/sysdeps/nacl/dl-map-segments.h
index 501d8be6ec..ab2ad43838 100644
--- a/sysdeps/nacl/dl-map-segments.h
+++ b/sysdeps/nacl/dl-map-segments.h
@@ -16,12 +16,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _NACL_DL_MAP_SEGMENTS_H
+#define _NACL_DL_MAP_SEGMENTS_H 1
+
 #include <assert.h>
 #include <dl-load.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <unistd.h>
-#include <libc-internal.h>
+#include <libc-pointer-arith.h>
 
 
 /* This is basically pread, but with iteration after short reads.  */
@@ -262,3 +265,5 @@ _dl_map_segments (struct link_map *l, int fd,
 
   return NULL;
 }
+
+#endif /* dl-map-segments.h */
diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h
index 532d47d6a3..be7a33f460 100644
--- a/sysdeps/nptl/futex-internal.h
+++ b/sysdeps/nptl/futex-internal.h
@@ -23,7 +23,7 @@
 #include <sys/time.h>
 #include <stdio.h>
 #include <stdbool.h>
-#include <libc-internal.h>
+#include <libc-diag.h>
 
 /* This file defines futex operations used internally in glibc.  A futex
    consists of the so-called futex word in userspace, which is of type
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
index 957a4b1599..e744cae6a9 100644
--- a/sysdeps/unix/clock_settime.c
+++ b/sysdeps/unix/clock_settime.c
@@ -18,7 +18,6 @@
 #include <errno.h>
 #include <time.h>
 #include <sys/time.h>
-#include <libc-internal.h>
 #include <ldsodefs.h>
 
 
diff --git a/sysdeps/unix/sysv/linux/i386/get_clockfreq.c b/sysdeps/unix/sysv/linux/i386/get_clockfreq.c
index bee3fe84e5..88e14b5f04 100644
--- a/sysdeps/unix/sysv/linux/i386/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/i386/get_clockfreq.c
@@ -20,8 +20,6 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
-#include <libc-internal.h>
-
 
 hp_timing_t
 __get_clockfreq (void)
diff --git a/sysdeps/unix/sysv/linux/ia64/get_clockfreq.c b/sysdeps/unix/sysv/linux/ia64/get_clockfreq.c
index 5dd9c01261..603c7d516e 100644
--- a/sysdeps/unix/sysv/linux/ia64/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/ia64/get_clockfreq.c
@@ -20,7 +20,6 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
-#include <libc-internal.h>
 
 
 hp_timing_t
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
index ad1622d601..b8d01d8ca6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
@@ -21,7 +21,6 @@
 #include <stdint.h>
 #include <string.h>
 #include <unistd.h>
-#include <libc-internal.h>
 #include <sysdep.h>
 #include <libc-vdso.h>
 #include <not-cancel.h>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c b/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
index dc9ba695bb..a0349790dc 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
@@ -24,7 +24,6 @@
 #include <stdlib.h>
 #include <inttypes.h>
 #include <sys/ioctl.h>
-#include <libc-internal.h>
 #include <asm/openpromio.h>
 
 static hp_timing_t
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index 2daf0c5ef0..24f75dbd9c 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -30,8 +30,8 @@
 #include <shlib-compat.h>
 #include <nptl/pthreadP.h>
 #include <dl-sysdep.h>
+#include <libc-pointer-arith.h>
 #include <ldsodefs.h>
-#include <libc-internal.h>
 #include "spawn_int.h"
 
 /* The Linux implementation of posix_spawn{p} uses the clone syscall directly
diff --git a/sysdeps/x86_64/atomic-machine.h b/sysdeps/x86_64/atomic-machine.h
index 672a7eb025..2e8a9aad04 100644
--- a/sysdeps/x86_64/atomic-machine.h
+++ b/sysdeps/x86_64/atomic-machine.h
@@ -16,10 +16,12 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <stdint.h>
-#include <tls.h>	/* For tcbhead_t.  */
-#include <libc-internal.h>
+#ifndef _X86_64_ATOMIC_MACHINE_H
+#define _X86_64_ATOMIC_MACHINE_H 1
 
+#include <stdint.h>
+#include <tls.h>                   /* For tcbhead_t.  */
+#include <libc-pointer-arith.h>    /* For cast_to_integer.  */
 
 typedef int8_t atomic8_t;
 typedef uint8_t uatomic8_t;
@@ -475,3 +477,5 @@ typedef uintmax_t uatomic_max_t;
     __asm __volatile (LOCK_PREFIX "orl $0, (%%rsp)" ::: "memory")
 #define atomic_read_barrier() __asm ("" ::: "memory")
 #define atomic_write_barrier() __asm ("" ::: "memory")
+
+#endif /* atomic-machine.h */
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
index f2afe85602..53b41bc84f 100644
--- a/sysdeps/x86_64/nptl/tls.h
+++ b/sysdeps/x86_64/nptl/tls.h
@@ -26,7 +26,7 @@
 # include <stdint.h>
 # include <stdlib.h>
 # include <sysdep.h>
-# include <libc-internal.h>
+# include <libc-pointer-arith.h> /* For cast_to_integer.  */
 # include <kernel-features.h>
 # include <dl-dtv.h>
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes.
  2017-02-20 15:13         ` Carlos O'Donell
  2017-02-20 15:32           ` Zack Weinberg
@ 2017-02-27 13:34           ` Zack Weinberg
  2017-03-01 18:17             ` Carlos O'Donell
  1 sibling, 1 reply; 30+ messages in thread
From: Zack Weinberg @ 2017-02-27 13:34 UTC (permalink / raw)
  To: Carlos O'Donell, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/20/2017 10:13 AM, Carlos O'Donell wrote:
> On 02/20/2017 08:03 AM, Zack Weinberg wrote:
>> This is the main change, adding a new build module called 'testsuite'.
>> IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
>> (which means several ad-hoc tests for __cplusplus can go away).
>> libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
>> defined; in particular, _ISOMAC mode does not get config.h
>> automatically anymore.

I'm going through your low-level comments now; here are a few notes.
I'll post a revised patch later today, or tomorrow.

> - Fix tst-dladdr by removing DL_LOOKUP_ADDRESS usage and keeping it in
>   tests instead of tests-internal. I think this test should be as close
>   to a real application as possible.

Just to be sure that I understand the change you have in mind here: is
this right?

--- a/dlfcn/tst-dladdr.c
+++ b/dlfcn/tst-dladdr.c
@@ -24,8 +24,6 @@
 #include <stdlib.h>
 #include <string.h>

-#include <ldsodefs.h>
-

 #define TEST_FUNCTION do_test ()
 extern int do_test (void);
@@ -53,8 +51,6 @@ do_test (void)
   if (ret == 0)
     error (EXIT_FAILURE, 0, "dladdr failed");

-  printf ("address of ref1 = %lx\n",
-         (unsigned long int)  DL_LOOKUP_ADDRESS (sym));
   printf ("ret = %d\n", ret);
   printf ("info.dli_fname = %p (\"%s\")\n", info.dli_fname,
info.dli_fname);
   printf ("info.dli_fbase = %p\n", info.dli_fbase);


> - Please carry out a built artifact comparison to ensure the IS_IN
>   changes did not change any code generation in the library. Minimally
>   x86_64 and one other architecture of your choice.

Will do.

> - The include/stdio.h change needs a detailed comment about why we undef 
>   _IO_MTSAFE_IO.

Eegh, that's complicated.  Rather than add a comment, I am going to
simplify the situation.

_IO_MTSAFE_IO is only ever defined during the build of glibc itself, and
it does not change the public API or ABI.  There are two uses in
libio.h, which is a public header.  One changes the definitions of a
handful of internal-use-only _IO_* macros.  The other controls whether
libio.h defines _IO_lock_t itself (as an incomplete type) or leaves it
to stdio-lock.h (which is a non-installed header).  Unfortunately, some
versions of stdio-lock.h can only define _IO_lock_t as a typedef, so we
have to have the ability for libio.h not to do it at all.

What I'm going to do is remove the internal-use-only _IO_* macros to
include/libio.h, and invent a new macro _IO_lock_t_defined which all
versions of stdio-lock.h will define; libio.h will define the stub
_IO_lock_t if that macro is not defined, with a comment explaining that
this is only relevant when building glibc itself.  Then there will be no
uses of _IO_MTSAFE_IO in public headers, and it won't be necessary to
undefine it in include/stdio.h.

>> +    $(tests) $(tests-internal) $(xtests) $(test-srcs))): \
>> +	$(objpfx)libpthread.so \
>> +	$(objpfx)libpthread_nonshared.a
>
> Why doesn't this use $(shared-thread-library)?

It was that way when I got here, and I don't actually see any code that
*sets* $(shared-thread-library) anywhere in the Makefiles, so I can't
confirm that it'd be the same thing.

> - Why is tst-cancel-getpwuid_r in tests-internal? It was designed to be
>   a standalone cancellation test.

It calls __nss_configure_lookup.  I didn't look very hard when I saw
that - I see now that nss.h does count as a public header, so I'll
change it back.

> - New test stdlib/tst-strtod1i.c should use new support/ test infrastructure.
> 
> - New test stdlib/tst-strtod5i.c needs a copyright header and should use
>   new support/ test infrastructure.

Will do.  I am also going to make those changes to the tests they were
cloned from (tst-strtod.c and tst-strtod5.c).

zw

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes.
  2017-02-27 13:34           ` Zack Weinberg
@ 2017-03-01 18:17             ` Carlos O'Donell
  2017-03-01 18:48               ` Zack Weinberg
  0 siblings, 1 reply; 30+ messages in thread
From: Carlos O'Donell @ 2017-03-01 18:17 UTC (permalink / raw)
  To: Zack Weinberg, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/27/2017 08:34 AM, Zack Weinberg wrote:
> On 02/20/2017 10:13 AM, Carlos O'Donell wrote:
>> On 02/20/2017 08:03 AM, Zack Weinberg wrote:
>>> This is the main change, adding a new build module called 'testsuite'.
>>> IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
>>> (which means several ad-hoc tests for __cplusplus can go away).
>>> libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
>>> defined; in particular, _ISOMAC mode does not get config.h
>>> automatically anymore.
> 
> I'm going through your low-level comments now; here are a few notes.
> I'll post a revised patch later today, or tomorrow.
> 
>> - Fix tst-dladdr by removing DL_LOOKUP_ADDRESS usage and keeping it in
>>   tests instead of tests-internal. I think this test should be as close
>>   to a real application as possible.
> 
> Just to be sure that I understand the change you have in mind here: is
> this right?
> 
> --- a/dlfcn/tst-dladdr.c
> +++ b/dlfcn/tst-dladdr.c
> @@ -24,8 +24,6 @@
>  #include <stdlib.h>
>  #include <string.h>
> 
> -#include <ldsodefs.h>
> -
> 
>  #define TEST_FUNCTION do_test ()
>  extern int do_test (void);
> @@ -53,8 +51,6 @@ do_test (void)
>    if (ret == 0)
>      error (EXIT_FAILURE, 0, "dladdr failed");
> 
> -  printf ("address of ref1 = %lx\n",
> -         (unsigned long int)  DL_LOOKUP_ADDRESS (sym));
>    printf ("ret = %d\n", ret);
>    printf ("info.dli_fname = %p (\"%s\")\n", info.dli_fname,
> info.dli_fname);
>    printf ("info.dli_fbase = %p\n", info.dli_fbase);

Yes. Exactly.

> 
>> - Please carry out a built artifact comparison to ensure the IS_IN
>>   changes did not change any code generation in the library. Minimally
>>   x86_64 and one other architecture of your choice.
> 
> Will do.
 
OK.

> - The include/stdio.h change needs a detailed comment about why we undef 
>>   _IO_MTSAFE_IO.
> 
> Eegh, that's complicated.  Rather than add a comment, I am going to
> simplify the situation.
> 
> _IO_MTSAFE_IO is only ever defined during the build of glibc itself, and
> it does not change the public API or ABI.  There are two uses in
> libio.h, which is a public header.  One changes the definitions of a
> handful of internal-use-only _IO_* macros.  The other controls whether
> libio.h defines _IO_lock_t itself (as an incomplete type) or leaves it
> to stdio-lock.h (which is a non-installed header).  Unfortunately, some
> versions of stdio-lock.h can only define _IO_lock_t as a typedef, so we
> have to have the ability for libio.h not to do it at all.
> 
> What I'm going to do is remove the internal-use-only _IO_* macros to
> include/libio.h, and invent a new macro _IO_lock_t_defined which all
> versions of stdio-lock.h will define; libio.h will define the stub
> _IO_lock_t if that macro is not defined, with a comment explaining that
> this is only relevant when building glibc itself.  Then there will be no
> uses of _IO_MTSAFE_IO in public headers, and it won't be necessary to
> undefine it in include/stdio.h.

OK, make sure we don't break old libstdc++ here, which I vaguely remember
was tied into this macro and stdio-lock.h.

>>> +    $(tests) $(tests-internal) $(xtests) $(test-srcs))): \
>>> +	$(objpfx)libpthread.so \
>>> +	$(objpfx)libpthread_nonshared.a
>>
>> Why doesn't this use $(shared-thread-library)?
> 
> It was that way when I got here, and I don't actually see any code that
> *sets* $(shared-thread-library) anywhere in the Makefiles, so I can't
> confirm that it'd be the same thing.

sysdeps/nptl/Makeconfig:

have-thread-library = yes

shared-thread-library = $(common-objpfx)nptl/libpthread_nonshared.a \
                        $(common-objpfx)nptl/libpthread.so
static-thread-library = $(common-objpfx)nptl/libpthread.a

rpath-dirs += nptl

>> - Why is tst-cancel-getpwuid_r in tests-internal? It was designed to be
>>   a standalone cancellation test.
> 
> It calls __nss_configure_lookup.  I didn't look very hard when I saw
> that - I see now that nss.h does count as a public header, so I'll
> change it back.

Right, it's in the implementation namespace but it's actually a public API
that special programs use to get around bootstrap issues.

>> - New test stdlib/tst-strtod1i.c should use new support/ test infrastructure.
>>
>> - New test stdlib/tst-strtod5i.c needs a copyright header and should use
>>   new support/ test infrastructure.
> 
> Will do.  I am also going to make those changes to the tests they were
> cloned from (tst-strtod.c and tst-strtod5.c).

Thanks for that too.

-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-27  1:38             ` Zack Weinberg
@ 2017-03-01 18:22               ` Carlos O'Donell
  2017-03-02 13:57               ` Andreas Schwab
  1 sibling, 0 replies; 30+ messages in thread
From: Carlos O'Donell @ 2017-03-01 18:22 UTC (permalink / raw)
  To: Zack Weinberg, Florian Weimer
  Cc: GNU C Library, Joseph Myers, Adhemerval Zanella

On 02/26/2017 08:37 PM, Zack Weinberg wrote:
> On Sat, Feb 25, 2017 at 4:06 PM, Florian Weimer <fw@deneb.enyo.de> wrote:
>> * Zack Weinberg:
>>
>>> wordexp-test.c is currently not even using the old test skeleton, and
>>> does some fairly hairy things with fork handlers.  I would prefer not to
>>> go down a rabbit hole.  Instead I propose to do something similar to
>>> what I did for the DIAG_* macros: introduce a new header in include/
>>> called libc-pointer-arith.h; move cast_to_integer, ALIGN_UP, ALIGN_DOWN,
>>> PTR_ALIGN_UP, and PTR_ALIGN_DOWN there; have libc-internal.h include it;
>>> have wordexp-test.c include it instead of libc-internal.h; and call that
>>> good enough for now.  OK?
>>
>> If we move into that direction, can we also replace #include
>> <libc-internal.h> in sysdeps/x86_64/nptl/tls.h?
>>
>> I think this is one major cause why things compile on x86-64, but not
>> other architectures.
> 
> I looked into that, and it turns out that the users of libc-internal.h
> divide neatly into four classes: those that want the DIAG_* macros,
> those that want the ALIGN macros, those that want the other stuff
> (mostly early init), and those that don't need it at all.  See
> attached - not quite fully baked but does pass many-glibcs tests.  I'm
> not sure you're going to get your wish, because x86/nptl/tls.h does
> need to keep including libc-pointer-arith.h, and the #1 cause of
> failures in many-glibcs that I didn't see in a regular x86-64 build
> was ... needing to include libc-pointer-arith.h.  But this still seems
> like a good cleanup.

This looks good to me.

-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes.
  2017-03-01 18:17             ` Carlos O'Donell
@ 2017-03-01 18:48               ` Zack Weinberg
  2017-03-01 19:21                 ` Carlos O'Donell
  0 siblings, 1 reply; 30+ messages in thread
From: Zack Weinberg @ 2017-03-01 18:48 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: GNU C Library, Joseph Myers, Adhemerval Zanella

On Wed, Mar 1, 2017 at 1:17 PM, Carlos O'Donell <carlos@redhat.com> wrote:
> On 02/27/2017 08:34 AM, Zack Weinberg wrote:
>>
>> I'm going through your low-level comments now; here are a few notes.
>> I'll post a revised patch later today, or tomorrow.

FYI, a lot of the changes you requested got reshuffled into the
preparation patchset I posted this morning.  I have revised the core
change as well but I'm not going to post it until I do the built
artifact comparison, which I may not have time for till the weekend.

>> What I'm going to do is remove the internal-use-only _IO_* macros to
>> include/libio.h, and invent a new macro _IO_lock_t_defined which all
>> versions of stdio-lock.h will define; libio.h will define the stub
>> _IO_lock_t if that macro is not defined, with a comment explaining that
>> this is only relevant when building glibc itself.  Then there will be no
>> uses of _IO_MTSAFE_IO in public headers, and it won't be necessary to
>> undefine it in include/stdio.h.
>
> OK, make sure we don't break old libstdc++ here, which I vaguely remember
> was tied into this macro and stdio-lock.h.

I'll do some archaeology and find out for sure, but I _think_ that has
not been relevant since before libstdc++-v3 (so we're going all the
way back to the EGCS period).  Moreover, we do not install
stdio-lock.h; any external software that attempts to define
_IO_MTSAFE_IO without supplying a definition of _IO_lock_t will fail
to compile, and do we really want to support software that provides
its own definition of _IO_lock_t?

>>>> +    $(tests) $(tests-internal) $(xtests) $(test-srcs))): \
>>>> +   $(objpfx)libpthread.so \
>>>> +   $(objpfx)libpthread_nonshared.a
>>>
>>> Why doesn't this use $(shared-thread-library)?
>>
>> It was that way when I got here, and I don't actually see any code that
>> *sets* $(shared-thread-library) anywhere in the Makefiles, so I can't
>> confirm that it'd be the same thing.
>
> sysdeps/nptl/Makeconfig:

Oh ghod, you mean to tell me subdirectories can have Makeconfig fragments too?

> shared-thread-library = $(common-objpfx)nptl/libpthread_nonshared.a \
>                         $(common-objpfx)nptl/libpthread.so

That's in the opposite order from the opencoded sequence in
nptl/Makefile.  Are we sure it doesn't matter?

zw

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes.
  2017-03-01 18:48               ` Zack Weinberg
@ 2017-03-01 19:21                 ` Carlos O'Donell
  0 siblings, 0 replies; 30+ messages in thread
From: Carlos O'Donell @ 2017-03-01 19:21 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: GNU C Library, Joseph Myers, Adhemerval Zanella

On 03/01/2017 01:48 PM, Zack Weinberg wrote:
> On Wed, Mar 1, 2017 at 1:17 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>> On 02/27/2017 08:34 AM, Zack Weinberg wrote:
>>>
>>> I'm going through your low-level comments now; here are a few notes.
>>> I'll post a revised patch later today, or tomorrow.
> 
> FYI, a lot of the changes you requested got reshuffled into the
> preparation patchset I posted this morning.  I have revised the core
> change as well but I'm not going to post it until I do the built
> artifact comparison, which I may not have time for till the weekend.

Thanks. Saw that and replied already.

>>> What I'm going to do is remove the internal-use-only _IO_* macros to
>>> include/libio.h, and invent a new macro _IO_lock_t_defined which all
>>> versions of stdio-lock.h will define; libio.h will define the stub
>>> _IO_lock_t if that macro is not defined, with a comment explaining that
>>> this is only relevant when building glibc itself.  Then there will be no
>>> uses of _IO_MTSAFE_IO in public headers, and it won't be necessary to
>>> undefine it in include/stdio.h.
>>
>> OK, make sure we don't break old libstdc++ here, which I vaguely remember
>> was tied into this macro and stdio-lock.h.
> 
> I'll do some archaeology and find out for sure, but I _think_ that has
> not been relevant since before libstdc++-v3 (so we're going all the
> way back to the EGCS period).  Moreover, we do not install
> stdio-lock.h; any external software that attempts to define
> _IO_MTSAFE_IO without supplying a definition of _IO_lock_t will fail
> to compile, and do we really want to support software that provides
> its own definition of _IO_lock_t?

OK, I just reviewed this on our side.

In RHEL7 (glibc 2.17) we install stdio-lock.h because we need to build
our ancient compat versions of the compiler e.g. GCC-2.95.3:
~~~
# NPTL <bits/stdio-lock.h> is not usable outside of glibc, so include
# the generic one (#162634)
cp -a bits/stdio-lock.h $RPM_BUILD_ROOT%{_prefix}/include/bits/stdio-lock.h
# And <bits/libc-lock.h> needs sanitizing as well.
cp -a releng/libc-lock.h $RPM_BUILD_ROOT%{_prefix}/include/bits/libc-lock.h
~~~

I recently removed this requirement from Fedora and forced the old gcc package
to carry it's own copies of the headers to use during builds.

>>>>> +    $(tests) $(tests-internal) $(xtests) $(test-srcs))): \
>>>>> +   $(objpfx)libpthread.so \
>>>>> +   $(objpfx)libpthread_nonshared.a
>>>>
>>>> Why doesn't this use $(shared-thread-library)?
>>>
>>> It was that way when I got here, and I don't actually see any code that
>>> *sets* $(shared-thread-library) anywhere in the Makefiles, so I can't
>>> confirm that it'd be the same thing.
>>
>> sysdeps/nptl/Makeconfig:
> 
> Oh ghod, you mean to tell me subdirectories can have Makeconfig fragments too?

Yes :-)

>> shared-thread-library = $(common-objpfx)nptl/libpthread_nonshared.a \
>>                         $(common-objpfx)nptl/libpthread.so
> 
> That's in the opposite order from the opencoded sequence in
> nptl/Makefile.  Are we sure it doesn't matter?

It better not matter in this case. We are using it everywhere as our replacement.

-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-25 16:34         ` Zack Weinberg
  2017-02-25 21:06           ` Florian Weimer
@ 2017-03-01 20:19           ` Carlos O'Donell
  1 sibling, 0 replies; 30+ messages in thread
From: Carlos O'Donell @ 2017-03-01 20:19 UTC (permalink / raw)
  To: Zack Weinberg, libc-alpha; +Cc: joseph, adhemerval.zanella

On 02/25/2017 11:34 AM, Zack Weinberg wrote:
> On 02/20/2017 09:11 AM, Carlos O'Donell wrote:
>> On 02/20/2017 08:03 AM, Zack Weinberg wrote:
>>>
>>> posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; I
>>> duplicated the definition into the .c file, which is not ideal, but
>>> since this didn't come up anywhere else, inventing a new header for it
>>> seems like excessive polish.
>>
>> Please add PTR_ALIGN_DOWN to the support/ subsystem for testing and port
>> the test to support/.
>>
>> We will conceivably need similar macros for other tests and as a glibc
>> developer I like to have access to the same helper macros I use in glib.
> 
> wordexp-test.c is currently not even using the old test skeleton, and
> does some fairly hairy things with fork handlers.  I would prefer not to
> go down a rabbit hole.  Instead I propose to do something similar to
> what I did for the DIAG_* macros: introduce a new header in include/
> called libc-pointer-arith.h; move cast_to_integer, ALIGN_UP, ALIGN_DOWN,
> PTR_ALIGN_UP, and PTR_ALIGN_DOWN there; have libc-internal.h include it;
> have wordexp-test.c include it instead of libc-internal.h; and call that
> good enough for now.  OK?

Yeah, that seems like a sensible compromise.

-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-02-27  1:38             ` Zack Weinberg
  2017-03-01 18:22               ` Carlos O'Donell
@ 2017-03-02 13:57               ` Andreas Schwab
  2017-03-02 14:02                 ` Zack Weinberg
  2017-03-02 19:02                 ` Florian Weimer
  1 sibling, 2 replies; 30+ messages in thread
From: Andreas Schwab @ 2017-03-02 13:57 UTC (permalink / raw)
  To: Zack Weinberg
  Cc: Florian Weimer, Carlos O'Donell, GNU C Library, Joseph Myers,
	Adhemerval Zanella

On Feb 26 2017, Zack Weinberg <zackw@panix.com> wrote:

> diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
> index 86760d8844..6413558975 100644
> --- a/elf/get-dynamic-info.h
> +++ b/elf/get-dynamic-info.h
> @@ -16,8 +16,11 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> +#ifndef _GET_DYNAMIC_INFO_H
> +#define _GET_DYNAMIC_INFO_H 1
> +
>  #include <assert.h>
> -#include <libc-internal.h>
> +#include <libc-diag.h>
>  
>  #ifndef RESOLVE_MAP
>  static
> @@ -179,3 +182,5 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
>      info[DT_RPATH] = NULL;
>  #endif
>  }
> +
> +#endif /* get-dynamic-info.h */

This is bogus.  The file must be included multiple times, depending on
the definition of RESOLVE_MAP.

This breaks powerpc
<https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/p/ppc>.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-03-02 13:57               ` Andreas Schwab
@ 2017-03-02 14:02                 ` Zack Weinberg
  2017-03-02 19:02                 ` Florian Weimer
  1 sibling, 0 replies; 30+ messages in thread
From: Zack Weinberg @ 2017-03-02 14:02 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Florian Weimer, Carlos O'Donell, GNU C Library, Joseph Myers,
	Adhemerval Zanella

On Thu, Mar 2, 2017 at 8:56 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> On Feb 26 2017, Zack Weinberg <zackw@panix.com> wrote:
>>
>> +#ifndef _GET_DYNAMIC_INFO_H
>> +#define _GET_DYNAMIC_INFO_H 1
>> +
>
> This is bogus.  The file must be included multiple times, depending on
> the definition of RESOLVE_MAP.
>
> This breaks powerpc
> <https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/p/ppc>.

I will not be able to investigate until tomorrow.  If it's blocking
you, go ahead and revert this piece.

zw

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/4] Miscellaneous 'safe' testsuite changes.
  2017-03-02 13:57               ` Andreas Schwab
  2017-03-02 14:02                 ` Zack Weinberg
@ 2017-03-02 19:02                 ` Florian Weimer
  1 sibling, 0 replies; 30+ messages in thread
From: Florian Weimer @ 2017-03-02 19:02 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: libc-alpha, Carlos O'Donell, Zack Weinberg, joseph,
	adhemerval.zanella, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]

On 03/02/2017 02:56 PM, Andreas Schwab wrote:
>> +
>> +#endif /* get-dynamic-info.h */
> This is bogus.  The file must be included multiple times, depending on
> the definition of RESOLVE_MAP.
>
> This breaks powerpc
> <https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/p/ppc>.

Thanks for identifying the root cause.

I've tested the attached patch on ppc64, ppc64le, ppc, aarch64, and 
s390x, and committed it.

Thanks,
Florian


[-- Attachment #2: guard.patch --]
[-- Type: text/x-patch, Size: 920 bytes --]

Remove header file inclusion guard from elf/get-dynamic-info.h

This file is included multiple times, so the guard is harmful.
Fixes commit 9090848d0607e93fb08a1d68d9f263846ee33f02.

2017-03-02  Florian Weimer  <fweimer@redhat.com>

	* elf/get-dynamic-info.h: Remove header file inclusion guard.

diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
index 6413558..7525c3a 100644
--- a/elf/get-dynamic-info.h
+++ b/elf/get-dynamic-info.h
@@ -16,8 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _GET_DYNAMIC_INFO_H
-#define _GET_DYNAMIC_INFO_H 1
+/* This file is included multiple times and therefore lacks a header
+   file inclusion guard.  */
 
 #include <assert.h>
 #include <libc-diag.h>
@@ -182,5 +182,3 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
     info[DT_RPATH] = NULL;
 #endif
 }
-
-#endif /* get-dynamic-info.h */

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2017-03-02 19:02 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-20 13:03 [PATCH 0/4] Suppress internal declarations for most of the testsuite Zack Weinberg
2017-02-20 13:03 ` [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h Zack Weinberg
2017-02-20 13:03   ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Zack Weinberg
2017-02-20 13:03     ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Zack Weinberg
2017-02-20 13:04       ` [PATCH 4/4] Add IS_IN (testsuite) and remaining fixes Zack Weinberg
2017-02-20 15:13         ` Carlos O'Donell
2017-02-20 15:32           ` Zack Weinberg
2017-02-27 13:34           ` Zack Weinberg
2017-03-01 18:17             ` Carlos O'Donell
2017-03-01 18:48               ` Zack Weinberg
2017-03-01 19:21                 ` Carlos O'Donell
2017-02-20 14:11       ` [PATCH 3/4] Miscellaneous 'safe' testsuite changes Carlos O'Donell
2017-02-20 16:26         ` Joseph Myers
2017-02-25 16:34         ` Zack Weinberg
2017-02-25 21:06           ` Florian Weimer
2017-02-27  1:38             ` Zack Weinberg
2017-03-01 18:22               ` Carlos O'Donell
2017-03-02 13:57               ` Andreas Schwab
2017-03-02 14:02                 ` Zack Weinberg
2017-03-02 19:02                 ` Florian Weimer
2017-03-01 20:19           ` Carlos O'Donell
2017-02-20 14:52       ` Joseph Myers
2017-02-20 15:34         ` Zack Weinberg
2017-02-20 16:05           ` Carlos O'Donell
2017-02-20 16:30           ` Joseph Myers
2017-02-25 16:14         ` Zack Weinberg
2017-02-20 16:15       ` Joseph Myers
2017-02-20 13:58     ` [PATCH 2/4] Allow direct use of math_ldbl.h in testsuite Carlos O'Donell
2017-02-25 15:28       ` Zack Weinberg
2017-02-20 13:52   ` [PATCH 1/4] Split DIAG_* macros to new header libc-diag.h Carlos O'Donell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).