[6/6] Deprecate xlocale.h and add bits/types/locale_t.h.

Message ID 20170610171738.22362-7-zackw@panix.com
State Superseded
Headers

Commit Message

Zack Weinberg June 10, 2017, 5:17 p.m. UTC
  xlocale.h is already a single-type micro-header, defining locale_t, so
it would be nice to bring it into the overall bits/types/ scheme.
Unfortunately, it's in the top level of the system-header namespace
and, despite the comment saying "This file is not standardized, don't
rely on it, it can go away without warning", there are a lot of
external uses, so we need to deprecate it first, which is what this
patch does.

The implementation-namespace alias, __locale_t, may not actually be
necessary; there are no situations where it is available but locale_t
isn't, and I did not find any cases in Issue 7 where a header that
defines functions taking a locale_t argument is not also supposed to
declare locale_t.  However, like xlocale.h it seems to have a fair
number of external uses, so we are probably stuck with it.

I also took the opportunity to clean up comments in various public
header files that still talk about the *_l interfaces as though they
were completely nonstandard.  There are a few of them, notably the
strtoX_l and wcstoX_l families, that haven't been standardized, but
the bulk are in POSIX.1-2008.

	* locale/bits/types/locale_t.h: New file containing former
	contents of locale/xlocale.h, with minor adjustments to commentary.
	* locale/xlocale.h: Replace with deprecation shim that issues a
	warning and includes <locale.h>.
	* locale/Makefile: Install bits/types/locale_t.h.
	* scripts/check-installed-headers.sh: Skip xlocale.h.
	* include/xlocale.h: Delete wrapper.
	* include/bits/types/locale_t.h: New wrapper.

	* ctype/ctype.h, include/printf.h, include/time.h
	* locale/langinfo.h, locale/locale.h, stdlib/monetary.h
	* stdlib/stdlib.h, string/string.h, string/strings.h, time/time.h
	* wcsmbs/wchar.h, wctype/wctype.h: Use bits/types/locale_t.h.
	Correct outdated comments regarding the standardization status of
	the functions that take locale_t arguments.

	* stdlib/strtod_l.c, stdlib/strtof_l.c, stdlib/strtol_l.c
	* stdlib/strtold_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
	* sysdeps/ieee754/ldbl-128ibm/strtold_l.c
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c
        * wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
	* wcsmbs/wcstof_l.c, wcsmbs/wcstold.c, wcsmbs/wcstold_l.c:
        Don't include xlocale.h. If necessary, include locale.h instead.

	* stdlib/strtold_l.c: Unconditionally include wchar.h.
---
 NEWS                                    |  3 ++
 ctype/ctype.h                           | 16 ++---------
 include/bits/types/locale_t.h           |  1 +
 include/printf.h                        |  2 +-
 include/time.h                          |  2 +-
 include/xlocale.h                       |  1 -
 locale/Makefile                         |  3 +-
 locale/bits/types/locale_t.h            | 44 +++++++++++++++++++++++++++++
 locale/langinfo.h                       |  7 ++---
 locale/locale.h                         | 20 +++++--------
 locale/xlocale.h                        | 50 +++++++--------------------------
 scripts/check-installed-headers.sh      |  4 +++
 stdlib/monetary.h                       |  3 +-
 stdlib/stdlib.h                         | 20 +++----------
 stdlib/strtod_l.c                       |  3 +-
 stdlib/strtof_l.c                       |  2 +-
 stdlib/strtol_l.c                       |  1 -
 stdlib/strtold_l.c                      |  6 +---
 stdlib/strtoll_l.c                      |  2 +-
 stdlib/strtoul_l.c                      |  2 +-
 stdlib/strtoull_l.c                     |  2 +-
 string/string.h                         |  3 +-
 string/strings.h                        |  3 +-
 sysdeps/ieee754/ldbl-128ibm/strtold_l.c |  1 -
 sysdeps/ieee754/ldbl-64-128/strtold_l.c |  1 -
 time/time.h                             |  2 +-
 wcsmbs/wchar.h                          | 27 ++++--------------
 wcsmbs/wcstod.c                         |  2 +-
 wcsmbs/wcstod_l.c                       |  2 +-
 wcsmbs/wcstof.c                         |  2 +-
 wcsmbs/wcstof_l.c                       |  2 +-
 wcsmbs/wcstold.c                        |  2 +-
 wcsmbs/wcstold_l.c                      |  2 +-
 wctype/wctype.h                         |  4 +--
 34 files changed, 108 insertions(+), 139 deletions(-)
 create mode 100644 include/bits/types/locale_t.h
 delete mode 100644 include/xlocale.h
 create mode 100644 locale/bits/types/locale_t.h
  

