public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h.
@ 2019-06-26 15:49 Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-06-26 15:49 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 15832 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ce244b34f08e38f75255d3353132bfded89debfb

commit ce244b34f08e38f75255d3353132bfded89debfb
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Mar 16 21:01:12 2019 -0400

    Limit the set of strings.h functions also exposed in string.h.
    
    As someone who can remember when you might not be able to include both
    string.h and strings.h at the same time, it annoys me that strings.h
    still exists and is the only standard source for str(n)casecmp(_l) and
    ffs.  I think it’s right that we expose those functions from string.h.
    However, there’s no reason we need to keep exposing the other obsolete
    functions that strings.h declares from string.h.
    
    This patch creates <bits/strings_x2k8.h>, which declares the
    non-obsolete functions whose official home is strings.h.  strings.h
    includes it unconditionally, and string.h includes it under
    __USE_MISC, instead of strings.h.
    
    Two tests of the obsolete strings.h functions had to be adjusted.
    
    	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
    	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
    	* string/bits/strings_x2k8.h: ... this new file.
    	* string/Makefile: Install bits/strings_x2k8.h.
    	* include/bits/strings_x2k8h: New wrapper.
    	* string/string.h: Include bits/strings_x2k8.h instead of
    	strings.h.
    
    	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
    	* scripts/check-obsolete-constructs.py: string.h is no longer
    	expected to include strings.h.
    
    	* sysdeps/i386/i686/multiarch/bcopy.c
    	* sysdeps/i386/i686/multiarch/bzero.c
    	* sysdeps/i386/i686/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy.c
    	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
    	* sysdeps/s390/bzero.c
    	* sysdeps/s390/multiarch/ifunc-impl-list.c
    	* sysdeps/sparc/sparc64/multiarch/bzero.c
    	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c:
            Include strings.h.

Diff:
---
 NEWS                                               |  3 +
 debug/tst-chk1.c                                   |  1 +
 include/bits/strings_x2k8.h                        |  1 +
 scripts/check-obsolete-constructs.py               |  1 -
 string/Makefile                                    |  2 +-
 string/bits/strings_x2k8.h                         | 70 ++++++++++++++++++++++
 string/string.h                                    |  2 +-
 string/strings.h                                   | 39 +-----------
 string/test-string.h                               |  1 +
 sysdeps/i386/i686/multiarch/bcopy.c                |  1 +
 sysdeps/i386/i686/multiarch/bzero.c                |  1 +
 sysdeps/i386/i686/multiarch/ifunc-impl-list.c      |  1 +
 .../powerpc32/power4/multiarch/ifunc-impl-list.c   |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c  |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy.c        |  1 +
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  1 +
 sysdeps/s390/bzero.c                               |  1 +
 sysdeps/s390/multiarch/ifunc-impl-list.c           |  1 +
 sysdeps/sparc/sparc64/multiarch/bzero.c            |  1 +
 sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c  |  1 +
 20 files changed, 91 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index edf7739..974ed39 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
+  longer declared in <string.h>, only <strings.h>.
+
 * The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
   are no longer defined by <sys/types.h> in strict conformance modes.
   These types were historically provided by <sys/types.h> on BSD systems,
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index c6f11af..014b08f 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <wchar.h>
 #include <sys/poll.h>
diff --git a/include/bits/strings_x2k8.h b/include/bits/strings_x2k8.h
new file mode 100644
index 0000000..7eddd92
--- /dev/null
+++ b/include/bits/strings_x2k8.h
@@ -0,0 +1 @@
+#include <string/bits/strings_x2k8.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index e95e587..bd5a97f 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -506,7 +506,6 @@ HEADER_ALLOWED_INCLUDES = {
     "inttypes.h":                  [ "stdint.h" ],
     "signal.h":                    [ "sys/ucontext.h" ],
     "stdlib.h":                    [ "alloca.h", "sys/types.h" ],
-    "string.h":                    [ "strings.h" ],
     "tgmath.h":                    [ "complex.h", "math.h" ],
     "threads.h":                   [ "time.h" ],
 
diff --git a/string/Makefile b/string/Makefile
index 3e5721e..c9ebede 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -23,7 +23,7 @@ subdir	:= string
 include ../Makeconfig
 
 headers		:= string.h bits/string_fortified.h			\
-		   strings.h bits/strings_fortified.h			\
+		   strings.h bits/strings_x2k8.h bits/strings_fortified.h \
 		   byteswap.h bits/byteswap.h				\
 		   endian.h bits/endian.h bits/endianness.h		\
 		   bits/uintn-identity.h				\