Comments

Florian Weimer June 14, 2017, 11:11 a.m. UTC | #1
On 06/10/2017 07:17 PM, Zack Weinberg wrote:
> xlocale.h is already a single-type micro-header, defining locale_t, so
> it would be nice to bring it into the overall bits/types/ scheme.
> Unfortunately, it's in the top level of the system-header namespace
> and, despite the comment saying "This file is not standardized, don't
> rely on it, it can go away without warning", there are a lot of
> external uses, so we need to deprecate it first, which is what this
> patch does.

I would suggest to remove it outright.  I saw quite a few references to
<xlocale.h> covered under autoconf tests.  Removal means that the tests
fail, and the #include <xlocale.h> is #ifdef'ed out in the actual
sources.  A deprecation warning will cause the autoconf test to fail,
but then the #include may still fail due to the deprecation warning and
-Werror.

Thanks,
Florian
  
Zack Weinberg June 14, 2017, 11:25 a.m. UTC | #2
On Wed, Jun 14, 2017 at 7:11 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 06/10/2017 07:17 PM, Zack Weinberg wrote:
>> xlocale.h is already a single-type micro-header, defining locale_t, so
>> it would be nice to bring it into the overall bits/types/ scheme.
>> Unfortunately, it's in the top level of the system-header namespace
>> and, despite the comment saying "This file is not standardized, don't
>> rely on it, it can go away without warning", there are a lot of
>> external uses, so we need to deprecate it first, which is what this
>> patch does.
>
> I would suggest to remove it outright.  I saw quite a few references to
> <xlocale.h> covered under autoconf tests.  Removal means that the tests
> fail, and the #include <xlocale.h> is #ifdef'ed out in the actual
> sources.  A deprecation warning will cause the autoconf test to fail,
> but then the #include may still fail due to the deprecation warning and
> -Werror.

(I assume you meant "the autoconf test will succeed".)

I'm willing to do that if there is general agreement but I'd like to
hear from some more people first.

zw
  
Florian Weimer June 14, 2017, 11:27 a.m. UTC | #3
On 06/14/2017 01:25 PM, Zack Weinberg wrote:
> On Wed, Jun 14, 2017 at 7:11 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 06/10/2017 07:17 PM, Zack Weinberg wrote:
>>> xlocale.h is already a single-type micro-header, defining locale_t, so
>>> it would be nice to bring it into the overall bits/types/ scheme.
>>> Unfortunately, it's in the top level of the system-header namespace
>>> and, despite the comment saying "This file is not standardized, don't
>>> rely on it, it can go away without warning", there are a lot of
>>> external uses, so we need to deprecate it first, which is what this
>>> patch does.
>>
>> I would suggest to remove it outright.  I saw quite a few references to
>> <xlocale.h> covered under autoconf tests.  Removal means that the tests
>> fail, and the #include <xlocale.h> is #ifdef'ed out in the actual
>> sources.  A deprecation warning will cause the autoconf test to fail,
>> but then the #include may still fail due to the deprecation warning and
>> -Werror.
> 
> (I assume you meant "the autoconf test will succeed".)

Right.

> I'm willing to do that if there is general agreement but I'd like to
> hear from some more people first.

Good idea, let's wait and see what others have to say.

Thanks,
Florian
  
Joseph Myers June 14, 2017, 3:20 p.m. UTC | #4
On Wed, 14 Jun 2017, Zack Weinberg wrote:

> On Wed, Jun 14, 2017 at 7:11 AM, Florian Weimer <fweimer@redhat.com> wrote:
> > On 06/10/2017 07:17 PM, Zack Weinberg wrote:
> >> xlocale.h is already a single-type micro-header, defining locale_t, so
> >> it would be nice to bring it into the overall bits/types/ scheme.
> >> Unfortunately, it's in the top level of the system-header namespace
> >> and, despite the comment saying "This file is not standardized, don't
> >> rely on it, it can go away without warning", there are a lot of
> >> external uses, so we need to deprecate it first, which is what this
> >> patch does.
> >
> > I would suggest to remove it outright.  I saw quite a few references to
> > <xlocale.h> covered under autoconf tests.  Removal means that the tests
> > fail, and the #include <xlocale.h> is #ifdef'ed out in the actual
> > sources.  A deprecation warning will cause the autoconf test to fail,
> > but then the #include may still fail due to the deprecation warning and
> > -Werror.
> 
> (I assume you meant "the autoconf test will succeed".)
> 
> I'm willing to do that if there is general agreement but I'd like to
> hear from some more people first.

I'd be fine with getting rid of xlocale.h.

I think __locale_t may well be one of the many interfaces that need 
providing under implementation-namespace names for libstdc++ headers to be 
namespace-clean and not require _GNU_SOURCE to implement standard C++ 
functionality (but I haven't checked exactly how it's used in libstdc++).
  
Zack Weinberg June 14, 2017, 3:51 p.m. UTC | #5
On Wed, Jun 14, 2017 at 11:20 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>
> I think __locale_t may well be one of the many interfaces that need
> providing under implementation-namespace names for libstdc++ headers to be
> namespace-clean and not require _GNU_SOURCE to implement standard C++
> functionality (but I haven't checked exactly how it's used in libstdc++).

I don't see any existing uses of locale_t or __locale_t under
/usr/include/c++ but I would have no objection to adding a
bits/types/__locale_t.h that provided *only* the impl-namespace name,
even though nothing needs it right now.

It's just that right now xlocale.h insists on exposing both __locale_t
and locale_t, and I think all of the uses of __locale_t in our own
headers could be locale_t.

zw
  
Joseph Myers June 14, 2017, 3:54 p.m. UTC | #6
On Wed, 14 Jun 2017, Zack Weinberg wrote:

> On Wed, Jun 14, 2017 at 11:20 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > I think __locale_t may well be one of the many interfaces that need
> > providing under implementation-namespace names for libstdc++ headers to be
> > namespace-clean and not require _GNU_SOURCE to implement standard C++
> > functionality (but I haven't checked exactly how it's used in libstdc++).
> 
> I don't see any existing uses of locale_t or __locale_t under
> /usr/include/c++ but I would have no objection to adding a
> bits/types/__locale_t.h that provided *only* the impl-namespace name,
> even though nothing needs it right now.

In the GCC 6 compiler I use for building glibc, I see "typedef __locale_t 
__c_locale;" in the multilib-specific bits/c++locale.h files.
  
Zack Weinberg June 14, 2017, 3:58 p.m. UTC | #7
On Wed, Jun 14, 2017 at 11:54 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Wed, 14 Jun 2017, Zack Weinberg wrote:
>> On Wed, Jun 14, 2017 at 11:20 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>> > I think __locale_t may well be one of the many interfaces that need
>> > providing under implementation-namespace names for libstdc++ headers to be
>> > namespace-clean and not require _GNU_SOURCE to implement standard C++
>> > functionality (but I haven't checked exactly how it's used in libstdc++).
>>
>> I don't see any existing uses of locale_t or __locale_t under
>> /usr/include/c++ but I would have no objection to adding a
>> bits/types/__locale_t.h that provided *only* the impl-namespace name,
>> even though nothing needs it right now.
>
> In the GCC 6 compiler I use for building glibc, I see "typedef __locale_t
> __c_locale;" in the multilib-specific bits/c++locale.h files.

Doh, I forgot to check /usr/include/x86_64-linux-gnu/c++.  Yes, I see
that now as well.

zw
  

Patch

diff --git a/NEWS b/NEWS
index 1b96b3897d..cbb0c80d78 100644
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,9 @@  Version 2.26
 
 * The obsolete signal constant SIGUNUSED is no longer defined by <signal.h>.  
 
+* The nonstandard header <xlocale.h> is deprecated, and will be removed in a
+  future release.  Most programs should use <locale.h> instead.
+
 * The reallocarray function has been added to libc.  It is a realloc
   replacement with a check for integer overflow when calculating total
   allocation size.