diff --git a/string/bits/strings_x2k8.h b/string/bits/strings_x2k8.h
new file mode 100644
index 0000000..dbcb0b2
--- /dev/null
+++ b/string/bits/strings_x2k8.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2019 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 _BITS_STRINGS_X2K8_H
+#define _BITS_STRINGS_X2K8_H 1
+
+/* This header file declares all of the strings.h functions that are
+   not marked as "obsolete" in POSIX.1-2008.  As a GNU extension,
+   these functions are also made available via string.h.  */
+
+#if !defined _STRING_H && !defined _STRINGS_H
+# error "Never include <bits/strings_x2k8.h> directly, use <string(s).h>."
+#endif
+
+__BEGIN_DECLS
+
+/* Compare S1 and S2, ignoring case.  */
+extern int strcasecmp (const char *__s1, const char *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef	__USE_XOPEN2K8
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
+
+/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
+extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+
+/* Compare no more than N chars of S1 and S2, ignoring case, using
+   collation rules from LOC.  */
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+			  size_t __n, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+#endif
+
+#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
+/* Return the position of the first bit set in I, or 0 if none are set.
+   The least-significant bit is position 1, the most-significant 32.  */
+extern int ffs (int __i) __THROW __attribute_const__;
+#endif
+
+/* The following two functions are non-standard but necessary for non-32 bit
+   platforms.  */
+#ifdef	__USE_MISC
+extern int ffsl (long int __l) __THROW __attribute_const__;
+__extension__ extern int ffsll (long long int __ll)
+     __THROW __attribute_const__;
+#endif
+
+__END_DECLS
+
+#endif /* bits/strings_x2k8.h */
diff --git a/string/string.h b/string/string.h
index 2cc4f50..6c9cdc0 100644
--- a/string/string.h
+++ b/string/string.h
@@ -426,7 +426,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
 #endif
 
 #ifdef __USE_MISC
-# include <strings.h>
+# include <bits/strings_x2k8.h>
 
 /* Set N bytes of S to 0.  The compiler will not delete a call to this
    function, even if S is dead after the call.  */
diff --git a/string/strings.h b/string/strings.h
index 17e1bf7..bec458f 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -21,6 +21,8 @@
 #include <features.h>
 #include <bits/types/size_t.h>
 
+#include <bits/strings_x2k8.h>
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
@@ -97,43 +99,6 @@ extern char *rindex (const char *__s, int __c)
 # endif
 #endif
 
-#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
-/* Return the position of the first bit set in I, or 0 if none are set.
-   The least-significant bit is position 1, the most-significant 32.  */
-extern int ffs (int __i) __THROW __attribute_const__;
-#endif
-
-/* The following two functions are non-standard but necessary for non-32 bit
-   platforms.  */
-# ifdef	__USE_MISC
-extern int ffsl (long int __l) __THROW __attribute_const__;
-__extension__ extern int ffsll (long long int __ll)
-     __THROW __attribute_const__;
-# endif
-
-/* Compare S1 and S2, ignoring case.  */
-extern int strcasecmp (const char *__s1, const char *__s2)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case.  */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-#ifdef	__USE_XOPEN2K8
-/* POSIX.1-2008 extended locale interface (see locale.h).  */
-# include <bits/types/locale_t.h>
-
-/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
-extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-/* Compare no more than N chars of S1 and S2, ignoring case, using
-   collation rules from LOC.  */
-extern int strncasecmp_l (const char *__s1, const char *__s2,
-			  size_t __n, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
 __END_DECLS
 
 #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
diff --git a/string/test-string.h b/string/test-string.h
index befd3e9..2c1c016 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -55,6 +55,7 @@ extern impl_t __start_impls[], __stop_impls[];
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <unistd.h>
diff --git a/sysdeps/i386/i686/multiarch/bcopy.c b/sysdeps/i386/i686/multiarch/bcopy.c
index c2d1d25..e1cd57c 100644
--- a/sysdeps/i386/i686/multiarch/bcopy.c
+++ b/sysdeps/i386/i686/multiarch/bcopy.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bcopy __redirect_bcopy
 # include <string.h>
+# include <strings.h>
 # undef bcopy
 
 # define SYMBOL_NAME bcopy
diff --git a/sysdeps/i386/i686/multiarch/bzero.c b/sysdeps/i386/i686/multiarch/bzero.c
index 6b4834e..182a496 100644
--- a/sysdeps/i386/i686/multiarch/bzero.c
+++ b/sysdeps/i386/i686/multiarch/bzero.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # define SYMBOL_NAME bzero
diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
index e2428e0..5408aec 100644
--- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include "init-arch.h"
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index 16a64be..ac6784a 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
index 6772e0a..9ba96f7 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 
 extern __typeof (bcopy)   __bcopy_ppc attribute_hidden;
 extern __typeof (memmove) __memmove_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
index 8c6f2fb..b402117 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 #include "init-arch.h"
 
 extern __typeof (bcopy) __bcopy_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index c0a927d..c6a227f 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/s390/bzero.c b/sysdeps/s390/bzero.c
index 5477ed4..18f7eb8 100644
--- a/sysdeps/s390/bzero.c
+++ b/sysdeps/s390/bzero.c
@@ -19,6 +19,7 @@
 #include <ifunc-memset.h>
 #if HAVE_MEMSET_IFUNC
 # include <string.h>
+# include <strings.h>
 # include <ifunc-resolve.h>
 
 # if HAVE_MEMSET_Z900_G5
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
index 1948436..bede348 100644
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include <ifunc-resolve.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/bzero.c b/sysdeps/sparc/sparc64/multiarch/bzero.c
index 2d7c06b..3801d8d 100644
--- a/sysdeps/sparc/sparc64/multiarch/bzero.c
+++ b/sysdeps/sparc/sparc64/multiarch/bzero.c
@@ -20,6 +20,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # include <sparc-ifunc.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
index 00ed640..8326a7b 100644
--- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <sysdep.h>


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

* [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h.
@ 2020-01-08 19:20 Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2020-01-08 19:20 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 15836 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7e2c24ffcbb36f4c568da4d7c6b31f89b21613ab

commit 7e2c24ffcbb36f4c568da4d7c6b31f89b21613ab
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Mar 16 21:01:12 2019 -0400

    Limit the set of strings.h functions also exposed in string.h.
    
    As someone who can remember when you might not be able to include both
    string.h and strings.h at the same time, it annoys me that strings.h
    still exists and is the only standard source for str(n)casecmp(_l) and
    ffs.  I think it’s right that we expose those functions from string.h.
    However, there’s no reason we need to keep exposing the other obsolete
    functions that strings.h declares from string.h.
    
    This patch creates <bits/strings_x2k8.h>, which declares the
    non-obsolete functions whose official home is strings.h.  strings.h
    includes it unconditionally, and string.h includes it under
    __USE_MISC, instead of strings.h.
    
    Two tests of the obsolete strings.h functions had to be adjusted.
    
    	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
    	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
    	* string/bits/strings_x2k8.h: ... this new file.
    	* string/Makefile: Install bits/strings_x2k8.h.
    	* include/bits/strings_x2k8h: New wrapper.
    	* string/string.h: Include bits/strings_x2k8.h instead of
    	strings.h.
    
    	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
    	* scripts/check-obsolete-constructs.py: string.h is no longer
    	expected to include strings.h.
    
    	* sysdeps/i386/i686/multiarch/bcopy.c
    	* sysdeps/i386/i686/multiarch/bzero.c
    	* sysdeps/i386/i686/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy.c
    	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
    	* sysdeps/s390/bzero.c
    	* sysdeps/s390/multiarch/ifunc-impl-list.c
    	* sysdeps/sparc/sparc64/multiarch/bzero.c
    	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c:
            Include strings.h.

Diff:
---
 NEWS                                               |  3 +
 debug/tst-chk1.c                                   |  1 +
 include/bits/strings_x2k8.h                        |  1 +
 scripts/check-obsolete-constructs.py               |  1 -
 string/Makefile                                    |  2 +-
 string/bits/strings_x2k8.h                         | 70 ++++++++++++++++++++++
 string/string.h                                    |  2 +-
 string/strings.h                                   | 39 +-----------
 string/test-string.h                               |  1 +
 sysdeps/i386/i686/multiarch/bcopy.c                |  1 +
 sysdeps/i386/i686/multiarch/bzero.c                |  1 +
 sysdeps/i386/i686/multiarch/ifunc-impl-list.c      |  1 +
 .../powerpc32/power4/multiarch/ifunc-impl-list.c   |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c  |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy.c        |  1 +
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  1 +
 sysdeps/s390/bzero.c                               |  1 +
 sysdeps/s390/multiarch/ifunc-impl-list.c           |  1 +
 sysdeps/sparc/sparc64/multiarch/bzero.c            |  1 +
 sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c  |  1 +
 20 files changed, 91 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index 599db8f..93be478 100644
--- a/NEWS
+++ b/NEWS
@@ -187,6 +187,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
+  longer declared in <string.h>, only <strings.h>.
+
 * The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
   are no longer defined by <sys/types.h> in strict conformance modes.
   These types were historically provided by <sys/types.h> on BSD systems,
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 5d02592..ae7d0c2 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <wchar.h>
 #include <sys/poll.h>
diff --git a/include/bits/strings_x2k8.h b/include/bits/strings_x2k8.h
new file mode 100644
index 0000000..7eddd92
--- /dev/null
+++ b/include/bits/strings_x2k8.h
@@ -0,0 +1 @@
+#include <string/bits/strings_x2k8.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 77253df..dfe0d0f 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -506,7 +506,6 @@ HEADER_ALLOWED_INCLUDES = {
     "inttypes.h":                  [ "stdint.h" ],
     "signal.h":                    [ "sys/ucontext.h" ],
     "stdlib.h":                    [ "alloca.h", "sys/types.h" ],
-    "string.h":                    [ "strings.h" ],
     "tgmath.h":                    [ "complex.h", "math.h" ],
     "threads.h":                   [ "time.h" ],
 
diff --git a/string/Makefile b/string/Makefile
index c46785f..d9503bd 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -23,7 +23,7 @@ subdir	:= string
 include ../Makeconfig
 
 headers		:= string.h bits/string_fortified.h			\
-		   strings.h bits/strings_fortified.h			\
+		   strings.h bits/strings_x2k8.h bits/strings_fortified.h \
 		   byteswap.h bits/byteswap.h				\
 		   endian.h bits/endian.h bits/endianness.h		\
 		   bits/uintn-identity.h				\
diff --git a/string/bits/strings_x2k8.h b/string/bits/strings_x2k8.h
new file mode 100644
index 0000000..dbcb0b2
--- /dev/null
+++ b/string/bits/strings_x2k8.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2019 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 _BITS_STRINGS_X2K8_H
+#define _BITS_STRINGS_X2K8_H 1
+
+/* This header file declares all of the strings.h functions that are
+   not marked as "obsolete" in POSIX.1-2008.  As a GNU extension,
+   these functions are also made available via string.h.  */
+
+#if !defined _STRING_H && !defined _STRINGS_H
+# error "Never include <bits/strings_x2k8.h> directly, use <string(s).h>."
+#endif
+
+__BEGIN_DECLS
+
+/* Compare S1 and S2, ignoring case.  */
+extern int strcasecmp (const char *__s1, const char *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef	__USE_XOPEN2K8
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
+
+/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
+extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+
+/* Compare no more than N chars of S1 and S2, ignoring case, using
+   collation rules from LOC.  */
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+			  size_t __n, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+#endif
+
+#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
+/* Return the position of the first bit set in I, or 0 if none are set.
+   The least-significant bit is position 1, the most-significant 32.  */
+extern int ffs (int __i) __THROW __attribute_const__;
+#endif
+
+/* The following two functions are non-standard but necessary for non-32 bit
+   platforms.  */
+#ifdef	__USE_MISC
+extern int ffsl (long int __l) __THROW __attribute_const__;
+__extension__ extern int ffsll (long long int __ll)
+     __THROW __attribute_const__;
+#endif
+
+__END_DECLS
+
+#endif /* bits/strings_x2k8.h */
diff --git a/string/string.h b/string/string.h
index 234ee91..fcb7da8 100644
--- a/string/string.h
+++ b/string/string.h
@@ -427,7 +427,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
 #endif
 
 #ifdef __USE_MISC
-# include <strings.h>
+# include <bits/strings_x2k8.h>
 
 /* Set N bytes of S to 0.  The compiler will not delete a call to this
    function, even if S is dead after the call.  */
diff --git a/string/strings.h b/string/strings.h
index 65dfca8..540eb15 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -21,6 +21,8 @@
 #include <features.h>
 #include <bits/types/size_t.h>
 
+#include <bits/strings_x2k8.h>
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
@@ -97,43 +99,6 @@ extern char *rindex (const char *__s, int __c)
 # endif
 #endif
 
-#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
-/* Return the position of the first bit set in I, or 0 if none are set.
-   The least-significant bit is position 1, the most-significant 32.  */
-extern int ffs (int __i) __THROW __attribute_const__;
-#endif
-
-/* The following two functions are non-standard but necessary for non-32 bit
-   platforms.  */
-# ifdef	__USE_MISC
-extern int ffsl (long int __l) __THROW __attribute_const__;
-__extension__ extern int ffsll (long long int __ll)
-     __THROW __attribute_const__;
-# endif
-
-/* Compare S1 and S2, ignoring case.  */
-extern int strcasecmp (const char *__s1, const char *__s2)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case.  */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-#ifdef	__USE_XOPEN2K8
-/* POSIX.1-2008 extended locale interface (see locale.h).  */
-# include <bits/types/locale_t.h>
-
-/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
-extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-/* Compare no more than N chars of S1 and S2, ignoring case, using
-   collation rules from LOC.  */
-extern int strncasecmp_l (const char *__s1, const char *__s2,
-			  size_t __n, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
 __END_DECLS
 
 #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
diff --git a/string/test-string.h b/string/test-string.h
index 0efe5d8..a6d8d1e 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -55,6 +55,7 @@ extern impl_t __start_impls[], __stop_impls[];
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <unistd.h>
diff --git a/sysdeps/i386/i686/multiarch/bcopy.c b/sysdeps/i386/i686/multiarch/bcopy.c
index 2145ab7..929dc70 100644
--- a/sysdeps/i386/i686/multiarch/bcopy.c
+++ b/sysdeps/i386/i686/multiarch/bcopy.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bcopy __redirect_bcopy
 # include <string.h>
+# include <strings.h>
 # undef bcopy
 
 # define SYMBOL_NAME bcopy
diff --git a/sysdeps/i386/i686/multiarch/bzero.c b/sysdeps/i386/i686/multiarch/bzero.c
index 3b68e1c..3655262 100644
--- a/sysdeps/i386/i686/multiarch/bzero.c
+++ b/sysdeps/i386/i686/multiarch/bzero.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # define SYMBOL_NAME bzero
diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
index 23774fb..8101c0a 100644
--- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include "init-arch.h"
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index fca6c2c..07de0a9 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
index 0851afa..4b530cd 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 
 extern __typeof (bcopy)   __bcopy_ppc attribute_hidden;
 extern __typeof (memmove) __memmove_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
index 2aebfc0..1a7c909 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 #include "init-arch.h"
 
 extern __typeof (bcopy) __bcopy_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index b9fef3f..41d1330 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/s390/bzero.c b/sysdeps/s390/bzero.c
index fc0d46e..fc641e1 100644
--- a/sysdeps/s390/bzero.c
+++ b/sysdeps/s390/bzero.c
@@ -19,6 +19,7 @@
 #include <ifunc-memset.h>
 #if HAVE_MEMSET_IFUNC
 # include <string.h>
+# include <strings.h>
 # include <ifunc-resolve.h>
 
 # if HAVE_MEMSET_Z900_G5
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
index e6195c6..0d94949 100644
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include <ifunc-resolve.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/bzero.c b/sysdeps/sparc/sparc64/multiarch/bzero.c
index ee50150..fc7af26 100644
--- a/sysdeps/sparc/sparc64/multiarch/bzero.c
+++ b/sysdeps/sparc/sparc64/multiarch/bzero.c
@@ -20,6 +20,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # include <sparc-ifunc.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
index ad79a26..2fa7a3a 100644
--- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <sysdep.h>


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

* [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h.
@ 2019-06-20 16:06 Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-06-20 16:06 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 15832 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f6480a080eb82cef6d79ddf1096c4b25b4320ff5

commit f6480a080eb82cef6d79ddf1096c4b25b4320ff5
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Mar 16 21:01:12 2019 -0400

    Limit the set of strings.h functions also exposed in string.h.
    
    As someone who can remember when you might not be able to include both
    string.h and strings.h at the same time, it annoys me that strings.h
    still exists and is the only standard source for str(n)casecmp(_l) and
    ffs.  I think it’s right that we expose those functions from string.h.
    However, there’s no reason we need to keep exposing the other obsolete
    functions that strings.h declares from string.h.
    
    This patch creates <bits/strings_x2k8.h>, which declares the
    non-obsolete functions whose official home is strings.h.  strings.h
    includes it unconditionally, and string.h includes it under
    __USE_MISC, instead of strings.h.
    
    Two tests of the obsolete strings.h functions had to be adjusted.
    
    	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
    	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
    	* string/bits/strings_x2k8.h: ... this new file.
    	* string/Makefile: Install bits/strings_x2k8.h.
    	* include/bits/strings_x2k8h: New wrapper.
    	* string/string.h: Include bits/strings_x2k8.h instead of
    	strings.h.
    
    	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
    	* scripts/check-obsolete-constructs.py: string.h is no longer
    	expected to include strings.h.
    
    	* sysdeps/i386/i686/multiarch/bcopy.c
    	* sysdeps/i386/i686/multiarch/bzero.c
    	* sysdeps/i386/i686/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy.c
    	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
    	* sysdeps/s390/bzero.c
    	* sysdeps/s390/multiarch/ifunc-impl-list.c
    	* sysdeps/sparc/sparc64/multiarch/bzero.c
    	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c:
            Include strings.h.

Diff:
---
 NEWS                                               |  3 +
 debug/tst-chk1.c                                   |  1 +
 include/bits/strings_x2k8.h                        |  1 +
 scripts/check-obsolete-constructs.py               |  1 -
 string/Makefile                                    |  2 +-
 string/bits/strings_x2k8.h                         | 70 ++++++++++++++++++++++
 string/string.h                                    |  2 +-
 string/strings.h                                   | 39 +-----------
 string/test-string.h                               |  1 +
 sysdeps/i386/i686/multiarch/bcopy.c                |  1 +
 sysdeps/i386/i686/multiarch/bzero.c                |  1 +
 sysdeps/i386/i686/multiarch/ifunc-impl-list.c      |  1 +
 .../powerpc32/power4/multiarch/ifunc-impl-list.c   |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c  |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy.c        |  1 +
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  1 +
 sysdeps/s390/bzero.c                               |  1 +
 sysdeps/s390/multiarch/ifunc-impl-list.c           |  1 +
 sysdeps/sparc/sparc64/multiarch/bzero.c            |  1 +
 sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c  |  1 +
 20 files changed, 91 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index edf7739..974ed39 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
+  longer declared in <string.h>, only <strings.h>.
+
 * The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
   are no longer defined by <sys/types.h> in strict conformance modes.
   These types were historically provided by <sys/types.h> on BSD systems,
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index c6f11af..014b08f 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <wchar.h>
 #include <sys/poll.h>
diff --git a/include/bits/strings_x2k8.h b/include/bits/strings_x2k8.h
new file mode 100644
index 0000000..7eddd92
--- /dev/null
+++ b/include/bits/strings_x2k8.h
@@ -0,0 +1 @@
+#include <string/bits/strings_x2k8.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index e95e587..bd5a97f 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -506,7 +506,6 @@ HEADER_ALLOWED_INCLUDES = {
     "inttypes.h":                  [ "stdint.h" ],
     "signal.h":                    [ "sys/ucontext.h" ],
     "stdlib.h":                    [ "alloca.h", "sys/types.h" ],
-    "string.h":                    [ "strings.h" ],
     "tgmath.h":                    [ "complex.h", "math.h" ],
     "threads.h":                   [ "time.h" ],
 
diff --git a/string/Makefile b/string/Makefile
index 3e5721e..c9ebede 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -23,7 +23,7 @@ subdir	:= string
 include ../Makeconfig
 
 headers		:= string.h bits/string_fortified.h			\
-		   strings.h bits/strings_fortified.h			\
+		   strings.h bits/strings_x2k8.h bits/strings_fortified.h \
 		   byteswap.h bits/byteswap.h				\
 		   endian.h bits/endian.h bits/endianness.h		\
 		   bits/uintn-identity.h				\
diff --git a/string/bits/strings_x2k8.h b/string/bits/strings_x2k8.h
new file mode 100644
index 0000000..dbcb0b2
--- /dev/null
+++ b/string/bits/strings_x2k8.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2019 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 _BITS_STRINGS_X2K8_H
+#define _BITS_STRINGS_X2K8_H 1
+
+/* This header file declares all of the strings.h functions that are
+   not marked as "obsolete" in POSIX.1-2008.  As a GNU extension,
+   these functions are also made available via string.h.  */
+
+#if !defined _STRING_H && !defined _STRINGS_H
+# error "Never include <bits/strings_x2k8.h> directly, use <string(s).h>."
+#endif
+
+__BEGIN_DECLS
+
+/* Compare S1 and S2, ignoring case.  */
+extern int strcasecmp (const char *__s1, const char *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef	__USE_XOPEN2K8
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
+
+/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
+extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+
+/* Compare no more than N chars of S1 and S2, ignoring case, using
+   collation rules from LOC.  */
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+			  size_t __n, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+#endif
+
+#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
+/* Return the position of the first bit set in I, or 0 if none are set.
+   The least-significant bit is position 1, the most-significant 32.  */
+extern int ffs (int __i) __THROW __attribute_const__;
+#endif
+
+/* The following two functions are non-standard but necessary for non-32 bit
+   platforms.  */
+#ifdef	__USE_MISC
+extern int ffsl (long int __l) __THROW __attribute_const__;
+__extension__ extern int ffsll (long long int __ll)
+     __THROW __attribute_const__;
+#endif
+
+__END_DECLS
+
+#endif /* bits/strings_x2k8.h */
diff --git a/string/string.h b/string/string.h
index 2cc4f50..6c9cdc0 100644
--- a/string/string.h
+++ b/string/string.h
@@ -426,7 +426,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
 #endif
 
 #ifdef __USE_MISC
-# include <strings.h>
+# include <bits/strings_x2k8.h>
 
 /* Set N bytes of S to 0.  The compiler will not delete a call to this
    function, even if S is dead after the call.  */
diff --git a/string/strings.h b/string/strings.h
index 17e1bf7..bec458f 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -21,6 +21,8 @@
 #include <features.h>
 #include <bits/types/size_t.h>
 
+#include <bits/strings_x2k8.h>
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
@@ -97,43 +99,6 @@ extern char *rindex (const char *__s, int __c)
 # endif
 #endif
 
-#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
-/* Return the position of the first bit set in I, or 0 if none are set.
-   The least-significant bit is position 1, the most-significant 32.  */
-extern int ffs (int __i) __THROW __attribute_const__;
-#endif
-
-/* The following two functions are non-standard but necessary for non-32 bit
-   platforms.  */
-# ifdef	__USE_MISC
-extern int ffsl (long int __l) __THROW __attribute_const__;
-__extension__ extern int ffsll (long long int __ll)
-     __THROW __attribute_const__;
-# endif
-
-/* Compare S1 and S2, ignoring case.  */
-extern int strcasecmp (const char *__s1, const char *__s2)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case.  */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-#ifdef	__USE_XOPEN2K8
-/* POSIX.1-2008 extended locale interface (see locale.h).  */
-# include <bits/types/locale_t.h>
-
-/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
-extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-/* Compare no more than N chars of S1 and S2, ignoring case, using
-   collation rules from LOC.  */
-extern int strncasecmp_l (const char *__s1, const char *__s2,
-			  size_t __n, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
 __END_DECLS
 
 #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
diff --git a/string/test-string.h b/string/test-string.h
index befd3e9..2c1c016 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -55,6 +55,7 @@ extern impl_t __start_impls[], __stop_impls[];
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <unistd.h>
diff --git a/sysdeps/i386/i686/multiarch/bcopy.c b/sysdeps/i386/i686/multiarch/bcopy.c
index c2d1d25..e1cd57c 100644
--- a/sysdeps/i386/i686/multiarch/bcopy.c
+++ b/sysdeps/i386/i686/multiarch/bcopy.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bcopy __redirect_bcopy
 # include <string.h>
+# include <strings.h>
 # undef bcopy
 
 # define SYMBOL_NAME bcopy
diff --git a/sysdeps/i386/i686/multiarch/bzero.c b/sysdeps/i386/i686/multiarch/bzero.c
index 6b4834e..182a496 100644
--- a/sysdeps/i386/i686/multiarch/bzero.c
+++ b/sysdeps/i386/i686/multiarch/bzero.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # define SYMBOL_NAME bzero
diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
index e2428e0..5408aec 100644
--- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include "init-arch.h"
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index 16a64be..ac6784a 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
index 6772e0a..9ba96f7 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 
 extern __typeof (bcopy)   __bcopy_ppc attribute_hidden;
 extern __typeof (memmove) __memmove_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
index 8c6f2fb..b402117 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 #include "init-arch.h"
 
 extern __typeof (bcopy) __bcopy_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index c0a927d..c6a227f 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/s390/bzero.c b/sysdeps/s390/bzero.c
index 5477ed4..18f7eb8 100644
--- a/sysdeps/s390/bzero.c
+++ b/sysdeps/s390/bzero.c
@@ -19,6 +19,7 @@
 #include <ifunc-memset.h>
 #if HAVE_MEMSET_IFUNC
 # include <string.h>
+# include <strings.h>
 # include <ifunc-resolve.h>
 
 # if HAVE_MEMSET_Z900_G5
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
index 1948436..bede348 100644
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include <ifunc-resolve.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/bzero.c b/sysdeps/sparc/sparc64/multiarch/bzero.c
index 2d7c06b..3801d8d 100644
--- a/sysdeps/sparc/sparc64/multiarch/bzero.c
+++ b/sysdeps/sparc/sparc64/multiarch/bzero.c
@@ -20,6 +20,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # include <sparc-ifunc.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
index 00ed640..8326a7b 100644
--- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <sysdep.h>


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

* [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h.
@ 2019-06-18 15:33 Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-06-18 15:33 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 15822 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=03c421800dcba44e692d4187650f65bd2a3000ba

commit 03c421800dcba44e692d4187650f65bd2a3000ba
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Mar 16 21:01:12 2019 -0400

    Limit the set of strings.h functions also exposed in string.h.
    
    As someone who can remember when you might not be able to include both
    string.h and strings.h at the same time, it annoys me that strings.h
    still exists and is the only standard source for str(n)casecmp(_l) and
    ffs.  I think it’s right that we expose those functions from string.h.
    However, there’s no reason we need to keep exposing the other obsolete
    functions that strings.h declares from string.h.
    
    This patch creates <bits/strings_x2k8.h>, which declares the
    non-obsolete functions whose official home is strings.h.  strings.h
    includes it unconditionally, and string.h includes it under
    __USE_MISC, instead of strings.h.
    
    Two tests of the obsolete strings.h functions had to be adjusted.
    
    	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
    	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
    	* string/bits/strings_x2k8.h: ... this new file.
    	* string/Makefile: Install bits/strings_x2k8.h.
    	* include/bits/strings_x2k8h: New wrapper.
    	* string/string.h: Include bits/strings_x2k8.h instead of
    	strings.h.
    
    	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
    	* scripts/check-obsolete-constructs.py: string.h is no longer
    	expected to include strings.h.
    
    	* sysdeps/i386/i686/multiarch/bcopy.c
    	* sysdeps/i386/i686/multiarch/bzero.c
    	* sysdeps/i386/i686/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy.c
    	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
    	* sysdeps/s390/bzero.c
    	* sysdeps/s390/multiarch/ifunc-impl-list.c
    	* sysdeps/sparc/sparc64/multiarch/bzero.c
    	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c:
            Include strings.h.

Diff:
---
 NEWS                                               |  3 +
 debug/tst-chk1.c                                   |  1 +
 include/bits/strings_x2k8.h                        |  1 +
 scripts/check-obsolete-constructs.py               |  1 -
 string/Makefile                                    |  2 +-
 string/bits/strings_x2k8.h                         | 70 ++++++++++++++++++++++
 string/string.h                                    |  2 +-
 string/strings.h                                   | 39 +-----------
 string/test-string.h                               |  1 +
 sysdeps/i386/i686/multiarch/bcopy.c                |  1 +
 sysdeps/i386/i686/multiarch/bzero.c                |  1 +
 sysdeps/i386/i686/multiarch/ifunc-impl-list.c      |  1 +
 .../powerpc32/power4/multiarch/ifunc-impl-list.c   |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c  |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy.c        |  1 +
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  1 +
 sysdeps/s390/bzero.c                               |  1 +
 sysdeps/s390/multiarch/ifunc-impl-list.c           |  1 +
 sysdeps/sparc/sparc64/multiarch/bzero.c            |  1 +
 sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c  |  1 +
 20 files changed, 91 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index edf7739..974ed39 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
+  longer declared in <string.h>, only <strings.h>.
+
 * The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
   are no longer defined by <sys/types.h> in strict conformance modes.
   These types were historically provided by <sys/types.h> on BSD systems,
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index c6f11af..014b08f 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <wchar.h>
 #include <sys/poll.h>
diff --git a/include/bits/strings_x2k8.h b/include/bits/strings_x2k8.h
new file mode 100644
index 0000000..7eddd92
--- /dev/null
+++ b/include/bits/strings_x2k8.h
@@ -0,0 +1 @@
+#include <string/bits/strings_x2k8.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 5c1bb50..91ea3eb 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -515,7 +515,6 @@ HEADER_ALLOWED_INCLUDES = {
     "inttypes.h":                  [ "stdint.h" ],
     "signal.h":                    [ "sys/ucontext.h" ],
     "stdlib.h":                    [ "alloca.h", "sys/types.h" ],
-    "string.h":                    [ "strings.h" ],
     "tgmath.h":                    [ "complex.h", "math.h" ],
     "threads.h":                   [ "time.h" ],
 
diff --git a/string/Makefile b/string/Makefile
index 38b26a0..4420a39 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -23,7 +23,7 @@ subdir	:= string
 include ../Makeconfig
 
 headers		:= string.h bits/string_fortified.h			\
-		   strings.h bits/strings_fortified.h			\
+		   strings.h bits/strings_x2k8.h bits/strings_fortified.h \
 		   byteswap.h bits/byteswap.h				\
 		   endian.h bits/endian.h bits/uintn-identity.h		\
 		   memory.h argz.h envz.h
diff --git a/string/bits/strings_x2k8.h b/string/bits/strings_x2k8.h
new file mode 100644
index 0000000..dbcb0b2
--- /dev/null
+++ b/string/bits/strings_x2k8.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2019 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 _BITS_STRINGS_X2K8_H
+#define _BITS_STRINGS_X2K8_H 1
+
+/* This header file declares all of the strings.h functions that are
+   not marked as "obsolete" in POSIX.1-2008.  As a GNU extension,
+   these functions are also made available via string.h.  */
+
+#if !defined _STRING_H && !defined _STRINGS_H
+# error "Never include <bits/strings_x2k8.h> directly, use <string(s).h>."
+#endif
+
+__BEGIN_DECLS
+
+/* Compare S1 and S2, ignoring case.  */
+extern int strcasecmp (const char *__s1, const char *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef	__USE_XOPEN2K8
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
+
+/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
+extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+
+/* Compare no more than N chars of S1 and S2, ignoring case, using
+   collation rules from LOC.  */
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+			  size_t __n, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+#endif
+
+#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
+/* Return the position of the first bit set in I, or 0 if none are set.
+   The least-significant bit is position 1, the most-significant 32.  */
+extern int ffs (int __i) __THROW __attribute_const__;
+#endif
+
+/* The following two functions are non-standard but necessary for non-32 bit
+   platforms.  */
+#ifdef	__USE_MISC
+extern int ffsl (long int __l) __THROW __attribute_const__;
+__extension__ extern int ffsll (long long int __ll)
+     __THROW __attribute_const__;
+#endif
+
+__END_DECLS
+
+#endif /* bits/strings_x2k8.h */
diff --git a/string/string.h b/string/string.h
index c38eea9..6b25243 100644
--- a/string/string.h
+++ b/string/string.h
@@ -428,7 +428,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
 #endif
 
 #ifdef __USE_MISC
-# include <strings.h>
+# include <bits/strings_x2k8.h>
 
 /* Set N bytes of S to 0.  The compiler will not delete a call to this
    function, even if S is dead after the call.  */
diff --git a/string/strings.h b/string/strings.h
index 5428bc4..8f380bf 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -22,6 +22,8 @@
 #define __need_size_t
 #include <stddef.h>
 
+#include <bits/strings_x2k8.h>
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
@@ -98,43 +100,6 @@ extern char *rindex (const char *__s, int __c)
 # endif
 #endif
 
-#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
-/* Return the position of the first bit set in I, or 0 if none are set.
-   The least-significant bit is position 1, the most-significant 32.  */
-extern int ffs (int __i) __THROW __attribute_const__;
-#endif
-
-/* The following two functions are non-standard but necessary for non-32 bit
-   platforms.  */
-# ifdef	__USE_MISC
-extern int ffsl (long int __l) __THROW __attribute_const__;
-__extension__ extern int ffsll (long long int __ll)
-     __THROW __attribute_const__;
-# endif
-
-/* Compare S1 and S2, ignoring case.  */
-extern int strcasecmp (const char *__s1, const char *__s2)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case.  */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-#ifdef	__USE_XOPEN2K8
-/* POSIX.1-2008 extended locale interface (see locale.h).  */
-# include <bits/types/locale_t.h>
-
-/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
-extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-/* Compare no more than N chars of S1 and S2, ignoring case, using
-   collation rules from LOC.  */
-extern int strncasecmp_l (const char *__s1, const char *__s2,
-			  size_t __n, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
 __END_DECLS
 
 #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
diff --git a/string/test-string.h b/string/test-string.h
index befd3e9..2c1c016 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -55,6 +55,7 @@ extern impl_t __start_impls[], __stop_impls[];
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <unistd.h>
diff --git a/sysdeps/i386/i686/multiarch/bcopy.c b/sysdeps/i386/i686/multiarch/bcopy.c
index c2d1d25..e1cd57c 100644
--- a/sysdeps/i386/i686/multiarch/bcopy.c
+++ b/sysdeps/i386/i686/multiarch/bcopy.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bcopy __redirect_bcopy
 # include <string.h>
+# include <strings.h>
 # undef bcopy
 
 # define SYMBOL_NAME bcopy
diff --git a/sysdeps/i386/i686/multiarch/bzero.c b/sysdeps/i386/i686/multiarch/bzero.c
index 6b4834e..182a496 100644
--- a/sysdeps/i386/i686/multiarch/bzero.c
+++ b/sysdeps/i386/i686/multiarch/bzero.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # define SYMBOL_NAME bzero
diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
index e2428e0..5408aec 100644
--- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include "init-arch.h"
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index 16a64be..ac6784a 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
index 6772e0a..9ba96f7 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 
 extern __typeof (bcopy)   __bcopy_ppc attribute_hidden;
 extern __typeof (memmove) __memmove_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
index 8c6f2fb..b402117 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 #include "init-arch.h"
 
 extern __typeof (bcopy) __bcopy_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index c0a927d..c6a227f 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/s390/bzero.c b/sysdeps/s390/bzero.c
index 5477ed4..18f7eb8 100644
--- a/sysdeps/s390/bzero.c
+++ b/sysdeps/s390/bzero.c
@@ -19,6 +19,7 @@
 #include <ifunc-memset.h>
 #if HAVE_MEMSET_IFUNC
 # include <string.h>
+# include <strings.h>
 # include <ifunc-resolve.h>
 
 # if HAVE_MEMSET_Z900_G5
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
index 1948436..bede348 100644
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include <ifunc-resolve.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/bzero.c b/sysdeps/sparc/sparc64/multiarch/bzero.c
index 2d7c06b..3801d8d 100644
--- a/sysdeps/sparc/sparc64/multiarch/bzero.c
+++ b/sysdeps/sparc/sparc64/multiarch/bzero.c
@@ -20,6 +20,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # include <sparc-ifunc.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
index 00ed640..8326a7b 100644
--- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <sysdep.h>


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

* [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h.
@ 2019-05-26 16:36 Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-05-26 16:36 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 15822 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7bbccaf5c38075f93bec5b02b5c4c503a4045dcd

commit 7bbccaf5c38075f93bec5b02b5c4c503a4045dcd
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Mar 16 21:01:12 2019 -0400

    Limit the set of strings.h functions also exposed in string.h.
    
    As someone who can remember when you might not be able to include both
    string.h and strings.h at the same time, it annoys me that strings.h
    still exists and is the only standard source for str(n)casecmp(_l) and
    ffs.  I think it’s right that we expose those functions from string.h.
    However, there’s no reason we need to keep exposing the other obsolete
    functions that strings.h declares from string.h.
    
    This patch creates <bits/strings_x2k8.h>, which declares the
    non-obsolete functions whose official home is strings.h.  strings.h
    includes it unconditionally, and string.h includes it under
    __USE_MISC, instead of strings.h.
    
    Two tests of the obsolete strings.h functions had to be adjusted.
    
    	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
    	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
    	* string/bits/strings_x2k8.h: ... this new file.
    	* string/Makefile: Install bits/strings_x2k8.h.
    	* include/bits/strings_x2k8h: New wrapper.
    	* string/string.h: Include bits/strings_x2k8.h instead of
    	strings.h.
    
    	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
    	* scripts/check-obsolete-constructs.py: string.h is no longer
    	expected to include strings.h.
    
    	* sysdeps/i386/i686/multiarch/bcopy.c
    	* sysdeps/i386/i686/multiarch/bzero.c
    	* sysdeps/i386/i686/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
    	* sysdeps/powerpc/powerpc64/multiarch/bcopy.c
    	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
    	* sysdeps/s390/bzero.c
    	* sysdeps/s390/multiarch/ifunc-impl-list.c
    	* sysdeps/sparc/sparc64/multiarch/bzero.c
    	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c:
            Include strings.h.

Diff:
---
 NEWS                                               |  3 +
 debug/tst-chk1.c                                   |  1 +
 include/bits/strings_x2k8.h                        |  1 +
 scripts/check-obsolete-constructs.py               |  1 -
 string/Makefile                                    |  2 +-
 string/bits/strings_x2k8.h                         | 70 ++++++++++++++++++++++
 string/string.h                                    |  2 +-
 string/strings.h                                   | 39 +-----------
 string/test-string.h                               |  1 +
 sysdeps/i386/i686/multiarch/bcopy.c                |  1 +
 sysdeps/i386/i686/multiarch/bzero.c                |  1 +
 sysdeps/i386/i686/multiarch/ifunc-impl-list.c      |  1 +
 .../powerpc32/power4/multiarch/ifunc-impl-list.c   |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c  |  1 +
 sysdeps/powerpc/powerpc64/multiarch/bcopy.c        |  1 +
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  1 +
 sysdeps/s390/bzero.c                               |  1 +
 sysdeps/s390/multiarch/ifunc-impl-list.c           |  1 +
 sysdeps/sparc/sparc64/multiarch/bzero.c            |  1 +
 sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c  |  1 +
 20 files changed, 91 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index 5bc422d..336bbaf 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
+  longer declared in <string.h>, only <strings.h>.
+
 * The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
   are no longer defined by <sys/types.h> in strict conformance modes.
   These types were historically provided by <sys/types.h> on BSD systems,
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index c6f11af..014b08f 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <wchar.h>
 #include <sys/poll.h>
diff --git a/include/bits/strings_x2k8.h b/include/bits/strings_x2k8.h
new file mode 100644
index 0000000..7eddd92
--- /dev/null
+++ b/include/bits/strings_x2k8.h
@@ -0,0 +1 @@
+#include <string/bits/strings_x2k8.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 5c1bb50..91ea3eb 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -515,7 +515,6 @@ HEADER_ALLOWED_INCLUDES = {
     "inttypes.h":                  [ "stdint.h" ],
     "signal.h":                    [ "sys/ucontext.h" ],
     "stdlib.h":                    [ "alloca.h", "sys/types.h" ],
-    "string.h":                    [ "strings.h" ],
     "tgmath.h":                    [ "complex.h", "math.h" ],
     "threads.h":                   [ "time.h" ],
 
diff --git a/string/Makefile b/string/Makefile
index 38b26a0..4420a39 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -23,7 +23,7 @@ subdir	:= string
 include ../Makeconfig
 
 headers		:= string.h bits/string_fortified.h			\
-		   strings.h bits/strings_fortified.h			\
+		   strings.h bits/strings_x2k8.h bits/strings_fortified.h \
 		   byteswap.h bits/byteswap.h				\
 		   endian.h bits/endian.h bits/uintn-identity.h		\
 		   memory.h argz.h envz.h
diff --git a/string/bits/strings_x2k8.h b/string/bits/strings_x2k8.h
new file mode 100644
index 0000000..dbcb0b2
--- /dev/null
+++ b/string/bits/strings_x2k8.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2019 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 _BITS_STRINGS_X2K8_H
+#define _BITS_STRINGS_X2K8_H 1
+
+/* This header file declares all of the strings.h functions that are
+   not marked as "obsolete" in POSIX.1-2008.  As a GNU extension,
+   these functions are also made available via string.h.  */
+
+#if !defined _STRING_H && !defined _STRINGS_H
+# error "Never include <bits/strings_x2k8.h> directly, use <string(s).h>."
+#endif
+
+__BEGIN_DECLS
+
+/* Compare S1 and S2, ignoring case.  */
+extern int strcasecmp (const char *__s1, const char *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef	__USE_XOPEN2K8
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
+
+/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
+extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+
+/* Compare no more than N chars of S1 and S2, ignoring case, using
+   collation rules from LOC.  */
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+			  size_t __n, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+#endif
+
+#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
+/* Return the position of the first bit set in I, or 0 if none are set.
+   The least-significant bit is position 1, the most-significant 32.  */
+extern int ffs (int __i) __THROW __attribute_const__;
+#endif
+
+/* The following two functions are non-standard but necessary for non-32 bit
+   platforms.  */
+#ifdef	__USE_MISC
+extern int ffsl (long int __l) __THROW __attribute_const__;
+__extension__ extern int ffsll (long long int __ll)
+     __THROW __attribute_const__;
+#endif
+
+__END_DECLS
+
+#endif /* bits/strings_x2k8.h */
diff --git a/string/string.h b/string/string.h
index c38eea9..6b25243 100644
--- a/string/string.h
+++ b/string/string.h
@@ -428,7 +428,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
 #endif
 
 #ifdef __USE_MISC
-# include <strings.h>
+# include <bits/strings_x2k8.h>
 
 /* Set N bytes of S to 0.  The compiler will not delete a call to this
    function, even if S is dead after the call.  */
diff --git a/string/strings.h b/string/strings.h
index 5428bc4..8f380bf 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -22,6 +22,8 @@
 #define __need_size_t
 #include <stddef.h>
 
+#include <bits/strings_x2k8.h>
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
@@ -98,43 +100,6 @@ extern char *rindex (const char *__s, int __c)
 # endif
 #endif
 
-#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
-/* Return the position of the first bit set in I, or 0 if none are set.
-   The least-significant bit is position 1, the most-significant 32.  */
-extern int ffs (int __i) __THROW __attribute_const__;
-#endif
-
-/* The following two functions are non-standard but necessary for non-32 bit
-   platforms.  */
-# ifdef	__USE_MISC
-extern int ffsl (long int __l) __THROW __attribute_const__;
-__extension__ extern int ffsll (long long int __ll)
-     __THROW __attribute_const__;
-# endif
-
-/* Compare S1 and S2, ignoring case.  */
-extern int strcasecmp (const char *__s1, const char *__s2)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case.  */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-#ifdef	__USE_XOPEN2K8
-/* POSIX.1-2008 extended locale interface (see locale.h).  */
-# include <bits/types/locale_t.h>
-
-/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
-extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-/* Compare no more than N chars of S1 and S2, ignoring case, using
-   collation rules from LOC.  */
-extern int strncasecmp_l (const char *__s1, const char *__s2,
-			  size_t __n, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
 __END_DECLS
 
 #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
diff --git a/string/test-string.h b/string/test-string.h
index befd3e9..2c1c016 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -55,6 +55,7 @@ extern impl_t __start_impls[], __stop_impls[];
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <unistd.h>
diff --git a/sysdeps/i386/i686/multiarch/bcopy.c b/sysdeps/i386/i686/multiarch/bcopy.c
index c2d1d25..e1cd57c 100644
--- a/sysdeps/i386/i686/multiarch/bcopy.c
+++ b/sysdeps/i386/i686/multiarch/bcopy.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bcopy __redirect_bcopy
 # include <string.h>
+# include <strings.h>
 # undef bcopy
 
 # define SYMBOL_NAME bcopy
diff --git a/sysdeps/i386/i686/multiarch/bzero.c b/sysdeps/i386/i686/multiarch/bzero.c
index 6b4834e..182a496 100644
--- a/sysdeps/i386/i686/multiarch/bzero.c
+++ b/sysdeps/i386/i686/multiarch/bzero.c
@@ -21,6 +21,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # define SYMBOL_NAME bzero
diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
index e2428e0..5408aec 100644
--- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include "init-arch.h"
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index 16a64be..ac6784a 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
index 6772e0a..9ba96f7 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 
 extern __typeof (bcopy)   __bcopy_ppc attribute_hidden;
 extern __typeof (memmove) __memmove_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
index 8c6f2fb..b402117 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <strings.h>
 #include "init-arch.h"
 
 extern __typeof (bcopy) __bcopy_ppc attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index c0a927d..c6a227f 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <ifunc-impl-list.h>
diff --git a/sysdeps/s390/bzero.c b/sysdeps/s390/bzero.c
index 5477ed4..18f7eb8 100644
--- a/sysdeps/s390/bzero.c
+++ b/sysdeps/s390/bzero.c
@@ -19,6 +19,7 @@
 #include <ifunc-memset.h>
 #if HAVE_MEMSET_IFUNC
 # include <string.h>
+# include <strings.h>
 # include <ifunc-resolve.h>
 
 # if HAVE_MEMSET_Z900_G5
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
index 1948436..bede348 100644
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ifunc-impl-list.h>
 #include <ifunc-resolve.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/bzero.c b/sysdeps/sparc/sparc64/multiarch/bzero.c
index 2d7c06b..3801d8d 100644
--- a/sysdeps/sparc/sparc64/multiarch/bzero.c
+++ b/sysdeps/sparc/sparc64/multiarch/bzero.c
@@ -20,6 +20,7 @@
 #if IS_IN (libc)
 # define bzero __redirect_bzero
 # include <string.h>
+# include <strings.h>
 # undef bzero
 
 # include <sparc-ifunc.h>
diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
index 00ed640..8326a7b 100644
--- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <strings.h>
 #include <wchar.h>
 #include <ldsodefs.h>
 #include <sysdep.h>


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

* [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h.
@ 2019-05-16 18:42 Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-05-16 18:42 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 10102 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=94dda58a954e5a96d3ffefd25700661d25aa4dd9

commit 94dda58a954e5a96d3ffefd25700661d25aa4dd9
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Mar 16 21:01:12 2019 -0400

    Limit the set of strings.h functions also exposed in string.h.
    
    As someone who can remember when you might not be able to include both
    string.h and strings.h at the same time, I kinda resent that strings.h
    still exists and is the only standard source for str(n)casecmp(_l) and
    ffs.  I think it’s right that we expose those functions from string.h.
    However, there’s no reason we need to keep exposing the other obsolete
    functions that strings.h declares from string.h.
    
    This patch creates <bits/strings_x2k8.h>, which declares the
    non-obsolete functions whose official home is strings.h.  strings.h
    includes it unconditionally, and string.h includes it under
    __USE_MISC, instead of strings.h.
    
    Two tests of the obsolete strings.h functions had to be adjusted.
    
    	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
    	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
    	* string/bits/strings_x2k8.h: ... this new file.
    	* string/Makefile: Install bits/strings_x2k8.h.
    	* include/bits/strings_x2k8h: New wrapper.
    	* string/string.h: Include bits/strings_x2k8.h instead of
    	strings.h.
    
    	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
    	* scripts/check-obsolete-constructs.py: string.h is no longer
    	expected to include strings.h.

Diff:
---
 NEWS                                 |  3 ++
 debug/tst-chk1.c                     |  1 +
 include/bits/strings_x2k8.h          |  1 +
 scripts/check-obsolete-constructs.py |  1 -
 string/Makefile                      |  2 +-
 string/bits/strings_x2k8.h           | 70 ++++++++++++++++++++++++++++++++++++
 string/string.h                      |  2 +-
 string/strings.h                     | 39 ++------------------
 string/test-string.h                 |  1 +
 9 files changed, 80 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index 3dace08..25bf198 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
+  longer declared in <string.h>, only <strings.h>.
+
 * The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
   are no longer defined by <sys/types.h> in strict conformance modes.
   These types were historically provided by <sys/types.h> on BSD systems,
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index c6f11af..014b08f 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <wchar.h>
 #include <sys/poll.h>
diff --git a/include/bits/strings_x2k8.h b/include/bits/strings_x2k8.h
new file mode 100644
index 0000000..7eddd92
--- /dev/null
+++ b/include/bits/strings_x2k8.h
@@ -0,0 +1 @@
+#include <string/bits/strings_x2k8.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index a06e986..9bda57f 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -514,7 +514,6 @@ HEADER_ALLOWED_INCLUDES = {
     "inttypes.h":                  [ "stdint.h" ],
     "signal.h":                    [ "sys/ucontext.h" ],
     "stdlib.h":                    [ "alloca.h", "sys/types.h" ],
-    "string.h":                    [ "strings.h" ],
     "tgmath.h":                    [ "complex.h", "math.h" ],
     "threads.h":                   [ "time.h" ],
 
diff --git a/string/Makefile b/string/Makefile
index 3e5721e..c9ebede 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -23,7 +23,7 @@ subdir	:= string
 include ../Makeconfig
 
 headers		:= string.h bits/string_fortified.h			\
-		   strings.h bits/strings_fortified.h			\
+		   strings.h bits/strings_x2k8.h bits/strings_fortified.h \
 		   byteswap.h bits/byteswap.h				\
 		   endian.h bits/endian.h bits/endianness.h		\
 		   bits/uintn-identity.h				\
diff --git a/string/bits/strings_x2k8.h b/string/bits/strings_x2k8.h
new file mode 100644
index 0000000..dbcb0b2
--- /dev/null
+++ b/string/bits/strings_x2k8.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2019 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 _BITS_STRINGS_X2K8_H
+#define _BITS_STRINGS_X2K8_H 1
+
+/* This header file declares all of the strings.h functions that are
+   not marked as "obsolete" in POSIX.1-2008.  As a GNU extension,
+   these functions are also made available via string.h.  */
+
+#if !defined _STRING_H && !defined _STRINGS_H
+# error "Never include <bits/strings_x2k8.h> directly, use <string(s).h>."
+#endif
+
+__BEGIN_DECLS
+
+/* Compare S1 and S2, ignoring case.  */
+extern int strcasecmp (const char *__s1, const char *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef	__USE_XOPEN2K8
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
+
+/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
+extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+
+/* Compare no more than N chars of S1 and S2, ignoring case, using
+   collation rules from LOC.  */
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+			  size_t __n, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+#endif
+
+#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
+/* Return the position of the first bit set in I, or 0 if none are set.
+   The least-significant bit is position 1, the most-significant 32.  */
+extern int ffs (int __i) __THROW __attribute_const__;
+#endif
+
+/* The following two functions are non-standard but necessary for non-32 bit
+   platforms.  */
+#ifdef	__USE_MISC
+extern int ffsl (long int __l) __THROW __attribute_const__;
+__extension__ extern int ffsll (long long int __ll)
+     __THROW __attribute_const__;
+#endif
+
+__END_DECLS
+
+#endif /* bits/strings_x2k8.h */
diff --git a/string/string.h b/string/string.h
index c38eea9..6b25243 100644
--- a/string/string.h
+++ b/string/string.h
@@ -428,7 +428,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
 #endif
 
 #ifdef __USE_MISC
-# include <strings.h>
+# include <bits/strings_x2k8.h>
 
 /* Set N bytes of S to 0.  The compiler will not delete a call to this
    function, even if S is dead after the call.  */
diff --git a/string/strings.h b/string/strings.h
index 5428bc4..8f380bf 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -22,6 +22,8 @@
 #define __need_size_t
 #include <stddef.h>
 
+#include <bits/strings_x2k8.h>
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
@@ -98,43 +100,6 @@ extern char *rindex (const char *__s, int __c)
 # endif
 #endif
 
-#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
-/* Return the position of the first bit set in I, or 0 if none are set.
-   The least-significant bit is position 1, the most-significant 32.  */
-extern int ffs (int __i) __THROW __attribute_const__;
-#endif
-
-/* The following two functions are non-standard but necessary for non-32 bit
-   platforms.  */
-# ifdef	__USE_MISC
-extern int ffsl (long int __l) __THROW __attribute_const__;
-__extension__ extern int ffsll (long long int __ll)
-     __THROW __attribute_const__;
-# endif
-
-/* Compare S1 and S2, ignoring case.  */
-extern int strcasecmp (const char *__s1, const char *__s2)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case.  */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-#ifdef	__USE_XOPEN2K8
-/* POSIX.1-2008 extended locale interface (see locale.h).  */
-# include <bits/types/locale_t.h>
-
-/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
-extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-/* Compare no more than N chars of S1 and S2, ignoring case, using
-   collation rules from LOC.  */
-extern int strncasecmp_l (const char *__s1, const char *__s2,
-			  size_t __n, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
 __END_DECLS
 
 #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
diff --git a/string/test-string.h b/string/test-string.h
index befd3e9..2c1c016 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -55,6 +55,7 @@ extern impl_t __start_impls[], __stop_impls[];
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <unistd.h>


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

* [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h.
@ 2019-05-16 18:36 Zack Weinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-05-16 18:36 UTC (permalink / raw)
  To: glibc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 10102 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d6fa230a3afe8422698faf9bcd60ad99047edb41

commit d6fa230a3afe8422698faf9bcd60ad99047edb41
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Mar 16 21:01:12 2019 -0400

    Limit the set of strings.h functions also exposed in string.h.
    
    As someone who can remember when you might not be able to include both
    string.h and strings.h at the same time, I kinda resent that strings.h
    still exists and is the only standard source for str(n)casecmp(_l) and
    ffs.  I think it’s right that we expose those functions from string.h.
    However, there’s no reason we need to keep exposing the other obsolete
    functions that strings.h declares from string.h.
    
    This patch creates <bits/strings_x2k8.h>, which declares the
    non-obsolete functions whose official home is strings.h.  strings.h
    includes it unconditionally, and string.h includes it under
    __USE_MISC, instead of strings.h.
    
    Two tests of the obsolete strings.h functions had to be adjusted.
    
    	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
    	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
    	* string/bits/strings_x2k8.h: ... this new file.
    	* string/Makefile: Install bits/strings_x2k8.h.
    	* include/bits/strings_x2k8h: New wrapper.
    	* string/string.h: Include bits/strings_x2k8.h instead of
    	strings.h.
    
    	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
    	* scripts/check-obsolete-constructs.py: string.h is no longer
    	expected to include strings.h.

Diff:
---
 NEWS                                 |  3 ++
 debug/tst-chk1.c                     |  1 +
 include/bits/strings_x2k8.h          |  1 +
 scripts/check-obsolete-constructs.py |  1 -
 string/Makefile                      |  2 +-
 string/bits/strings_x2k8.h           | 70 ++++++++++++++++++++++++++++++++++++
 string/string.h                      |  2 +-
 string/strings.h                     | 39 ++------------------
 string/test-string.h                 |  1 +
 9 files changed, 80 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index 3dace08..25bf198 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The obsolete and never-implemented XSI STREAMS header files <stropts.h>
   and <sys/stropts.h> have been removed.
 
+* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
+  longer declared in <string.h>, only <strings.h>.
+
 * The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
   are no longer defined by <sys/types.h> in strict conformance modes.
   These types were historically provided by <sys/types.h> on BSD systems,
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index c6f11af..014b08f 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <wchar.h>
 #include <sys/poll.h>
diff --git a/include/bits/strings_x2k8.h b/include/bits/strings_x2k8.h
new file mode 100644
index 0000000..7eddd92
--- /dev/null
+++ b/include/bits/strings_x2k8.h
@@ -0,0 +1 @@
+#include <string/bits/strings_x2k8.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index a06e986..9bda57f 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -514,7 +514,6 @@ HEADER_ALLOWED_INCLUDES = {
     "inttypes.h":                  [ "stdint.h" ],
     "signal.h":                    [ "sys/ucontext.h" ],
     "stdlib.h":                    [ "alloca.h", "sys/types.h" ],
-    "string.h":                    [ "strings.h" ],
     "tgmath.h":                    [ "complex.h", "math.h" ],
     "threads.h":                   [ "time.h" ],
 
diff --git a/string/Makefile b/string/Makefile
index 3e5721e..c9ebede 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -23,7 +23,7 @@ subdir	:= string
 include ../Makeconfig
 
 headers		:= string.h bits/string_fortified.h			\
-		   strings.h bits/strings_fortified.h			\
+		   strings.h bits/strings_x2k8.h bits/strings_fortified.h \
 		   byteswap.h bits/byteswap.h				\
 		   endian.h bits/endian.h bits/endianness.h		\
 		   bits/uintn-identity.h				\
diff --git a/string/bits/strings_x2k8.h b/string/bits/strings_x2k8.h
new file mode 100644
index 0000000..dbcb0b2
--- /dev/null
+++ b/string/bits/strings_x2k8.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2019 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 _BITS_STRINGS_X2K8_H
+#define _BITS_STRINGS_X2K8_H 1
+
+/* This header file declares all of the strings.h functions that are
+   not marked as "obsolete" in POSIX.1-2008.  As a GNU extension,
+   these functions are also made available via string.h.  */
+
+#if !defined _STRING_H && !defined _STRINGS_H
+# error "Never include <bits/strings_x2k8.h> directly, use <string(s).h>."
+#endif
+
+__BEGIN_DECLS
+
+/* Compare S1 and S2, ignoring case.  */
+extern int strcasecmp (const char *__s1, const char *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef	__USE_XOPEN2K8
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
+
+/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
+extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+
+/* Compare no more than N chars of S1 and S2, ignoring case, using
+   collation rules from LOC.  */
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+			  size_t __n, locale_t __loc)
+     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+#endif
+
+#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
+/* Return the position of the first bit set in I, or 0 if none are set.
+   The least-significant bit is position 1, the most-significant 32.  */
+extern int ffs (int __i) __THROW __attribute_const__;
+#endif
+
+/* The following two functions are non-standard but necessary for non-32 bit
+   platforms.  */
+#ifdef	__USE_MISC
+extern int ffsl (long int __l) __THROW __attribute_const__;
+__extension__ extern int ffsll (long long int __ll)
+     __THROW __attribute_const__;
+#endif
+
+__END_DECLS
+
+#endif /* bits/strings_x2k8.h */
diff --git a/string/string.h b/string/string.h
index c38eea9..6b25243 100644
--- a/string/string.h
+++ b/string/string.h
@@ -428,7 +428,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
 #endif
 
 #ifdef __USE_MISC
-# include <strings.h>
+# include <bits/strings_x2k8.h>
 
 /* Set N bytes of S to 0.  The compiler will not delete a call to this
    function, even if S is dead after the call.  */
diff --git a/string/strings.h b/string/strings.h
index 5428bc4..8f380bf 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -22,6 +22,8 @@
 #define __need_size_t
 #include <stddef.h>
 
+#include <bits/strings_x2k8.h>
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
@@ -98,43 +100,6 @@ extern char *rindex (const char *__s, int __c)
 # endif
 #endif
 
-#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
-/* Return the position of the first bit set in I, or 0 if none are set.
-   The least-significant bit is position 1, the most-significant 32.  */
-extern int ffs (int __i) __THROW __attribute_const__;
-#endif
-
-/* The following two functions are non-standard but necessary for non-32 bit
-   platforms.  */
-# ifdef	__USE_MISC
-extern int ffsl (long int __l) __THROW __attribute_const__;
-__extension__ extern int ffsll (long long int __ll)
-     __THROW __attribute_const__;
-# endif
-
-/* Compare S1 and S2, ignoring case.  */
-extern int strcasecmp (const char *__s1, const char *__s2)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case.  */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
-     __THROW __attribute_pure__ __nonnull ((1, 2));
-
-#ifdef	__USE_XOPEN2K8
-/* POSIX.1-2008 extended locale interface (see locale.h).  */
-# include <bits/types/locale_t.h>
-
-/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
-extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-/* Compare no more than N chars of S1 and S2, ignoring case, using
-   collation rules from LOC.  */
-extern int strncasecmp_l (const char *__s1, const char *__s2,
-			  size_t __n, locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
 __END_DECLS
 
 #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
diff --git a/string/test-string.h b/string/test-string.h
index befd3e9..2c1c016 100644
--- a/string/test-string.h
+++ b/string/test-string.h
@@ -55,6 +55,7 @@ extern impl_t __start_impls[], __stop_impls[];
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <unistd.h>


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

end of thread, other threads:[~2020-01-08 19:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 15:49 [glibc/zack/no-nested-includes] Limit the set of strings.h functions also exposed in string.h Zack Weinberg
  -- strict thread matches above, loose matches on Subject: below --
2020-01-08 19:20 Zack Weinberg
2019-06-20 16:06 Zack Weinberg
2019-06-18 15:33 Zack Weinberg
2019-05-26 16:36 Zack Weinberg
2019-05-16 18:42 Zack Weinberg
2019-05-16 18:36 Zack Weinberg

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).