diff --git a/ctype/ctype.h b/ctype/ctype.h
index 1fe89cf836..ce598d53e5 100644
--- a/ctype/ctype.h
+++ b/ctype/ctype.h
@@ -233,20 +233,8 @@  __NTH (toupper (int __c))
 
 
 #ifdef __USE_XOPEN2K8
-/* The concept of one static locale per category is not very well
-   thought out.  Many applications will need to process its data using
-   information from several different locales.  Another application is
-   the implementation of the internationalization handling in the
-   upcoming ISO C++ standard library.  To support this another set of
-   the functions using locale data exist which have an additional
-   argument.
-
-   Attention: all these functions are *not* standardized in any form.
-   This is a proof-of-concept implementation.  */
-
-/* Structure for reentrant locale using functions.  This is an
-   (almost) opaque type for the user level programs.  */
-# include <xlocale.h>
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
 
 /* These definitions are similar to the ones above but all functions
    take as an argument a handle for the locale which shall be used.  */
diff --git a/include/bits/types/locale_t.h b/include/bits/types/locale_t.h
new file mode 100644
index 0000000000..24b074872f
--- /dev/null
+++ b/include/bits/types/locale_t.h
@@ -0,0 +1 @@ 
+#include <locale/bits/types/locale_t.h>
diff --git a/include/printf.h b/include/printf.h
index 984f263167..7b4d209c47 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -4,7 +4,7 @@ 
 
 # ifndef _ISOMAC
 
-#include <xlocale.h>
+#include <bits/types/locale_t.h>
 
 /* Now define the internal interfaces.  */
 extern int __printf_fphex (FILE *, const struct printf_info *,
diff --git a/include/time.h b/include/time.h
index 3a828e0420..0a67cf3a19 100644
--- a/include/time.h
+++ b/include/time.h
@@ -2,7 +2,7 @@ 
 #include <time/time.h>
 
 #ifndef _ISOMAC
-# include <xlocale.h>
+# include <bits/types/locale_t.h>
 
 extern __typeof (strftime_l) __strftime_l;
 libc_hidden_proto (__strftime_l)
diff --git a/include/xlocale.h b/include/xlocale.h
deleted file mode 100644
index 5280ef0bc4..0000000000
--- a/include/xlocale.h
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <locale/xlocale.h>
diff --git a/locale/Makefile b/locale/Makefile
index d9ef48fe93..2f81311a0e 100644
--- a/locale/Makefile
+++ b/locale/Makefile
@@ -22,7 +22,8 @@  subdir	:= locale
 
 include ../Makeconfig
 
-headers		= locale.h bits/locale.h langinfo.h xlocale.h
+headers		= locale.h bits/locale.h bits/types/locale_t.h \
+		  langinfo.h xlocale.h
 routines	= setlocale findlocale loadlocale loadarchive \
 		  localeconv nl_langinfo nl_langinfo_l mb_cur_max \
 		  newlocale duplocale freelocale uselocale
diff --git a/locale/bits/types/locale_t.h b/locale/bits/types/locale_t.h
new file mode 100644
index 0000000000..4d4def583c
--- /dev/null
+++ b/locale/bits/types/locale_t.h
@@ -0,0 +1,44 @@ 
+/* Definition of locale datatype.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   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_TYPES_LOCALE_T_H
+#define _BITS_TYPES_LOCALE_T_H	1
+
+/* POSIX.1-2008: the locale_t type, representing a locale context.
+   This type should be treated as opaque by applications; some details
+   are exposed for the sake of efficiency in e.g. ctype functions.  */
+
+struct __locale_struct
+{
+  /* Note: LC_ALL is not a valid index into this array.  */
+  struct __locale_data *__locales[13]; /* 13 = __LC_LAST. */
+
+  /* To increase the speed of this solution we add some special members.  */
+  const unsigned short int *__ctype_b;
+  const int *__ctype_tolower;
+  const int *__ctype_toupper;
+
+  /* Note: LC_ALL is not a valid index into this array.  */
+  const char *__names[13];
+};
+
+typedef struct __locale_struct *__locale_t;
+typedef struct __locale_struct *locale_t;
+
+#endif /* xlocale.h */
diff --git a/locale/langinfo.h b/locale/langinfo.h
index 759adfbd1f..93d84463b5 100644
--- a/locale/langinfo.h
+++ b/locale/langinfo.h
@@ -584,11 +584,8 @@  extern char *nl_langinfo (nl_item __item) __THROW;
 
 
 #ifdef __USE_XOPEN2K8
-/* This interface is for the extended locale model.  See <locale.h> for
-   more information.  */
-
-/* Get locale datatype definition.  */
-# include <xlocale.h>
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
 
 /* Just like nl_langinfo but get the information from the locale object L.  */
 extern char *nl_langinfo_l (nl_item __item, __locale_t __l);
diff --git a/locale/locale.h b/locale/locale.h
index 9a5fce9d47..6c1b22051b 100644
--- a/locale/locale.h
+++ b/locale/locale.h
@@ -126,19 +126,13 @@  extern struct lconv *localeconv (void) __THROW;
 
 
 #ifdef	__USE_XOPEN2K8
-/* The concept of one static locale per category is not very well
-   thought out.  Many applications will need to process its data using
-   information from several different locales.  Another application is
-   the implementation of the internationalization handling in the
-   upcoming ISO C++ standard library.  To support this another set of
-   the functions using locale data exist which have an additional
-   argument.
-
-   Attention: all these functions are *not* standardized in any form.
-   This is a proof-of-concept implementation.  */
-
-/* Get locale datatype definition.  */
-# include <xlocale.h>
+/* POSIX.1-2008 extends the locale interface with functions for
+   explicit creation and manipulation of 'locale_t' objects
+   representing locale contexts, and a set of parallel
+   locale-sensitive text processing functions that take a locale_t
+   argument.  This enables applications to work with data from
+   multiple locales simultaneously and thread-safely.  */
+# include <bits/types/locale_t.h>
 
 /* Return a reference to a data structure representing a set of locale
    datasets.  Unlike for the CATEGORY parameter for `setlocale' the
diff --git a/locale/xlocale.h b/locale/xlocale.h
index 20b2c1109f..d0bc5b040d 100644
--- a/locale/xlocale.h
+++ b/locale/xlocale.h
@@ -1,44 +1,14 @@ 
-/* Definition of locale datatype.
-   Copyright (C) 1997-2017 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   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 _XLOCALE_H
-#define _XLOCALE_H	1
+#define _XLOCALE_H
 
-/* Structure for reentrant locale using functions.  This is an
-   (almost) opaque type for the user level programs.  The file and
-   this data structure is not standardized.  Don't rely on it.  It can
-   go away without warning.  */
-typedef struct __locale_struct
-{
-  /* Note: LC_ALL is not a valid index into this array.  */
-  struct __locale_data *__locales[13]; /* 13 = __LC_LAST. */
+/* xlocale.h was never intended to be a public header, but it existed
+   for a long time and was widely used enough that we are providing a
+   shim.  If you have a concrete reason to want just the definition of
+   locale_t, not anything else from locale.h (for instance, you are a
+   library implementing a standard that places restrictions on what
+   symbols your headers may expose), use <bits/types/locale_t.h>.  */
 
-  /* To increase the speed of this solution we add some special members.  */
-  const unsigned short int *__ctype_b;
-  const int *__ctype_tolower;
-  const int *__ctype_toupper;
+#warning "xlocale.h is deprecated, use locale.h instead"
+#include <locale.h>
 
-  /* Note: LC_ALL is not a valid index into this array.  */
-  const char *__names[13];
-} *__locale_t;
-
-/* POSIX 2008 makes locale_t official.  */
-typedef __locale_t locale_t;
-
-#endif /* xlocale.h */
+#endif
diff --git a/scripts/check-installed-headers.sh b/scripts/check-installed-headers.sh
index 4cbef0ea49..30afebb28a 100644
--- a/scripts/check-installed-headers.sh
+++ b/scripts/check-installed-headers.sh
@@ -78,6 +78,10 @@  for header in "$@"; do
         (bits/* | regexp.h | rpcsvc/*.x)
             continue;;
 
+	# xlocale.h contains an unconditional deprecation #warning.
+	(xlocale.h)
+	    continue;;
+
         # All extant versions of sys/elf.h contain nothing more than an
         # exhortation (either a #warning or an #error) to use sys/procfs.h
         # instead, plus an inclusion of that header.
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index dcfbfc5262..c1fcbf06d1 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -40,7 +40,8 @@  extern ssize_t strfmon (char *__restrict __s, size_t __maxsize,
      __THROW __attribute_format_strfmon__ (3, 4);
 
 #ifdef __USE_XOPEN2K8
-# include <xlocale.h>
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
 
 /* Formatting a monetary value according to the given locale.  */
 extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize,
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 0a693c2b41..ad56bf3648 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -186,23 +186,11 @@  extern int strfromf128 (char *__dest, size_t __size, const char * __format,
 
 
 #ifdef __USE_GNU
-/* The concept of one static locale per category is not very well
-   thought out.  Many applications will need to process its data using
-   information from several different locales.  Another problem is
-   the implementation of the internationalization handling in the
-   ISO C++ standard library.  To support this another set of
-   the functions using locale data exist which take an additional
-   argument.
+/* Parallel versions of the functions above which take the locale to
+   use as an additional parameter.  These are GNU extensions inspired
+   by the POSIX.1-2008 extended locale API.  */
+# include <bits/types/locale_t.h>
 
-   Attention: even though several *_l interfaces are part of POSIX:2008,
-   these are not.  */
-
-/* Structure for reentrant locale using functions.  This is an
-   (almost) opaque type for the user level programs.  */
-# include <xlocale.h>
-
-/* Special versions of the functions above which take the locale to
-   use as an additional parameter.  */
 extern long int strtol_l (const char *__restrict __nptr,
 			  char **__restrict __endptr, int __base,
 			  __locale_t __loc) __THROW __nonnull ((1, 4));
diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index 99c2af357e..a782a2434b 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -17,7 +17,7 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <xlocale.h>
+#include <locale.h>
 
 extern double ____strtod_l_internal (const char *, char **, int, __locale_t);
 
@@ -46,7 +46,6 @@  extern double ____strtod_l_internal (const char *, char **, int, __locale_t);
 #include <errno.h>
 #include <float.h>
 #include "../locale/localeinfo.h"
-#include <locale.h>
 #include <math.h>
 #include <math_private.h>
 #include <stdlib.h>
diff --git a/stdlib/strtof_l.c b/stdlib/strtof_l.c
index 57e557516a..ea76c344f4 100644
--- a/stdlib/strtof_l.c
+++ b/stdlib/strtof_l.c
@@ -17,7 +17,7 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <xlocale.h>
+#include <locale.h>
 
 extern float ____strtof_l_internal (const char *, char **, int, __locale_t);
 
diff --git a/stdlib/strtol_l.c b/stdlib/strtol_l.c
index 5a0683b2bb..48e9ab5310 100644
--- a/stdlib/strtol_l.c
+++ b/stdlib/strtol_l.c
@@ -41,7 +41,6 @@ 
 #include <stdlib.h>
 #include <string.h>
 #include <locale.h>
-#include <xlocale.h>
 #include <stdint.h>
 #include <bits/wordsize.h>
 
diff --git a/stdlib/strtold_l.c b/stdlib/strtold_l.c
index bef2a4d3d7..7b9efd8819 100644
--- a/stdlib/strtold_l.c
+++ b/stdlib/strtold_l.c
@@ -17,11 +17,7 @@ 
 
 #include <math.h>
 #include <stdlib.h>
-#include <xlocale.h>
-
-#if defined _LIBC || defined HAVE_WCHAR_H
-# include <wchar.h>
-#endif
+#include <wchar.h>
 
 #ifdef USE_WIDE_CHAR
 # define STRING_TYPE	wchar_t
diff --git a/stdlib/strtoll_l.c b/stdlib/strtoll_l.c
index 2a712eb80e..003f425db8 100644
--- a/stdlib/strtoll_l.c
+++ b/stdlib/strtoll_l.c
@@ -19,7 +19,7 @@ 
 
 #define QUAD	1
 
-#include <xlocale.h>
+#include <locale.h>
 
 extern long long int ____strtoll_l_internal (const char *, char **, int, int,
 					     __locale_t);
diff --git a/stdlib/strtoul_l.c b/stdlib/strtoul_l.c
index 6d23ee2964..45b0585342 100644
--- a/stdlib/strtoul_l.c
+++ b/stdlib/strtoul_l.c
@@ -19,7 +19,7 @@ 
 
 #define UNSIGNED	1
 
-#include <xlocale.h>
+#include <locale.h>
 
 extern unsigned long int ____strtoul_l_internal (const char *, char **, int,
 						 int, __locale_t);
diff --git a/stdlib/strtoull_l.c b/stdlib/strtoull_l.c
index 53ecb916df..da6d7cde8c 100644
--- a/stdlib/strtoull_l.c
+++ b/stdlib/strtoull_l.c
@@ -20,7 +20,7 @@ 
 #define QUAD		1
 #define UNSIGNED	1
 
-#include <xlocale.h>
+#include <locale.h>
 
 extern unsigned long long int ____strtoull_l_internal (const char *, char **,
 						       int, int, __locale_t);
diff --git a/string/string.h b/string/string.h
index 8eed67d77d..e623f81052 100644
--- a/string/string.h
+++ b/string/string.h
@@ -148,7 +148,8 @@  extern size_t strxfrm (char *__restrict __dest,
      __THROW __nonnull ((2));
 
 #ifdef __USE_XOPEN2K8
-# include <xlocale.h>
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+# include <bits/types/locale_t.h>
 
 /* Compare the collated forms of S1 and S2, using sorting rules from L.  */
 extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
diff --git a/string/strings.h b/string/strings.h
index 43207af09c..53d1b5c944 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -121,7 +121,8 @@  extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
      __THROW __attribute_pure__ __nonnull ((1, 2));
 
 #ifdef	__USE_XOPEN2K8
-# include <xlocale.h>
+/* 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)
diff --git a/sysdeps/ieee754/ldbl-128ibm/strtold_l.c b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
index 37034cb254..341de78063 100644
--- a/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
@@ -18,7 +18,6 @@ 
 #include <math.h>
 #include <stdlib.h>
 #include <wchar.h>
-#include <xlocale.h>
 
 /* The actual implementation for all floating point sizes is in strtod.c.
    These macros tell it to produce the `long double' version, `strtold'.  */
diff --git a/sysdeps/ieee754/ldbl-64-128/strtold_l.c b/sysdeps/ieee754/ldbl-64-128/strtold_l.c
index 37034cb254..341de78063 100644
--- a/sysdeps/ieee754/ldbl-64-128/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-64-128/strtold_l.c
@@ -18,7 +18,6 @@ 
 #include <math.h>
 #include <stdlib.h>
 #include <wchar.h>
-#include <xlocale.h>
 
 /* The actual implementation for all floating point sizes is in strtod.c.
    These macros tell it to produce the `long double' version, `strtold'.  */
diff --git a/time/time.h b/time/time.h
index bb4994feee..17cc1e6614 100644
--- a/time/time.h
+++ b/time/time.h
@@ -57,7 +57,7 @@  typedef __pid_t pid_t;
 #endif
 
 #ifdef __USE_XOPEN2K8
-# include <xlocale.h>
+# include <bits/types/locale_t.h>
 #endif
 
 #ifdef __USE_ISOC11
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index d389428daa..a5ed1738dc 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -42,6 +42,9 @@ 
 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
 # include <bits/types/FILE.h>
 #endif
+#ifdef __USE_XOPEN2K8
+# include <bits/types/locale_t.h>
+#endif
 
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
@@ -113,8 +116,6 @@  extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
 
 /* Similar to the two functions above but take the information from
    the provided locale and not the global locale.  */
-# include <xlocale.h>
-
 extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
 			 __locale_t __loc) __THROW;
 
@@ -426,23 +427,9 @@  extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
 #endif /* Use GNU.  */
 
 #ifdef __USE_GNU
-/* The concept of one static locale per category is not very well
-   thought out.  Many applications will need to process its data using
-   information from several different locales.  Another application is
-   the implementation of the internationalization handling in the
-   upcoming ISO C++ standard library.  To support this another set of
-   the functions using locale data exist which have an additional
-   argument.
-
-   Attention: all these functions are *not* standardized in any form.
-   This is a proof-of-concept implementation.  */
-
-/* Structure for reentrant locale using functions.  This is an
-   (almost) opaque type for the user level programs.  */
-# include <xlocale.h>
-
-/* Special versions of the functions above which take the locale to
-   use as an additional parameter.  */
+/* Parallel versions of the functions above which take the locale to
+   use as an additional parameter.  These are GNU extensions inspired
+   by the POSIX.1-2008 extended locale API.  */
 extern long int wcstol_l (const wchar_t *__restrict __nptr,
 			  wchar_t **__restrict __endptr, int __base,
 			  __locale_t __loc) __THROW;
@@ -768,8 +755,6 @@  extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
 			const struct tm *__restrict __tp) __THROW;
 
 # ifdef __USE_GNU
-# include <xlocale.h>
-
 /* Similar to `wcsftime' but takes the information from
    the provided locale and not the global locale.  */
 extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
diff --git a/wcsmbs/wcstod.c b/wcsmbs/wcstod.c
index b7db11b935..72fa7eaaa4 100644
--- a/wcsmbs/wcstod.c
+++ b/wcsmbs/wcstod.c
@@ -17,7 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <stddef.h>
-#include <xlocale.h>
+#include <locale.h>
 
 
 #define	USE_WIDE_CHAR	1
diff --git a/wcsmbs/wcstod_l.c b/wcsmbs/wcstod_l.c
index 5f7498c4f8..1d5c67cf36 100644
--- a/wcsmbs/wcstod_l.c
+++ b/wcsmbs/wcstod_l.c
@@ -18,7 +18,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <stddef.h>
-#include <xlocale.h>
+#include <locale.h>
 
 
 extern double ____wcstod_l_internal (const wchar_t *, wchar_t **, int,
diff --git a/wcsmbs/wcstof.c b/wcsmbs/wcstof.c
index 29cdec3a98..67c16e0cfd 100644
--- a/wcsmbs/wcstof.c
+++ b/wcsmbs/wcstof.c
@@ -17,7 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <stddef.h>
-#include <xlocale.h>
+#include <locale.h>
 
 #define	USE_WIDE_CHAR	1
 
diff --git a/wcsmbs/wcstof_l.c b/wcsmbs/wcstof_l.c
index 23d402d7ea..d430bf1c3b 100644
--- a/wcsmbs/wcstof_l.c
+++ b/wcsmbs/wcstof_l.c
@@ -18,7 +18,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <stddef.h>
-#include <xlocale.h>
+#include <locale.h>
 
 
 #define	USE_WIDE_CHAR	1
diff --git a/wcsmbs/wcstold.c b/wcsmbs/wcstold.c
index e5c1cc3071..816f43bf69 100644
--- a/wcsmbs/wcstold.c
+++ b/wcsmbs/wcstold.c
@@ -17,7 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <stddef.h>
-#include <xlocale.h>
+#include <locale.h>
 
 #define USE_WIDE_CHAR	1
 
diff --git a/wcsmbs/wcstold_l.c b/wcsmbs/wcstold_l.c
index 3dd33a729a..86f63e8801 100644
--- a/wcsmbs/wcstold_l.c
+++ b/wcsmbs/wcstold_l.c
@@ -18,7 +18,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <stddef.h>
-#include <xlocale.h>
+#include <locale.h>
 
 #define USE_WIDE_CHAR	1
 
diff --git a/wctype/wctype.h b/wctype/wctype.h
index 962aef1de6..7945795b44 100644
--- a/wctype/wctype.h
+++ b/wctype/wctype.h
@@ -55,8 +55,8 @@  extern wctrans_t wctrans (const char *__property) __THROW;
 extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
 
 # ifdef __USE_XOPEN2K8
-/* Declare the interface to extended locale model.  */
-#  include <xlocale.h>
+/* POSIX.1-2008 extended locale interface (see locale.h).  */
+#  include <bits/types/locale_t.h>
 
 /* Test for any wide character for which `iswalpha' or `iswdigit' is
    true.  */