public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] libstdc++: implement locale support for AIX
       [not found] ` <CAGWvny=XpcWGnyb=MWg5ziYSND7O1AnQ6-NAX811p1b5urH0YA@mail.gmail.com>
@ 2021-01-11 15:35   ` Rainer Orth
  2021-01-11 15:40     ` Jonathan Wakely
       [not found]   ` <PA4PR02MB6686C2022E2B42D82DC9F269EAAB0@PA4PR02MB6686.eurprd02.prod.outlook.com>
  1 sibling, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-11 15:35 UTC (permalink / raw)
  To: David Edelsohn via Gcc-patches
  Cc: CHIGOT, CLEMENT, David Edelsohn, libstdc++, Jonathan Wakely

Hi David, Clement,

> The patch is local to libstdc++ AIX support, so I believe that I can approve it.

have you considered merging the dragonfly and aix trees?  I'm asking
because it seems prudent to try and avoid creating more and more
almost-but-not-quite-similar configurations (Solaris might be able to
use the same code, at least in 11.4 which has XPG7 support).

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
       [not found]   ` <PA4PR02MB6686C2022E2B42D82DC9F269EAAB0@PA4PR02MB6686.eurprd02.prod.outlook.com>
@ 2021-01-11 15:38     ` Rainer Orth
  0 siblings, 0 replies; 43+ messages in thread
From: Rainer Orth @ 2021-01-11 15:38 UTC (permalink / raw)
  To: CHIGOT, CLEMENT via Gcc-patches
  Cc: David Edelsohn, CHIGOT, CLEMENT, libstdc++, Jonathan Wakely

Hi Clement,

> Would "Skip if target = aix" be ok, especially for the few that I have
> absolutely no idea why they are failing ?

you should try to avoid such skips if at all possible.  Should the tests
start to PASS in the future, either due to AIX changes or changes in
libstdc++, this would go unnoticed.  Use xfail instead.

Besides, you should file PRs for the failing tests and preferably
mention the relevant PR in the xfail.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-11 15:35   ` [PATCH] libstdc++: implement locale support for AIX Rainer Orth
@ 2021-01-11 15:40     ` Jonathan Wakely
  2021-01-11 15:56       ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Jonathan Wakely @ 2021-01-11 15:40 UTC (permalink / raw)
  To: Rainer Orth
  Cc: David Edelsohn via Gcc-patches, libstdc++,
	CHIGOT, CLEMENT, David Edelsohn

On 11/01/21 16:35 +0100, Rainer Orth wrote:
>Hi David, Clement,
>
>> The patch is local to libstdc++ AIX support, so I believe that I can approve it.
>
>have you considered merging the dragonfly and aix trees?  I'm asking
>because it seems prudent to try and avoid creating more and more
>almost-but-not-quite-similar configurations (Solaris might be able to
>use the same code, at least in 11.4 which has XPG7 support).

Agreed.

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57585

As I'm sure I've said before, all patches for libstdc++ need to be
sent to the libstdc++ list.



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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-11 15:40     ` Jonathan Wakely
@ 2021-01-11 15:56       ` CHIGOT, CLEMENT
  2021-01-11 22:20         ` David Edelsohn
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-11 15:56 UTC (permalink / raw)
  To: Jonathan Wakely, Rainer Orth
  Cc: David Edelsohn via Gcc-patches, libstdc++, David Edelsohn

>> Hi David, Clement,
>>
>>> The patch is local to libstdc++ AIX support, so I believe that I can approve it.
>>
>>have you considered merging the dragonfly and aix trees?  I'm asking
>>because it seems prudent to try and avoid creating more and more
>>almost-but-not-quite-similar configurations (Solaris might be able to
>>use the same code, at least in 11.4 which has XPG7 support).
>
>Agreed.
>
>See also https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgcc.gnu.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D57585&amp;data=04%7C01%7Cclement.chigot%40atos.net%7Cb9820136976149e643b408d8b64756c2%7C33440fc6b7c7412cbb730e70b0198d5a%7C0%7C0%7C637459764803442555%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=qinNdbwsbyUdvijD76PanMf0Y1iSfn1FhRAt2T2dl%2B0%3D&amp;reserved=0<https://eur01.safelinks.protection.outlook.com/?>url=https%3A%2F%2Fgcc.gnu.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D57585&amp;data=04%7C01%7Cclement.chigot%40atos.net%7Cb9820136976149e643b408d8b64756c2%7C33440fc6b7c7412cbb730e70b0198d5a%7C0%7C0%7C637459764803442555%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=qinNdbwsbyUdvijD76PanMf0Y1iSfn1FhRAt2T2dl%2B0%3D&amp;reserved=0>

I haven't thought about that. It should be possible.
The main problem with AIX are the few missing locale functions
(strtof_l, localeconv_l, etc). I've defined some in c_locale.h, some
are simply wrapped by uselocale in the code itself.
The question is if we merged dragonfly, aix and allow others OS
to use this new locale support, what should go in c_locale.h ?
Do we want it to define all missing functions or do we rather
have some #ifdef wrapping "uselocale" when a *_l function
is missing ?
Both way, I'm fearing there will be a lot of #ifdef.

> As I'm sure I've said before, all patches for libstdc++ need to be
> sent to the libstdc++ list.
Sorry, I've forgotten that. I'll try to be more careful next time !

Clément



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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-11 15:56       ` CHIGOT, CLEMENT
@ 2021-01-11 22:20         ` David Edelsohn
  2021-01-12 15:14           ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: David Edelsohn @ 2021-01-11 22:20 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: Jonathan Wakely, Rainer Orth, David Edelsohn via Gcc-patches, libstdc++

On Mon, Jan 11, 2021 at 10:56 AM CHIGOT, CLEMENT
<clement.chigot@atos.net> wrote:
>
> >> Hi David, Clement,
> >>
> >>> The patch is local to libstdc++ AIX support, so I believe that I can approve it.
> >>
> >>have you considered merging the dragonfly and aix trees?  I'm asking
> >>because it seems prudent to try and avoid creating more and more
> >>almost-but-not-quite-similar configurations (Solaris might be able to
> >>use the same code, at least in 11.4 which has XPG7 support).
> >
> >Agreed.
> >
> >See also https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgcc.gnu.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D57585&amp;data=04%7C01%7Cclement.chigot%40atos.net%7Cb9820136976149e643b408d8b64756c2%7C33440fc6b7c7412cbb730e70b0198d5a%7C0%7C0%7C637459764803442555%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=qinNdbwsbyUdvijD76PanMf0Y1iSfn1FhRAt2T2dl%2B0%3D&amp;reserved=0
>
> I haven't thought about that. It should be possible.
> The main problem with AIX are the few missing locale functions
> (strtof_l, localeconv_l, etc). I've defined some in c_locale.h, some
> are simply wrapped by uselocale in the code itself.
> The question is if we merged dragonfly, aix and allow others OS
> to use this new locale support, what should go in c_locale.h ?
> Do we want it to define all missing functions or do we rather
> have some #ifdef wrapping "uselocale" when a *_l function
> is missing ?
> Both ways, I'm fearing there will be a lot of #ifdef.

The OS-specific definitions could be placed in
config/os/XXX/os_defines.h.  And the DragonFly locale files could
include <bits/c++config.h> to obtain the definitions.

I'm not certain where to place the uselocale changes.  Either #ifdefs
or move part of the files to config/os/XXX/...

Thanks, David

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-11 22:20         ` David Edelsohn
@ 2021-01-12 15:14           ` CHIGOT, CLEMENT
  2021-01-12 15:23             ` CHIGOT, CLEMENT
                               ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-12 15:14 UTC (permalink / raw)
  To: David Edelsohn, Jonathan Wakely, Rainer Orth
  Cc: David Edelsohn via Gcc-patches, libstdc++

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

Hi everyone, 

I've reworked the patch to merged dragonfly and AIX
models into the new one named "ieee_1003.1-2008". 
It seems okay on the AIX part but if someone can test
on Dragonfly and Freebsd I would be glad. Configure 
needs to be regenerated, first.

For now, I've used #ifdef inside the code for the few
differences. There are less than I thought. So, it seems 
okay to me. 
However, I haven't changed all the (locale_t) casts 
made on Dragonfly when passing a locale object to
a syscall. On AIX, this is transparent, __c_locale being 
locale_t. 

I haven't updated tests failing on AIX yet. 
And I don't know for the Changelog/Patch, how renamed 
files must be handled ? I've retrieved my git commit with 
"git format-patch --no-renames" and thus the Changelog 
is made of "Removed" and "New File". Is it okay or is there 
anything special to add ? I didn't find the answer quickly. 

Thanks, 
Clément

[-- Attachment #2: 0001-libstdc-implement-locale-support-for-POSIX-2008.txt --]
[-- Type: text/plain, Size: 23598 bytes --]

From d36a04c7d4eb390817d711dc59ad0e0759bccdce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Tue, 29 Dec 2020 11:08:33 +0100
Subject: [PATCH] libstdc++: implement locale support for POSIX 2008
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The implementation is based on dragonfly one.
It also adds support for AIX with a few tweaks.
As of now, a few locale functions are missing on AIX.
For strftime_l, localeconv_l, mbstowcs_l and wcsftime_l,
uselocale must be set prior to use the version without _l.
For strtof_l, strtod_l, strtold_l, a wrapper simply calls
the default version.

libstdc++-v3/ChangeLog:
2021-01-12  Clément Chigot  <clement.chigot@atos.net>

	* acinclude.m4: Add ieee_1003.1-2008 locale model.
	* configure: Regenerate.
	* config/os/aix/ctype_configure_char.cc: Enable locale support.
        * testsuite/lib/libstdc++.exp (check_v3_target_namedlocale):
        Handle AIX locale names.
	* testsuite/util/testsuite_hooks.h: Likewise.
	* config/locale/dragonfly/c_locale.cc: Removed.
	* config/locale/dragonfly/c_locale.h: Removed.
	* config/locale/dragonfly/codecvt_members.cc: Removed.
	* config/locale/dragonfly/collate_members.cc: Removed.
	* config/locale/dragonfly/ctype_members.cc: Removed.
	* config/locale/dragonfly/monetary_members.cc: Removed.
	* config/locale/dragonfly/numeric_members.cc: Removed.
	* config/locale/dragonfly/time_members.cc: Removed.
	* config/locale/dragonfly/time_members.h: Removed.
	* config/locale/ieee_1003.1-2008/c_locale.cc: New file.
	* config/locale/ieee_1003.1-2008/c_locale.h: New file.
	* config/locale/ieee_1003.1-2008/codecvt_members.cc: New file.
	* config/locale/ieee_1003.1-2008/collate_members.cc: New file.
	* config/locale/ieee_1003.1-2008/ctype_members.cc: New file.
	* config/locale/ieee_1003.1-2008/monetary_members.cc: New file.
	* config/locale/ieee_1003.1-2008/numeric_members.cc: New file.
	* config/locale/ieee_1003.1-2008/time_members.cc: New file.
	* config/locale/ieee_1003.1-2008/time_members.h: New file.
---
 libstdc++-v3/acinclude.m4                     | 41 ++++++-------
 .../c_locale.cc                               |  3 +
 .../c_locale.h                                | 31 ++++++++++
 .../codecvt_members.cc                        |  0
 .../collate_members.cc                        |  0
 .../ctype_members.cc                          | 58 +++++++++++++++++++
 .../monetary_members.cc                       | 39 ++++++++++++-
 .../numeric_members.cc                        | 27 +++++++++
 .../time_members.cc                           | 32 +++++++++-
 .../time_members.h                            |  0
 .../config/os/aix/ctype_configure_char.cc     | 44 +++++++++++---
 libstdc++-v3/testsuite/lib/libstdc++.exp      |  5 ++
 libstdc++-v3/testsuite/util/testsuite_hooks.h |  3 +
 13 files changed, 252 insertions(+), 31 deletions(-)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/c_locale.cc (99%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/c_locale.h (80%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/codecvt_members.cc (100%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/collate_members.cc (100%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/ctype_members.cc (82%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/monetary_members.cc (97%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/numeric_members.cc (93%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/time_members.cc (94%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/time_members.h (100%)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index e4175ea3e64..64a91b72359 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2421,7 +2421,7 @@ dnl
 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
     [use MODEL for target locale package],
-    [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
+    [permit generic|gnu|ieee_1003.1-2001|ieee_1003.1-2008|newlib|yes|no|auto])
 
   # Deal with gettext issues.  Default to not using it (=no) until we detect
   # support for it later.  Let the user turn it off via --e/d, but let that
@@ -2448,8 +2448,8 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       darwin*)
 	enable_clocale_flag=darwin
 	;;
-      dragonfly* | freebsd*)
-	enable_clocale_flag=dragonfly
+      aix* | dragonfly* | freebsd*)
+	enable_clocale_flag=ieee_1003.1-2008
 	;;
       openbsd*)
 	enable_clocale_flag=newlib
@@ -2543,23 +2543,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
 
-    dragonfly)
-      AC_MSG_RESULT(dragonfly or freebsd)
-
-      CLOCALE_H=config/locale/dragonfly/c_locale.h
-      CLOCALE_CC=config/locale/dragonfly/c_locale.cc
-      CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
-      CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
-      CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
-      CMESSAGES_H=config/locale/generic/messages_members.h
-      CMESSAGES_CC=config/locale/generic/messages_members.cc
-      CMONEY_CC=config/locale/dragonfly/monetary_members.cc
-      CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
-      CTIME_H=config/locale/dragonfly/time_members.h
-      CTIME_CC=config/locale/dragonfly/time_members.cc
-      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
-      ;;
-
     gnu)
       AC_MSG_RESULT(gnu)
 
@@ -2610,6 +2593,24 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
+
+    ieee_1003.1-2008)
+      AC_MSG_RESULT(ieee_1003.1-2008)
+
+      CLOCALE_H=config/locale/ieee_1003.1-2008/c_locale.h
+      CLOCALE_CC=config/locale/ieee_1003.1-2008/c_locale.cc
+      CCODECVT_CC=config/locale/ieee_1003.1-2008/codecvt_members.cc
+      CCOLLATE_CC=config/locale/ieee_1003.1-2008/collate_members.cc
+      CCTYPE_CC=config/locale/ieee_1003.1-2008/ctype_members.cc
+      CMESSAGES_H=config/locale/generic/messages_members.h
+      CMESSAGES_CC=config/locale/generic/messages_members.cc
+      CMONEY_CC=config/locale/ieee_1003.1-2008/monetary_members.cc
+      CNUMERIC_CC=config/locale/ieee_1003.1-2008/numeric_members.cc
+      CTIME_H=config/locale/ieee_1003.1-2008/time_members.h
+      CTIME_CC=config/locale/ieee_1003.1-2008/time_members.cc
+      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+      ;;
+
     newlib)
       AC_MSG_RESULT(newlib)
 
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc
similarity index 99%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc
index 02df4605bb5..988f34ab6ed 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc
@@ -33,8 +33,11 @@
 #include <locale>
 #include <stdexcept>
 #include <limits>
+
+#ifdef __DragonFly__
 #include <langinfo.h>
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h
similarity index 80%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.h
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h
index cf4281cebbf..f77f815c61b 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.h
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h
@@ -40,7 +40,34 @@
 #pragma GCC system_header
 
 #include <clocale>
+#ifdef __DragonFly__
 #include <xlocale.h>
+#endif
+
+#ifdef _AIX
+// The following are not POSIX routines.  These are quick-and-dirty hacks
+// to make things pretend to work
+extern "C" inline
+float strtof_l (const char *__nptr, char **__endptr,
+		locale_t locale)
+{
+  return strtof(__nptr, __endptr);
+}
+
+extern "C" inline
+double strtod_l (const char *__nptr, char **__endptr,
+		 locale_t locale)
+{
+  return strtod(__nptr, __endptr);
+}
+
+extern "C" inline
+long double strtold_l (const char *__nptr, char **__endptr,
+		       locale_t locale)
+{
+  return strtold(__nptr, __endptr);
+}
+#endif
 
 #define _GLIBCXX_NUM_CATEGORIES 0
 
@@ -48,7 +75,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#ifdef __DragonFly__
   typedef int*			__c_locale;
+#else
+  typedef locale_t			__c_locale;
+#endif
 
   // Convert numeric value of type double and long double to string and
   // return length of string.  If vsnprintf is available use it, otherwise
diff --git a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/codecvt_members.cc
similarity index 100%
rename from libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/codecvt_members.cc
diff --git a/libstdc++-v3/config/locale/dragonfly/collate_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc
similarity index 100%
rename from libstdc++-v3/config/locale/dragonfly/collate_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc
diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
similarity index 82%
rename from libstdc++-v3/config/locale/dragonfly/ctype_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
index 420cb51e07a..ad9d3a4709b 100644
--- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
@@ -34,7 +34,11 @@
 #include <cstdio>
 
 #ifndef _ISbit
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
+#else
+#define _ISbit(bit) (1 << bit)
+#endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -135,6 +139,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __hi;
   }
 
+#ifndef __DragonFly__
+  bool
+  ctype<wchar_t>::
+  do_is(mask __m, char_type __c) const
+  {
+    bool __ret = false;
+    // Highest bitmask in ctype_base == 11
+    const size_t __bitmasksize = 11;
+    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+      if (__m & _M_bit[__bitcur]
+	  && iswctype(__c, _M_wmask[__bitcur]))
+	{
+	  __ret = true;
+	  break;
+	}
+    return __ret;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+  {
+    for (;__lo < __hi; ++__vec, ++__lo)
+      {
+	// Highest bitmask in ctype_base == 11
+	const size_t __bitmasksize = 11;
+	mask __m = 0;
+	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+	  if (iswctype(*__lo, _M_wmask[__bitcur]))
+	    __m |= _M_bit[__bitcur];
+	*__vec = __m;
+      }
+    return __hi;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
+  {
+    while (__lo < __hi && !this->do_is(__m, *__lo))
+      ++__lo;
+    return __lo;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
+  {
+    while (__lo < __hi && this->do_is(__m, *__lo) != 0)
+      ++__lo;
+    return __lo;
+  }
+#endif
+
   wchar_t
   ctype<wchar_t>::
   do_widen(char __c) const
diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
similarity index 97%
rename from libstdc++-v3/config/locale/dragonfly/monetary_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
index e1decc61cbf..7680a1a3916 100644
--- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
@@ -31,7 +31,10 @@
 
 #include <locale>
 #include <cstring>
+
+#ifdef __DragonFly__
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -241,7 +244,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _AIX
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#else
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -348,6 +356,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifdef _AIX
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -360,6 +371,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->int_n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifdef _AIX
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -395,7 +409,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _AIX
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#else
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -502,6 +521,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifdef _AIX
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -514,6 +536,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifdef _AIX
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -581,9 +606,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _AIX
+	  lconv* lc = localeconv();
+#else
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -741,9 +771,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _AIX
+	  lconv* lc = localeconv();
+#else
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc
similarity index 93%
rename from libstdc++-v3/config/locale/dragonfly/numeric_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc
index cac6fe8c710..eb460c94088 100644
--- a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc
@@ -31,7 +31,10 @@
 
 #include <locale>
 #include <cstring>
+
+#ifdef __DragonFly__
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -63,7 +66,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _AIX
+	  // uselocale is needed for localeconv
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#else
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -103,6 +112,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifdef _AIX
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -113,6 +125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifdef _AIX
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
@@ -162,7 +177,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _AIX
+	  // uselocale is needed for localeconv
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#else
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -201,6 +222,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifdef _AIX
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -211,6 +235,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifdef _AIX
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc
similarity index 94%
rename from libstdc++-v3/config/locale/dragonfly/time_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc
index c8b621a323f..660fc26de1a 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc
@@ -35,7 +35,10 @@
 #include <cwchar>
 #include <stdlib.h>
 #include <langinfo.h>
+
+#ifdef __DragonFly__
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -47,8 +50,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(char* __s, size_t __maxlen, const char* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _AIX
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = strftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#else
       const size_t __len = strftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = '\0';
@@ -196,15 +205,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _AIX
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#else
       const size_t __len = wcsftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = L'\0';
     }
 
+#ifdef _AIX
+  // mbstowcs_l deosn't exist on AIX. "uselocale" must
+  // be called before using this macro.
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE) \
+  mbstowcs (WCSTRING, STRING, NUMBER);
+#else
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs_l (WCSTRING, STRING, NUMBER, LOCALE);
+#endif
 #define WIDE_LANGINFO(M,FMT) \
-	fmtlen = mbstowcs_l (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
+	fmtlen = MBSTOWCS_L (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
 		128, (locale_t)__cloc); \
 	langstring = new wchar_t[fmtlen + 1]; \
 	wcsncpy (langstring, holder, fmtlen); \
@@ -281,6 +305,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
+#ifdef _AIX
+	  __c_locale __old = uselocale(__cloc);
+#endif
 	  wchar_t *langstring = 0;
 	  wchar_t holder[128];
 	  size_t fmtlen;
@@ -342,6 +369,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  WIDE_LANGINFO(_M_amonth10, ABMON_10)
 	  WIDE_LANGINFO(_M_amonth11, ABMON_11)
 	  WIDE_LANGINFO(_M_amonth12, ABMON_12)
+#ifdef _AIX
+	  uselocale(__old);
+#endif
 	}
     }
 
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.h b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.h
similarity index 100%
rename from libstdc++-v3/config/locale/dragonfly/time_members.h
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.h
diff --git a/libstdc++-v3/config/os/aix/ctype_configure_char.cc b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
index b12c0bd435c..3af3457ef41 100644
--- a/libstdc++-v3/config/os/aix/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
@@ -44,25 +44,53 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
 		     size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+  _M_del(__table != 0 && __del),
   _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
+    char* __old = setlocale(LC_CTYPE, NULL);
+    char* __sav = NULL;
+    if (strcmp(__old, "C"))
+      {
+	const size_t __len = strlen(__old) + 1;
+	__sav = new char[__len];
+	memcpy(__sav, __old, __len);
+	setlocale(LC_CTYPE, "C");
+      }
+    if (__sav)
+      {
+	setlocale(LC_CTYPE, __sav);
+	delete [] __sav;
+      }
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+  _M_del(__table != 0 && __del),
   _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
+    char* __old = setlocale(LC_CTYPE, NULL);
+    char* __sav = NULL;
+    if (strcmp(__old, "C"))
+      {
+	const size_t __len = strlen(__old) + 1;
+	__sav = new char[__len];
+	memcpy(__sav, __old, __len);
+	setlocale(LC_CTYPE, "C");
+      }
+    if (__sav)
+      {
+	setlocale(LC_CTYPE, __sav);
+	delete [] __sav;
+      }
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   char
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 30a4345b14f..200602d003e 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -904,6 +904,11 @@ proc check_v3_target_namedlocale { args } {
 	puts $f "    strcpy(result, name);"
 	puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
 	puts $f "    /* fall-through */"
+	puts $f "#elif defined _AIX"
+	puts $f "    char *p = strstr(result, \"ISO8859-15\");"
+	puts $f "    if (p) {"
+	puts $f "       strcpy(p, \"8859-15\");"
+	puts $f "    }"
 	puts $f "#else"
 	puts $f "    if (strstr(result, \"ISO8859-15\")) {"
 	puts $f "        strcat(result, \"@euro\");"
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index b5e0767211a..a632f5f31f8 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -77,6 +77,9 @@
 
 #if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__
 # define ISO_8859(part,langTERR) #langTERR ".ISO8859-" #part
+#elif defined _AIX
+# define ISO_8859(part,langTERR) ((part) == 15 ?\
+         #langTERR ".8859-" #part : #langTERR ".ISO8859-" #part)
 #else
 # define ISO_8859(part,langTERR) ((part) == 15 ?\
          #langTERR ".ISO8859-" #part "@euro" : #langTERR ".ISO8859-" #part)
-- 
2.25.0


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:14           ` CHIGOT, CLEMENT
@ 2021-01-12 15:23             ` CHIGOT, CLEMENT
  2021-01-12 15:25             ` Jonathan Wakely
  2021-01-12 16:00             ` Rainer Orth
  2 siblings, 0 replies; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-12 15:23 UTC (permalink / raw)
  To: David Edelsohn, Jonathan Wakely, Rainer Orth
  Cc: David Edelsohn via Gcc-patches, libstdc++

> And I don't know for the Changelog/Patch, how renamed 
> files must be handled ? I've retrieved my git commit with 
> "git format-patch --no-renames" and thus the Changelog 
> is made of "Removed" and "New File". Is it okay or is there 
> anything special to add ? I didn't find the answer quickly. 
Actually, on the one, I've sent I've forgotten the 
"--no-renames" thus it's using git mechanism... 


Thanks, 
Clément

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:14           ` CHIGOT, CLEMENT
  2021-01-12 15:23             ` CHIGOT, CLEMENT
@ 2021-01-12 15:25             ` Jonathan Wakely
  2021-01-12 15:40               ` CHIGOT, CLEMENT
                                 ` (2 more replies)
  2021-01-12 16:00             ` Rainer Orth
  2 siblings, 3 replies; 43+ messages in thread
From: Jonathan Wakely @ 2021-01-12 15:25 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: David Edelsohn, Rainer Orth, David Edelsohn via Gcc-patches, libstdc++

On 12/01/21 15:14 +0000, CHIGOT, CLEMENT wrote:
>Hi everyone, 
>
>I've reworked the patch to merged dragonfly and AIX
>models into the new one named "ieee_1003.1-2008". 
>It seems okay on the AIX part but if someone can test
>on Dragonfly and Freebsd I would be glad. Configure
>needs to be regenerated, first.

Presumably it could also be tested on GNU/Linux and Solaris, since
they implement the POSIX 2008 APIs needed.



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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:25             ` Jonathan Wakely
@ 2021-01-12 15:40               ` CHIGOT, CLEMENT
  2021-01-12 15:44               ` David Edelsohn
  2021-01-12 15:52               ` Rainer Orth
  2 siblings, 0 replies; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-12 15:40 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: David Edelsohn, Rainer Orth, David Edelsohn via Gcc-patches, libstdc++

> >Hi everyone, 
> >
> >I've reworked the patch to merged dragonfly and AIX
> >models into the new one named "ieee_1003.1-2008". 
> >It seems okay on the AIX part but if someone can test
> >on Dragonfly and Freebsd I would be glad. Configure
> >needs to be regenerated, first.
> 
> Presumably it could also be tested on GNU/Linux and Solaris, since
> they implement the POSIX 2008 APIs needed.
Indeed, I'll try it tomorrow for Linux. I don't have any Solaris 
VMs on my labs. 
Note that I've forgotten to add some "defined(__FreeBSD__)"
in the current patch, so it should not work on it. I'll send 
a better one tomorrow after having check on Linux.


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:25             ` Jonathan Wakely
  2021-01-12 15:40               ` CHIGOT, CLEMENT
@ 2021-01-12 15:44               ` David Edelsohn
  2021-01-12 17:34                 ` Jonathan Wakely
  2021-01-12 15:52               ` Rainer Orth
  2 siblings, 1 reply; 43+ messages in thread
From: David Edelsohn @ 2021-01-12 15:44 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: CHIGOT, CLEMENT, Rainer Orth, David Edelsohn via Gcc-patches, libstdc++

On Tue, Jan 12, 2021 at 10:25 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On 12/01/21 15:14 +0000, CHIGOT, CLEMENT wrote:
> >Hi everyone,
> >
> >I've reworked the patch to merged dragonfly and AIX
> >models into the new one named "ieee_1003.1-2008".
> >It seems okay on the AIX part but if someone can test
> >on Dragonfly and Freebsd I would be glad. Configure
> >needs to be regenerated, first.
>
> Presumably it could also be tested on GNU/Linux and Solaris, since
> they implement the POSIX 2008 APIs needed.

GNU/Linux currently uses the "gnu" locale configuration.  Are you
suggesting that GNU/Linux use the new POSIX 2008 locale configuration
by default or to use GNU/Linux as another sniff test?

Thanks, David

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:25             ` Jonathan Wakely
  2021-01-12 15:40               ` CHIGOT, CLEMENT
  2021-01-12 15:44               ` David Edelsohn
@ 2021-01-12 15:52               ` Rainer Orth
  2021-01-12 17:41                 ` Rainer Orth
  2 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-12 15:52 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: CHIGOT, CLEMENT, David Edelsohn, David Edelsohn via Gcc-patches,
	libstdc++

Hi Jonathan,

> On 12/01/21 15:14 +0000, CHIGOT, CLEMENT wrote:
>>Hi everyone, 
>>
>>I've reworked the patch to merged dragonfly and AIX
>>models into the new one named "ieee_1003.1-2008". 
>>It seems okay on the AIX part but if someone can test
>>on Dragonfly and Freebsd I would be glad. Configure
>>needs to be regenerated, first.
>
> Presumably it could also be tested on GNU/Linux and Solaris, since
> they implement the POSIX 2008 APIs needed.

I'll give the patch a whirl on Solaris.  However, we will need to
distinguish between 11.3 (which is XPG6 only) and 11.4 (which support
XPG7).

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:14           ` CHIGOT, CLEMENT
  2021-01-12 15:23             ` CHIGOT, CLEMENT
  2021-01-12 15:25             ` Jonathan Wakely
@ 2021-01-12 16:00             ` Rainer Orth
  2 siblings, 0 replies; 43+ messages in thread
From: Rainer Orth @ 2021-01-12 16:00 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: David Edelsohn, Jonathan Wakely, David Edelsohn via Gcc-patches,
	libstdc++

Hi Clement,

> I've reworked the patch to merged dragonfly and AIX
> models into the new one named "ieee_1003.1-2008". 
> It seems okay on the AIX part but if someone can test
> on Dragonfly and Freebsd I would be glad. Configure 
> needs to be regenerated, first.
>
> For now, I've used #ifdef inside the code for the few
> differences. There are less than I thought. So, it seems 
> okay to me. 

TBH, I find this liberal sprinkling of target-specific #ifdefs over the
code horrible: it's completely out of style with GCC conventions.  This
is exactly what autoconf is for: test for the existance of headers and
functions like strtof_l and act accordingly.  If in the future other
OSes will make use of the code, most differences will already be handled
and it's way easier to understand defined(HAVE_STRTOF_L) than
defined(_AIX) || defined(HP_UX).  From your code one simply cannot tell
why some code is used on AIX while something else on (say) DragonflyBSD.
It gets even worse when (as does happen) standard support differs
between versions: expressing this with platform ifdefs is nothing short
of a nightmare.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:44               ` David Edelsohn
@ 2021-01-12 17:34                 ` Jonathan Wakely
  0 siblings, 0 replies; 43+ messages in thread
From: Jonathan Wakely @ 2021-01-12 17:34 UTC (permalink / raw)
  To: David Edelsohn
  Cc: CHIGOT, CLEMENT, Rainer Orth, David Edelsohn via Gcc-patches, libstdc++

On 12/01/21 10:44 -0500, David Edelsohn wrote:
>On Tue, Jan 12, 2021 at 10:25 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>>
>> On 12/01/21 15:14 +0000, CHIGOT, CLEMENT wrote:
>> >Hi everyone,
>> >
>> >I've reworked the patch to merged dragonfly and AIX
>> >models into the new one named "ieee_1003.1-2008".
>> >It seems okay on the AIX part but if someone can test
>> >on Dragonfly and Freebsd I would be glad. Configure
>> >needs to be regenerated, first.
>>
>> Presumably it could also be tested on GNU/Linux and Solaris, since
>> they implement the POSIX 2008 APIs needed.
>
>GNU/Linux currently uses the "gnu" locale configuration.  Are you
>suggesting that GNU/Linux use the new POSIX 2008 locale configuration
>by default or to use GNU/Linux as another sniff test?

I'm suggesting to use it for testing that the new config is portable
to other systems that provide the POSIX 2008 APIs.

We wouldn't want to use it by default, because POSIX doesn't provide
strtod_l etc that glibc provides. But maybe the "gnu" model should use
newlocale and uselocale instead of __newlocale etc. so that we depend
on fewer GNU extensions that are only defined with _GNU_SOURCE.



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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 15:52               ` Rainer Orth
@ 2021-01-12 17:41                 ` Rainer Orth
  2021-01-12 17:44                   ` David Edelsohn
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-12 17:41 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: libstdc++,
	David Edelsohn via Gcc-patches, CHIGOT, CLEMENT, David Edelsohn

Hi Jonathan,

>> On 12/01/21 15:14 +0000, CHIGOT, CLEMENT wrote:
>>>Hi everyone, 
>>>
>>>I've reworked the patch to merged dragonfly and AIX
>>>models into the new one named "ieee_1003.1-2008". 
>>>It seems okay on the AIX part but if someone can test
>>>on Dragonfly and Freebsd I would be glad. Configure
>>>needs to be regenerated, first.
>>
>> Presumably it could also be tested on GNU/Linux and Solaris, since
>> they implement the POSIX 2008 APIs needed.
>
> I'll give the patch a whirl on Solaris.  However, we will need to
> distinguish between 11.3 (which is XPG6 only) and 11.4 (which support
> XPG7).

as almost expected, a build on Solaris 11.4 failed miserably due to the
use of the various BSD extensions (localeconv_l, mbstowcs_l, strtod_l,
strtof_l, strtold_l, wcsftime_l), whose use or fallback implementations
are currently guarded by _AIX.  Should those be used in a directory
supposed to conform to POSIX.1-2008 at all?  OTOH, almost duplicating
the code into a separate bsd (or whatever, it's certainly not only
DragonflyBSD) directory for this sole reason would be a shame.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 17:41                 ` Rainer Orth
@ 2021-01-12 17:44                   ` David Edelsohn
  2021-01-12 19:58                     ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: David Edelsohn @ 2021-01-12 17:44 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches, CHIGOT, CLEMENT

On Tue, Jan 12, 2021 at 12:41 PM Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
> Hi Jonathan,
>
> >> On 12/01/21 15:14 +0000, CHIGOT, CLEMENT wrote:
> >>>Hi everyone,Â
> >>>
> >>>I've reworked the patch to merged dragonfly and AIX
> >>>models into the new one named "ieee_1003.1-2008".Â
> >>>It seems okay on the AIX part but if someone can test
> >>>on Dragonfly and Freebsd I would be glad. Configure
> >>>needs to be regenerated, first.
> >>
> >> Presumably it could also be tested on GNU/Linux and Solaris, since
> >> they implement the POSIX 2008 APIs needed.
> >
> > I'll give the patch a whirl on Solaris.  However, we will need to
> > distinguish between 11.3 (which is XPG6 only) and 11.4 (which support
> > XPG7).
>
> as almost expected, a build on Solaris 11.4 failed miserably due to the
> use of the various BSD extensions (localeconv_l, mbstowcs_l, strtod_l,
> strtof_l, strtold_l, wcsftime_l), whose use or fallback implementations
> are currently guarded by _AIX.  Should those be used in a directory
> supposed to conform to POSIX.1-2008 at all?  OTOH, almost duplicating
> the code into a separate bsd (or whatever, it's certainly not only
> DragonflyBSD) directory for this sole reason would be a shame.

Hi, Rainer

Thanks for testing.

I agree that #ifdef's are not the correct approach, but, if you enable
the fallbacks for Solaris, does everything then work?  Are those
fallbacks portable and we solely need a better mechanism to enable
them on platforms that require them?

Thanks, David

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 17:44                   ` David Edelsohn
@ 2021-01-12 19:58                     ` Rainer Orth
  2021-01-13 11:57                       ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-12 19:58 UTC (permalink / raw)
  To: David Edelsohn
  Cc: Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches, CHIGOT, CLEMENT

Hi David,

>> >> Presumably it could also be tested on GNU/Linux and Solaris, since
>> >> they implement the POSIX 2008 APIs needed.
>> >
>> > I'll give the patch a whirl on Solaris.  However, we will need to
>> > distinguish between 11.3 (which is XPG6 only) and 11.4 (which support
>> > XPG7).
>>
>> as almost expected, a build on Solaris 11.4 failed miserably due to the
>> use of the various BSD extensions (localeconv_l, mbstowcs_l, strtod_l,
>> strtof_l, strtold_l, wcsftime_l), whose use or fallback implementations
>> are currently guarded by _AIX.  Should those be used in a directory
>> supposed to conform to POSIX.1-2008 at all?  OTOH, almost duplicating
>> the code into a separate bsd (or whatever, it's certainly not only
>> DragonflyBSD) directory for this sole reason would be a shame.
>
> Hi, Rainer
>
> Thanks for testing.
>
> I agree that #ifdef's are not the correct approach, but, if you enable
> the fallbacks for Solaris, does everything then work?  Are those
> fallbacks portable and we solely need a better mechanism to enable
> them on platforms that require them?

it mostly compiles, with two caveats:

* c_locale.h needs to include <cstdlib> for declarations of strtod and
  friends.

* Solaris <locale.h> only declares the int_p_cs_precedes etc. members of
  struct lconv for C99+, but not for C++11+, as it should.  I'll file a
  bug for that, but for now one can work around the issue by defining
  _LCONV_C99 before including <locale> in monetary_members.cc.

With those changes, I can at least build libstdc++ with
--enable-clocale=ieee_1003.1-2008.  Bootstrap still running, though.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-12 19:58                     ` Rainer Orth
@ 2021-01-13 11:57                       ` Rainer Orth
  2021-01-13 12:23                         ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-13 11:57 UTC (permalink / raw)
  To: David Edelsohn
  Cc: Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches, CHIGOT, CLEMENT

Hi David,

>> I agree that #ifdef's are not the correct approach, but, if you enable
>> the fallbacks for Solaris, does everything then work?  Are those
>> fallbacks portable and we solely need a better mechanism to enable
>> them on platforms that require them?
>
> it mostly compiles, with two caveats:
>
> * c_locale.h needs to include <cstdlib> for declarations of strtod and
>   friends.
>
> * Solaris <locale.h> only declares the int_p_cs_precedes etc. members of
>   struct lconv for C99+, but not for C++11+, as it should.  I'll file a
>   bug for that, but for now one can work around the issue by defining
>   _LCONV_C99 before including <locale> in monetary_members.cc.
>
> With those changes, I can at least build libstdc++ with
> --enable-clocale=ieee_1003.1-2008.  Bootstrap still running, though.

while that allowed the compilation to succeed, test results are not
good:

+FAIL: libstdc++-abi/abi_check

# of added symbols:              173
# of missing symbols:            72
# of undesignated symbols:       0
# of incompatible symbols:       144

This alone makes the patch inacceptable in its present form: breaking
the libstdc++ ABI is a non-starter.  However, I suspect this can be
avoided somehow.

+FAIL: 22_locale/classification/isblank.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/classification/isblank.cc:38: void test02(): Assertion 'std::isblank(L' ', std::locale::classic())' failed.

It turns out that this is caused by ieee_1003.1-2008/ctype_members.cc
using __bitmapsize = 11 in a couple of places, unlike the generic
version which uses 15 to accomodate variations in <ctype.h> character
classifications.

Making this change lets a few tests PASS:

@@ -3354 +3354 @@
-FAIL: 22_locale/classification/isblank.cc execution test
+PASS: 22_locale/classification/isblank.cc execution test
@@ -3621 +3621 @@
-FAIL: 22_locale/ctype/is/wchar_t/1.cc execution test
+PASS: 22_locale/ctype/is/wchar_t/1.cc execution test
@@ -3655 +3655 @@
-FAIL: 22_locale/ctype/scan/wchar_t/1.cc execution test
+PASS: 22_locale/ctype/scan/wchar_t/1.cc execution test
@@ -3657 +3657 @@
-FAIL: 22_locale/ctype/scan/wchar_t/wrapped_env.cc execution test
+PASS: 22_locale/ctype/scan/wchar_t/wrapped_env.cc execution test
@@ -10864 +10864 @@
-FAIL: 28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc execution test
+PASS: 28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc execution test
@@ -11070 +11070 @@
-FAIL: 28_regex/traits/wchar_t/isctype.cc execution test
+PASS: 28_regex/traits/wchar_t/isctype.cc execution test

However, there are many more which I haven't even started to
investigate.  I suspect there's one (or a few) reasons immediately
obvious to someone familiar with the code.

+FAIL: 22_locale/codecvt/in/wchar_t/3.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc:118: void test03(): Assertion '!int_traits::compare(i_arr, i_lit, size)' failed.

+FAIL: 22_locale/codecvt/max_length/wchar_t/4.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/codecvt/max_length/wchar_t/4.cc:41: void test04(): Assertion 'k == 6' failed.

+FAIL: 22_locale/codecvt/out/wchar_t/3.cc execution test

vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/3.cc:113: void test03(): Assertion 'r2 == codecvt_base::ok' failed.

+FAIL: 22_locale/collate/compare/wchar_t/3.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/3.cc:61: void test03(): Assertion 'i == -1' failed.

+FAIL: 22_locale/collate/transform/wchar_t/3.cc execution test

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::append

+FAIL: 22_locale/ctype/is/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/1.cc:71: void test01(): Assertion 'gctype.is(std::ctype_base::punct, c40)' failed.

+FAIL: 22_locale/ctype/is/wchar_t/wrapped_env.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/1.cc:71: void test01(): Assertion 'gctype.is(std::ctype_base::punct, c40)' failed.

+FAIL: 22_locale/ctype/scan/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/scan/wchar_t/1.cc:69: void test01(): Assertion 'gctype.scan_is((std::ctype_base::xdigit), (ca), (ca) + traits_type::length(ca)) == (ca)' failed.

+FAIL: 22_locale/ctype/scan/wchar_t/wrapped_env.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/scan/wchar_t/1.cc:69: void test01(): Assertion 'gctype.scan_is((std::ctype_base::xdigit), (ca), (ca) + traits_type::length(ca)) == (ca)' failed.

+FAIL: 22_locale/ctype/widen/wchar_t/2.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/widen/wchar_t/2.cc:39: void test02(): Assertion 'wc == static_cast<wchar_t>(0xff)' failed.

+FAIL: 22_locale/locale/cons/29217.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc:33: void test01(): Assertion 'locale().name() == "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;" "LC_TIME=C;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=C;" "LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;" "LC_MEASUREMENT=C;LC_IDENTIFICATION=C"' failed.

+FAIL: 22_locale/locale/cons/38368.cc execution test

terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid

+FAIL: 22_locale/messages/members/char/1.cc execution test

vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc:52: void test01(): Assertion 's01 == "bitte"' failed.

+FAIL: 22_locale/messages_byname/named_equivalence.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc:58: void test01(): Assertion 's01 == "bitte"' failed.

+FAIL: 22_locale/money_get/get/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc:115: void test01(): Assertion 'result8 == digits1' failed.

+FAIL: 22_locale/money_put/put/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/1.cc:77: void test01(): Assertion 'result4 == L"7.200.000.000,00 \x20ac"' failed.

+FAIL: 22_locale/money_put/put/wchar_t/3.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/3.cc:74: void test03(): Assertion 'result4 == L"7.200.000.000,00 \x20ac"' failed.

+FAIL: 22_locale/time_put/put/char/2.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/time_put/put/char/2.cc:49: void test02(): Assertion 'result2 == "Son" || result2 == "So"' failed.

+FAIL: 22_locale/time_put/put/wchar_t/2.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/time_put/put/wchar_t/2.cc:50: void test02(): Assertion 'result2 == L"Son" || result2 == L"So"' failed.

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-1.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-2.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-3.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-4.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/manipulators/extended/get_time/char/2.cc execution test

vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc:41: void test01(): Assertion 'time1.tm_wday == 2' failed.

+FAIL: 28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc execution test

terminate called after throwing an instance of 'std::regex_error'
  what():  Unexpected end of regex when ascii character.

+FAIL: 28_regex/algorithms/regex_match/extended/wstring_locale.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:43: void test01(): Assertion 'regex_match_debug(str2, m2, re2)' failed.

+FAIL: 28_regex/iterators/regex_token_iterator/wchar_t/wstring_02.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/wchar_t/wstring_02.cc:44: void test01(): Assertion 'p == end' failed.

+FAIL: 28_regex/traits/wchar_t/isctype.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/28_regex/traits/wchar_t/isctype.cc:51: void test01(): Assertion 't.isctype(L' ', t.lookup_classname(range(blank)))' failed.

I've also added the locale handling changes in
config/os/aix/ctype_configure_char.cc to
config/os/solaris/ctype_configure_char.cc (ctype<char>::ctype), but that
made no difference.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-13 11:57                       ` Rainer Orth
@ 2021-01-13 12:23                         ` CHIGOT, CLEMENT
  2021-01-13 12:31                           ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-13 12:23 UTC (permalink / raw)
  To: Rainer Orth, David Edelsohn
  Cc: Jonathan Wakely, libstdc++, David Edelsohn via Gcc-patches

Hi Rainer,

> This alone makes the patch inacceptable in its present form: breaking
> the libstdc++ ABI is a non-starter.  However, I suspect this can be
> avoided somehow.
Thanks for having tried and I agree the patch isn't ready at all. I've just
wanted to see how behave on other systems and it seems that it might
not work as is.
However, is the C++ ABI not standard ? I don't have this test failing on
AIX, AFAIK. Strange.


> +FAIL: 22_locale/classification/isblank.cc execution test
>
> /vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/classification/isblank.cc:38: void test02(): Assertion 'std::isblank(L' ', std::locale::classic())' failed.
>
> It turns out that this is caused by ieee_1003.1-2008/ctype_members.cc
> using __bitmapsize = 11 in a couple of places, unlike the generic
> version which uses 15 to accomodate variations in <ctype.h> character
> classifications.
11 is the correct value on AIX and maybe also in Dragnofly/FreeBSD,
based on the value of Dragonfly model. However, big endian vs little
endian needs to be handled. I haven't fix that part on the current
patch I guess. (when bitmapsize = 15, there is no difference, endianness
doesn't matter). However, it might be simpler to set bitmapsize = 15
for everyone, instead of having some defines for that. Maybe.

> However, there are many more which I haven't even started to
> investigate.  I suspect there's one (or a few) reasons immediately
> obvious to someone familiar with the code.
Thanks for the list. I'll check if there is some common with AIX. But
wait until I push the new patch to start studying them.
It'll have the correct #ifdef based on configure and I'll try it on Linux.
Thus, it should be far better.


Thanks,
Clément

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-13 12:23                         ` CHIGOT, CLEMENT
@ 2021-01-13 12:31                           ` Rainer Orth
  2021-01-13 12:41                             ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-13 12:31 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: David Edelsohn, Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches

Hi Clement,

>> This alone makes the patch inacceptable in its present form: breaking
>> the libstdc++ ABI is a non-starter.  However, I suspect this can be
>> avoided somehow.
> Thanks for having tried and I agree the patch isn't ready at all. I've just
> wanted to see how behave on other systems and it seems that it might
> not work as is.

even if it did, this is certainly not stage3 material.  However,
submitting the patch early gives us enough time to work out the issues
in time for GCC 12.

> However, is the C++ ABI not standard ? I don't have this test failing on
> AIX, AFAIK. Strange.

Not really: the ABI tests rely on symbol versioning, which is only
available on Solaris and GNU ELF targets.

>> +FAIL: 22_locale/classification/isblank.cc execution test
>>
>> /vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/classification/isblank.cc:38:
>> void test02(): Assertion 'std::isblank(L' ', std::locale::classic())'
>> failed.
>>
>> It turns out that this is caused by ieee_1003.1-2008/ctype_members.cc
>> using __bitmapsize = 11 in a couple of places, unlike the generic
>> version which uses 15 to accomodate variations in <ctype.h> character
>> classifications.
> 11 is the correct value on AIX and maybe also in Dragnofly/FreeBSD,
> based on the value of Dragonfly model. However, big endian vs little
> endian needs to be handled. I haven't fix that part on the current
> patch I guess. (when bitmapsize = 15, there is no difference, endianness
> doesn't matter). However, it might be simpler to set bitmapsize = 15
> for everyone, instead of having some defines for that. Maybe.

I guess so, because this matches what the generic version does:
obviously there are targets that need it depending in their <ctype.h>
constants, and Solaris may be just one of them.

OTOH, I wondered if it wouldn't be better to start from the GNU code
which is certainly known to work, rather than the DragonflyBSD one which
may well have bitrotten since most of the BSDs moved to LLVM.  Then
again, it may not: Gerald tests on FreeBSD regularly.  Perhaps a 3-way
merge of gnu and *bsd -> ieee_1003.1-2008 is in order?

>> However, there are many more which I haven't even started to
>> investigate.  I suspect there's one (or a few) reasons immediately
>> obvious to someone familiar with the code.
> Thanks for the list. I'll check if there is some common with AIX. But
> wait until I push the new patch to start studying them.
> It'll have the correct #ifdef based on configure and I'll try it on Linux.
> Thus, it should be far better.

That has been my plan: you're obviously way more familiar with this code
than I am.

Thanks for doing all this work.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-13 12:31                           ` Rainer Orth
@ 2021-01-13 12:41                             ` CHIGOT, CLEMENT
  2021-01-13 12:47                               ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-13 12:41 UTC (permalink / raw)
  To: Rainer Orth
  Cc: David Edelsohn, Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches

> > However, is the C++ ABI not standard ? I don't have this test failing on
> > AIX, AFAIK. Strange.
>
> Not really: the ABI tests rely on symbol versioning, which is only
> available on Solaris and GNU ELF targets.
Maybe it's normal then.

> OTOH, I wondered if it wouldn't be better to start from the GNU code
> which is certainly known to work, rather than the DragonflyBSD one which
> may well have bitrotten since most of the BSDs moved to LLVM.  Then
> again, it may not: Gerald tests on FreeBSD regularly.  Perhaps a 3-way
merge of gnu and *bsd -> ieee_1003.1-2008 is in order?
Gnu model is really different as it implements catalogues, is using
nl_langinfo_l with GNU specific defines instead of localeconv_l, and few
other stuffs like this.
I'll check if some parts might be interesting. But BSD seems closer to want
we actually want.


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-13 12:41                             ` CHIGOT, CLEMENT
@ 2021-01-13 12:47                               ` Rainer Orth
  2021-01-21 12:48                                 ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-13 12:47 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: David Edelsohn, Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches

Hi Clement,

>> OTOH, I wondered if it wouldn't be better to start from the GNU code
>> which is certainly known to work, rather than the DragonflyBSD one which
>> may well have bitrotten since most of the BSDs moved to LLVM.  Then
>> again, it may not: Gerald tests on FreeBSD regularly.  Perhaps a 3-way
> merge of gnu and *bsd -> ieee_1003.1-2008 is in order?

not in the sense of actually combining the code bases, I'd say, but
certainly comparing all three.  gnu is guaranteed to be better
maintained/kept up to date.

> Gnu model is really different as it implements catalogues, is using
> nl_langinfo_l with GNU specific defines instead of localeconv_l, and few
> other stuffs like this.

True: we can only take parts that are in POSIX.1-2008/XPG7, obviously.
But checking for differences is still in order, I believe.

> I'll check if some parts might be interesting. But BSD seems closer to want
> we actually want.

Right, except for the fear that the code has partially bitrotten.  It's
up to Jonathan, of course, to decide if we're better off keeping gnu,
dragonfly (better renamed to bsd to match actual use) and
ieee-1003.1-2008 separate or update/rename the dragonfly code to work on
both the BSDs and POSIX.1-2008 systems.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-13 12:47                               ` Rainer Orth
@ 2021-01-21 12:48                                 ` CHIGOT, CLEMENT
  2021-01-21 16:36                                   ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-21 12:48 UTC (permalink / raw)
  To: libstdc++
  Cc: David Edelsohn, Jonathan Wakely, David Edelsohn via Gcc-patches,
	Rainer Orth

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

Hi everyone, 

Here is a new version of the patch. I've tested on Linux and AIX.
There are still some tests failing but it starts having a good shape ! 
However, I have few questions:

1) locale.name and syscalls
locale.name() is returning a string having the description of each locale
category. It looks like 
"LC_CTYPE=en_US.UTF-8; LC_NUMERIC=en_US.UTF-8; ...".
However, in locale::global() or sometimes in c_locale.cc functions, this
name is used as arguments of setlocale, newlocale, etc. 
It seems to work with GNU locale model but when I'm trying to do it 
with the POSIX_2008 model, it doesn't work. A simple C program 
seems to refuse it, anyway.
Thus, is there any define on Linux enabling this behavior ? And in 
a more general way, I'm not sure it will work on all POSIX 2008 
system. We might need to modify std:global() and other functions 
ending up using locale.name() as syscalls argument. 

2) Detect locale model during tests
Is there already a function in the testsuite to detect which locale model
is being used ? I didn't find any and as I'm not use to runtest scripts, 
I don't really know how to implement one. 
Ideally, it would be something like "has_locale_modele { gnu }". It would 
allow to skip some tests which are made only for GNU model.
Is there any function I can based myself on ?  

3) POSIX 2017 and non-POSIX functions
Many of the *_l functions being used in GNU or dragonfly models aren't 
POSIX 2008, but mainly POSIX 2017 or like strtof_l not POSIX at all. 
However, there are really useful in the code, thus I've made a double 
implementation based on "#ifdef HAVE_". Is it ok for you ? It's not really
POSIX 2008 but more POSIX 2008 with 2017 compatibility. 
For the configure, I didn't find any better way to check each syscall, as 
they all depend on different includes. Tell me if you have a better idea.

4) ctype_configure_char.cc 
I've some troubles knowing what is supposed to be implemented on this file. 
I don't really understand the part with setlocale which appears in many 
os. When I'm adding it, some tests start failing, some start working... 
Moreover, on Linux, if I understand correctly, there is some optimizations 
based on classic_table(), _M_toupper and _M_tolower. Could you confirm 
that it's only useful on Linux ?

5) Some tests results
Here are the remaining tests failing on Linux x86:
FAIL: 22_locale/locale/cons/29217.cc execution test
FAIL: 22_locale/locale/cons/38368.cc execution test
FAIL: 22_locale/locale/cons/40184.cc execution test
FAIL: 22_locale/locale/cons/5.cc execution test
FAIL: 22_locale/locale/global_locale_objects/14071.cc execution test
 => linked to 1)

FAIL: 22_locale/messages/13631.cc execution test
FAIL: 22_locale/messages/members/char/1.cc execution test
FAIL: 22_locale/messages/members/char/2.cc execution test
FAIL: 22_locale/messages/members/char/wrapped_env.cc execution test
FAIL: 22_locale/messages/members/char/wrapped_locale.cc execution test
FAIL: 22_locale/messages_byname/named_equivalence.cc execution test
  => linked to message_members.cc not being implemented.
        Reason behind 2)

FAIL: 22_locale/numpunct/members/char/3.cc execution test
  => No idea yet. Maybe 1) too.

FAIL: 22_locale/time_get/get_time/char/2.cc execution test
FAIL: 22_locale/time_get/get_time/char/wrapped_env.cc execution test
FAIL: 22_locale/time_get/get_time/char/wrapped_locale.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/2.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_env.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_locale.cc execution test
  => Not related. 

Feel free to try in on other OS. But I've made modifications only for AIX and 
Linux, as I can test the other ones. 

Thanks, 
Clément

[-- Attachment #2: 0001-libstdc-implement-locale-support-for-POSIX-2008.txt --]
[-- Type: text/plain, Size: 51237 bytes --]

From 6b82a9c6b49d16e701f096891550c93661a58bbe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Tue, 29 Dec 2020 11:08:33 +0100
Subject: [PATCH] libstdc++: implement locale support for POSIX 2008
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The implementation is based on dragonfly one.
It also adds support for AIX with a few tweaks.
As of now, a few locale functions are missing on AIX.
For strftime_l, localeconv_l, mbstowcs_l and wcsftime_l,
uselocale must be set prior to use the version without _l.
For strtof_l, strtod_l, strtold_l, a wrapper simply calls
the default version.

libstdc++-v3/ChangeLog:
2021-01-12  Clément Chigot  <clement.chigot@atos.net>

	* acinclude.m4: Add ieee_1003.1-2008 locale model.
	* configure: Regenerate.
	* config/os/aix/ctype_configure_char.cc: Enable locale support.
        * testsuite/lib/libstdc++.exp (check_v3_target_namedlocale):
        Handle AIX locale names.
	* testsuite/util/testsuite_hooks.h: Likewise.
	* config/locale/dragonfly/c_locale.cc: Removed.
	* config/locale/dragonfly/c_locale.h: Removed.
	* config/locale/dragonfly/codecvt_members.cc: Removed.
	* config/locale/dragonfly/collate_members.cc: Removed.
	* config/locale/dragonfly/ctype_members.cc: Removed.
	* config/locale/dragonfly/monetary_members.cc: Removed.
	* config/locale/dragonfly/numeric_members.cc: Removed.
	* config/locale/dragonfly/time_members.cc: Removed.
	* config/locale/dragonfly/time_members.h: Removed.
	* config/locale/ieee_1003.1-2008/c_locale.cc: New file.
	* config/locale/ieee_1003.1-2008/c_locale.h: New file.
	* config/locale/ieee_1003.1-2008/codecvt_members.cc: New file.
	* config/locale/ieee_1003.1-2008/collate_members.cc: New file.
	* config/locale/ieee_1003.1-2008/ctype_members.cc: New file.
	* config/locale/ieee_1003.1-2008/monetary_members.cc: New file.
	* config/locale/ieee_1003.1-2008/numeric_members.cc: New file.
	* config/locale/ieee_1003.1-2008/time_members.cc: New file.
	* config/locale/ieee_1003.1-2008/time_members.h: New file.
---
 libstdc++-v3/acinclude.m4                     | 360 +++++++++++++++++-
 libstdc++-v3/config.h.in                      |  45 +++
 .../c_locale.cc                               |   3 +
 .../c_locale.h                                |  45 +++
 .../codecvt_members.cc                        |   0
 .../collate_members.cc                        |  35 +-
 .../ctype_members.cc                          | 156 +++++++-
 .../monetary_members.cc                       |  39 +-
 .../numeric_members.cc                        |  25 ++
 .../time_members.cc                           |  31 +-
 .../time_members.h                            |   0
 .../config/os/aix/ctype_configure_char.cc     |  10 +-
 .../os/gnu-linux/ctype_configure_char.cc      |   4 +-
 .../22_locale/codecvt/in/wchar_t/2.cc         |   1 +
 .../22_locale/codecvt/in/wchar_t/3.cc         |   1 +
 .../22_locale/codecvt/in/wchar_t/4.cc         |   1 +
 .../22_locale/codecvt/in/wchar_t/7.cc         |   1 +
 .../22_locale/codecvt/in/wchar_t/8.cc         |   1 +
 .../22_locale/codecvt/in/wchar_t/9.cc         |   1 +
 .../22_locale/codecvt/length/wchar_t/4.cc     |   1 +
 .../22_locale/codecvt/out/wchar_t/4.cc        |   1 +
 .../22_locale/codecvt/unshift/wchar_t/4.cc    |   1 +
 .../basic_filebuf/overflow/wchar_t/11305-1.cc |   1 +
 .../basic_filebuf/overflow/wchar_t/11305-2.cc |   1 +
 .../basic_filebuf/overflow/wchar_t/11305-3.cc |   1 +
 .../basic_filebuf/overflow/wchar_t/11305-4.cc |   1 +
 libstdc++-v3/testsuite/lib/libstdc++.exp      |   5 +
 libstdc++-v3/testsuite/util/testsuite_hooks.h |   3 +
 28 files changed, 727 insertions(+), 47 deletions(-)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/c_locale.cc (99%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/c_locale.h (72%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/codecvt_members.cc (100%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/collate_members.cc (71%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/ctype_members.cc (57%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/monetary_members.cc (96%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/numeric_members.cc (92%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/time_members.cc (93%)
 rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/time_members.h (100%)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index e4175ea3e64..e1d705309d7 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2421,7 +2421,7 @@ dnl
 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
     [use MODEL for target locale package],
-    [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
+    [permit generic|gnu|ieee_1003.1-2001|ieee_1003.1-2008|newlib|yes|no|auto])
 
   # Deal with gettext issues.  Default to not using it (=no) until we detect
   # support for it later.  Let the user turn it off via --e/d, but let that
@@ -2448,8 +2448,8 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       darwin*)
 	enable_clocale_flag=darwin
 	;;
-      dragonfly* | freebsd*)
-	enable_clocale_flag=dragonfly
+      aix* | dragonfly* | freebsd*)
+	enable_clocale_flag=ieee_1003.1-2008
 	;;
       openbsd*)
 	enable_clocale_flag=newlib
@@ -2543,23 +2543,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
 
-    dragonfly)
-      AC_MSG_RESULT(dragonfly or freebsd)
-
-      CLOCALE_H=config/locale/dragonfly/c_locale.h
-      CLOCALE_CC=config/locale/dragonfly/c_locale.cc
-      CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
-      CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
-      CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
-      CMESSAGES_H=config/locale/generic/messages_members.h
-      CMESSAGES_CC=config/locale/generic/messages_members.cc
-      CMONEY_CC=config/locale/dragonfly/monetary_members.cc
-      CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
-      CTIME_H=config/locale/dragonfly/time_members.h
-      CTIME_CC=config/locale/dragonfly/time_members.cc
-      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
-      ;;
-
     gnu)
       AC_MSG_RESULT(gnu)
 
@@ -2610,6 +2593,24 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
+
+    ieee_1003.1-2008)
+      AC_MSG_RESULT(ieee_1003.1-2008)
+
+      CLOCALE_H=config/locale/ieee_1003.1-2008/c_locale.h
+      CLOCALE_CC=config/locale/ieee_1003.1-2008/c_locale.cc
+      CCODECVT_CC=config/locale/ieee_1003.1-2008/codecvt_members.cc
+      CCOLLATE_CC=config/locale/ieee_1003.1-2008/collate_members.cc
+      CCTYPE_CC=config/locale/ieee_1003.1-2008/ctype_members.cc
+      CMESSAGES_H=config/locale/generic/messages_members.h
+      CMESSAGES_CC=config/locale/generic/messages_members.cc
+      CMONEY_CC=config/locale/ieee_1003.1-2008/monetary_members.cc
+      CNUMERIC_CC=config/locale/ieee_1003.1-2008/numeric_members.cc
+      CTIME_H=config/locale/ieee_1003.1-2008/time_members.h
+      CTIME_CC=config/locale/ieee_1003.1-2008/time_members.cc
+      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+      ;;
+
     newlib)
       AC_MSG_RESULT(newlib)
 
@@ -2656,6 +2657,325 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   AC_SUBST(CTIME_CC)
   AC_SUBST(CLOCALE_CC)
   AC_SUBST(CLOCALE_INTERNAL_H)
+
+  if test $enable_clocale_flag = ieee_1003.1-2008; then
+     case ${target_os} in
+     	  dragonfly* | freebsd*) AC_DEFINE(_GLIBCXX_NEED_XLOCALE_H, 1,
+	    [Define if <xlocale.h> must be included for locale support.]);;
+     esac
+
+     # Set it to scream when it hurts.
+     ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="-Wimplicit-function-declaration -Werror"
+
+     # Use strtof_l if available.
+     AC_MSG_CHECKING([for strtof_l])
+     AC_CACHE_VAL(glibcxx_cv_strtof_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <stdlib.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [strtof_l(0,0,0)],
+	 [glibcxx_cv_strtof_l=yes],
+	 [glibcxx_cv_strtof_l=no])
+     ])
+     if test $glibcxx_cv_strtof_l = yes; then
+       AC_DEFINE(HAVE_STRTOF_L, 1,
+	 [Define if strtof_l is available in <stdlib.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_strtof_l)
+
+     # Use strtod_l if available.
+     AC_MSG_CHECKING([for strtod_l])
+     AC_CACHE_VAL(glibcxx_cv_strtod_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <stdlib.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [strtod_l(0,0,0)],
+	 [glibcxx_cv_strtod_l=yes],
+	 [glibcxx_cv_strtod_l=no])
+     ])
+     if test $glibcxx_cv_strtod_l = yes; then
+       AC_DEFINE(HAVE_STRTOD_L, 1,
+	 [Define if strtod_l is available in <stdlib.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_strtod_l)
+
+     # Use strtold_l if available.
+     AC_MSG_CHECKING([for strtold_l])
+     AC_CACHE_VAL(glibcxx_cv_strtold_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <stdlib.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [strtold_l(0,0,0)],
+	 [glibcxx_cv_strtold_l=yes],
+	 [glibcxx_cv_strtold_l=no])
+     ])
+     if test $glibcxx_cv_strtold_l = yes; then
+       AC_DEFINE(HAVE_STRTOLD_L, 1,
+	 [Define if strtold_l is available in <stdlib.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_strtold_l)
+
+     # Use localeconv_l if available.
+     AC_MSG_CHECKING([for localeconv_l])
+     AC_CACHE_VAL(glibcxx_cv_localeconv_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <locale.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [localeconv_l(0)],
+	 [glibcxx_cv_localeconv_l=yes],
+	 [glibcxx_cv_localeconv_l=no])
+     ])
+     if test $glibcxx_cv_localeconv_l = yes; then
+       AC_DEFINE(HAVE_LOCALECONV_L, 1,
+	 [Define if localeconv_l is available in <locale.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_localeconv_l)
+
+     # Use mbstowcs_l if available.
+     AC_MSG_CHECKING([for mbstowcs_l])
+     AC_CACHE_VAL(glibcxx_cv_mbstowcs_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <stdlib.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [mbstowcs_l(0,0,0,0)],
+	 [glibcxx_cv_mbstowcs_l=yes],
+	 [glibcxx_cv_mbstowcs_l=no])
+     ])
+     if test $glibcxx_cv_mbstowcs_l = yes; then
+       AC_DEFINE(HAVE_MBSTOWCS_L, 1,
+	 [Define if mbstowcs_l is available in <stdlib.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_mbstowcs_l)
+
+     # Use wcsftime_l if available.
+     AC_MSG_CHECKING([for wcsftime_l])
+     AC_CACHE_VAL(glibcxx_cv_wcsftime_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <wchar.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [wcsftime_l(0,0,0,0,0)],
+	 [glibcxx_cv_wcsftime_l=yes],
+	 [glibcxx_cv_wcsftime_l=no])
+     ])
+     if test $glibcxx_cv_wcsftime_l = yes; then
+       AC_DEFINE(HAVE_WCSFTIME_L, 1,
+	 [Define if wcsftime_l is available in <wchar.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_wcsftime_l)
+
+     # Use iswctype_l if available.
+     AC_MSG_CHECKING([for iswctype_l])
+     AC_CACHE_VAL(glibcxx_cv_iswctype_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <wchar.h>
+	   #include <wctype.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [iswctype_l(0,0,0)],
+	 [glibcxx_cv_iswctype_l=yes],
+	 [glibcxx_cv_iswctype_l=no])
+     ])
+     if test $glibcxx_cv_iswctype_l = yes; then
+       AC_DEFINE(HAVE_ISWCTYPE_L, 1,
+	 [Define if iswctype_l is available in <wchar.h> or <wctype.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_iswctype_l)
+
+     # Use wctype_l if available.
+     AC_MSG_CHECKING([for wctype_l])
+     AC_CACHE_VAL(glibcxx_cv_wctype_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <wchar.h>
+	   #include <wctype.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [wctype_l(0,0)],
+	 [glibcxx_cv_wctype_l=yes],
+	 [glibcxx_cv_wctype_l=no])
+     ])
+     if test $glibcxx_cv_wctype_l = yes; then
+       AC_DEFINE(HAVE_WCTYPE_L, 1,
+	 [Define if wctype_l is available in <wchar.h> or <wctype.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_wctype_l)
+
+     # Use strcoll_l if available.
+     AC_MSG_CHECKING([for strcoll_l])
+     AC_CACHE_VAL(glibcxx_cv_strcoll_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <string.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [strcoll_l(0,0,0)],
+	 [glibcxx_cv_strcoll_l=yes],
+	 [glibcxx_cv_strcoll_l=no])
+     ])
+     if test $glibcxx_cv_strcoll_l = yes; then
+       AC_DEFINE(HAVE_STRCOLL_L, 1,
+	 [Define if strcoll_l is available in <string.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_strcoll_l)
+
+     # Use strxfrm_l if available.
+     AC_MSG_CHECKING([for strxfrm_l])
+     AC_CACHE_VAL(glibcxx_cv_strxfrm_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <string.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [strxfrm_l(0,0,0,0)],
+	 [glibcxx_cv_strxfrm_l=yes],
+	 [glibcxx_cv_strxfrm_l=no])
+     ])
+     if test $glibcxx_cv_strxfrm_l = yes; then
+       AC_DEFINE(HAVE_STRXFRM_L, 1,
+	 [Define if strxfrm_l is available in <string.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_strxfrm_l)
+
+     # Use wcscoll_l if available.
+     AC_MSG_CHECKING([for wcscoll_l])
+     AC_CACHE_VAL(glibcxx_cv_wcscoll_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <string.h>
+	   #include <wchar.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [wcscoll_l(0,0,0)],
+	 [glibcxx_cv_wcscoll_l=yes],
+	 [glibcxx_cv_wcscoll_l=no])
+     ])
+     if test $glibcxx_cv_wcscoll_l = yes; then
+       AC_DEFINE(HAVE_WCSCOLL_L, 1,
+	 [Define if wcscoll_l is available in <stdlib.h> or <wchar.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_wcscoll_l)
+
+     # Use wcsxfrm_l if available.
+     AC_MSG_CHECKING([for wcsxfrm_l])
+     AC_CACHE_VAL(glibcxx_cv_wcsxfrm_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <string.h>
+	   #include <wchar.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [wcsxfrm_l(0,0,0,0)],
+	 [glibcxx_cv_wcsxfrm_l=yes],
+	 [glibcxx_cv_wcsxfrm_l=no])
+     ])
+     if test $glibcxx_cv_wcsxfrm_l = yes; then
+       AC_DEFINE(HAVE_WCSXFRM_L, 1,
+	 [Define if wcsxfrm_l is available in <stdlib.h> or <wchar.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_wcsxfrm_l)
+
+     # Use towlower_l if available.
+     AC_MSG_CHECKING([for towlower_l])
+     AC_CACHE_VAL(glibcxx_cv_towlower_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <wchar.h>
+	   #include <wctype.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [towlower_l(0,0)],
+	 [glibcxx_cv_towlower_l=yes],
+	 [glibcxx_cv_towlower_l=no])
+     ])
+     if test $glibcxx_cv_towlower_l = yes; then
+       AC_DEFINE(HAVE_TOWLOWER_L, 1,
+	 [Define if towlower_l is available in <wchar.h> or <wctype.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_towlower_l)
+
+     # Use towupper_l if available.
+     AC_MSG_CHECKING([for towupper_l])
+     AC_CACHE_VAL(glibcxx_cv_towupper_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <wchar.h>
+	   #include <wctype.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [towupper_l(0,0)],
+	 [glibcxx_cv_towupper_l=yes],
+	 [glibcxx_cv_towupper_l=no])
+     ])
+     if test $glibcxx_cv_towupper_l = yes; then
+       AC_DEFINE(HAVE_TOWUPPER_L, 1,
+         [Define if towupper_l is available in <wchar.h> or <wctype.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_towupper_l)
+
+     # Use strftime_l if available.
+     AC_MSG_CHECKING([for strftime_l])
+     AC_CACHE_VAL(glibcxx_cv_strftime_l, [
+       AC_TRY_COMPILE(
+         [
+	   #include <time.h>
+	   #ifdef _GLIBCXX_NEED_XLOCALE_H
+	   #include <xlocale.h>
+	   #endif
+	 ],
+	 [strftime_l(0,0,0,0,0)],
+	 [glibcxx_cv_strftime_l=yes],
+	 [glibcxx_cv_strftime_l=no])
+     ])
+     if test $glibcxx_cv_strftime_l = yes; then
+       AC_DEFINE(HAVE_STRFTIME_L, 1,
+	 [Define if strftime_l is available in <time.h>.])
+     fi
+     AC_MSG_RESULT($glibcxx_cv_strftime_l)
+
+     CFLAGS="$ac_save_CFLAGS"
+  fi
 ])
 
 
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index d36ca2620b4..b02bf922364 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -186,6 +186,9 @@
 /* Defined if iswblank exists. */
 #undef HAVE_ISWBLANK
 
+/* Define if iswctype_l is available in <wchar.h> or <wctype.h>. */
+#undef HAVE_ISWCTYPE_L
+
 /* Define if LC_MESSAGES is available in <locale.h>. */
 #undef HAVE_LC_MESSAGES
 
@@ -225,6 +228,9 @@
 /* Define to 1 if you have the <linux/types.h> header file. */
 #undef HAVE_LINUX_TYPES_H
 
+/* Define if localeconv_l is available in <locale.h>. */
+#undef HAVE_LOCALECONV_L
+
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
@@ -249,6 +255,9 @@
 /* Define if mbstate_t exists in wchar.h. */
 #undef HAVE_MBSTATE_T
 
+/* Define if mbstowcs_l is available in <stdlib.h>. */
+#undef HAVE_MBSTOWCS_L
+
 /* Define to 1 if you have the `memalign' function. */
 #undef HAVE_MEMALIGN
 
@@ -354,24 +363,39 @@
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
+/* Define if strcoll_l is available in <string.h>. */
+#undef HAVE_STRCOLL_L
+
 /* Define if strerror_l is available in <string.h>. */
 #undef HAVE_STRERROR_L
 
 /* Define if strerror_r is available in <string.h>. */
 #undef HAVE_STRERROR_R
 
+/* Define if strftime_l is available in <time.h>. */
+#undef HAVE_STRFTIME_L
+
 /* Define to 1 if you have the <strings.h> header file. */
 #undef HAVE_STRINGS_H
 
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
+/* Define if strtod_l is available in <stdlib.h>. */
+#undef HAVE_STRTOD_L
+
 /* Define to 1 if you have the `strtof' function. */
 #undef HAVE_STRTOF
 
+/* Define if strtof_l is available in <stdlib.h>. */
+#undef HAVE_STRTOF_L
+
 /* Define to 1 if you have the `strtold' function. */
 #undef HAVE_STRTOLD
 
+/* Define if strtold_l is available in <stdlib.h>. */
+#undef HAVE_STRTOLD_L
+
 /* Define to 1 if `d_type' is a member of `struct dirent'. */
 #undef HAVE_STRUCT_DIRENT_D_TYPE
 
@@ -460,6 +484,12 @@
 /* Define to 1 if the target supports thread-local storage. */
 #undef HAVE_TLS
 
+/* Define if towlower_l is available in <wchar.h> or <wctype.h>. */
+#undef HAVE_TOWLOWER_L
+
+/* Define if towupper_l is available in <wchar.h> or <wctype.h>. */
+#undef HAVE_TOWUPPER_L
+
 /* Define if truncate is available in <unistd.h>. */
 #undef HAVE_TRUNCATE
 
@@ -490,12 +520,24 @@
 /* Define to 1 if you have the <wchar.h> header file. */
 #undef HAVE_WCHAR_H
 
+/* Define if wcscoll_l is available in <stdlib.h> or <wchar.h>. */
+#undef HAVE_WCSCOLL_L
+
+/* Define if wcsftime_l is available in <wchar.h>. */
+#undef HAVE_WCSFTIME_L
+
 /* Defined if wcstof exists. */
 #undef HAVE_WCSTOF
 
+/* Define if wcsxfrm_l is available in <stdlib.h> or <wchar.h>. */
+#undef HAVE_WCSXFRM_L
+
 /* Define to 1 if you have the <wctype.h> header file. */
 #undef HAVE_WCTYPE_H
 
+/* Define if wctype_l is available in <wchar.h> or <wctype.h>. */
+#undef HAVE_WCTYPE_L
+
 /* Defined if Sleep exists. */
 #undef HAVE_WIN32_SLEEP
 
@@ -835,6 +877,9 @@
 /* Define to the letter to which size_t is mangled. */
 #undef _GLIBCXX_MANGLE_SIZE_T
 
+/* Define if <xlocale.h> must be included for locale support. */
+#undef _GLIBCXX_NEED_XLOCALE_H
+
 /* Define if C99 llrint and llround functions are missing from <math.h>. */
 #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS
 
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc
similarity index 99%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc
index 02df4605bb5..ea1531f5691 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc
@@ -33,8 +33,11 @@
 #include <locale>
 #include <stdexcept>
 #include <limits>
+
 #include <langinfo.h>
+#ifdef _GLIBCXX_NEED_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h
similarity index 72%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.h
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h
index cf4281cebbf..31c9aab6712 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.h
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h
@@ -40,7 +40,48 @@
 #pragma GCC system_header
 
 #include <clocale>
+#include <cstdlib>
+#ifdef _GLIBCXX_NEED_XLOCALE_H
 #include <xlocale.h>
+#endif
+
+#define _GLIBCXX_C_LOCALE_IEEE_2008 1
+
+#ifndef _GLIBCXX_HAVE_STRTOF_L
+extern "C" inline
+float strtof_l (const char *__nptr, char **__endptr,
+		locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  float __res = strtof(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+#endif
+
+#ifndef _GLIBCXX_HAVE_STRTOD_L
+extern "C" inline
+double strtod_l (const char *__nptr, char **__endptr,
+		 locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  double __res = strtod(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+#endif
+
+#ifndef _GLIBCXX_HAVE_STRTOLD_L
+extern "C" inline
+long double strtold_l (const char *__nptr, char **__endptr,
+		       locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  long double __res = strtold(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+#endif
 
 #define _GLIBCXX_NUM_CATEGORIES 0
 
@@ -48,7 +89,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if defined(__DragonFly__) || defined(__FreeBSD__)
   typedef int*			__c_locale;
+#else
+  typedef locale_t			__c_locale;
+#endif
 
   // Convert numeric value of type double and long double to string and
   // return length of string.  If vsnprintf is available use it, otherwise
diff --git a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/codecvt_members.cc
similarity index 100%
rename from libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/codecvt_members.cc
diff --git a/libstdc++-v3/config/locale/dragonfly/collate_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc
similarity index 71%
rename from libstdc++-v3/config/locale/dragonfly/collate_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc
index 64c7d864a61..6ecf29bfc65 100644
--- a/libstdc++-v3/config/locale/dragonfly/collate_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc
@@ -43,7 +43,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     collate<char>::_M_compare(const char* __one,
 			      const char* __two) const throw()
     {
+#ifdef _GLIBCXX_HAVE_STRCOLL_L
       int __cmp = strcoll_l(__one, __two, (locale_t)_M_c_locale_collate);
+#else
+      __c_locale __old = uselocale((locale_t)_M_c_locale_collate);
+      int __cmp = strcoll(__one, __two);
+      uselocale(__old);
+#endif
       return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
     }
 
@@ -51,7 +57,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     size_t
     collate<char>::_M_transform(char* __to, const char* __from,
 				size_t __n) const throw()
-    { return strxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate); }
+    {
+#ifdef _GLIBCXX_HAVE_STRXFRM_L
+      return strxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate);
+#else
+      __c_locale __old = uselocale((locale_t)_M_c_locale_collate);
+      size_t __res =  strxfrm(__to, __from, __n);
+      uselocale(__old);
+      return __res;
+#endif
+    }
 
 #ifdef _GLIBCXX_USE_WCHAR_T
   template<>
@@ -59,7 +74,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     collate<wchar_t>::_M_compare(const wchar_t* __one,
 				 const wchar_t* __two) const throw()
     {
+#ifdef _GLIBCXX_HAVE_WCSCOLL_L
       int __cmp = wcscoll_l(__one, __two, (locale_t)_M_c_locale_collate);
+#else
+      __c_locale __old = uselocale((locale_t)_M_c_locale_collate);
+      int __cmp = wcscoll(__one, __two);
+      uselocale(__old);
+#endif
+
       return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
     }
 
@@ -67,7 +89,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     size_t
     collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
 				   size_t __n) const throw()
-    { return wcsxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate); }
+    {
+#ifdef _GLIBCXX_HAVE_WCSXFRM_L
+      return wcsxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate);
+#else
+      __c_locale __old = uselocale((locale_t)_M_c_locale_collate);
+      size_t __res =  wcsxfrm(__to, __from, __n);
+      uselocale(__old);
+      return __res;
+#endif
+    }
 #endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
similarity index 57%
rename from libstdc++-v3/config/locale/dragonfly/ctype_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
index 420cb51e07a..e37e9fb3b83 100644
--- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
@@ -34,7 +34,11 @@
 #include <cstdio>
 
 #ifndef _ISbit
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
+#else
+#define _ISbit(bit) (1 << bit)
+#endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -56,85 +60,209 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   ctype_byname<char>::~ctype_byname()
   { }
 
+#ifdef _GLIBCXX_HAVE_WCTYPE_L
+#define WCTYPE_L(PROP, LOCALE) wctype_l(PROP, LOCALE)
+#else
+  // "uselocale" must be called before using this macro.
+#define WCTYPE_L(PROP, LOCALE) wctype(PROP)
+#endif
+
 #ifdef _GLIBCXX_USE_WCHAR_T
   ctype<wchar_t>::__wmask_type
   ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const throw()
   {
+#ifndef _GLIBCXX_HAVE_WCTYPE_L
+    __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
+#endif
     __wmask_type __ret;
     switch (__m)
       {
       case space:
-	__ret = wctype_l("space", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("space", (locale_t)_M_c_locale_ctype);
 	break;
       case print:
-	__ret = wctype_l("print", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("print", (locale_t)_M_c_locale_ctype);
 	break;
       case cntrl:
-	__ret = wctype_l("cntrl", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("cntrl", (locale_t)_M_c_locale_ctype);
 	break;
       case upper:
-	__ret = wctype_l("upper", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("upper", (locale_t)_M_c_locale_ctype);
 	break;
       case lower:
-	__ret = wctype_l("lower", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("lower", (locale_t)_M_c_locale_ctype);
 	break;
       case alpha:
-	__ret = wctype_l("alpha", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("alpha", (locale_t)_M_c_locale_ctype);
 	break;
       case digit:
-	__ret = wctype_l("digit", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("digit", (locale_t)_M_c_locale_ctype);
 	break;
       case punct:
-	__ret = wctype_l("punct", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("punct", (locale_t)_M_c_locale_ctype);
 	break;
       case xdigit:
-	__ret = wctype_l("xdigit", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("xdigit", (locale_t)_M_c_locale_ctype);
 	break;
       case alnum:
-	__ret = wctype_l("alnum", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("alnum", (locale_t)_M_c_locale_ctype);
 	break;
       case graph:
-	__ret = wctype_l("graph", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("graph", (locale_t)_M_c_locale_ctype);
 	break;
       case blank:
-	__ret = wctype_l("blank", (locale_t)_M_c_locale_ctype);
+	__ret = WCTYPE_L("blank", (locale_t)_M_c_locale_ctype);
 	break;
       default:
 	__ret = __wmask_type();
       }
+#ifndef _GLIBCXX_HAVE_WCTYPE_L
+    uselocale(__old);
+#endif
     return __ret;
   }
 
   wchar_t
   ctype<wchar_t>::do_toupper(wchar_t __c) const
-  { return towupper_l(__c, (locale_t)_M_c_locale_ctype); }
+  {
+#ifdef _GLIBCXX_HAVE_TOWUPPER_L
+    return towupper_l(__c, (locale_t)_M_c_locale_ctype);
+#else
+    __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
+    wchar_t __res = towupper(__c);
+    uselocale(__old);
+    return __res;
+#endif
+  }
 
   const wchar_t*
   ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
   {
+#ifndef _GLIBCXX_HAVE_TOWUPPER_L
+    __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
+#endif
     while (__lo < __hi)
       {
+#ifdef _GLIBCXX_HAVE_TOWUPPER_L
         *__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype);
+#else
+        *__lo = towupper(*__lo);
+#endif
         ++__lo;
       }
+#ifndef _GLIBCXX_HAVE_TOWUPPER_L
+    uselocale(__old);
+#endif
     return __hi;
   }
 
   wchar_t
   ctype<wchar_t>::do_tolower(wchar_t __c) const
-  { return towlower_l(__c, (locale_t)_M_c_locale_ctype); }
+  {
+#ifdef _GLIBCXX_HAVE_TOWLOWER_L
+    return towlower_l(__c, (locale_t)_M_c_locale_ctype);
+#else
+    __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
+    wchar_t __res = towlower(__c);
+    uselocale(__old);
+    return __res;
+#endif
+  }
 
   const wchar_t*
   ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
   {
+#ifndef _GLIBCXX_HAVE_TOWLOWER_L
+    __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
+#endif
     while (__lo < __hi)
       {
+#ifdef _GLIBCXX_HAVE_TOWLOWER_L
         *__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype);
+#else
+        *__lo = towlower(*__lo);
+#endif
         ++__lo;
       }
+#ifndef _GLIBCXX_HAVE_TOWLOWER_L
+    uselocale(__old);
+#endif
+    return __hi;
+  }
+
+#if !defined(__DragonFly__) && !defined(__FreeBSD__)
+  bool
+  ctype<wchar_t>::
+  do_is(mask __m, char_type __c) const
+  {
+    bool __ret = false;
+    const size_t __bitmasksize = 11;
+#ifndef _GLIBCXX_HAVE_ISWCTYPE_L
+    __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
+#endif
+    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+      if (__m & _M_bit[__bitcur]
+#ifdef _GLIBCXX_HAVE_ISWCTYPE_L
+	  && iswctype_l(__c, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype)
+#else
+	  && iswctype(__c, _M_wmask[__bitcur])
+#endif
+	  )
+	{
+	  __ret = true;
+	  break;
+	}
+#ifndef _GLIBCXX_HAVE_ISWCTYPE_L
+    uselocale(__old);
+#endif
+    return __ret;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+  {
+#ifndef _GLIBCXX_HAVE_ISWCTYPE_L
+    __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
+#endif
+    for (;__lo < __hi; ++__vec, ++__lo)
+      {
+	const size_t __bitmasksize = 11;
+	mask __m = 0;
+	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+#ifdef _GLIBCXX_HAVE_ISWCTYPE_L
+	  if (iswctype_l(*__lo, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype))
+#else
+	  if (iswctype(*__lo, _M_wmask[__bitcur]))
+#endif
+	    __m |= _M_bit[__bitcur];
+	*__vec = __m;
+      }
+#ifndef _GLIBCXX_HAVE_ISWCTYPE_L
+    uselocale(__old);
+#endif
     return __hi;
   }
 
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
+  {
+    while (__lo < __hi && !this->do_is(__m, *__lo))
+      ++__lo;
+    return __lo;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
+  {
+    while (__lo < __hi && this->do_is(__m, *__lo) != 0)
+      ++__lo;
+    return __lo;
+  }
+#endif
+
   wchar_t
   ctype<wchar_t>::
   do_widen(char __c) const
diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
similarity index 96%
rename from libstdc++-v3/config/locale/dragonfly/monetary_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
index e1decc61cbf..700098c5562 100644
--- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
@@ -31,7 +31,10 @@
 
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_NEED_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -241,7 +244,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -348,6 +356,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -360,6 +371,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->int_n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -395,7 +409,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -502,6 +521,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -514,6 +536,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -581,9 +606,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -741,9 +771,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc
similarity index 92%
rename from libstdc++-v3/config/locale/dragonfly/numeric_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc
index cac6fe8c710..196f2952218 100644
--- a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc
@@ -31,7 +31,10 @@
 
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_NEED_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -63,7 +66,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -103,6 +111,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -113,6 +124,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
@@ -162,7 +176,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -201,6 +220,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -211,6 +233,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc
similarity index 93%
rename from libstdc++-v3/config/locale/dragonfly/time_members.cc
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc
index c8b621a323f..926cc5269b2 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc
@@ -35,7 +35,10 @@
 #include <cwchar>
 #include <stdlib.h>
 #include <langinfo.h>
+
+#ifdef _GLIBCXX_NEED_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -47,8 +50,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(char* __s, size_t __maxlen, const char* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_STRFTIME_L
       const size_t __len = strftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = strftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = '\0';
@@ -196,15 +205,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_WCSFTIME_L
       const size_t __len = wcsftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = L'\0';
     }
 
+#ifdef _GLIBCXX_HAVE_MBSTOWCS_L
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs_l (WCSTRING, STRING, NUMBER, LOCALE);
+#else
+  // "uselocale" must be called before using this macro.
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs (WCSTRING, STRING, NUMBER);
+#endif
 #define WIDE_LANGINFO(M,FMT) \
-	fmtlen = mbstowcs_l (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
+	fmtlen = MBSTOWCS_L (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
 		128, (locale_t)__cloc); \
 	langstring = new wchar_t[fmtlen + 1]; \
 	wcsncpy (langstring, holder, fmtlen); \
@@ -281,6 +304,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  __c_locale __old = uselocale(__cloc);
+#endif
 	  wchar_t *langstring = 0;
 	  wchar_t holder[128];
 	  size_t fmtlen;
@@ -342,6 +368,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  WIDE_LANGINFO(_M_amonth10, ABMON_10)
 	  WIDE_LANGINFO(_M_amonth11, ABMON_11)
 	  WIDE_LANGINFO(_M_amonth12, ABMON_12)
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  uselocale(__old);
+#endif
 	}
     }
 
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.h b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.h
similarity index 100%
rename from libstdc++-v3/config/locale/dragonfly/time_members.h
rename to libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.h
diff --git a/libstdc++-v3/config/os/aix/ctype_configure_char.cc b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
index b12c0bd435c..38f9308893b 100644
--- a/libstdc++-v3/config/os/aix/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
@@ -46,23 +46,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		     size_t __refs)
   : facet(__refs), _M_del(__table != 0 && __del),
   _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
   : facet(__refs), _M_del(__table != 0 && __del),
   _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   char
diff --git a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
index d6ab73175b8..9cf21500271 100644
--- a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
@@ -38,7 +38,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // Information as gleaned from /usr/include/ctype.h
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_IEEE_2008
   const ctype_base::mask*
   ctype<char>::classic_table() throw()
   { return _S_get_c_locale()->__ctype_b; }
@@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_IEEE_2008
   ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
   : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
index ea0c43a20fc..71e198843d2 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
index 54206f8000a..ffde94108a1 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO-8859-15" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
index f27d667daf5..9193b598162 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
index b5383af657c..e4b428c9fc6 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
index 1d40a1723a4..ffbd856640b 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
index 9801e085683..5e42a373547 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
index f70d0fc6c58..01bf1a57917 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
index 5cde0b66331..25dfa02b99d 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
index 1e4ce5a8e3e..5d00a62c9a9 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
index c747f7bfb02..46713cca118 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
index 76a387768fe..a3a4bbf5833 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
index 24d192921cb..2a314589714 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
index 2c0a2ab61db..71393bbd255 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 30a4345b14f..200602d003e 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -904,6 +904,11 @@ proc check_v3_target_namedlocale { args } {
 	puts $f "    strcpy(result, name);"
 	puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
 	puts $f "    /* fall-through */"
+	puts $f "#elif defined _AIX"
+	puts $f "    char *p = strstr(result, \"ISO8859-15\");"
+	puts $f "    if (p) {"
+	puts $f "       strcpy(p, \"8859-15\");"
+	puts $f "    }"
 	puts $f "#else"
 	puts $f "    if (strstr(result, \"ISO8859-15\")) {"
 	puts $f "        strcat(result, \"@euro\");"
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index b5e0767211a..a632f5f31f8 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -77,6 +77,9 @@
 
 #if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__
 # define ISO_8859(part,langTERR) #langTERR ".ISO8859-" #part
+#elif defined _AIX
+# define ISO_8859(part,langTERR) ((part) == 15 ?\
+         #langTERR ".8859-" #part : #langTERR ".ISO8859-" #part)
 #else
 # define ISO_8859(part,langTERR) ((part) == 15 ?\
          #langTERR ".ISO8859-" #part "@euro" : #langTERR ".ISO8859-" #part)
-- 
2.25.0


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-21 12:48                                 ` CHIGOT, CLEMENT
@ 2021-01-21 16:36                                   ` Rainer Orth
  2021-01-22  9:57                                     ` CHIGOT, CLEMENT
  2021-01-22 11:02                                     ` Jonathan Wakely
  0 siblings, 2 replies; 43+ messages in thread
From: Rainer Orth @ 2021-01-21 16:36 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: libstdc++,
	David Edelsohn, Jonathan Wakely, David Edelsohn via Gcc-patches

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

Hi Clement,

> Here is a new version of the patch. I've tested on Linux and AIX.
> There are still some tests failing but it starts having a good shape ! 
> However, I have few questions:
>
> 1) locale.name and syscalls

just a terminology nit: none of those are syscalls.

> 3) POSIX 2017 and non-POSIX functions
> Many of the *_l functions being used in GNU or dragonfly models aren't 
> POSIX 2008, but mainly POSIX 2017 or like strtof_l not POSIX at all. 
> However, there are really useful in the code, thus I've made a double 
> implementation based on "#ifdef HAVE_". Is it ok for you ? It's not really
> POSIX 2008 but more POSIX 2008 with 2017 compatibility. 
> For the configure, I didn't find any better way to check each syscall, as 
> they all depend on different includes. Tell me if you have a better idea.

First a general observation: there are two groups of functions you're
testing for:

* Pure BSD additions, not available in either POSIX.1, ISO C, or glibc:

  localeconv_l
  mbstowcs_l
  strtod_l
  strtof_l
  strtold_l
  wcsftime_l

* Part of XPG7:

  iswctype_l
  strcoll_l
  strftime_l
  strxfrm_l
  towlower_l
  towupper_l
  wcscoll_l
  wcsxfrm_l
  wctype_l

My suggestion would be not to have configure tests _GLIBCXX_HAVE_<FUNC>
for any of the second group at all: this is ieee_1003.1-2008, after all,
so if some OS selects that clocale variant, it better implement all of
those.  If really need be, one could a configure check for those and
error out if any is missing.  This makes the code way more readable than
trying to handle some hypothetical partial implementation.

As for the BSD group, I suggest to have one representative configure
test (for localeconv_l perhaps) and then use an appropriate name for the
group as a whole.  Again, this will most likely be an all-or-nothing
thing.

Besides, your configure tests are way too complicated: just use
AC_CHECK_FUNCS doing a link test and be done with it.

In a similar vein, configure.ac already has
AC_CHECK_HEADERS([xlocale.h]).  Rather than hardcoding the existance of
the header based on the configure triple, just use the existing
HAVE_XLOCALE_H.  This ways, things will simply fall into place for
e.g. NetBSD, OpenBSD and possibly others.

> 4) ctype_configure_char.cc 
> I've some troubles knowing what is supposed to be implemented on this file. 
> I don't really understand the part with setlocale which appears in many 
> os. When I'm adding it, some tests start failing, some start working... 
> Moreover, on Linux, if I understand correctly, there is some optimizations 
> based on classic_table(), _M_toupper and _M_tolower. Could you confirm 
> that it's only useful on Linux ?

I don't know myself.  However, when trying the first version of your
patch (augmented to compile on Solaris), the corresponding change to the
solaris file made no difference in test results.

> Feel free to try in on other OS. But I've made modifications only for AIX and 
> Linux, as I can test the other ones. 

While reading through the patch, I saw that in two places you still use
__DragonFly__ || __FreeBSD__ tests.  For one, it's hard to tell what
feature they are really about, besides they will require fiddling with
e.g. for other BSDs.  Please use a descriptive macro which says which
difference this is about.

That said, I gave the new patch a try on Solaris 11.4.  To get it to
compile, I had to apply two changes that I'd mentioned (without an actual
patch) when commenting on the first patch:

* The C99 fields of struct lconv need _LCONV_C99 to be visible for
  C++11.

* Some ctype macros need __bitmapsize = 15, as the generic clocale
  implementation uses.

With the attached patch, the code compiled using
--enable-clocale=ieee_1003.1-2008.

Compared to the augmented first patch, there are a few differences: a
couple of failures went away and I've now

+XPASS: 22_locale/ctype/is/wchar_t/2.cc execution test

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: lx7.patch --]
[-- Type: text/x-patch, Size: 1783 bytes --]

diff --git a/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
--- a/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc
@@ -196,7 +196,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul
   do_is(mask __m, char_type __c) const
   {
     bool __ret = false;
-    const size_t __bitmasksize = 11;
+    const size_t __bitmasksize = 15;
 #ifndef _GLIBCXX_HAVE_ISWCTYPE_L
     __c_locale __old = uselocale((locale_t)_M_c_locale_ctype);
 #endif
@@ -227,7 +227,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul
 #endif
     for (;__lo < __hi; ++__vec, ++__lo)
       {
-	const size_t __bitmasksize = 11;
+	const size_t __bitmasksize = 15;
 	mask __m = 0;
 	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
 #ifdef _GLIBCXX_HAVE_ISWCTYPE_L
@@ -345,7 +345,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul
 	 __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
       _M_widen[__j] = btowc(__j);
 
-    for (size_t __k = 0; __k <= 11; ++__k)
+    for (size_t __k = 0; __k <= 15; ++__k)
       {
 	_M_bit[__k] = static_cast<mask>(_ISbit(__k));
 	_M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
diff --git a/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
--- a/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc
@@ -29,6 +29,8 @@
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
 
+// Solaris 11.4 doesn't make C99 members of struct lconv visible for C++11
+// without this.
 #include <locale>
 #include <cstring>
 

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-21 16:36                                   ` Rainer Orth
@ 2021-01-22  9:57                                     ` CHIGOT, CLEMENT
  2021-01-22 11:04                                       ` Rainer Orth
  2021-01-22 11:12                                       ` Jonathan Wakely
  2021-01-22 11:02                                     ` Jonathan Wakely
  1 sibling, 2 replies; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-22  9:57 UTC (permalink / raw)
  To: Rainer Orth
  Cc: libstdc++,
	David Edelsohn, Jonathan Wakely, David Edelsohn via Gcc-patches

Hi Rainer

> > 3) POSIX 2017 and non-POSIX functions
> > Many of the *_l functions being used in GNU or dragonfly models aren't
> > POSIX 2008, but mainly POSIX 2017 or like strtof_l not POSIX at all.
> > However, there are really useful in the code, thus I've made a double
> > implementation based on "#ifdef HAVE_". Is it ok for you ? It's not really
> > POSIX 2008 but more POSIX 2008 with 2017 compatibility.
> > For the configure, I didn't find any better way to check each syscall, as
> > they all depend on different includes. Tell me if you have a better idea.
>
> First a general observation: there are two groups of functions you're
> testing for:
>
> * Pure BSD additions, not available in either POSIX.1, ISO C, or glibc:
>
>  localeconv_l
>  mbstowcs_l
>  strtod_l
>  strtof_l
>  strtold_l
>  wcsftime_l
>
> * Part of XPG7:
>
>   iswctype_l
>   strcoll_l
>   strftime_l
>   strxfrm_l
>   towlower_l
>   towupper_l
>   wcscoll_l
>   wcsxfrm_l
>   wctype_l
>
> My suggestion would be not to have configure tests _GLIBCXX_HAVE_<FUNC>
> for any of the second group at all: this is ieee_1003.1-2008, after all,
> so if some OS selects that clocale variant, it better implement all of
> those.  If really need be, one could a configure check for those and
> error out if any is missing.  This makes the code way more readable than
> trying to handle some hypothetical partial implementation.

In this case, it would be better to call it ieee_1003.1-2017 but I agree
it would be better to avoid all these #ifdef.
Some are still needed as for example only the last version of AIX have
strftime_l.

> As for the BSD group, I suggest to have one representative configure
>  test (for localeconv_l perhaps) and then use an appropriate name for the
> group as a whole.  Again, this will most likely be an all-or-nothing
> thing.

I'm not sure this is really all-or-nothing for these. Maybe strtof_l and cie
can be grouped by. But the 3 others are really different. Linux have wcsftime_l
but not the others. AIX avec none. BSD have all.

> Besides, your configure tests are way too complicated: just use
> AC_CHECK_FUNCS doing a link test and be done with it.

Sadly, you can't pass includes to AC_CHECK_FUNCS. That's why I had to do
that. I've made a first version with AC_CHECK_DECLS which allows extra
headers, but it didn't work too. I might know why though.

> In a similar vein, configure.ac already has
> AC_CHECK_HEADERS([xlocale.h]).  Rather than hardcoding the existance of
> the header based on the configure triple, just use the existing
> HAVE_XLOCALE_H.  This ways, things will simply fall into place for
> e.g. NetBSD, OpenBSD and possibly others.

Right, I'll make the change. Thanks !

> > 4) ctype_configure_char.cc
> > I've some troubles knowing what is supposed to be implemented on this file.
> > I don't really understand the part with setlocale which appears in many
> > os. When I'm adding it, some tests start failing, some start working...
> > Moreover, on Linux, if I understand correctly, there is some optimizations
> > based on classic_table(), _M_toupper and _M_tolower. Could you confirm
> > that it's only useful on Linux ?
>
> I don't know myself.  However, when trying the first version of your
> patch (augmented to compile on Solaris), the corresponding change to the
> solaris file made no difference in test results.

I might have found the correct code since yesterday's mail. The problem seems
to come from _M_c_locale_ctype initialization. With locale support, it must be
_S_clone_c_locale(__cloc), without it, it must be the default locale which ends up
being "C". I might push a newer patch this afternoon, with the correct code.

> > Feel free to try in on other OS. But I've made modifications only for AIX and
> > Linux, as I can test the other ones.
>
> While reading through the patch, I saw that in two places you still use
> __DragonFly__ || __FreeBSD__ tests.  For one, it's hard to tell what
> feature they are really about, besides they will require fiddling with
> e.g. for other BSDs.  Please use a descriptive macro which says which
> difference this is about.

Right, because I don't know how to handle them (and I've forgotten to ask
for it...).
The first is for typedef __c_locale. It seems to be int* instead of locale_t.
Could you confirm that this is wanted and mandatory ?
The second is in about some functions in ctype_members.cc which are
defined in config/os/../ctype_inlines.h for FreeBSD and Dragonfly. Someone
has to confirm that it can be merged with the new code, or if this is mandatory.

> That said, I gave the new patch a try on Solaris 11.4.  To get it to
> compile, I had to apply two changes that I'd mentioned (without an actual
> patch) when commenting on the first patch:
>
> * The C99 fields of struct lconv need _LCONV_C99 to be visible for
>   C++11.
>
>  * Some ctype macros need __bitmapsize = 15, as the generic clocale
>   implementation uses.

If I'm not mistaking, POSIX is only defining 11 bit for ctype. If we want
some optimizations we can have a define of bitmasksize or we can simply
fill the whole mask by setting bitmasksize=15 as in generic.
I don't know what's best.

> Compared to the augmented first patch, there are a few differences: a
> couple of failures went away and I've now
>
> +XPASS: 22_locale/ctype/is/wchar_t/2.cc execution test

This is normal, because I need a way to check for which locale model
is being used.

Thanks,
Clément

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-21 16:36                                   ` Rainer Orth
  2021-01-22  9:57                                     ` CHIGOT, CLEMENT
@ 2021-01-22 11:02                                     ` Jonathan Wakely
  1 sibling, 0 replies; 43+ messages in thread
From: Jonathan Wakely @ 2021-01-22 11:02 UTC (permalink / raw)
  To: Rainer Orth
  Cc: CHIGOT, CLEMENT, libstdc++,
	David Edelsohn via Gcc-patches, David Edelsohn

On 21/01/21 17:36 +0100, Rainer Orth wrote:
>Hi Clement,
>
>> Here is a new version of the patch. I've tested on Linux and AIX.
>> There are still some tests failing but it starts having a good shape ! 
>> However, I have few questions:
>>
>> 1) locale.name and syscalls
>
>just a terminology nit: none of those are syscalls.
>
>> 3) POSIX 2017 and non-POSIX functions
>> Many of the *_l functions being used in GNU or dragonfly models aren't
>> POSIX 2008, but mainly POSIX 2017 or like strtof_l not POSIX at all.
>> However, there are really useful in the code, thus I've made a double
>> implementation based on "#ifdef HAVE_". Is it ok for you ? It's not really
>> POSIX 2008 but more POSIX 2008 with 2017 compatibility.
>> For the configure, I didn't find any better way to check each syscall, as
>> they all depend on different includes. Tell me if you have a better idea.
>
>First a general observation: there are two groups of functions you're
>testing for:
>
>* Pure BSD additions, not available in either POSIX.1, ISO C, or glibc:
>
>  localeconv_l
>  mbstowcs_l
>  strtod_l
>  strtof_l
>  strtold_l
>  wcsftime_l

Glibc does provide the last four with _GNU_SOURCE defined (but not
localeconv_l or mbstowcs_l).

>
>* Part of XPG7:
>
>  iswctype_l
>  strcoll_l
>  strftime_l
>  strxfrm_l
>  towlower_l
>  towupper_l
>  wcscoll_l
>  wcsxfrm_l
>  wctype_l
>
>My suggestion would be not to have configure tests _GLIBCXX_HAVE_<FUNC>
>for any of the second group at all: this is ieee_1003.1-2008, after all,
>so if some OS selects that clocale variant, it better implement all of
>those.  If really need be, one could a configure check for those and
>error out if any is missing.  This makes the code way more readable than
>trying to handle some hypothetical partial implementation.

Agreed.

>As for the BSD group, I suggest to have one representative configure
>test (for localeconv_l perhaps) and then use an appropriate name for the
>group as a whole.  Again, this will most likely be an all-or-nothing
>thing.
>
>Besides, your configure tests are way too complicated: just use
>AC_CHECK_FUNCS doing a link test and be done with it.
>
>In a similar vein, configure.ac already has
>AC_CHECK_HEADERS([xlocale.h]).  Rather than hardcoding the existance of
>the header based on the configure triple, just use the existing
>HAVE_XLOCALE_H.  This ways, things will simply fall into place for
>e.g. NetBSD, OpenBSD and possibly others.

IIRC Darwin has that header, but I'm not sure how many of the xxx_l
extensions it provides.


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-22  9:57                                     ` CHIGOT, CLEMENT
@ 2021-01-22 11:04                                       ` Rainer Orth
  2021-01-22 11:29                                         ` Jonathan Wakely
  2021-01-22 11:12                                       ` Jonathan Wakely
  1 sibling, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-22 11:04 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: libstdc++,
	David Edelsohn, Jonathan Wakely, David Edelsohn via Gcc-patches

Hi Clement,

>> > 3) POSIX 2017 and non-POSIX functions
>> > Many of the *_l functions being used in GNU or dragonfly models aren't
>> > POSIX 2008, but mainly POSIX 2017 or like strtof_l not POSIX at all.
>> > However, there are really useful in the code, thus I've made a double
>> > implementation based on "#ifdef HAVE_". Is it ok for you ? It's not really
>> > POSIX 2008 but more POSIX 2008 with 2017 compatibility.
>> > For the configure, I didn't find any better way to check each syscall, as
>> > they all depend on different includes. Tell me if you have a better idea.
>>
>> First a general observation: there are two groups of functions you're
>> testing for:
>>
>> * Pure BSD additions, not available in either POSIX.1, ISO C, or glibc:
>>
>>  localeconv_l
>>  mbstowcs_l
>>  strtod_l
>>  strtof_l
>>  strtold_l
>>  wcsftime_l
>>
>> * Part of XPG7:
>>
>>   iswctype_l
>>   strcoll_l
>>   strftime_l
>>   strxfrm_l
>>   towlower_l
>>   towupper_l
>>   wcscoll_l
>>   wcsxfrm_l
>>   wctype_l
>>
>> My suggestion would be not to have configure tests _GLIBCXX_HAVE_<FUNC>
>> for any of the second group at all: this is ieee_1003.1-2008, after all,
>> so if some OS selects that clocale variant, it better implement all of
>> those.  If really need be, one could a configure check for those and
>> error out if any is missing.  This makes the code way more readable than
>> trying to handle some hypothetical partial implementation.
>
> In this case, it would be better to call it ieee_1003.1-2017 but I agree

why?  I've just double-checked the OpenGroup pages: all of the functions
listed as XPG7 above were part of IEEE 1003.1-2008, just some of them
have Technical Corrigenda applied.  IIUC IEEE 1003.1-2017 is just a
revision of the -2008 standard, not a new issue (XPG8 or something).

> it would be better to avoid all these #ifdef.
> Some are still needed as for example only the last version of AIX have
> strftime_l.

Then that version doesn't conform to XPG7 and shouldn't use that clocale
variant.  Until we have a clearer understanding of the variation here,
I'd argue that only P1003.1-2008 conforming OSes should use
ieee_1003.1-2008, rather than creating an impenetrable maze of #ifdefs
for all sorts of partial implementations.

>> As for the BSD group, I suggest to have one representative configure
>>  test (for localeconv_l perhaps) and then use an appropriate name for the
>> group as a whole.  Again, this will most likely be an all-or-nothing
>> thing.
>
> I'm not sure this is really all-or-nothing for these. Maybe strtof_l and cie
> can be grouped by. But the 3 others are really different. Linux have wcsftime_l
> but not the others. AIX avec none. BSD have all.

TBH, I don't care about Linux here: it will continue to use the gnu
variant anyway.  Besides, since the patch will have to work on targets
without wcsftime_l and the other BSD functions, I don't see any harm in
not using one non-standard one of them although it's present.

>> Besides, your configure tests are way too complicated: just use
>> AC_CHECK_FUNCS doing a link test and be done with it.
>
> Sadly, you can't pass includes to AC_CHECK_FUNCS. That's why I had to do
> that. I've made a first version with AC_CHECK_DECLS which allows extra
> headers, but it didn't work too. I might know why though.

Why would you need to?  AC_CHECK_FUNCS just perform a link test to check
if the functions are present in libc; no need to have a declaration
present.

>> In a similar vein, configure.ac already has
>> AC_CHECK_HEADERS([xlocale.h]).  Rather than hardcoding the existance of
>> the header based on the configure triple, just use the existing
>> HAVE_XLOCALE_H.  This ways, things will simply fall into place for
>> e.g. NetBSD, OpenBSD and possibly others.
>
> Right, I'll make the change. Thanks !
>
>> > 4) ctype_configure_char.cc
>> > I've some troubles knowing what is supposed to be implemented on this file.
>> > I don't really understand the part with setlocale which appears in many
>> > os. When I'm adding it, some tests start failing, some start working...
>> > Moreover, on Linux, if I understand correctly, there is some optimizations
>> > based on classic_table(), _M_toupper and _M_tolower. Could you confirm
>> > that it's only useful on Linux ?
>>
>> I don't know myself.  However, when trying the first version of your
>> patch (augmented to compile on Solaris), the corresponding change to the
>> solaris file made no difference in test results.
>
> I might have found the correct code since yesterday's mail. The problem seems
> to come from _M_c_locale_ctype initialization. With locale support, it must be
> _S_clone_c_locale(__cloc), without it, it must be the default locale which
> ends up
> being "C". I might push a newer patch this afternoon, with the correct code.

Nice; I'll certainly give it a whirl!

>> > Feel free to try in on other OS. But I've made modifications only for AIX and
>> > Linux, as I can test the other ones.
>>
>> While reading through the patch, I saw that in two places you still use
>> __DragonFly__ || __FreeBSD__ tests.  For one, it's hard to tell what
>> feature they are really about, besides they will require fiddling with
>> e.g. for other BSDs.  Please use a descriptive macro which says which
>> difference this is about.
>
> Right, because I don't know how to handle them (and I've forgotten to ask
> for it...).
> The first is for typedef __c_locale. It seems to be int* instead of locale_t.
> Could you confirm that this is wanted and mandatory ?
> The second is in about some functions in ctype_members.cc which are
> defined in config/os/../ctype_inlines.h for FreeBSD and Dragonfly. Someone
> has to confirm that it can be merged with the new code, or if this is mandatory.

That someone would most likely be Jonathan ;-)

>> That said, I gave the new patch a try on Solaris 11.4.  To get it to
>> compile, I had to apply two changes that I'd mentioned (without an actual
>> patch) when commenting on the first patch:
>>
>> * The C99 fields of struct lconv need _LCONV_C99 to be visible for
>>   C++11.
>>
>>  * Some ctype macros need __bitmapsize = 15, as the generic clocale
>>   implementation uses.
>
> If I'm not mistaking, POSIX is only defining 11 bit for ctype. If we want
> some optimizations we can have a define of bitmasksize or we can simply
> fill the whole mask by setting bitmasksize=15 as in generic.
> I don't know what's best.

AFAIK the constants used in <ctype.h> (or <iso/ctype_iso.h> on Solaris)
to describe the different character classes are just an implementation
detail of the respective OS; certainly none of them are listed on the
OpenGroup page for XPG7 <ctype.h>.  So OSes are free to implement this
any way they wish, and the generic variant (and Solaris) show that 11
bits are not enough on some.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-22  9:57                                     ` CHIGOT, CLEMENT
  2021-01-22 11:04                                       ` Rainer Orth
@ 2021-01-22 11:12                                       ` Jonathan Wakely
  1 sibling, 0 replies; 43+ messages in thread
From: Jonathan Wakely @ 2021-01-22 11:12 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: Rainer Orth, libstdc++, David Edelsohn via Gcc-patches, David Edelsohn

On 22/01/21 09:57 +0000, CHIGOT, CLEMENT via Libstdc++ wrote:
>Hi Rainer
>
>> > 3) POSIX 2017 and non-POSIX functions
>> > Many of the *_l functions being used in GNU or dragonfly models aren't
>> > POSIX 2008, but mainly POSIX 2017 or like strtof_l not POSIX at all.
>> > However, there are really useful in the code, thus I've made a double
>> > implementation based on "#ifdef HAVE_". Is it ok for you ? It's not really
>> > POSIX 2008 but more POSIX 2008 with 2017 compatibility.
>> > For the configure, I didn't find any better way to check each syscall, as
>> > they all depend on different includes. Tell me if you have a better idea.
>>
>> First a general observation: there are two groups of functions you're
>> testing for:
>>
>> * Pure BSD additions, not available in either POSIX.1, ISO C, or glibc:
>>
>>  localeconv_l
>>  mbstowcs_l
>>  strtod_l
>>  strtof_l
>>  strtold_l
>>  wcsftime_l
>>
>> * Part of XPG7:
>>
>>   iswctype_l
>>   strcoll_l
>>   strftime_l
>>   strxfrm_l
>>   towlower_l
>>   towupper_l
>>   wcscoll_l
>>   wcsxfrm_l
>>   wctype_l
>>
>> My suggestion would be not to have configure tests _GLIBCXX_HAVE_<FUNC>
>> for any of the second group at all: this is ieee_1003.1-2008, after all,
>> so if some OS selects that clocale variant, it better implement all of
>> those.  If really need be, one could a configure check for those and
>> error out if any is missing.  This makes the code way more readable than
>> trying to handle some hypothetical partial implementation.
>
>In this case, it would be better to call it ieee_1003.1-2017 but I agree
>it would be better to avoid all these #ifdef.

Yes, 2017 is the current standard (equivalent to 2008 plus
corrigenda), but we could also use a shorter, easier to remember name,
like posix.1-2017, xpg7, or susv4 (or even accept all four and make
them mean the same thing, though that will probably cause confusion).

>Some are still needed as for example only the last version of AIX have
>strftime_l.
>
>> As for the BSD group, I suggest to have one representative configure
>>  test (for localeconv_l perhaps) and then use an appropriate name for the
>> group as a whole.  Again, this will most likely be an all-or-nothing
>> thing.
>
>I'm not sure this is really all-or-nothing for these. Maybe strtof_l and cie
>can be grouped by. But the 3 others are really different. Linux have wcsftime_l
>but not the others. AIX avec none. BSD have all.

Glibc has strto{f,d,ld,l,ul,ll,ull}_l too:

See https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/stdlib.h;h=6360845d98e6e1c3f42821def14312dc2279d74c;hb=HEAD#l268



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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-22 11:04                                       ` Rainer Orth
@ 2021-01-22 11:29                                         ` Jonathan Wakely
  2021-01-22 11:54                                           ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: Jonathan Wakely @ 2021-01-22 11:29 UTC (permalink / raw)
  To: Rainer Orth
  Cc: CHIGOT, CLEMENT, libstdc++,
	David Edelsohn via Gcc-patches, David Edelsohn

On 22/01/21 12:04 +0100, Rainer Orth wrote:
>why?  I've just double-checked the OpenGroup pages: all of the functions
>listed as XPG7 above were part of IEEE 1003.1-2008, just some of them
>have Technical Corrigenda applied.  IIUC IEEE 1003.1-2017 is just a
>revision of the -2008 standard, not a new issue (XPG8 or something).

Technically, the 2008 standard has been withdrawn and replaced by
2017. Since the content is the same, it seems more correct to refer to
the current standard (even if Solaris only documents support for the
2008 edition, if it also implements the corrigenda then it conforms to
2017 even if it doesn't document that).

But as I said, a shorter, more memorable name like "xpg7" or just
"posix" might be preferable anyway.

>> it would be better to avoid all these #ifdef.
>> Some are still needed as for example only the last version of AIX have
>> strftime_l.
>
>Then that version doesn't conform to XPG7 and shouldn't use that clocale
>variant.  Until we have a clearer understanding of the variation here,
>I'd argue that only P1003.1-2008 conforming OSes should use
>ieee_1003.1-2008, rather than creating an impenetrable maze of #ifdefs
>for all sorts of partial implementations.
>
>>> As for the BSD group, I suggest to have one representative configure
>>>  test (for localeconv_l perhaps) and then use an appropriate name for the
>>> group as a whole.  Again, this will most likely be an all-or-nothing
>>> thing.
>>
>> I'm not sure this is really all-or-nothing for these. Maybe strtof_l and cie
>> can be grouped by. But the 3 others are really different. Linux have wcsftime_l
>> but not the others. AIX avec none. BSD have all.
>
>TBH, I don't care about Linux here: it will continue to use the gnu
>variant anyway.  Besides, since the patch will have to work on targets
>without wcsftime_l and the other BSD functions, I don't see any harm in
>not using one non-standard one of them although it's present.

I agree that GNU/Linux will continue to use the gnu model, but it can
still be usable as a useful extra test of the code's portablility,
since it implements everything in XPG7 (and more). We shouldn't spend
any effort doing linux-specific changes in this new model, since they
won't be used in practice. But if it works "out of the box" with no
tweaks, then that is useful for testing.

>>> Besides, your configure tests are way too complicated: just use
>>> AC_CHECK_FUNCS doing a link test and be done with it.
>>
>> Sadly, you can't pass includes to AC_CHECK_FUNCS. That's why I had to do
>> that. I've made a first version with AC_CHECK_DECLS which allows extra
>> headers, but it didn't work too. I might know why though.
>
>Why would you need to?  AC_CHECK_FUNCS just perform a link test to check
>if the functions are present in libc; no need to have a declaration
>present.

Right, I wondered about this too.

>>> In a similar vein, configure.ac already has
>>> AC_CHECK_HEADERS([xlocale.h]).  Rather than hardcoding the existance of
>>> the header based on the configure triple, just use the existing
>>> HAVE_XLOCALE_H.  This ways, things will simply fall into place for
>>> e.g. NetBSD, OpenBSD and possibly others.
>>
>> Right, I'll make the change. Thanks !
>>
>>> > 4) ctype_configure_char.cc
>>> > I've some troubles knowing what is supposed to be implemented on this file.
>>> > I don't really understand the part with setlocale which appears in many
>>> > os. When I'm adding it, some tests start failing, some start working...
>>> > Moreover, on Linux, if I understand correctly, there is some optimizations
>>> > based on classic_table(), _M_toupper and _M_tolower. Could you confirm
>>> > that it's only useful on Linux ?
>>>
>>> I don't know myself.  However, when trying the first version of your
>>> patch (augmented to compile on Solaris), the corresponding change to the
>>> solaris file made no difference in test results.
>>
>> I might have found the correct code since yesterday's mail. The problem seems
>> to come from _M_c_locale_ctype initialization. With locale support, it must be
>> _S_clone_c_locale(__cloc), without it, it must be the default locale which
>> ends up
>> being "C". I might push a newer patch this afternoon, with the correct code.
>
>Nice; I'll certainly give it a whirl!
>
>>> > Feel free to try in on other OS. But I've made modifications only for AIX and
>>> > Linux, as I can test the other ones.
>>>
>>> While reading through the patch, I saw that in two places you still use
>>> __DragonFly__ || __FreeBSD__ tests.  For one, it's hard to tell what
>>> feature they are really about, besides they will require fiddling with
>>> e.g. for other BSDs.  Please use a descriptive macro which says which
>>> difference this is about.
>>
>> Right, because I don't know how to handle them (and I've forgotten to ask
>> for it...).
>> The first is for typedef __c_locale. It seems to be int* instead of locale_t.
>> Could you confirm that this is wanted and mandatory ?
>> The second is in about some functions in ctype_members.cc which are
>> defined in config/os/../ctype_inlines.h for FreeBSD and Dragonfly. Someone
>> has to confirm that it can be merged with the new code, or if this is mandatory.
>
>That someone would most likely be Jonathan ;-)

I'll have to do some digging and refresh my memory of how all the
different clocale models work, which probably isn't going to happen
until stage 1.



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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-22 11:29                                         ` Jonathan Wakely
@ 2021-01-22 11:54                                           ` Rainer Orth
  2021-01-22 12:23                                             ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-22 11:54 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: CHIGOT, CLEMENT, libstdc++,
	David Edelsohn via Gcc-patches, David Edelsohn

Hi Jonathan,

> On 22/01/21 12:04 +0100, Rainer Orth wrote:
>>why?  I've just double-checked the OpenGroup pages: all of the functions
>>listed as XPG7 above were part of IEEE 1003.1-2008, just some of them
>>have Technical Corrigenda applied.  IIUC IEEE 1003.1-2017 is just a
>>revision of the -2008 standard, not a new issue (XPG8 or something).
>
> Technically, the 2008 standard has been withdrawn and replaced by
> 2017. Since the content is the same, it seems more correct to refer to
> the current standard (even if Solaris only documents support for the
> 2008 edition, if it also implements the corrigenda then it conforms to
> 2017 even if it doesn't document that).

I've found no macro that would distinguish P1003.1-2008 and -2017.  It
seems both are identified by _XOPEN_SOURCE=700 and
_POSIX_C_SOURCE=200809L.

> But as I said, a shorter, more memorable name like "xpg7" or just
> "posix" might be preferable anyway.

I'd strongly prefer xpg7 over posix: after all, xpg6 systems are still
around (Solaris 11.3 being one of them, and I suspect older AIX versions
as well).  It's certainly much less of a mouthful than ieee_1003.1-2008 ;-)

>>>> As for the BSD group, I suggest to have one representative configure
>>>>  test (for localeconv_l perhaps) and then use an appropriate name for the
>>>> group as a whole.  Again, this will most likely be an all-or-nothing
>>>> thing.
>>>
>>> I'm not sure this is really all-or-nothing for these. Maybe strtof_l and cie
>>> can be grouped by. But the 3 others are really different. Linux have
>>> wcsftime_l
>>> but not the others. AIX avec none. BSD have all.
>>
>>TBH, I don't care about Linux here: it will continue to use the gnu
>>variant anyway.  Besides, since the patch will have to work on targets
>>without wcsftime_l and the other BSD functions, I don't see any harm in
>>not using one non-standard one of them although it's present.
>
> I agree that GNU/Linux will continue to use the gnu model, but it can
> still be usable as a useful extra test of the code's portablility,
> since it implements everything in XPG7 (and more). We shouldn't spend
> any effort doing linux-specific changes in this new model, since they
> won't be used in practice. But if it works "out of the box" with no
> tweaks, then that is useful for testing.

Absolutely: the more different implementation we can throw at the code,
the better for portability.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-22 11:54                                           ` Rainer Orth
@ 2021-01-22 12:23                                             ` CHIGOT, CLEMENT
  2021-01-27 12:52                                               ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-22 12:23 UTC (permalink / raw)
  To: Rainer Orth, Jonathan Wakely
  Cc: libstdc++, David Edelsohn via Gcc-patches, David Edelsohn

Hi Rainer, Jonathan

>>>why?  I've just double-checked the OpenGroup pages: all of the functions
>>>listed as XPG7 above were part of IEEE 1003.1-2008, just some of them
>>>have Technical Corrigenda applied.  IIUC IEEE 1003.1-2017 is just a
>>>revision of the -2008 standard, not a new issue (XPG8 or something).
>>
>> Technically, the 2008 standard has been withdrawn and replaced by
>> 2017. Since the content is the same, it seems more correct to refer to
>> the current standard (even if Solaris only documents support for the
>> 2008 edition, if it also implements the corrigenda then it conforms to
>> 2017 even if it doesn't document that).
>
>I've found no macro that would distinguish P1003.1-2008 and -2017.  It
>seems both are identified by _XOPEN_SOURCE=700 and
>_POSIX_C_SOURCE=200809L.
>
>> But as I said, a shorter, more memorable name like "xpg7" or just
>> "posix" might be preferable anyway.
>
> I'd strongly prefer xpg7 over posix: after all, xpg6 systems are still
> around (Solaris 11.3 being one of them, and I suspect older AIX versions
> as well).  It's certainly much less of a mouthful than ieee_1003.1-2008 ;-)

I honestly don't master all these conventions. So I'll follow you on the right
name to give.

>> Some are still needed as for example only the last version of AIX have
>> strftime_l.
>
> Then that version doesn't conform to XPG7 and shouldn't use that clocale
> variant.  Until we have a clearer understanding of the variation here,
> I'd argue that only P1003.1-2008 conforming OSes should use
> ieee_1003.1-2008, rather than creating an impenetrable maze of #ifdefs
> for all sorts of partial implementations.

Yes, AIX before 7.2 TL5 is Unix03 compliant, and after UNIXv7.
However, my aim is to implement locale support for these older versions
too. Thus, maybe I can create a fake strftime_l in config/os/aix. But I want
to use this model for AIX. Otherwise, I'll simply revert to the AIX model
as I've made in the first patch, as it's not possible to use this new
model for my purpose.
I mean no offense, but my aim is to improve AIX. Of course,
I'm glad to help other OS too, but I can't work on it if there is no
impact for AIX at the end.

>>>> Besides, your configure tests are way too complicated: just use
>>>> AC_CHECK_FUNCS doing a link test and be done with it.
>>>
>>> Sadly, you can't pass includes to AC_CHECK_FUNCS. That's why I had to do
>>> that. I've made a first version with AC_CHECK_DECLS which allows extra
>>> headers, but it didn't work too. I might know why though.
>>
>>Why would you need to?  AC_CHECK_FUNCS just perform a link test to check
>>if the functions are present in libc; no need to have a declaration
>>present.
>
>Right, I wondered about this too.

I didn't work when I've tried. Maybe I've missed something. I'll check.

Thanks,
Clément
________________________________
From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Sent: Friday, January 22, 2021 12:54 PM
To: Jonathan Wakely <jwakely@redhat.com>
Cc: CHIGOT, CLEMENT <clement.chigot@atos.net>; libstdc++ <libstdc++@gcc.gnu.org>; David Edelsohn via Gcc-patches <gcc-patches@gcc.gnu.org>; David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] libstdc++: implement locale support for AIX

Caution! External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.

Hi Jonathan,

> On 22/01/21 12:04 +0100, Rainer Orth wrote:
>>why?  I've just double-checked the OpenGroup pages: all of the functions
>>listed as XPG7 above were part of IEEE 1003.1-2008, just some of them
>>have Technical Corrigenda applied.  IIUC IEEE 1003.1-2017 is just a
>>revision of the -2008 standard, not a new issue (XPG8 or something).
>
> Technically, the 2008 standard has been withdrawn and replaced by
> 2017. Since the content is the same, it seems more correct to refer to
> the current standard (even if Solaris only documents support for the
> 2008 edition, if it also implements the corrigenda then it conforms to
> 2017 even if it doesn't document that).

I've found no macro that would distinguish P1003.1-2008 and -2017.  It
seems both are identified by _XOPEN_SOURCE=700 and
_POSIX_C_SOURCE=200809L.

> But as I said, a shorter, more memorable name like "xpg7" or just
> "posix" might be preferable anyway.

I'd strongly prefer xpg7 over posix: after all, xpg6 systems are still
around (Solaris 11.3 being one of them, and I suspect older AIX versions
as well).  It's certainly much less of a mouthful than ieee_1003.1-2008 ;-)

>>>> As for the BSD group, I suggest to have one representative configure
>>>>  test (for localeconv_l perhaps) and then use an appropriate name for the
>>>> group as a whole.  Again, this will most likely be an all-or-nothing
>>>> thing.
>>>
>>> I'm not sure this is really all-or-nothing for these. Maybe strtof_l and cie
>>> can be grouped by. But the 3 others are really different. Linux have
>>> wcsftime_l
>>> but not the others. AIX avec none. BSD have all.
>>
>>TBH, I don't care about Linux here: it will continue to use the gnu
>>variant anyway.  Besides, since the patch will have to work on targets
>>without wcsftime_l and the other BSD functions, I don't see any harm in
>>not using one non-standard one of them although it's present.
>
> I agree that GNU/Linux will continue to use the gnu model, but it can
> still be usable as a useful extra test of the code's portablility,
> since it implements everything in XPG7 (and more). We shouldn't spend
> any effort doing linux-specific changes in this new model, since they
> won't be used in practice. But if it works "out of the box" with no
> tweaks, then that is useful for testing.

Absolutely: the more different implementation we can throw at the code,
the better for portability.

        Rainer

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-22 12:23                                             ` CHIGOT, CLEMENT
@ 2021-01-27 12:52                                               ` CHIGOT, CLEMENT
  2021-01-27 14:26                                                 ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-27 12:52 UTC (permalink / raw)
  To: Rainer Orth, Jonathan Wakely
  Cc: libstdc++, David Edelsohn via Gcc-patches, David Edelsohn

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

Hi everyone, 

Here is a better version of the patch. 
All tests are on Linux are passing. Few have been disabled as 
they are working only with GNU model. 
For AIX, few failures remains. I haven't XFAIL them yet, as I 
want to know if they AIX only or related to the model itself. 

A few part still need to be improved (dg-require-localmodel,
std::locale:global, FreeBSD specific #ifdef). 
But at least it can be tested in most of the platforms as is. 

Note that I'll stop working on it until gcc12. Mostly because gcc
is on freeze but also because I've more urgent stuff to do right now. 
Of course any feedbacks is welcome ! But I might not send a
new patch if it requires too much time (at least not right now). 

Thanks anyway Rainer and Jonathan for your help ! I hope this 
version suits you better !

Clément


[-- Attachment #2: 0001-libstdc-implement-locale-support-for-XPG7.patch --]
[-- Type: application/octet-stream, Size: 52884 bytes --]

From 10f7048f2fb53f818493766cc0a60cf9e7b20635 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Tue, 29 Dec 2020 11:08:33 +0100
Subject: [PATCH] libstdc++: implement locale support for XPG7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Create a new locale model for POSIX operating systems.
The implementation is based on dragonfly one.

There are few known limitations.
std::messages isn't implemented.
Creation std::locale with a string describing each LC_* category
isn't possible (eg std::locale("LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;...")

libstdc++-v3/ChangeLog:
2020-01-25  Clément Chigot  <clement.chigot@atos.net>

	* acinclude.m4: Add XPG7 model.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* config/locale/dragonfly/c_locale.cc: Rename to ...
	* config/locale/xpg7/c_locale.cc: ... here.
	* config/locale/dragonfly/c_locale.h: Rename to ...
	* config/locale/xpg7/c_locale.h: ... here.
	(_GLIBCXX_C_LOCALE_XPG7): New define.
	(strtof_l): New function if not provided by the system.
	(strtod_l): Likewise.
	(strtold_l): Likewise.
	* config/locale/dragonfly/ctype_members.cc: Rename to ...
	* config/locale/xpg7/ctype_members.cc: ... here.
	* config/locale/dragonfly/monetary_members.cc: Rename to ...
	* config/locale/xpg7/monetary_members.cc: ... here.
	* config/locale/dragonfly/numeric_members.cc: Rename to ...
	* config/locale/xpg7/numeric_members.cc: ... here.
	* config/locale/dragonfly/time_members.cc: Rename to ...
	* config/locale/xpg7/time_members.cc: ... here.
	* config/os/aix/ctype_configure_char.cc (ctype<char>::ctype):
	Add support for XPG7 model.
	* config/os/gnu-linux/ctype_configure_char.cc: Likewise.
	* src/c++98/locale_init.cc (locale::global): Call setlocale
	for each category instead of once when not using gnu model.
	* testsuite/22_locale/codecvt/in/wchar_t/2.cc: Add xfail for
	wchar_t on 16bit.
	* testsuite/22_locale/codecvt/in/wchar_t/3.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/7.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/8.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/9.cc: Likewise.
	* testsuite/22_locale/codecvt/length/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/out/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/unshift/wchar_t/4.cc: Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc:
	Likewise.
	* testsuite/22_locale/ctype/is/wchar_t/2.cc: Remove xfail
	with xpg7 model.
	* testsuite/22_locale/locale/cons/29217.cc: Add skip when not
	using gnu model.
	* testsuite/22_locale/locale/cons/38368.cc: Likewise.
	* testsuite/22_locale/locale/cons/40184.cc: Likewise.
	* testsuite/22_locale/locale/cons/5.cc: Likewise.
	* testsuite/22_locale/locale/global_locale_objects/14071.cc:
	Likewise.
	* testsuite/22_locale/messages/13631.cc: Likewise.
	* testsuite/22_locale/messages/members/char/1.cc: Likewise.
	* testsuite/22_locale/messages/members/char/2.cc: Likewise.
	* testsuite/22_locale/messages/members/char/3.cc: Likewise.
	* testsuite/22_locale/messages/members/char/wrapped_env.cc:
	Likewise.
	* testsuite/22_locale/messages/members/char/wrapped_locale.cc:
	Likewise.
	* testsuite/22_locale/messages_byname/named_equivalence.cc:
	Likewise.
	* testsuite/lib/dg-options.exp (dg-require-localemodel): New.
	* testsuite/lib/libstdc++.exp (check_v3_target_namedlocale): Add
	AIX support.
	(check_v3_target_localemodel): New.
	* testsuite/util/testsuite_hooks.h (ISO_8859): Add AIX support.
---
 libstdc++-v3/acinclude.m4                     | 47 ++++++------
 libstdc++-v3/config.h.in                      | 15 ++++
 .../locale/{dragonfly => xpg7}/c_locale.cc    |  8 ++-
 .../locale/{dragonfly => xpg7}/c_locale.h     | 48 ++++++++++++-
 .../{dragonfly => xpg7}/codecvt_members.cc    |  4 +-
 .../{dragonfly => xpg7}/collate_members.cc    |  4 +-
 .../{dragonfly => xpg7}/ctype_members.cc      | 71 +++++++++++++++++--
 .../{dragonfly => xpg7}/monetary_members.cc   | 47 ++++++++++--
 .../{dragonfly => xpg7}/numeric_members.cc    | 30 +++++++-
 .../{dragonfly => xpg7}/time_members.cc       | 36 +++++++++-
 .../locale/{dragonfly => xpg7}/time_members.h |  4 +-
 .../config/os/aix/ctype_configure_char.cc     | 71 ++++++++++++++++---
 .../os/gnu-linux/ctype_configure_char.cc      |  4 +-
 libstdc++-v3/src/c++98/locale_init.cc         | 12 ++++
 .../22_locale/codecvt/in/wchar_t/2.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/3.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/4.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/7.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/8.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/9.cc         |  1 +
 .../22_locale/codecvt/length/wchar_t/4.cc     |  1 +
 .../22_locale/codecvt/out/wchar_t/4.cc        |  1 +
 .../22_locale/codecvt/unshift/wchar_t/4.cc    |  1 +
 .../testsuite/22_locale/ctype/is/wchar_t/2.cc |  2 +-
 .../testsuite/22_locale/locale/cons/29217.cc  |  1 +
 .../testsuite/22_locale/locale/cons/38368.cc  |  1 +
 .../testsuite/22_locale/locale/cons/40184.cc  |  1 +
 .../testsuite/22_locale/locale/cons/5.cc      |  1 +
 .../locale/global_locale_objects/14071.cc     |  1 +
 .../testsuite/22_locale/messages/13631.cc     |  1 +
 .../22_locale/messages/members/char/1.cc      |  1 +
 .../22_locale/messages/members/char/2.cc      |  1 +
 .../22_locale/messages/members/char/3.cc      |  1 +
 .../messages/members/char/wrapped_env.cc      |  1 +
 .../messages/members/char/wrapped_locale.cc   |  1 +
 .../messages_byname/named_equivalence.cc      |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-1.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-2.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-3.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-4.cc |  1 +
 libstdc++-v3/testsuite/lib/dg-options.exp     |  9 +++
 libstdc++-v3/testsuite/lib/libstdc++.exp      | 31 ++++++++
 libstdc++-v3/testsuite/util/testsuite_hooks.h |  3 +
 43 files changed, 414 insertions(+), 57 deletions(-)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/c_locale.cc (96%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/c_locale.h (67%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/codecvt_members.cc (98%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/collate_members.cc (94%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/ctype_members.cc (77%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/monetary_members.cc (95%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/numeric_members.cc (89%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/time_members.cc (92%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/time_members.h (95%)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index e4175ea3e64..e1853e7a947 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2421,7 +2421,7 @@ dnl
 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
     [use MODEL for target locale package],
-    [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
+    [permit generic|gnu|ieee_1003.1-2001|newlib|xpg7|yes|no|auto])
 
   # Deal with gettext issues.  Default to not using it (=no) until we detect
   # support for it later.  Let the user turn it off via --e/d, but let that
@@ -2448,8 +2448,8 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       darwin*)
 	enable_clocale_flag=darwin
 	;;
-      dragonfly* | freebsd*)
-	enable_clocale_flag=dragonfly
+      aix* | dragonfly* | freebsd*)
+	enable_clocale_flag=xpg7
 	;;
       openbsd*)
 	enable_clocale_flag=newlib
@@ -2543,23 +2543,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
 
-    dragonfly)
-      AC_MSG_RESULT(dragonfly or freebsd)
-
-      CLOCALE_H=config/locale/dragonfly/c_locale.h
-      CLOCALE_CC=config/locale/dragonfly/c_locale.cc
-      CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
-      CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
-      CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
-      CMESSAGES_H=config/locale/generic/messages_members.h
-      CMESSAGES_CC=config/locale/generic/messages_members.cc
-      CMONEY_CC=config/locale/dragonfly/monetary_members.cc
-      CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
-      CTIME_H=config/locale/dragonfly/time_members.h
-      CTIME_CC=config/locale/dragonfly/time_members.cc
-      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
-      ;;
-
     gnu)
       AC_MSG_RESULT(gnu)
 
@@ -2610,6 +2593,24 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
+
+    xpg7)
+      AC_MSG_RESULT(xpg7)
+
+      CLOCALE_H=config/locale/xpg7/c_locale.h
+      CLOCALE_CC=config/locale/xpg7/c_locale.cc
+      CCODECVT_CC=config/locale/xpg7/codecvt_members.cc
+      CCOLLATE_CC=config/locale/xpg7/collate_members.cc
+      CCTYPE_CC=config/locale/xpg7/ctype_members.cc
+      CMESSAGES_H=config/locale/generic/messages_members.h
+      CMESSAGES_CC=config/locale/generic/messages_members.cc
+      CMONEY_CC=config/locale/xpg7/monetary_members.cc
+      CNUMERIC_CC=config/locale/xpg7/numeric_members.cc
+      CTIME_H=config/locale/xpg7/time_members.h
+      CTIME_CC=config/locale/xpg7/time_members.cc
+      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+      ;;
+
     newlib)
       AC_MSG_RESULT(newlib)
 
@@ -2656,6 +2657,12 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   AC_SUBST(CTIME_CC)
   AC_SUBST(CLOCALE_CC)
   AC_SUBST(CLOCALE_INTERNAL_H)
+
+  if test $enable_clocale_flag = xpg7; then
+     AC_CHECK_HEADERS(xlocale.h)
+
+     AC_CHECK_FUNCS([strtof_l localeconv_l mbstowcs_l wcsftime_l strftime_l])
+  fi
 ])
 
 
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index d36ca2620b4..0b726524cc5 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -225,6 +225,9 @@
 /* Define to 1 if you have the <linux/types.h> header file. */
 #undef HAVE_LINUX_TYPES_H
 
+/* Define to 1 if you have the `localeconv_l' function. */
+#undef HAVE_LOCALECONV_L
+
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
@@ -249,6 +252,9 @@
 /* Define if mbstate_t exists in wchar.h. */
 #undef HAVE_MBSTATE_T
 
+/* Define to 1 if you have the `mbstowcs_l' function. */
+#undef HAVE_MBSTOWCS_L
+
 /* Define to 1 if you have the `memalign' function. */
 #undef HAVE_MEMALIGN
 
@@ -360,6 +366,9 @@
 /* Define if strerror_r is available in <string.h>. */
 #undef HAVE_STRERROR_R
 
+/* Define to 1 if you have the `strftime_l' function. */
+#undef HAVE_STRFTIME_L
+
 /* Define to 1 if you have the <strings.h> header file. */
 #undef HAVE_STRINGS_H
 
@@ -369,6 +378,9 @@
 /* Define to 1 if you have the `strtof' function. */
 #undef HAVE_STRTOF
 
+/* Define to 1 if you have the `strtof_l' function. */
+#undef HAVE_STRTOF_L
+
 /* Define to 1 if you have the `strtold' function. */
 #undef HAVE_STRTOLD
 
@@ -490,6 +502,9 @@
 /* Define to 1 if you have the <wchar.h> header file. */
 #undef HAVE_WCHAR_H
 
+/* Define to 1 if you have the `wcsftime_l' function. */
+#undef HAVE_WCSFTIME_L
+
 /* Defined if wcstof exists. */
 #undef HAVE_WCSTOF
 
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/xpg7/c_locale.cc
similarity index 96%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.cc
rename to libstdc++-v3/config/locale/xpg7/c_locale.cc
index 02df4605bb5..fcd50ac4aec 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc
+++ b/libstdc++-v3/config/locale/xpg7/c_locale.cc
@@ -1,6 +1,6 @@
-// localization implementation details, DragonFly version -*- C++ -*-
+// localization implementation details, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2014-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -28,13 +28,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <cstdlib>
 #include <locale>
 #include <stdexcept>
 #include <limits>
+
 #include <langinfo.h>
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/xpg7/c_locale.h
similarity index 67%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.h
rename to libstdc++-v3/config/locale/xpg7/c_locale.h
index cf4281cebbf..5b5c7ba451d 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.h
+++ b/libstdc++-v3/config/locale/xpg7/c_locale.h
@@ -1,6 +1,6 @@
-// localization implementation details, DragonFly version -*- C++ -*-
+// localization implementation details, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2001-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -33,6 +33,7 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #ifndef _GLIBCXX_CXX_LOCALE_H
 #define _GLIBCXX_CXX_LOCALE_H 1
@@ -40,7 +41,46 @@
 #pragma GCC system_header
 
 #include <clocale>
+#include <cstdlib>
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
+
+#define _GLIBCXX_C_LOCALE_XPG7 1
+
+// Assume that if strtof_l is missing then strtod_l and strold_l
+// are missing too.
+#ifndef _GLIBCXX_HAVE_STRTOF_L
+extern "C" inline
+float strtof_l (const char *__nptr, char **__endptr,
+		locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  float __res = strtof(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+
+extern "C" inline
+double strtod_l (const char *__nptr, char **__endptr,
+		 locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  double __res = strtod(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+
+extern "C" inline
+long double strtold_l (const char *__nptr, char **__endptr,
+		       locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  long double __res = strtold(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+#endif
 
 #define _GLIBCXX_NUM_CATEGORIES 0
 
@@ -48,7 +88,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if defined(__DragonFly__) || defined(__FreeBSD__)
   typedef int*			__c_locale;
+#else
+  typedef locale_t			__c_locale;
+#endif
 
   // Convert numeric value of type double and long double to string and
   // return length of string.  If vsnprintf is available use it, otherwise
diff --git a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc b/libstdc++-v3/config/locale/xpg7/codecvt_members.cc
similarity index 98%
rename from libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
rename to libstdc++-v3/config/locale/xpg7/codecvt_members.cc
index 11cbcdae59f..178966f0fdb 100644
--- a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/codecvt_members.cc
@@ -1,6 +1,6 @@
-// std::codecvt implementation details, DragonFly version -*- C++ -*-
+// std::codecvt implementation details, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2015-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
diff --git a/libstdc++-v3/config/locale/dragonfly/collate_members.cc b/libstdc++-v3/config/locale/xpg7/collate_members.cc
similarity index 94%
rename from libstdc++-v3/config/locale/dragonfly/collate_members.cc
rename to libstdc++-v3/config/locale/xpg7/collate_members.cc
index 64c7d864a61..605b8a42c08 100644
--- a/libstdc++-v3/config/locale/dragonfly/collate_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/collate_members.cc
@@ -1,6 +1,6 @@
-// std::collate implementation details, DragonFly version -*- C++ -*-
+// std::collate implementation details, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2015-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/xpg7/ctype_members.cc
similarity index 77%
rename from libstdc++-v3/config/locale/dragonfly/ctype_members.cc
rename to libstdc++-v3/config/locale/xpg7/ctype_members.cc
index 420cb51e07a..d9c1e0f8681 100644
--- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/ctype_members.cc
@@ -1,6 +1,6 @@
-// std::ctype implementation details, DragonFly version -*- C++ -*-
+// std::ctype implementation details, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2014-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -28,13 +28,18 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <cstring>
 #include <cstdio>
 
 #ifndef _ISbit
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
+#else
+#define _ISbit(bit) (1 << bit)
+#endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -114,8 +119,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
     while (__lo < __hi)
       {
-        *__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype);
-        ++__lo;
+	*__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype);
+	++__lo;
       }
     return __hi;
   }
@@ -129,12 +134,64 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
     while (__lo < __hi)
       {
-        *__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype);
-        ++__lo;
+	*__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype);
+	++__lo;
+      }
+    return __hi;
+  }
+
+#if !defined(__DragonFly__) && !defined(__FreeBSD__)
+  bool
+  ctype<wchar_t>::
+  do_is(mask __m, char_type __c) const
+  {
+    bool __ret = false;
+    const size_t __bitmasksize = 15;
+    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+      if (__m & _M_bit[__bitcur]
+	  && iswctype_l(__c, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype))
+	{
+	  __ret = true;
+	  break;
+	}
+    return __ret;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+  {
+    for (;__lo < __hi; ++__vec, ++__lo)
+      {
+	const size_t __bitmasksize = 15;
+	mask __m = 0;
+	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+	  if (iswctype_l(*__lo, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype))
+	    __m |= _M_bit[__bitcur];
+	*__vec = __m;
       }
     return __hi;
   }
 
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
+  {
+    while (__lo < __hi && !this->do_is(__m, *__lo))
+      ++__lo;
+    return __lo;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
+  {
+    while (__lo < __hi && this->do_is(__m, *__lo) != 0)
+      ++__lo;
+    return __lo;
+  }
+#endif
+
   wchar_t
   ctype<wchar_t>::
   do_widen(char __c) const
@@ -217,7 +274,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	 __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
       _M_widen[__j] = btowc(__j);
 
-    for (size_t __k = 0; __k <= 11; ++__k)
+    for (size_t __k = 0; __k <= 15; ++__k)
       {
 	_M_bit[__k] = static_cast<mask>(_ISbit(__k));
 	_M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/xpg7/monetary_members.cc
similarity index 95%
rename from libstdc++-v3/config/locale/dragonfly/monetary_members.cc
rename to libstdc++-v3/config/locale/xpg7/monetary_members.cc
index e1decc61cbf..0ef52de0990 100644
--- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/monetary_members.cc
@@ -1,6 +1,6 @@
-// std::moneypunct implementation details, DragonFly version -*- C++ -*-
+// std::moneypunct implementation details, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2015-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -28,10 +28,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
+// Solaris 11.4 doesn't make C99 members of struct lconv visible for C++11
+// without this.
+#define _LCONV_C99
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -241,7 +248,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -348,6 +360,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -360,6 +375,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->int_n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -395,7 +413,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -502,6 +525,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -514,6 +540,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -581,9 +610,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -741,9 +775,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/xpg7/numeric_members.cc
similarity index 89%
rename from libstdc++-v3/config/locale/dragonfly/numeric_members.cc
rename to libstdc++-v3/config/locale/xpg7/numeric_members.cc
index cac6fe8c710..26432c13c1b 100644
--- a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/numeric_members.cc
@@ -1,6 +1,6 @@
-// std::numpunct implementation details, DragonFly version -*- C++ -*-
+// std::numpunct implementation details, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2015-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -28,10 +28,14 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -63,7 +67,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -103,6 +112,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -113,6 +125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
@@ -162,7 +177,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -201,6 +221,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -211,6 +234,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc b/libstdc++-v3/config/locale/xpg7/time_members.cc
similarity index 92%
rename from libstdc++-v3/config/locale/dragonfly/time_members.cc
rename to libstdc++-v3/config/locale/xpg7/time_members.cc
index c8b621a323f..17bdb3808d9 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/time_members.cc
@@ -1,6 +1,6 @@
-// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
+// std::time_get, std::time_put implementation, AIX version -*- C++ -*-
 
-// Copyright (C) 2001-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -29,13 +29,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <ctime>
 #include <cwchar>
 #include <stdlib.h>
 #include <langinfo.h>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -47,8 +51,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(char* __s, size_t __maxlen, const char* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_STRFTIME_L
       const size_t __len = strftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = strftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = '\0';
@@ -196,15 +206,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_WCSFTIME_L
       const size_t __len = wcsftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = L'\0';
     }
 
+#ifdef _GLIBCXX_HAVE_MBSTOWCS_L
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs_l (WCSTRING, STRING, NUMBER, LOCALE);
+#else
+  // "uselocale" must be called before using this macro.
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs (WCSTRING, STRING, NUMBER);
+#endif
 #define WIDE_LANGINFO(M,FMT) \
-	fmtlen = mbstowcs_l (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
+	fmtlen = MBSTOWCS_L (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
 		128, (locale_t)__cloc); \
 	langstring = new wchar_t[fmtlen + 1]; \
 	wcsncpy (langstring, holder, fmtlen); \
@@ -281,6 +305,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  __c_locale __old = uselocale(__cloc);
+#endif
 	  wchar_t *langstring = 0;
 	  wchar_t holder[128];
 	  size_t fmtlen;
@@ -342,6 +369,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  WIDE_LANGINFO(_M_amonth10, ABMON_10)
 	  WIDE_LANGINFO(_M_amonth11, ABMON_11)
 	  WIDE_LANGINFO(_M_amonth12, ABMON_12)
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  uselocale(__old);
+#endif
 	}
     }
 
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.h b/libstdc++-v3/config/locale/xpg7/time_members.h
similarity index 95%
rename from libstdc++-v3/config/locale/dragonfly/time_members.h
rename to libstdc++-v3/config/locale/xpg7/time_members.h
index 04b7e995d6f..74763df0c40 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.h
+++ b/libstdc++-v3/config/locale/xpg7/time_members.h
@@ -1,6 +1,6 @@
-// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
+// std::time_get, std::time_put implementation, XPG7 version -*- C++ -*-
 
-// Copyright (C) 2015-2021 Free Software Foundation, Inc.
+// Copyright (C) 2021-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
diff --git a/libstdc++-v3/config/os/aix/ctype_configure_char.cc b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
index b12c0bd435c..870417cd778 100644
--- a/libstdc++-v3/config/os/aix/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
@@ -42,28 +42,83 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   ctype<char>::classic_table() throw()
   { return 0; }
 
+#if _GLIBCXX_C_LOCALE_IEEE_2008
+  ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
+		     size_t __refs)
+    : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
+    _M_del(__table != 0 && __del),
+    _M_toupper(NULL), _M_tolower(NULL),
+    _M_table(__table ? __table : classic_table()),
+    _M_widen_ok(0), _M_narrow_ok(0)
+    {
+      memset(_M_widen, 0, sizeof(_M_widen));
+      memset(_M_narrow, 0, sizeof(_M_narrow));
+    }
+#else
   ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
 		     size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+  _M_del(__table != 0 && __del),
   _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
+    char* __old = setlocale(LC_CTYPE, NULL);
+    char* __sav = NULL;
+    if (strcmp(__old, "C"))
+      {
+	const size_t __len = strlen(__old) + 1;
+	__sav = new char[__len];
+	memcpy(__sav, __old, __len);
+	setlocale(LC_CTYPE, "C");
+      }
+    if (__sav)
+      {
+	setlocale(LC_CTYPE, __sav);
+	delete [] __sav;
+      }
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
+#endif
 
+#if _GLIBCXX_C_LOCALE_IEEE_2008
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+    : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+    _M_del(__table != 0 && __del),
+    _M_toupper(NULL), _M_tolower(NULL),
+    _M_table(__table ? __table : classic_table()),
+    _M_widen_ok(0), _M_narrow_ok(0)
+    {
+      memset(_M_widen, 0, sizeof(_M_widen));
+      memset(_M_narrow, 0, sizeof(_M_narrow));
+    }
+#else
+  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+  _M_del(__table != 0 && __del),
   _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
+    char* __old = setlocale(LC_CTYPE, NULL);
+    char* __sav = NULL;
+    if (strcmp(__old, "C"))
+      {
+	const size_t __len = strlen(__old) + 1;
+	__sav = new char[__len];
+	memcpy(__sav, __old, __len);
+	setlocale(LC_CTYPE, "C");
+      }
+    if (__sav)
+      {
+	setlocale(LC_CTYPE, __sav);
+	delete [] __sav;
+      }
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
+#endif
 
   char
   ctype<char>::do_toupper(char __c) const
diff --git a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
index d6ab73175b8..991ca32d9d5 100644
--- a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
@@ -38,7 +38,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // Information as gleaned from /usr/include/ctype.h
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   const ctype_base::mask*
   ctype<char>::classic_table() throw()
   { return _S_get_c_locale()->__ctype_b; }
@@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
   : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc
index 4bec50bf595..dcea799aeaf 100644
--- a/libstdc++-v3/src/c++98/locale_init.cc
+++ b/libstdc++-v3/src/c++98/locale_init.cc
@@ -296,7 +296,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _S_global = __other._M_impl;
       const string __other_name = __other.name();
       if (__other_name != "*")
+#ifdef _GLIBCXX_C_LOCALE_GNU
 	setlocale(LC_ALL, __other_name.c_str());
+#else
+        {
+	  // In general, passing "LC_CTYPE=C;LC_NUMERIQUE=C;..." as
+	  // argument to setlocale isn't allowed.
+	  if (__other._M_impl->_M_check_same_name())
+	    setlocale(LC_ALL, __other_name.c_str());
+	  else
+	    for (size_t __i = 0; __i < __other._S_categories_size; ++__i)
+	      setlocale(__i, __other._M_impl->_M_names[__i]);
+	}
+#endif
     }
 
     // Reference count sanity check: one reference removed for the
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
index ea0c43a20fc..71e198843d2 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
index 54206f8000a..ffde94108a1 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO-8859-15" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
index f27d667daf5..9193b598162 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
index b5383af657c..e4b428c9fc6 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
index 1d40a1723a4..ffbd856640b 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
index 9801e085683..5e42a373547 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
index f70d0fc6c58..01bf1a57917 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
index 5cde0b66331..25dfa02b99d 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
index 1e4ce5a8e3e..5d00a62c9a9 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
index 5254c967018..1f2869e43f6 100644
--- a/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
@@ -1,5 +1,5 @@
-// { dg-do run { xfail { ! { *-*-linux* *-*-gnu* } } } }
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu xpg7" }
 
 // Copyright (C) 2000-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
index a60e98eee76..0cfcc042b1c 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2006-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
index 8d8f07f01cc..94fcfe3ac8b 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2008-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
index 6a8eff8737b..d41ee12603b 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "ja_JP.eucJP" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2009-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
index 66b939e2228..99abf566b81 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
@@ -3,6 +3,7 @@
 // { dg-require-namedlocale "es_MX" }
 // { dg-require-namedlocale "fr_FR" }
 // { dg-require-namedlocale "it_IT" }
+// { dg-require-localemodel "gnu" }
 
 // 2000-09-13 Benjamin Kosnik <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
index ea3992b03f6..30d4a31a64c 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
@@ -1,5 +1,6 @@
 // { dg-require-namedlocale "is_IS.ISO8859-1" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2004-02-09  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/13631.cc b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
index b8ae3d4f140..2509bba0845 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/13631.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
index c4d972124f0..fdf4a0af018 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
index 81d914f5c37..3345f43b342 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
index 5a503ef2c49..1d2f7ad3162 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
@@ -1,5 +1,6 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
index 35e7f6c740c..976b4d9fbf6 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
@@ -1,6 +1,7 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
index a44bf1476b2..b143d33a4cc 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
@@ -2,6 +2,7 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
index 1006f20c996..fabf281d3e6 100644
--- a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
index c747f7bfb02..46713cca118 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
index 76a387768fe..a3a4bbf5833 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
index 24d192921cb..2a314589714 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
index 2c0a2ab61db..71393bbd255 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 5160e4a72d1..c52663d30af 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -88,6 +88,15 @@ proc dg-require-namedlocale { args } {
     return
 }
 
+proc dg-require-localemodel { args } {
+    if { ![ check_v3_target_localemodel [lindex $args 1] ] } {
+	upvar dg-do-what dg-do-what
+	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+	return
+    }
+    return
+}
+
 proc dg-require-sharedlib { args } {
     if { ![ check_v3_target_sharedlib ] } {
 	upvar dg-do-what dg-do-what
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 30a4345b14f..81ae8b091bb 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -904,6 +904,11 @@ proc check_v3_target_namedlocale { args } {
 	puts $f "    strcpy(result, name);"
 	puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
 	puts $f "    /* fall-through */"
+	puts $f "#elif defined _AIX"
+	puts $f "    char *p = strstr(result, \"ISO8859-15\");"
+	puts $f "    if (p) {"
+	puts $f "       strcpy(p, \"8859-15\");"
+	puts $f "    }"
 	puts $f "#else"
 	puts $f "    if (strstr(result, \"ISO8859-15\")) {"
 	puts $f "        strcat(result, \"@euro\");"
@@ -954,6 +959,32 @@ proc check_v3_target_namedlocale { args } {
     }]
 }
 
+# Return 1 if the locale model is implemented.
+proc check_v3_target_localemodel { args } {
+    set key "et_locale $args"
+    return [check_v3_target_prop_cached $key {
+	global cxxflags
+	global DEFAULT_CXXFLAGS
+
+	set cond "0"
+	if [string match "*gnu*" $args] {
+	    set cond " $cond || defined _GLIBCXX_C_LOCALE_GNU"
+	}
+	if [string match "*xpg7*" $args] {
+	    set cond " $cond || defined _GLIBCXX_C_LOCALE_XPG7"
+	}
+	
+	set code "
+	#include <bits/c++locale.h>
+	#if ! ($cond)
+	#error '$cond' is false
+	#endif
+	"
+	set flags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+	return [v3_try_preprocess name $code $flags]
+    }]
+}
+
 # Returns 1 if the tokens in CODE can be preprocessed successfully using FLAGS,
 # returns 0 otherwise.
 proc v3_try_preprocess { name code flags } {
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index b5e0767211a..a632f5f31f8 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -77,6 +77,9 @@
 
 #if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__
 # define ISO_8859(part,langTERR) #langTERR ".ISO8859-" #part
+#elif defined _AIX
+# define ISO_8859(part,langTERR) ((part) == 15 ?\
+         #langTERR ".8859-" #part : #langTERR ".ISO8859-" #part)
 #else
 # define ISO_8859(part,langTERR) ((part) == 15 ?\
          #langTERR ".ISO8859-" #part "@euro" : #langTERR ".ISO8859-" #part)
-- 
2.25.0


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-27 12:52                                               ` CHIGOT, CLEMENT
@ 2021-01-27 14:26                                                 ` Rainer Orth
  2021-01-27 14:44                                                   ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-01-27 14:26 UTC (permalink / raw)
  To: CHIGOT, CLEMENT
  Cc: Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches, David Edelsohn

Hi Clement,

> Here is a better version of the patch. 
> All tests are on Linux are passing. Few have been disabled as 
> they are working only with GNU model. 
> For AIX, few failures remains. I haven't XFAIL them yet, as I 
> want to know if they AIX only or related to the model itself. 
>
> A few part still need to be improved (dg-require-localmodel,
> std::locale:global, FreeBSD specific #ifdef). 
> But at least it can be tested in most of the platforms as is. 
>
> Note that I'll stop working on it until gcc12. Mostly because gcc
> is on freeze but also because I've more urgent stuff to do right now. 
> Of course any feedbacks is welcome ! But I might not send a
> new patch if it requires too much time (at least not right now). 
>
> Thanks anyway Rainer and Jonathan for your help ! I hope this 
> version suits you better !

very much so, thanks a lot for your work!  I've just looked over it to
determine what changes to config/os/solaris are necessary and found a
few nits:

* There are minor formatting issues:

  Should the linebreak in the extern inline definitions of strtof_l be
  after the return type, not before, matching GNU coding standards?  It
  may well be that the C++ style is different, though.

  Unrelated whitespace changes in xpg7/ctype_members.cc

* The changes in the copyright ranges need to be undone, given that this
  is just a renamed/augmented version of the previous dragonfly code.

* Seeing the __DragonFly__ || __FreeBSD__ again, I had a quick look at
  the FreeBSD 12.2 headers and found that localeconv_l does take a
  locale_t arg, just like uselocale.  DragonFlyBSD seems to be the same
  according to their online manuals.  I expect to give the code a try in
  a FreeBSD 12.2 VM at some point to check.

* While you now define _GLIBCXX_C_LOCALE_XPG7 in
  config/locale/xpg7/c_locale.h, config/os/aix/ctype_configure_char.cc
  still tests the previous _GLIBCXX_C_LOCALE_IEEE_2008.

Nothing tested yet, just wanted to point those out ASAP.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-27 14:26                                                 ` Rainer Orth
@ 2021-01-27 14:44                                                   ` CHIGOT, CLEMENT
  2021-01-28 10:09                                                     ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-27 14:44 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches, David Edelsohn

> * There are minor formatting issues:
> 
>   Should the linebreak in the extern inline definitions of strtof_l be
>   after the return type, not before, matching GNU coding standards?  It
>   may well be that the C++ style is different, though.
> 
>  Unrelated whitespace changes in xpg7/ctype_members.cc

I haven't yet check all the format issues. Especially, because the previous
code was already wrongly formatted at some point. I'll do that when 
releasing a "final" version of the patch.

> * The changes in the copyright ranges need to be undone, given that this
>  is just a renamed/augmented version of the previous dragonfly code.

Ok, I wasn't sure about that. I'll revert. 

> * Seeing the __DragonFly__ || __FreeBSD__ again, I had a quick look at
>   the FreeBSD 12.2 headers and found that localeconv_l does take a
>   locale_t arg, just like uselocale.  DragonFlyBSD seems to be the same
>   according to their online manuals.  I expect to give the code a try in
>   a FreeBSD 12.2 VM at some point to check.

Actually, it seems that the problem isn't about input argument, but 
the output which should "int*".

> * While you now define _GLIBCXX_C_LOCALE_XPG7 in
>  config/locale/xpg7/c_locale.h, config/os/aix/ctype_configure_char.cc
>   still tests the previous _GLIBCXX_C_LOCALE_IEEE_2008.

Arf, I've missed that. it might not be the last patch then. 
(I've made so much versions of it as I've tried to backport it to our 
old versions. It seems that I've mixed up things...) 

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-27 14:44                                                   ` CHIGOT, CLEMENT
@ 2021-01-28 10:09                                                     ` CHIGOT, CLEMENT
  2021-05-17  9:17                                                       ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-01-28 10:09 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Jonathan Wakely, libstdc++,
	David Edelsohn via Gcc-patches, David Edelsohn

>> * While you now define _GLIBCXX_C_LOCALE_XPG7 in
>>  config/locale/xpg7/c_locale.h, config/os/aix/ctype_configure_char.cc
>>   still tests the previous _GLIBCXX_C_LOCALE_IEEE_2008.
>
> Arf, I've missed that. it might not be the last patch then. 
> (I've made so much versions of it as I've tried to backport it to our 
> old versions. It seems that I've mixed up things...) 

Well, after several tries this morning, I can tell that I still don't 
understand at all how to setup this ctype for char... 
I'm sure it have improved things at a moment. But now, whether 
I'm removing or adding it, nothing changes.. 
Anyway, _GLIBCXX_C_LOCALE_XPG7 is needed for gnu or for the new 
testsuite check. So I'm just going to update aix/ctype_configure_char.c 
locally. I'll see later if I can figure what's wrong. 

Clément
going to update it locally. 

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-01-28 10:09                                                     ` CHIGOT, CLEMENT
@ 2021-05-17  9:17                                                       ` CHIGOT, CLEMENT
  2021-06-08  6:59                                                         ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-05-17  9:17 UTC (permalink / raw)
  To: libstdc++; +Cc: Jonathan Wakely, David Edelsohn, Rainer Orth

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

Hi everyone, 

Now that GCC11 is out, I've rebased my patch and improve a bit 
the ctype_configure_char.cc for AIX.  
If some people can take a look other OSes especially BSD-like one, 
it would help me to know if everything is good. 

Thanks, 
Clément

[-- Attachment #2: 0001-libstdc-implement-locale-support-for-XPG7.patch --]
[-- Type: application/octet-stream, Size: 50220 bytes --]

From f7911962effa7ecd09ccb8fd1a46d97e27336093 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Tue, 29 Dec 2020 11:08:33 +0100
Subject: [PATCH] libstdc++: implement locale support for XPG7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Create a new locale model for POSIX operating systems.
The implementation is based on dragonfly one.

There are few known limitations.
std::messages isn't implemented.
Creation std::locale with a string describing each LC_* category
isn't possible (eg std::locale("LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;...")

libstdc++-v3/ChangeLog:
2020-01-25  Clément Chigot  <clement.chigot@atos.net>

	* acinclude.m4: Add XPG7 model.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* config/locale/dragonfly/c_locale.cc: Rename to ...
	* config/locale/xpg7/c_locale.cc: ... here.
	* config/locale/dragonfly/c_locale.h: Rename to ...
	* config/locale/xpg7/c_locale.h: ... here.
	(_GLIBCXX_C_LOCALE_XPG7): New define.
	(strtof_l): New function if not provided by the system.
	(strtod_l): Likewise.
	(strtold_l): Likewise.
	* config/locale/dragonfly/ctype_members.cc: Rename to ...
	* config/locale/xpg7/ctype_members.cc: ... here.
	* config/locale/dragonfly/monetary_members.cc: Rename to ...
	* config/locale/xpg7/monetary_members.cc: ... here.
	* config/locale/dragonfly/numeric_members.cc: Rename to ...
	* config/locale/xpg7/numeric_members.cc: ... here.
	* config/locale/dragonfly/time_members.cc: Rename to ...
	* config/locale/xpg7/time_members.cc: ... here.
	* config/os/aix/ctype_configure_char.cc (ctype<char>::ctype):
	Add support for XPG7 model.
	* config/os/gnu-linux/ctype_configure_char.cc: Likewise.
	* src/c++98/locale_init.cc (locale::global): Call setlocale
	for each category instead of once when not using gnu model.
	* testsuite/22_locale/codecvt/in/wchar_t/2.cc: Add xfail for
	wchar_t on 16bit.
	* testsuite/22_locale/codecvt/in/wchar_t/3.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/7.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/8.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/9.cc: Likewise.
	* testsuite/22_locale/codecvt/length/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/out/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/unshift/wchar_t/4.cc: Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc:
	Likewise.
	* testsuite/22_locale/ctype/is/wchar_t/2.cc: Remove xfail
	with xpg7 model.
	* testsuite/22_locale/locale/cons/29217.cc: Add skip when not
	using gnu model.
	* testsuite/22_locale/locale/cons/38368.cc: Likewise.
	* testsuite/22_locale/locale/cons/40184.cc: Likewise.
	* testsuite/22_locale/locale/cons/5.cc: Likewise.
	* testsuite/22_locale/locale/global_locale_objects/14071.cc:
	Likewise.
	* testsuite/22_locale/messages/13631.cc: Likewise.
	* testsuite/22_locale/messages/members/char/1.cc: Likewise.
	* testsuite/22_locale/messages/members/char/2.cc: Likewise.
	* testsuite/22_locale/messages/members/char/3.cc: Likewise.
	* testsuite/22_locale/messages/members/char/wrapped_env.cc:
	Likewise.
	* testsuite/22_locale/messages/members/char/wrapped_locale.cc:
	Likewise.
	* testsuite/22_locale/messages_byname/named_equivalence.cc:
	Likewise.
	* testsuite/lib/dg-options.exp (dg-require-localemodel): New.
	* testsuite/lib/libstdc++.exp (check_v3_target_namedlocale): Add
	AIX support.
	(check_v3_target_localemodel): New.
	* testsuite/util/testsuite_hooks.h (ISO_8859): Add AIX support.
---
 libstdc++-v3/acinclude.m4                     | 47 +++++++------
 libstdc++-v3/config.h.in                      | 15 ++++
 .../locale/{dragonfly => xpg7}/c_locale.cc    |  6 +-
 .../locale/{dragonfly => xpg7}/c_locale.h     | 46 ++++++++++++-
 .../{dragonfly => xpg7}/codecvt_members.cc    |  2 +-
 .../{dragonfly => xpg7}/collate_members.cc    |  2 +-
 .../{dragonfly => xpg7}/ctype_members.cc      | 69 +++++++++++++++++--
 .../{dragonfly => xpg7}/monetary_members.cc   | 45 +++++++++++-
 .../{dragonfly => xpg7}/numeric_members.cc    | 28 +++++++-
 .../{dragonfly => xpg7}/time_members.cc       | 34 ++++++++-
 .../locale/{dragonfly => xpg7}/time_members.h |  2 +-
 .../config/os/aix/ctype_configure_char.cc     | 38 +++++-----
 .../os/gnu-linux/ctype_configure_char.cc      |  6 +-
 libstdc++-v3/src/c++98/locale_init.cc         | 12 ++++
 .../22_locale/codecvt/in/wchar_t/2.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/3.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/4.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/7.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/8.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/9.cc         |  1 +
 .../22_locale/codecvt/length/wchar_t/4.cc     |  1 +
 .../22_locale/codecvt/out/wchar_t/4.cc        |  1 +
 .../22_locale/codecvt/unshift/wchar_t/4.cc    |  1 +
 .../testsuite/22_locale/ctype/is/wchar_t/2.cc |  2 +-
 .../testsuite/22_locale/locale/cons/29217.cc  |  1 +
 .../testsuite/22_locale/locale/cons/38368.cc  |  1 +
 .../testsuite/22_locale/locale/cons/40184.cc  |  1 +
 .../testsuite/22_locale/locale/cons/5.cc      |  1 +
 .../locale/global_locale_objects/14071.cc     |  1 +
 .../testsuite/22_locale/messages/13631.cc     |  1 +
 .../22_locale/messages/members/char/1.cc      |  1 +
 .../22_locale/messages/members/char/2.cc      |  1 +
 .../22_locale/messages/members/char/3.cc      |  1 +
 .../messages/members/char/wrapped_env.cc      |  1 +
 .../messages/members/char/wrapped_locale.cc   |  1 +
 .../messages_byname/named_equivalence.cc      |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-1.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-2.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-3.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-4.cc |  1 +
 libstdc++-v3/testsuite/lib/dg-options.exp     |  9 +++
 libstdc++-v3/testsuite/lib/libstdc++.exp      | 31 +++++++++
 libstdc++-v3/testsuite/util/testsuite_hooks.h |  3 +
 43 files changed, 362 insertions(+), 60 deletions(-)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/c_locale.cc (97%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/c_locale.h (69%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/codecvt_members.cc (99%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/collate_members.cc (97%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/ctype_members.cc (78%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/monetary_members.cc (95%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/numeric_members.cc (90%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/time_members.cc (92%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/time_members.h (97%)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 1c0a4c13052..bb165d18f00 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2421,7 +2421,7 @@ dnl
 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
     [use MODEL for target locale package],
-    [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
+    [permit generic|gnu|ieee_1003.1-2001|newlib|xpg7|yes|no|auto])
 
   # Deal with gettext issues.  Default to not using it (=no) until we detect
   # support for it later.  Let the user turn it off via --e/d, but let that
@@ -2448,8 +2448,8 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       darwin*)
 	enable_clocale_flag=darwin
 	;;
-      dragonfly* | freebsd*)
-	enable_clocale_flag=dragonfly
+      aix* | dragonfly* | freebsd*)
+	enable_clocale_flag=xpg7
 	;;
       openbsd*)
 	enable_clocale_flag=newlib
@@ -2543,23 +2543,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
 
-    dragonfly)
-      AC_MSG_RESULT(dragonfly or freebsd)
-
-      CLOCALE_H=config/locale/dragonfly/c_locale.h
-      CLOCALE_CC=config/locale/dragonfly/c_locale.cc
-      CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
-      CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
-      CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
-      CMESSAGES_H=config/locale/generic/messages_members.h
-      CMESSAGES_CC=config/locale/generic/messages_members.cc
-      CMONEY_CC=config/locale/dragonfly/monetary_members.cc
-      CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
-      CTIME_H=config/locale/dragonfly/time_members.h
-      CTIME_CC=config/locale/dragonfly/time_members.cc
-      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
-      ;;
-
     gnu)
       AC_MSG_RESULT(gnu)
 
@@ -2610,6 +2593,24 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
+
+    xpg7)
+      AC_MSG_RESULT(xpg7)
+
+      CLOCALE_H=config/locale/xpg7/c_locale.h
+      CLOCALE_CC=config/locale/xpg7/c_locale.cc
+      CCODECVT_CC=config/locale/xpg7/codecvt_members.cc
+      CCOLLATE_CC=config/locale/xpg7/collate_members.cc
+      CCTYPE_CC=config/locale/xpg7/ctype_members.cc
+      CMESSAGES_H=config/locale/generic/messages_members.h
+      CMESSAGES_CC=config/locale/generic/messages_members.cc
+      CMONEY_CC=config/locale/xpg7/monetary_members.cc
+      CNUMERIC_CC=config/locale/xpg7/numeric_members.cc
+      CTIME_H=config/locale/xpg7/time_members.h
+      CTIME_CC=config/locale/xpg7/time_members.cc
+      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+      ;;
+
     newlib)
       AC_MSG_RESULT(newlib)
 
@@ -2656,6 +2657,12 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   AC_SUBST(CTIME_CC)
   AC_SUBST(CLOCALE_CC)
   AC_SUBST(CLOCALE_INTERNAL_H)
+
+  if test $enable_clocale_flag = xpg7; then
+     AC_CHECK_HEADERS(xlocale.h)
+
+     AC_CHECK_FUNCS([strtof_l localeconv_l mbstowcs_l wcsftime_l strftime_l])
+  fi
 ])
 
 
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 37b56b82b0e..2598a2a7634 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -225,6 +225,9 @@
 /* Define to 1 if you have the <linux/types.h> header file. */
 #undef HAVE_LINUX_TYPES_H
 
+/* Define to 1 if you have the `localeconv_l' function. */
+#undef HAVE_LOCALECONV_L
+
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
@@ -249,6 +252,9 @@
 /* Define if mbstate_t exists in wchar.h. */
 #undef HAVE_MBSTATE_T
 
+/* Define to 1 if you have the `mbstowcs_l' function. */
+#undef HAVE_MBSTOWCS_L
+
 /* Define to 1 if you have the `memalign' function. */
 #undef HAVE_MEMALIGN
 
@@ -364,6 +370,9 @@
 /* Define if strerror_r is available in <string.h>. */
 #undef HAVE_STRERROR_R
 
+/* Define to 1 if you have the `strftime_l' function. */
+#undef HAVE_STRFTIME_L
+
 /* Define to 1 if you have the <strings.h> header file. */
 #undef HAVE_STRINGS_H
 
@@ -373,6 +382,9 @@
 /* Define to 1 if you have the `strtof' function. */
 #undef HAVE_STRTOF
 
+/* Define to 1 if you have the `strtof_l' function. */
+#undef HAVE_STRTOF_L
+
 /* Define to 1 if you have the `strtold' function. */
 #undef HAVE_STRTOLD
 
@@ -494,6 +506,9 @@
 /* Define to 1 if you have the <wchar.h> header file. */
 #undef HAVE_WCHAR_H
 
+/* Define to 1 if you have the `wcsftime_l' function. */
+#undef HAVE_WCSFTIME_L
+
 /* Defined if wcstof exists. */
 #undef HAVE_WCSTOF
 
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/xpg7/c_locale.cc
similarity index 97%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.cc
rename to libstdc++-v3/config/locale/xpg7/c_locale.cc
index 02df4605bb5..39ef58ea0a9 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc
+++ b/libstdc++-v3/config/locale/xpg7/c_locale.cc
@@ -1,4 +1,4 @@
-// localization implementation details, DragonFly version -*- C++ -*-
+// localization implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
 //
@@ -28,13 +28,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <cstdlib>
 #include <locale>
 #include <stdexcept>
 #include <limits>
+
 #include <langinfo.h>
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/xpg7/c_locale.h
similarity index 69%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.h
rename to libstdc++-v3/config/locale/xpg7/c_locale.h
index cf4281cebbf..e030a3368d1 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.h
+++ b/libstdc++-v3/config/locale/xpg7/c_locale.h
@@ -1,4 +1,4 @@
-// localization implementation details, DragonFly version -*- C++ -*-
+// localization implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2001-2021 Free Software Foundation, Inc.
 //
@@ -33,6 +33,7 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #ifndef _GLIBCXX_CXX_LOCALE_H
 #define _GLIBCXX_CXX_LOCALE_H 1
@@ -40,7 +41,46 @@
 #pragma GCC system_header
 
 #include <clocale>
+#include <cstdlib>
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
+
+#define _GLIBCXX_C_LOCALE_XPG7 1
+
+// Assume that if strtof_l is missing then strtod_l and strold_l
+// are missing too.
+#ifndef _GLIBCXX_HAVE_STRTOF_L
+extern "C" inline
+float strtof_l (const char *__nptr, char **__endptr,
+		locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  float __res = strtof(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+
+extern "C" inline
+double strtod_l (const char *__nptr, char **__endptr,
+		 locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  double __res = strtod(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+
+extern "C" inline
+long double strtold_l (const char *__nptr, char **__endptr,
+		       locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  long double __res = strtold(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+#endif
 
 #define _GLIBCXX_NUM_CATEGORIES 0
 
@@ -48,7 +88,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if defined(__DragonFly__) || defined(__FreeBSD__)
   typedef int*			__c_locale;
+#else
+  typedef locale_t			__c_locale;
+#endif
 
   // Convert numeric value of type double and long double to string and
   // return length of string.  If vsnprintf is available use it, otherwise
diff --git a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc b/libstdc++-v3/config/locale/xpg7/codecvt_members.cc
similarity index 99%
rename from libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
rename to libstdc++-v3/config/locale/xpg7/codecvt_members.cc
index 11cbcdae59f..3ce047a0851 100644
--- a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/codecvt_members.cc
@@ -1,4 +1,4 @@
-// std::codecvt implementation details, DragonFly version -*- C++ -*-
+// std::codecvt implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/config/locale/dragonfly/collate_members.cc b/libstdc++-v3/config/locale/xpg7/collate_members.cc
similarity index 97%
rename from libstdc++-v3/config/locale/dragonfly/collate_members.cc
rename to libstdc++-v3/config/locale/xpg7/collate_members.cc
index 64c7d864a61..9a586ce7599 100644
--- a/libstdc++-v3/config/locale/dragonfly/collate_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/collate_members.cc
@@ -1,4 +1,4 @@
-// std::collate implementation details, DragonFly version -*- C++ -*-
+// std::collate implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/xpg7/ctype_members.cc
similarity index 78%
rename from libstdc++-v3/config/locale/dragonfly/ctype_members.cc
rename to libstdc++-v3/config/locale/xpg7/ctype_members.cc
index 420cb51e07a..a87a603fa27 100644
--- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/ctype_members.cc
@@ -1,4 +1,4 @@
-// std::ctype implementation details, DragonFly version -*- C++ -*-
+// std::ctype implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
 //
@@ -28,13 +28,18 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <cstring>
 #include <cstdio>
 
 #ifndef _ISbit
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
+#else
+#define _ISbit(bit) (1 << bit)
+#endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -114,8 +119,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
     while (__lo < __hi)
       {
-        *__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype);
-        ++__lo;
+	*__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype);
+	++__lo;
       }
     return __hi;
   }
@@ -129,12 +134,64 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
     while (__lo < __hi)
       {
-        *__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype);
-        ++__lo;
+	*__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype);
+	++__lo;
+      }
+    return __hi;
+  }
+
+#if !defined(__DragonFly__) && !defined(__FreeBSD__)
+  bool
+  ctype<wchar_t>::
+  do_is(mask __m, char_type __c) const
+  {
+    bool __ret = false;
+    const size_t __bitmasksize = 15;
+    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+      if (__m & _M_bit[__bitcur]
+	  && iswctype_l(__c, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype))
+	{
+	  __ret = true;
+	  break;
+	}
+    return __ret;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+  {
+    for (;__lo < __hi; ++__vec, ++__lo)
+      {
+	const size_t __bitmasksize = 15;
+	mask __m = 0;
+	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+	  if (iswctype_l(*__lo, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype))
+	    __m |= _M_bit[__bitcur];
+	*__vec = __m;
       }
     return __hi;
   }
 
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
+  {
+    while (__lo < __hi && !this->do_is(__m, *__lo))
+      ++__lo;
+    return __lo;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
+  {
+    while (__lo < __hi && this->do_is(__m, *__lo) != 0)
+      ++__lo;
+    return __lo;
+  }
+#endif
+
   wchar_t
   ctype<wchar_t>::
   do_widen(char __c) const
@@ -217,7 +274,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	 __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
       _M_widen[__j] = btowc(__j);
 
-    for (size_t __k = 0; __k <= 11; ++__k)
+    for (size_t __k = 0; __k <= 15; ++__k)
       {
 	_M_bit[__k] = static_cast<mask>(_ISbit(__k));
 	_M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/xpg7/monetary_members.cc
similarity index 95%
rename from libstdc++-v3/config/locale/dragonfly/monetary_members.cc
rename to libstdc++-v3/config/locale/xpg7/monetary_members.cc
index e1decc61cbf..4dc35633fd2 100644
--- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/monetary_members.cc
@@ -1,4 +1,4 @@
-// std::moneypunct implementation details, DragonFly version -*- C++ -*-
+// std::moneypunct implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
@@ -28,10 +28,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
+// Solaris 11.4 doesn't make C99 members of struct lconv visible for C++11
+// without this.
+#define _LCONV_C99
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -241,7 +248,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -348,6 +360,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -360,6 +375,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->int_n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -395,7 +413,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -502,6 +525,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -514,6 +540,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -581,9 +610,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -741,9 +775,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/xpg7/numeric_members.cc
similarity index 90%
rename from libstdc++-v3/config/locale/dragonfly/numeric_members.cc
rename to libstdc++-v3/config/locale/xpg7/numeric_members.cc
index cac6fe8c710..5ee61f0fbb4 100644
--- a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/numeric_members.cc
@@ -1,4 +1,4 @@
-// std::numpunct implementation details, DragonFly version -*- C++ -*-
+// std::numpunct implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
@@ -28,10 +28,14 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -63,7 +67,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -103,6 +112,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -113,6 +125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
@@ -162,7 +177,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -201,6 +221,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -211,6 +234,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc b/libstdc++-v3/config/locale/xpg7/time_members.cc
similarity index 92%
rename from libstdc++-v3/config/locale/dragonfly/time_members.cc
rename to libstdc++-v3/config/locale/xpg7/time_members.cc
index c8b621a323f..fb287332c44 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/time_members.cc
@@ -1,4 +1,4 @@
-// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
+// std::time_get, std::time_put implementation, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2001-2021 Free Software Foundation, Inc.
 //
@@ -29,13 +29,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <ctime>
 #include <cwchar>
 #include <stdlib.h>
 #include <langinfo.h>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -47,8 +51,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(char* __s, size_t __maxlen, const char* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_STRFTIME_L
       const size_t __len = strftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = strftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = '\0';
@@ -196,15 +206,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_WCSFTIME_L
       const size_t __len = wcsftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = L'\0';
     }
 
+#ifdef _GLIBCXX_HAVE_MBSTOWCS_L
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs_l (WCSTRING, STRING, NUMBER, LOCALE);
+#else
+  // "uselocale" must be called before using this macro.
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs (WCSTRING, STRING, NUMBER);
+#endif
 #define WIDE_LANGINFO(M,FMT) \
-	fmtlen = mbstowcs_l (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
+	fmtlen = MBSTOWCS_L (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
 		128, (locale_t)__cloc); \
 	langstring = new wchar_t[fmtlen + 1]; \
 	wcsncpy (langstring, holder, fmtlen); \
@@ -281,6 +305,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  __c_locale __old = uselocale(__cloc);
+#endif
 	  wchar_t *langstring = 0;
 	  wchar_t holder[128];
 	  size_t fmtlen;
@@ -342,6 +369,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  WIDE_LANGINFO(_M_amonth10, ABMON_10)
 	  WIDE_LANGINFO(_M_amonth11, ABMON_11)
 	  WIDE_LANGINFO(_M_amonth12, ABMON_12)
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  uselocale(__old);
+#endif
 	}
     }
 
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.h b/libstdc++-v3/config/locale/xpg7/time_members.h
similarity index 97%
rename from libstdc++-v3/config/locale/dragonfly/time_members.h
rename to libstdc++-v3/config/locale/xpg7/time_members.h
index 04b7e995d6f..1457d4cce32 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.h
+++ b/libstdc++-v3/config/locale/xpg7/time_members.h
@@ -1,4 +1,4 @@
-// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
+// std::time_get, std::time_put implementation, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/config/os/aix/ctype_configure_char.cc b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
index b12c0bd435c..9cbfd0317b5 100644
--- a/libstdc++-v3/config/os/aix/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
@@ -42,28 +42,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   ctype<char>::classic_table() throw()
   { return 0; }
 
-  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
+  ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
-  _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
-  {
-    memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
-    memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
-  }
+    : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
+    _M_del(__table != 0 && __del),
+    _M_toupper(NULL), _M_tolower(NULL),
+    _M_table(__table ? __table : classic_table()),
+    _M_widen_ok(0), _M_narrow_ok(0)
+    {
+      memset(_M_widen, 0, sizeof(_M_widen));
+      memset(_M_narrow, 0, sizeof(_M_narrow));
+    }
 
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
-  _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
-  {
-    memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
-    memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
-  }
+    : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+    _M_del(__table != 0 && __del),
+    _M_toupper(NULL), _M_tolower(NULL),
+    _M_table(__table ? __table : classic_table()),
+    _M_widen_ok(0), _M_narrow_ok(0)
+    {
+      memset(_M_widen, 0, sizeof(_M_widen));
+      memset(_M_narrow, 0, sizeof(_M_narrow));
+    }
 
   char
   ctype<char>::do_toupper(char __c) const
diff --git a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
index d6ab73175b8..d909feefca3 100644
--- a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
@@ -38,7 +38,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // Information as gleaned from /usr/include/ctype.h
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   const ctype_base::mask*
   ctype<char>::classic_table() throw()
   { return _S_get_c_locale()->__ctype_b; }
@@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
   : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
@@ -117,7 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
   : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
   _M_del(__table != 0 && __del),
diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc
index 4bec50bf595..dcea799aeaf 100644
--- a/libstdc++-v3/src/c++98/locale_init.cc
+++ b/libstdc++-v3/src/c++98/locale_init.cc
@@ -296,7 +296,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _S_global = __other._M_impl;
       const string __other_name = __other.name();
       if (__other_name != "*")
+#ifdef _GLIBCXX_C_LOCALE_GNU
 	setlocale(LC_ALL, __other_name.c_str());
+#else
+        {
+	  // In general, passing "LC_CTYPE=C;LC_NUMERIQUE=C;..." as
+	  // argument to setlocale isn't allowed.
+	  if (__other._M_impl->_M_check_same_name())
+	    setlocale(LC_ALL, __other_name.c_str());
+	  else
+	    for (size_t __i = 0; __i < __other._S_categories_size; ++__i)
+	      setlocale(__i, __other._M_impl->_M_names[__i]);
+	}
+#endif
     }
 
     // Reference count sanity check: one reference removed for the
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
index ea0c43a20fc..71e198843d2 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
index 54206f8000a..ffde94108a1 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO-8859-15" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
index f27d667daf5..9193b598162 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
index b5383af657c..e4b428c9fc6 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
index 1d40a1723a4..ffbd856640b 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
index 9801e085683..5e42a373547 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
index f70d0fc6c58..01bf1a57917 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
index 5cde0b66331..25dfa02b99d 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
index 1e4ce5a8e3e..5d00a62c9a9 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
index 5254c967018..1f2869e43f6 100644
--- a/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
@@ -1,5 +1,5 @@
-// { dg-do run { xfail { ! { *-*-linux* *-*-gnu* } } } }
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu xpg7" }
 
 // Copyright (C) 2000-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
index a60e98eee76..0cfcc042b1c 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2006-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
index 8d8f07f01cc..94fcfe3ac8b 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2008-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
index 6a8eff8737b..d41ee12603b 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "ja_JP.eucJP" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2009-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
index 66b939e2228..99abf566b81 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
@@ -3,6 +3,7 @@
 // { dg-require-namedlocale "es_MX" }
 // { dg-require-namedlocale "fr_FR" }
 // { dg-require-namedlocale "it_IT" }
+// { dg-require-localemodel "gnu" }
 
 // 2000-09-13 Benjamin Kosnik <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
index ea3992b03f6..30d4a31a64c 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
@@ -1,5 +1,6 @@
 // { dg-require-namedlocale "is_IS.ISO8859-1" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2004-02-09  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/13631.cc b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
index b8ae3d4f140..2509bba0845 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/13631.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
index c4d972124f0..fdf4a0af018 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
index 81d914f5c37..3345f43b342 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
index 5a503ef2c49..1d2f7ad3162 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
@@ -1,5 +1,6 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
index 35e7f6c740c..976b4d9fbf6 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
@@ -1,6 +1,7 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
index a44bf1476b2..b143d33a4cc 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
@@ -2,6 +2,7 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
index 1006f20c996..fabf281d3e6 100644
--- a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
index c747f7bfb02..46713cca118 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
index 76a387768fe..a3a4bbf5833 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
index 24d192921cb..2a314589714 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
index 2c0a2ab61db..71393bbd255 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 872768f2620..8474e8df14b 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -88,6 +88,15 @@ proc dg-require-namedlocale { args } {
     return
 }
 
+proc dg-require-localemodel { args } {
+    if { ![ check_v3_target_localemodel [lindex $args 1] ] } {
+	upvar dg-do-what dg-do-what
+	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+	return
+    }
+    return
+}
+
 proc dg-require-sharedlib { args } {
     if { ![ check_v3_target_sharedlib ] } {
 	upvar dg-do-what dg-do-what
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 7f9580db8ed..d3574862d7a 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -895,6 +895,11 @@ proc check_v3_target_namedlocale { args } {
 	puts $f "    strcpy(result, name);"
 	puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
 	puts $f "    /* fall-through */"
+	puts $f "#elif defined _AIX"
+	puts $f "    char *p = strstr(result, \"ISO8859-15\");"
+	puts $f "    if (p) {"
+	puts $f "       strcpy(p, \"8859-15\");"
+	puts $f "    }"
 	puts $f "#else"
 	puts $f "    if (strstr(result, \"ISO8859-15\")) {"
 	puts $f "        strcat(result, \"@euro\");"
@@ -945,6 +950,32 @@ proc check_v3_target_namedlocale { args } {
     }]
 }
 
+# Return 1 if the locale model is implemented.
+proc check_v3_target_localemodel { args } {
+    set key "et_locale $args"
+    return [check_v3_target_prop_cached $key {
+	global cxxflags
+	global DEFAULT_CXXFLAGS
+
+	set cond "0"
+	if [string match "*gnu*" $args] {
+	    set cond " $cond || defined _GLIBCXX_C_LOCALE_GNU"
+	}
+	if [string match "*xpg7*" $args] {
+	    set cond " $cond || defined _GLIBCXX_C_LOCALE_XPG7"
+	}
+
+	set code "
+	#include <bits/c++locale.h>
+	#if ! ($cond)
+	#error '$cond' is false
+	#endif
+	"
+	set flags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+	return [v3_try_preprocess name $code $flags]
+    }]
+}
+
 # Returns 1 if the tokens in CODE can be preprocessed successfully using FLAGS,
 # returns 0 otherwise.
 proc v3_try_preprocess { name code flags } {
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index b5e0767211a..a632f5f31f8 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -77,6 +77,9 @@
 
 #if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__
 # define ISO_8859(part,langTERR) #langTERR ".ISO8859-" #part
+#elif defined _AIX
+# define ISO_8859(part,langTERR) ((part) == 15 ?\
+         #langTERR ".8859-" #part : #langTERR ".ISO8859-" #part)
 #else
 # define ISO_8859(part,langTERR) ((part) == 15 ?\
          #langTERR ".ISO8859-" #part "@euro" : #langTERR ".ISO8859-" #part)
-- 
2.31.1


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-05-17  9:17                                                       ` CHIGOT, CLEMENT
@ 2021-06-08  6:59                                                         ` CHIGOT, CLEMENT
  2021-06-09 14:50                                                           ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-06-08  6:59 UTC (permalink / raw)
  To: libstdc++; +Cc: Jonathan Wakely, David Edelsohn, Rainer Orth

Hi all, 

Did anyone have time to take a look at this patch ? 

Thanks, 
Clément

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-06-08  6:59                                                         ` CHIGOT, CLEMENT
@ 2021-06-09 14:50                                                           ` Rainer Orth
  2021-07-21 12:00                                                             ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-06-09 14:50 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: libstdc++, Jonathan Wakely, David Edelsohn

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

Hi Clement,

> Did anyone have time to take a look at this patch ?

I've finally manged to give it a try on sparc-sun-solaris2.11 (Solaris
11.4).  I had to apply the following additional patch, matching what you
did in config/os/aix/ctype_configure_char.cc:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sccc.patch --]
[-- Type: text/x-patch, Size: 1590 bytes --]

diff --git a/libstdc++-v3/config/os/solaris/ctype_configure_char.cc b/libstdc++-v3/config/os/solaris/ctype_configure_char.cc
--- a/libstdc++-v3/config/os/solaris/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/solaris/ctype_configure_char.cc
@@ -42,27 +42,27 @@ namespace std _GLIBCXX_VISIBILITY(defaul
   ctype<char>::classic_table() throw()
   { return __ctype_mask; }
 
-  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
+  ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+  : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
+  _M_del(__table != 0 && __del),
   _M_toupper(__trans_upper), _M_tolower(__trans_lower),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+  _M_del(__table != 0 && __del),
   _M_toupper(__trans_upper), _M_tolower(__trans_lower),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   char

[-- Attachment #3: Type: text/plain, Size: 4780 bytes --]


For now, I'm passing --enable-clocale=xpg7 at configure time rather than
changing the default.

Results are mixed: with the previous patch, I had 29 FAILs (both 32 and
64-bit).  The number has remained the same, but the exact set of failing
patches changed:

FAIL: libstdc++-abi/abi_check
FAIL: 22_locale/codecvt/encoding/wchar_t/wrapped_locale.cc execution test
FAIL: 22_locale/codecvt/in/wchar_t/3.cc execution test
FAIL: 22_locale/codecvt/max_length/wchar_t/4.cc execution test
FAIL: 22_locale/codecvt/max_length/wchar_t/wrapped_locale.cc execution test
FAIL: 22_locale/codecvt/out/wchar_t/3.cc execution test
FAIL: 22_locale/collate/compare/wchar_t/2.cc execution test
FAIL: 22_locale/collate/compare/wchar_t/3.cc execution test
FAIL: 22_locale/collate/compare/wchar_t/wrapped_env.cc execution test
FAIL: 22_locale/collate/compare/wchar_t/wrapped_locale.cc execution test
FAIL: 22_locale/collate/transform/wchar_t/2.cc execution test
FAIL: 22_locale/collate/transform/wchar_t/3.cc execution test
FAIL: 22_locale/collate/transform/wchar_t/wrapped_env.cc execution test
FAIL: 22_locale/collate/transform/wchar_t/wrapped_locale.cc execution test
FAIL: 22_locale/ctype/widen/wchar_t/2.cc execution test
FAIL: 22_locale/money_get/get/wchar_t/1.cc execution test
FAIL: 22_locale/money_put/put/char/9780-3.cc execution test
FAIL: 22_locale/money_put/put/wchar_t/1.cc execution test
FAIL: 22_locale/money_put/put/wchar_t/3.cc execution test
FAIL: 22_locale/time_get/get_date/wchar_t/4.cc execution test
FAIL: 22_locale/time_put/put/char/2.cc execution test
FAIL: 22_locale/time_put/put/char/4.cc execution test
FAIL: 22_locale/time_put/put/wchar_t/2.cc execution test
FAIL: 22_locale/time_put/put/wchar_t/4.cc execution test
FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-1.cc execution test
FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-2.cc execution test
FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-3.cc execution test
FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-4.cc execution test
FAIL: 27_io/manipulators/extended/get_time/char/2.cc execution test

-FAIL: 22_locale/codecvt/encoding/wchar_t/wrapped_locale.cc execution test

-FAIL: 22_locale/codecvt/max_length/wchar_t/wrapped_locale.cc execution test

-FAIL: 22_locale/collate/compare/wchar_t/2.cc execution test

-FAIL: 22_locale/collate/compare/wchar_t/wrapped_env.cc execution test
-FAIL: 22_locale/collate/compare/wchar_t/wrapped_locale.cc execution test
-FAIL: 22_locale/collate/transform/wchar_t/2.cc execution test

-FAIL: 22_locale/collate/transform/wchar_t/wrapped_env.cc execution test
-FAIL: 22_locale/collate/transform/wchar_t/wrapped_locale.cc execution test
+FAIL: 22_locale/ctype/is/wchar_t/1.cc execution test
+FAIL: 22_locale/ctype/is/wchar_t/wrapped_env.cc execution test
+FAIL: 22_locale/ctype/scan/wchar_t/1.cc execution test
+FAIL: 22_locale/ctype/scan/wchar_t/wrapped_env.cc execution test

+FAIL: 22_locale/locale/cons/29217.cc execution test
+FAIL: 22_locale/locale/cons/38368.cc execution test
+FAIL: 22_locale/messages/members/char/1.cc execution test
+FAIL: 22_locale/messages_byname/named_equivalence.cc execution test

-FAIL: 22_locale/money_put/put/char/9780-3.cc execution test

-FAIL: 22_locale/time_get/get_date/wchar_t/4.cc execution test

-FAIL: 22_locale/time_put/put/char/4.cc execution test

+FAIL: 28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc execution test
+FAIL: 28_regex/algorithms/regex_match/extended/wstring_locale.cc execution test
+FAIL: 28_regex/iterators/regex_token_iterator/wchar_t/wstring_02.cc execution test
+FAIL: 28_regex/traits/wchar_t/isctype.cc execution test

Just a number of comments on the patch itself:

* In a couple of places, you use uselocale, e.g. in
  config/locale/xpg7/c_locale.h.  E.g. on Solaris 11.3, this is
  missing, which is no wonder given that the OS only conforms to XPG6.
  We will either have to hardcode the clocale based on the minor/micro
  version or check for a couple of necessary XPG7 functions before
  enabling the xpg7 clocale.  However, we can cross that bridge once the
  code works on actual XPG7 systems.

* Your patch changes indentation in a couple of places
  (e.g. config/locale/xpg7/ctype_members.cc,
  config/os/aix/ctype_configure_char.cc) for no reason I can see.  This
  seems to violate the coding style.

* When I tried GCC master on FreeBSD (for the previous version of your
  patch), libstdc++ locale test results were pretty horrible, both
  without and with your patch.  If the dragonfly/xpg7 locale code has
  considerable problems even on the native system it originates from, I
  wonder if it's the best basis for the new xpg7 clocale.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-06-09 14:50                                                           ` Rainer Orth
@ 2021-07-21 12:00                                                             ` CHIGOT, CLEMENT
  2021-07-21 13:04                                                               ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-07-21 12:00 UTC (permalink / raw)
  To: libstdc++; +Cc: Jonathan Wakely, David Edelsohn, Rainer Orth

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

Hi everyone, 
 
Here is a new version of the patch with the Solaris part 
made by Rainer directly integrated in it. 
Rainer did you change anything in the configure file or 
did you just pass XPG7 model with the configure option ? 
I guess if it works fine on Solaris target, it can be 
directly chosen inside the configure. 

A part from that it would be good if someone familiar with
freebsd or dragonfly can take a look at it. There shouldn't be
any problems but it needs to be tested and a few #ifdef remain
for these two targets. 

Thanks, 
Clément

[-- Attachment #2: 0001-libstdc-implement-locale-support-for-XPG7.patch --]
[-- Type: application/octet-stream, Size: 52028 bytes --]

From dd9a67384e47508111fa7623991d14f01227c114 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Tue, 29 Dec 2020 11:08:33 +0100
Subject: [PATCH] libstdc++: implement locale support for XPG7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Create a new locale model for POSIX operating systems.
The implementation is based on dragonfly one.

There are few known limitations.
std::messages isn't implemented.
Creation std::locale with a string describing each LC_* category
isn't possible (eg std::locale("LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;...")

libstdc++-v3/ChangeLog:
2020-01-25  Clément Chigot  <clement.chigot@atos.net>

	* acinclude.m4: Add XPG7 model.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* config/locale/dragonfly/c_locale.cc: Rename to ...
	* config/locale/xpg7/c_locale.cc: ... here.
	* config/locale/dragonfly/c_locale.h: Rename to ...
	* config/locale/xpg7/c_locale.h: ... here.
	(_GLIBCXX_C_LOCALE_XPG7): New define.
	(strtof_l): New function if not provided by the system.
	(strtod_l): Likewise.
	(strtold_l): Likewise.
	* config/locale/dragonfly/ctype_members.cc: Rename to ...
	* config/locale/xpg7/ctype_members.cc: ... here.
	* config/locale/dragonfly/monetary_members.cc: Rename to ...
	* config/locale/xpg7/monetary_members.cc: ... here.
	* config/locale/dragonfly/numeric_members.cc: Rename to ...
	* config/locale/xpg7/numeric_members.cc: ... here.
	* config/locale/dragonfly/time_members.cc: Rename to ...
	* config/locale/xpg7/time_members.cc: ... here.
	* config/os/aix/ctype_configure_char.cc (ctype<char>::ctype):
	Add support for XPG7 model.
	* config/os/solaris/ctype_configure_char.cc (ctype<char>::ctype):
	Likewise.
	* config/os/gnu-linux/ctype_configure_char.cc: Likewise.
	* src/c++98/locale_init.cc (locale::global): Call setlocale
	for each category instead of once when not using gnu model.
	* testsuite/22_locale/codecvt/in/wchar_t/2.cc: Add xfail for
	wchar_t on 16bit.
	* testsuite/22_locale/codecvt/in/wchar_t/3.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/7.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/8.cc: Likewise.
	* testsuite/22_locale/codecvt/in/wchar_t/9.cc: Likewise.
	* testsuite/22_locale/codecvt/length/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/out/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/codecvt/unshift/wchar_t/4.cc: Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc:
	Likewise.
	* testsuite/22_locale/ctype/is/wchar_t/2.cc: Remove xfail
	with xpg7 model.
	* testsuite/22_locale/locale/cons/29217.cc: Add skip when not
	using gnu model.
	* testsuite/22_locale/locale/cons/38368.cc: Likewise.
	* testsuite/22_locale/locale/cons/40184.cc: Likewise.
	* testsuite/22_locale/locale/cons/5.cc: Likewise.
	* testsuite/22_locale/locale/global_locale_objects/14071.cc:
	Likewise.
	* testsuite/22_locale/messages/13631.cc: Likewise.
	* testsuite/22_locale/messages/members/char/1.cc: Likewise.
	* testsuite/22_locale/messages/members/char/2.cc: Likewise.
	* testsuite/22_locale/messages/members/char/3.cc: Likewise.
	* testsuite/22_locale/messages/members/char/wrapped_env.cc:
	Likewise.
	* testsuite/22_locale/messages/members/char/wrapped_locale.cc:
	Likewise.
	* testsuite/22_locale/messages_byname/named_equivalence.cc:
	Likewise.
	* testsuite/lib/dg-options.exp (dg-require-localemodel): New.
	* testsuite/lib/libstdc++.exp (check_v3_target_namedlocale): Add
	AIX support.
	(check_v3_target_localemodel): New.
	* testsuite/util/testsuite_hooks.h (ISO_8859): Add AIX support.
---
 libstdc++-v3/acinclude.m4                     | 46 +++++++------
 libstdc++-v3/config.h.in                      | 15 ++++
 .../locale/{dragonfly => xpg7}/c_locale.cc    |  6 +-
 .../locale/{dragonfly => xpg7}/c_locale.h     | 46 ++++++++++++-
 .../{dragonfly => xpg7}/codecvt_members.cc    |  2 +-
 .../{dragonfly => xpg7}/collate_members.cc    |  2 +-
 .../{dragonfly => xpg7}/ctype_members.cc      | 69 +++++++++++++++++--
 .../{dragonfly => xpg7}/monetary_members.cc   | 45 +++++++++++-
 .../{dragonfly => xpg7}/numeric_members.cc    | 28 +++++++-
 .../{dragonfly => xpg7}/time_members.cc       | 34 ++++++++-
 .../locale/{dragonfly => xpg7}/time_members.h |  2 +-
 .../config/os/aix/ctype_configure_char.cc     | 38 +++++-----
 .../os/gnu-linux/ctype_configure_char.cc      |  6 +-
 .../config/os/solaris/ctype_configure_char.cc | 18 ++---
 libstdc++-v3/src/c++98/locale_init.cc         | 12 ++++
 .../22_locale/codecvt/in/wchar_t/2.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/3.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/4.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/7.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/8.cc         |  1 +
 .../22_locale/codecvt/in/wchar_t/9.cc         |  1 +
 .../22_locale/codecvt/length/wchar_t/4.cc     |  1 +
 .../22_locale/codecvt/out/wchar_t/4.cc        |  1 +
 .../22_locale/codecvt/unshift/wchar_t/4.cc    |  1 +
 .../testsuite/22_locale/ctype/is/wchar_t/2.cc |  2 +-
 .../testsuite/22_locale/locale/cons/29217.cc  |  1 +
 .../testsuite/22_locale/locale/cons/38368.cc  |  1 +
 .../testsuite/22_locale/locale/cons/40184.cc  |  1 +
 .../testsuite/22_locale/locale/cons/5.cc      |  1 +
 .../locale/global_locale_objects/14071.cc     |  1 +
 .../testsuite/22_locale/messages/13631.cc     |  1 +
 .../22_locale/messages/members/char/1.cc      |  1 +
 .../22_locale/messages/members/char/2.cc      |  1 +
 .../22_locale/messages/members/char/3.cc      |  1 +
 .../messages/members/char/wrapped_env.cc      |  1 +
 .../messages/members/char/wrapped_locale.cc   |  1 +
 .../messages_byname/named_equivalence.cc      |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-1.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-2.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-3.cc |  1 +
 .../basic_filebuf/overflow/wchar_t/11305-4.cc |  1 +
 libstdc++-v3/testsuite/lib/dg-options.exp     |  9 +++
 libstdc++-v3/testsuite/lib/libstdc++.exp      | 31 +++++++++
 libstdc++-v3/testsuite/util/testsuite_hooks.h |  3 +
 44 files changed, 370 insertions(+), 69 deletions(-)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/c_locale.cc (97%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/c_locale.h (69%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/codecvt_members.cc (99%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/collate_members.cc (97%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/ctype_members.cc (78%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/monetary_members.cc (95%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/numeric_members.cc (90%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/time_members.cc (92%)
 rename libstdc++-v3/config/locale/{dragonfly => xpg7}/time_members.h (97%)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 90ecc4a87a2..8b6a7d612f7 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2364,7 +2364,7 @@ dnl
 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
     [use MODEL for target locale package],
-    [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
+    [permit generic|gnu|ieee_1003.1-2001|newlib|xpg7|yes|no|auto])
 
   # Deal with gettext issues.  Default to not using it (=no) until we detect
   # support for it later.  Let the user turn it off via --e/d, but let that
@@ -2394,8 +2394,8 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       vxworks*)
 	enable_clocale_flag=vxworks
 	;;
-      dragonfly* | freebsd*)
-	enable_clocale_flag=dragonfly
+      aix* | dragonfly* | freebsd*)
+	enable_clocale_flag=xpg7
 	;;
       openbsd*)
 	enable_clocale_flag=newlib
@@ -2504,23 +2504,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
-    dragonfly)
-      AC_MSG_RESULT(dragonfly or freebsd)
-
-      CLOCALE_H=config/locale/dragonfly/c_locale.h
-      CLOCALE_CC=config/locale/dragonfly/c_locale.cc
-      CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
-      CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
-      CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
-      CMESSAGES_H=config/locale/generic/messages_members.h
-      CMESSAGES_CC=config/locale/generic/messages_members.cc
-      CMONEY_CC=config/locale/dragonfly/monetary_members.cc
-      CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
-      CTIME_H=config/locale/dragonfly/time_members.h
-      CTIME_CC=config/locale/dragonfly/time_members.cc
-      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
-      ;;
-
     gnu)
       AC_MSG_RESULT(gnu)
 
@@ -2571,6 +2554,23 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
       CTIME_CC=config/locale/generic/time_members.cc
       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
       ;;
+    xpg7)
+      AC_MSG_RESULT(xpg7)
+
+      CLOCALE_H=config/locale/xpg7/c_locale.h
+      CLOCALE_CC=config/locale/xpg7/c_locale.cc
+      CCODECVT_CC=config/locale/xpg7/codecvt_members.cc
+      CCOLLATE_CC=config/locale/xpg7/collate_members.cc
+      CCTYPE_CC=config/locale/xpg7/ctype_members.cc
+      CMESSAGES_H=config/locale/generic/messages_members.h
+      CMESSAGES_CC=config/locale/generic/messages_members.cc
+      CMONEY_CC=config/locale/xpg7/monetary_members.cc
+      CNUMERIC_CC=config/locale/xpg7/numeric_members.cc
+      CTIME_H=config/locale/xpg7/time_members.h
+      CTIME_CC=config/locale/xpg7/time_members.cc
+      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
+      ;;
+
     newlib)
       AC_MSG_RESULT(newlib)
 
@@ -2617,6 +2617,12 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
   AC_SUBST(CTIME_CC)
   AC_SUBST(CLOCALE_CC)
   AC_SUBST(CLOCALE_INTERNAL_H)
+
+  if test $enable_clocale_flag = xpg7; then
+     AC_CHECK_HEADERS(xlocale.h)
+
+     AC_CHECK_FUNCS([strtof_l localeconv_l mbstowcs_l wcsftime_l strftime_l])
+  fi
 ])
 
 
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index e545488386a..36a6fc97fdf 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -216,6 +216,9 @@
 /* Define to 1 if you have the <linux/types.h> header file. */
 #undef HAVE_LINUX_TYPES_H
 
+/* Define to 1 if you have the `localeconv_l' function. */
+#undef HAVE_LOCALECONV_L
+
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
@@ -240,6 +243,9 @@
 /* Define if mbstate_t exists in wchar.h. */
 #undef HAVE_MBSTATE_T
 
+/* Define to 1 if you have the `mbstowcs_l' function. */
+#undef HAVE_MBSTOWCS_L
+
 /* Define to 1 if you have the `memalign' function. */
 #undef HAVE_MEMALIGN
 
@@ -355,6 +361,9 @@
 /* Define if strerror_r is available in <string.h>. */
 #undef HAVE_STRERROR_R
 
+/* Define to 1 if you have the `strftime_l' function. */
+#undef HAVE_STRFTIME_L
+
 /* Define to 1 if you have the <strings.h> header file. */
 #undef HAVE_STRINGS_H
 
@@ -364,6 +373,9 @@
 /* Define to 1 if you have the `strtof' function. */
 #undef HAVE_STRTOF
 
+/* Define to 1 if you have the `strtof_l' function. */
+#undef HAVE_STRTOF_L
+
 /* Define to 1 if you have the `strtold' function. */
 #undef HAVE_STRTOLD
 
@@ -485,6 +497,9 @@
 /* Define to 1 if you have the <wchar.h> header file. */
 #undef HAVE_WCHAR_H
 
+/* Define to 1 if you have the `wcsftime_l' function. */
+#undef HAVE_WCSFTIME_L
+
 /* Defined if wcstof exists. */
 #undef HAVE_WCSTOF
 
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/xpg7/c_locale.cc
similarity index 97%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.cc
rename to libstdc++-v3/config/locale/xpg7/c_locale.cc
index 02df4605bb5..39ef58ea0a9 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc
+++ b/libstdc++-v3/config/locale/xpg7/c_locale.cc
@@ -1,4 +1,4 @@
-// localization implementation details, DragonFly version -*- C++ -*-
+// localization implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
 //
@@ -28,13 +28,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <cstdlib>
 #include <locale>
 #include <stdexcept>
 #include <limits>
+
 #include <langinfo.h>
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/xpg7/c_locale.h
similarity index 69%
rename from libstdc++-v3/config/locale/dragonfly/c_locale.h
rename to libstdc++-v3/config/locale/xpg7/c_locale.h
index cf4281cebbf..e030a3368d1 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.h
+++ b/libstdc++-v3/config/locale/xpg7/c_locale.h
@@ -1,4 +1,4 @@
-// localization implementation details, DragonFly version -*- C++ -*-
+// localization implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2001-2021 Free Software Foundation, Inc.
 //
@@ -33,6 +33,7 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #ifndef _GLIBCXX_CXX_LOCALE_H
 #define _GLIBCXX_CXX_LOCALE_H 1
@@ -40,7 +41,46 @@
 #pragma GCC system_header
 
 #include <clocale>
+#include <cstdlib>
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
+
+#define _GLIBCXX_C_LOCALE_XPG7 1
+
+// Assume that if strtof_l is missing then strtod_l and strold_l
+// are missing too.
+#ifndef _GLIBCXX_HAVE_STRTOF_L
+extern "C" inline
+float strtof_l (const char *__nptr, char **__endptr,
+		locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  float __res = strtof(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+
+extern "C" inline
+double strtod_l (const char *__nptr, char **__endptr,
+		 locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  double __res = strtod(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+
+extern "C" inline
+long double strtold_l (const char *__nptr, char **__endptr,
+		       locale_t locale)
+{
+  locale_t __old = uselocale(locale);
+  long double __res = strtold(__nptr, __endptr);
+  uselocale(__old);
+  return __res;
+}
+#endif
 
 #define _GLIBCXX_NUM_CATEGORIES 0
 
@@ -48,7 +88,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if defined(__DragonFly__) || defined(__FreeBSD__)
   typedef int*			__c_locale;
+#else
+  typedef locale_t			__c_locale;
+#endif
 
   // Convert numeric value of type double and long double to string and
   // return length of string.  If vsnprintf is available use it, otherwise
diff --git a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc b/libstdc++-v3/config/locale/xpg7/codecvt_members.cc
similarity index 99%
rename from libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
rename to libstdc++-v3/config/locale/xpg7/codecvt_members.cc
index 11cbcdae59f..3ce047a0851 100644
--- a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/codecvt_members.cc
@@ -1,4 +1,4 @@
-// std::codecvt implementation details, DragonFly version -*- C++ -*-
+// std::codecvt implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/config/locale/dragonfly/collate_members.cc b/libstdc++-v3/config/locale/xpg7/collate_members.cc
similarity index 97%
rename from libstdc++-v3/config/locale/dragonfly/collate_members.cc
rename to libstdc++-v3/config/locale/xpg7/collate_members.cc
index 64c7d864a61..9a586ce7599 100644
--- a/libstdc++-v3/config/locale/dragonfly/collate_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/collate_members.cc
@@ -1,4 +1,4 @@
-// std::collate implementation details, DragonFly version -*- C++ -*-
+// std::collate implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/xpg7/ctype_members.cc
similarity index 78%
rename from libstdc++-v3/config/locale/dragonfly/ctype_members.cc
rename to libstdc++-v3/config/locale/xpg7/ctype_members.cc
index 420cb51e07a..a87a603fa27 100644
--- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/ctype_members.cc
@@ -1,4 +1,4 @@
-// std::ctype implementation details, DragonFly version -*- C++ -*-
+// std::ctype implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
 //
@@ -28,13 +28,18 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <cstring>
 #include <cstdio>
 
 #ifndef _ISbit
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
+#else
+#define _ISbit(bit) (1 << bit)
+#endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -114,8 +119,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
     while (__lo < __hi)
       {
-        *__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype);
-        ++__lo;
+	*__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype);
+	++__lo;
       }
     return __hi;
   }
@@ -129,12 +134,64 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
     while (__lo < __hi)
       {
-        *__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype);
-        ++__lo;
+	*__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype);
+	++__lo;
+      }
+    return __hi;
+  }
+
+#if !defined(__DragonFly__) && !defined(__FreeBSD__)
+  bool
+  ctype<wchar_t>::
+  do_is(mask __m, char_type __c) const
+  {
+    bool __ret = false;
+    const size_t __bitmasksize = 15;
+    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+      if (__m & _M_bit[__bitcur]
+	  && iswctype_l(__c, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype))
+	{
+	  __ret = true;
+	  break;
+	}
+    return __ret;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
+  {
+    for (;__lo < __hi; ++__vec, ++__lo)
+      {
+	const size_t __bitmasksize = 15;
+	mask __m = 0;
+	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+	  if (iswctype_l(*__lo, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype))
+	    __m |= _M_bit[__bitcur];
+	*__vec = __m;
       }
     return __hi;
   }
 
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
+  {
+    while (__lo < __hi && !this->do_is(__m, *__lo))
+      ++__lo;
+    return __lo;
+  }
+
+  const wchar_t*
+  ctype<wchar_t>::
+  do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
+  {
+    while (__lo < __hi && this->do_is(__m, *__lo) != 0)
+      ++__lo;
+    return __lo;
+  }
+#endif
+
   wchar_t
   ctype<wchar_t>::
   do_widen(char __c) const
@@ -217,7 +274,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	 __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
       _M_widen[__j] = btowc(__j);
 
-    for (size_t __k = 0; __k <= 11; ++__k)
+    for (size_t __k = 0; __k <= 15; ++__k)
       {
 	_M_bit[__k] = static_cast<mask>(_ISbit(__k));
 	_M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/xpg7/monetary_members.cc
similarity index 95%
rename from libstdc++-v3/config/locale/dragonfly/monetary_members.cc
rename to libstdc++-v3/config/locale/xpg7/monetary_members.cc
index e1decc61cbf..4dc35633fd2 100644
--- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/monetary_members.cc
@@ -1,4 +1,4 @@
-// std::moneypunct implementation details, DragonFly version -*- C++ -*-
+// std::moneypunct implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
@@ -28,10 +28,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
+// Solaris 11.4 doesn't make C99 members of struct lconv visible for C++11
+// without this.
+#define _LCONV_C99
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -241,7 +248,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -348,6 +360,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -360,6 +375,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->int_n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -395,7 +413,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -502,6 +525,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      delete [] __group;
 	      delete [] __ps;
 	      delete [] __ns;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	      uselocale(__old);
+#endif
 	      __throw_exception_again;
 	    }
 
@@ -514,6 +540,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  char __nspace = lc->n_sep_by_space;
 	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
 							__nposn);
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
     }
 
@@ -581,9 +610,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
@@ -741,9 +775,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
-	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
 	  // Named locale.
+	  // uselocale is needed for mbsrtowcs.
+	  __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  lconv* lc = localeconv();
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (lc->mon_decimal_point == NULL ||
diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/xpg7/numeric_members.cc
similarity index 90%
rename from libstdc++-v3/config/locale/dragonfly/numeric_members.cc
rename to libstdc++-v3/config/locale/xpg7/numeric_members.cc
index cac6fe8c710..5ee61f0fbb4 100644
--- a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/numeric_members.cc
@@ -1,4 +1,4 @@
-// std::numpunct implementation details, DragonFly version -*- C++ -*-
+// std::numpunct implementation details, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
@@ -28,10 +28,14 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <cstring>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -63,7 +67,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -103,6 +112,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -113,6 +125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
@@ -162,7 +177,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef _GLIBCXX_HAVE_LOCALECONV_L
 	  lconv* lc = localeconv_l((locale_t) __cloc);
+#else
+	  __c_locale __old = uselocale(__cloc);
+	  lconv* lc = localeconv();
+#endif
 
 	  // Decimal point should always be defined, but check null anyway
 	  if (lc->decimal_point == NULL)
@@ -201,6 +221,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    {
 		      delete _M_data;
 		      _M_data = 0;
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+		      uselocale(__old);
+#endif
 		      __throw_exception_again;
 		    }
 		}
@@ -211,6 +234,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		}
 	      _M_data->_M_grouping_size = __len;
 	    }
+#ifndef _GLIBCXX_HAVE_LOCALECONV_L
+	  uselocale(__old);
+#endif
 	}
 
       // NB: There is no way to extact this info from posix locales.
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc b/libstdc++-v3/config/locale/xpg7/time_members.cc
similarity index 92%
rename from libstdc++-v3/config/locale/dragonfly/time_members.cc
rename to libstdc++-v3/config/locale/xpg7/time_members.cc
index c8b621a323f..fb287332c44 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.cc
+++ b/libstdc++-v3/config/locale/xpg7/time_members.cc
@@ -1,4 +1,4 @@
-// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
+// std::time_get, std::time_put implementation, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2001-2021 Free Software Foundation, Inc.
 //
@@ -29,13 +29,17 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 // Modified for DragonFly by John Marino <gnugcc@marino.st>
+// Modified for XPG7 by Clément Chigot <clement.chigot@atos.net>
 
 #include <locale>
 #include <ctime>
 #include <cwchar>
 #include <stdlib.h>
 #include <langinfo.h>
+
+#ifdef _GLIBCXX_HAVE_XLOCALE_H
 #include <xlocale.h>
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -47,8 +51,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(char* __s, size_t __maxlen, const char* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_STRFTIME_L
       const size_t __len = strftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = strftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = '\0';
@@ -196,15 +206,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
 	   const tm* __tm) const throw()
     {
+#ifdef _GLIBCXX_HAVE_WCSFTIME_L
       const size_t __len = wcsftime_l(__s, __maxlen, __format, __tm,
 				      (locale_t)_M_c_locale_timepunct);
+#else
+      __c_locale __old = uselocale(_M_c_locale_timepunct);
+      const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
+      uselocale(__old);
+#endif
       // Make sure __s is null terminated.
       if (__len == 0)
 	__s[0] = L'\0';
     }
 
+#ifdef _GLIBCXX_HAVE_MBSTOWCS_L
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs_l (WCSTRING, STRING, NUMBER, LOCALE);
+#else
+  // "uselocale" must be called before using this macro.
+#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE)	\
+  mbstowcs (WCSTRING, STRING, NUMBER);
+#endif
 #define WIDE_LANGINFO(M,FMT) \
-	fmtlen = mbstowcs_l (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
+	fmtlen = MBSTOWCS_L (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \
 		128, (locale_t)__cloc); \
 	langstring = new wchar_t[fmtlen + 1]; \
 	wcsncpy (langstring, holder, fmtlen); \
@@ -281,6 +305,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       else
 	{
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  __c_locale __old = uselocale(__cloc);
+#endif
 	  wchar_t *langstring = 0;
 	  wchar_t holder[128];
 	  size_t fmtlen;
@@ -342,6 +369,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  WIDE_LANGINFO(_M_amonth10, ABMON_10)
 	  WIDE_LANGINFO(_M_amonth11, ABMON_11)
 	  WIDE_LANGINFO(_M_amonth12, ABMON_12)
+#ifndef _GLIBCXX_HAVE_MBSTOWCS_L
+	  uselocale(__old);
+#endif
 	}
     }
 
diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.h b/libstdc++-v3/config/locale/xpg7/time_members.h
similarity index 97%
rename from libstdc++-v3/config/locale/dragonfly/time_members.h
rename to libstdc++-v3/config/locale/xpg7/time_members.h
index 04b7e995d6f..1457d4cce32 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.h
+++ b/libstdc++-v3/config/locale/xpg7/time_members.h
@@ -1,4 +1,4 @@
-// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
+// std::time_get, std::time_put implementation, XPG7 version -*- C++ -*-
 
 // Copyright (C) 2015-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/config/os/aix/ctype_configure_char.cc b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
index b12c0bd435c..9cbfd0317b5 100644
--- a/libstdc++-v3/config/os/aix/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/aix/ctype_configure_char.cc
@@ -42,28 +42,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   ctype<char>::classic_table() throw()
   { return 0; }
 
-  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
+  ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
-  _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
-  {
-    memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
-    memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
-  }
+    : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
+    _M_del(__table != 0 && __del),
+    _M_toupper(NULL), _M_tolower(NULL),
+    _M_table(__table ? __table : classic_table()),
+    _M_widen_ok(0), _M_narrow_ok(0)
+    {
+      memset(_M_widen, 0, sizeof(_M_widen));
+      memset(_M_narrow, 0, sizeof(_M_narrow));
+    }
 
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
-  _M_toupper(NULL), _M_tolower(NULL),
-  _M_table(__table ? __table : classic_table())
-  {
-    memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
-    memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
-  }
+    : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+    _M_del(__table != 0 && __del),
+    _M_toupper(NULL), _M_tolower(NULL),
+    _M_table(__table ? __table : classic_table()),
+    _M_widen_ok(0), _M_narrow_ok(0)
+    {
+      memset(_M_widen, 0, sizeof(_M_widen));
+      memset(_M_narrow, 0, sizeof(_M_narrow));
+    }
 
   char
   ctype<char>::do_toupper(char __c) const
diff --git a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
index d6ab73175b8..d909feefca3 100644
--- a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc
@@ -38,7 +38,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // Information as gleaned from /usr/include/ctype.h
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   const ctype_base::mask*
   ctype<char>::classic_table() throw()
   { return _S_get_c_locale()->__ctype_b; }
@@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
   : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
@@ -117,7 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
-#if _GLIBCXX_C_LOCALE_GNU
+#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_XPG7
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
   : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
   _M_del(__table != 0 && __del),
diff --git a/libstdc++-v3/config/os/solaris/ctype_configure_char.cc b/libstdc++-v3/config/os/solaris/ctype_configure_char.cc
index 430c007ee2f..a1e0cf2fd31 100644
--- a/libstdc++-v3/config/os/solaris/ctype_configure_char.cc
+++ b/libstdc++-v3/config/os/solaris/ctype_configure_char.cc
@@ -42,27 +42,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   ctype<char>::classic_table() throw()
   { return __ctype_mask; }
 
-  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
+  ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
 		     size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+  : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
+  _M_del(__table != 0 && __del),
   _M_toupper(__trans_upper), _M_tolower(__trans_lower),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
-  : facet(__refs), _M_del(__table != 0 && __del),
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
+  _M_del(__table != 0 && __del),
   _M_toupper(__trans_upper), _M_tolower(__trans_lower),
-  _M_table(__table ? __table : classic_table())
+  _M_table(__table ? __table : classic_table()),
+  _M_widen_ok(0), _M_narrow_ok(0)
   {
     memset(_M_widen, 0, sizeof(_M_widen));
-    _M_widen_ok = 0;
     memset(_M_narrow, 0, sizeof(_M_narrow));
-    _M_narrow_ok = 0;
   }
 
   char
diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc
index 4bec50bf595..dcea799aeaf 100644
--- a/libstdc++-v3/src/c++98/locale_init.cc
+++ b/libstdc++-v3/src/c++98/locale_init.cc
@@ -296,7 +296,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _S_global = __other._M_impl;
       const string __other_name = __other.name();
       if (__other_name != "*")
+#ifdef _GLIBCXX_C_LOCALE_GNU
 	setlocale(LC_ALL, __other_name.c_str());
+#else
+        {
+	  // In general, passing "LC_CTYPE=C;LC_NUMERIQUE=C;..." as
+	  // argument to setlocale isn't allowed.
+	  if (__other._M_impl->_M_check_same_name())
+	    setlocale(LC_ALL, __other_name.c_str());
+	  else
+	    for (size_t __i = 0; __i < __other._S_categories_size; ++__i)
+	      setlocale(__i, __other._M_impl->_M_names[__i]);
+	}
+#endif
     }
 
     // Reference count sanity check: one reference removed for the
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
index ea0c43a20fc..71e198843d2 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
index 54206f8000a..ffde94108a1 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO-8859-15" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
index f27d667daf5..9193b598162 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
index b5383af657c..e4b428c9fc6 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
index 1d40a1723a4..ffbd856640b 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
index 9801e085683..5e42a373547 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
index f70d0fc6c58..01bf1a57917 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
index 5cde0b66331..25dfa02b99d 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
index 1e4ce5a8e3e..5d00a62c9a9 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // 2003-02-06  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
index 5254c967018..1f2869e43f6 100644
--- a/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/2.cc
@@ -1,5 +1,5 @@
-// { dg-do run { xfail { ! { *-*-linux* *-*-gnu* } } } }
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu xpg7" }
 
 // Copyright (C) 2000-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
index a60e98eee76..0cfcc042b1c 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2006-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
index 8d8f07f01cc..94fcfe3ac8b 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/38368.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2008-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
index 6a8eff8737b..d41ee12603b 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/40184.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "ja_JP.eucJP" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2009-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
index 66b939e2228..99abf566b81 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
@@ -3,6 +3,7 @@
 // { dg-require-namedlocale "es_MX" }
 // { dg-require-namedlocale "fr_FR" }
 // { dg-require-namedlocale "it_IT" }
+// { dg-require-localemodel "gnu" }
 
 // 2000-09-13 Benjamin Kosnik <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
index ea3992b03f6..30d4a31a64c 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc
@@ -1,5 +1,6 @@
 // { dg-require-namedlocale "is_IS.ISO8859-1" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2004-02-09  Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/13631.cc b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
index b8ae3d4f140..2509bba0845 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/13631.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
index c4d972124f0..fdf4a0af018 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
index 81d914f5c37..3345f43b342 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
index 5a503ef2c49..1d2f7ad3162 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/3.cc
@@ -1,5 +1,6 @@
 // { dg-require-namedlocale "en_US.ISO8859-1" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
index 35e7f6c740c..976b4d9fbf6 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_env.cc
@@ -1,6 +1,7 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
index a44bf1476b2..b143d33a4cc 100644
--- a/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages/members/char/wrapped_locale.cc
@@ -2,6 +2,7 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
 // { dg-require-namedlocale "fr_FR.ISO8859-15" }
 // { dg-require-namedlocale "en_US.ISO8859-1" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
index 1006f20c996..fabf281d3e6 100644
--- a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "de_DE.ISO8859-15" }
+// { dg-require-localemodel "gnu" }
 
 // 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
 
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
index c747f7bfb02..46713cca118 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
index 76a387768fe..a3a4bbf5833 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
index 24d192921cb..2a314589714 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
index 2c0a2ab61db..71393bbd255 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale "en_US.UTF-8" }
+// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } }
 
 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 872768f2620..8474e8df14b 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -88,6 +88,15 @@ proc dg-require-namedlocale { args } {
     return
 }
 
+proc dg-require-localemodel { args } {
+    if { ![ check_v3_target_localemodel [lindex $args 1] ] } {
+	upvar dg-do-what dg-do-what
+	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+	return
+    }
+    return
+}
+
 proc dg-require-sharedlib { args } {
     if { ![ check_v3_target_sharedlib ] } {
 	upvar dg-do-what dg-do-what
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 73b202ce212..bb3e34400e4 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -895,6 +895,11 @@ proc check_v3_target_namedlocale { args } {
 	puts $f "    strcpy(result, name);"
 	puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
 	puts $f "    /* fall-through */"
+	puts $f "#elif defined _AIX"
+	puts $f "    char *p = strstr(result, \"ISO8859-15\");"
+	puts $f "    if (p) {"
+	puts $f "       strcpy(p, \"8859-15\");"
+	puts $f "    }"
 	puts $f "#else"
 	puts $f "    if (strstr(result, \"ISO8859-15\")) {"
 	puts $f "        strcat(result, \"@euro\");"
@@ -945,6 +950,32 @@ proc check_v3_target_namedlocale { args } {
     }]
 }
 
+# Return 1 if the locale model is implemented.
+proc check_v3_target_localemodel { args } {
+    set key "et_locale $args"
+    return [check_v3_target_prop_cached $key {
+	global cxxflags
+	global DEFAULT_CXXFLAGS
+
+	set cond "0"
+	if [string match "*gnu*" $args] {
+	    set cond " $cond || defined _GLIBCXX_C_LOCALE_GNU"
+	}
+	if [string match "*xpg7*" $args] {
+	    set cond " $cond || defined _GLIBCXX_C_LOCALE_XPG7"
+	}
+
+	set code "
+	#include <bits/c++locale.h>
+	#if ! ($cond)
+	#error '$cond' is false
+	#endif
+	"
+	set flags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+	return [v3_try_preprocess name $code $flags]
+    }]
+}
+
 # Returns 1 if the tokens in CODE can be preprocessed successfully using FLAGS,
 # returns 0 otherwise.
 proc v3_try_preprocess { name code flags } {
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index b5e0767211a..a632f5f31f8 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -77,6 +77,9 @@
 
 #if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__
 # define ISO_8859(part,langTERR) #langTERR ".ISO8859-" #part
+#elif defined _AIX
+# define ISO_8859(part,langTERR) ((part) == 15 ?\
+         #langTERR ".8859-" #part : #langTERR ".ISO8859-" #part)
 #else
 # define ISO_8859(part,langTERR) ((part) == 15 ?\
          #langTERR ".ISO8859-" #part "@euro" : #langTERR ".ISO8859-" #part)
-- 
2.31.1


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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-07-21 12:00                                                             ` CHIGOT, CLEMENT
@ 2021-07-21 13:04                                                               ` Rainer Orth
  2021-07-22 12:09                                                                 ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-07-21 13:04 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: libstdc++, Jonathan Wakely, David Edelsohn

Hi Clement,

> Here is a new version of the patch with the Solaris part 
> made by Rainer directly integrated in it. 

fine, thanks.

> Rainer did you change anything in the configure file or 
> did you just pass XPG7 model with the configure option ? 

When I last tested it, I just configured with --enable-clocale=xpg7.

> I guess if it works fine on Solaris target, it can be 
> directly chosen inside the configure. 

Agreed, however right now we're not even close for that.

> A part from that it would be good if someone familiar with
> freebsd or dragonfly can take a look at it. There shouldn't be
> any problems but it needs to be tested and a few #ifdef remain
> for these two targets. 

I'd tried DragonflyBSD quite some time ago, but couldn't even get it to
boot in VirtualBox and didn't want to spend too much time on it.

However, the last i586-unknown-freebsd11.4 test results for unmodified
trunk are still terrible, showing 101 FAILs in libstdc++, a large number
among those being locale tests.  I had seen (not unexpectedly) similarly
abysmal results when I tried an earlier version of your patch on (I
believe) FreeBSD 12 in VirtualBox some time ago, which made me question
if that clocale implementation is a good basis for xpg7 if it doesn't
even work on the target it's supposed to support.

Could you please share the libstdc++-v3 mail-report.log snippet you get
on AIX with your latest patch as a point of comparison?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-07-21 13:04                                                               ` Rainer Orth
@ 2021-07-22 12:09                                                                 ` CHIGOT, CLEMENT
  2021-07-22 12:19                                                                   ` Rainer Orth
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-07-22 12:09 UTC (permalink / raw)
  To: Rainer Orth; +Cc: libstdc++, Jonathan Wakely, David Edelsohn

Hi Rainer,

>> A part from that it would be good if someone familiar with
>> freebsd or dragonfly can take a look at it. There shouldn't be
>> any problems but it needs to be tested and a few #ifdef remain
>> for these two targets.
>
> I'd tried DragonflyBSD quite some time ago, but couldn't even get it to
> boot in VirtualBox and didn't want to spend too much time on it.
>
> However, the last i586-unknown-freebsd11.4 test results for unmodified
> trunk are still terrible, showing 101 FAILs in libstdc++, a large number
> among those being locale tests.  I had seen (not unexpectedly) similarly
> abysmal results when I tried an earlier version of your patch on (I
> believe) FreeBSD 12 in VirtualBox some time ago, which made me question
> if that clocale implementation is a good basis for xpg7 if it doesn't
> even work on the target it's supposed to support.
>
> Could you please share the libstdc++-v3 mail-report.log snippet you get
> on AIX with your latest patch as a point of comparison?

Here are the result for AIX 32bit. Those are a bit different in 64bit but not much.
However, I don't have all the locale installed so some are skipped.

Native configuration is powerpc-ibm-aix7.2.3.0

                === libstdc++ tests ===


Running target unix
FAIL: 17_intro/headers/c++1998/charset.cc (test for excess errors)
FAIL: 17_intro/headers/c++2011/charset.cc (test for excess errors)
FAIL: 17_intro/headers/c++2014/charset.cc (test for excess errors)
FAIL: 17_intro/headers/c++2017/charset.cc (test for excess errors)
FAIL: 17_intro/headers/c++2020/charset.cc (test for excess errors)
UNRESOLVED: 22_locale/codecvt/in/wchar_t/4.cc compilation failed to produce executable
UNRESOLVED: 22_locale/codecvt/in/wchar_t/8.cc compilation failed to produce executable
UNRESOLVED: 22_locale/codecvt/in/wchar_t/9.cc compilation failed to produce executable
UNRESOLVED: 22_locale/codecvt/length/wchar_t/4.cc compilation failed to produce executable
FAIL: 22_locale/codecvt/max_length/wchar_t/4.cc execution test
UNRESOLVED: 22_locale/codecvt/out/wchar_t/4.cc compilation failed to produce executable
UNRESOLVED: 22_locale/codecvt/unshift/wchar_t/4.cc compilation failed to produce executable
FAIL: 22_locale/ctype/is/char/wrapped_env.cc execution test
FAIL: 22_locale/time_get/get_date/char/12750.cc execution test
FAIL: 22_locale/time_get/get_date/wchar_t/12750.cc execution test
FAIL: 22_locale/time_put/put/char/2.cc execution test
FAIL: 22_locale/time_put/put/wchar_t/2.cc execution test
FAIL: 23_containers/unordered_map/96088.cc execution test
FAIL: 23_containers/unordered_multimap/96088.cc execution test
FAIL: 23_containers/unordered_multiset/96088.cc execution test
FAIL: 23_containers/unordered_set/96088.cc execution test
FAIL: 27_io/filesystem/iterators/directory_iterator.cc execution test
FAIL: 27_io/filesystem/iterators/recursive_directory_iterator.cc execution test
FAIL: 27_io/filesystem/operations/canonical.cc execution test
FAIL: 27_io/filesystem/operations/exists.cc execution test
FAIL: 27_io/filesystem/operations/is_empty.cc execution test
FAIL: 27_io/filesystem/operations/remove.cc execution test
FAIL: 27_io/filesystem/operations/remove_all.cc execution test
FAIL: 27_io/filesystem/operations/status.cc execution test
FAIL: 27_io/filesystem/operations/symlink_status.cc execution test
FAIL: 27_io/filesystem/operations/temp_directory_path.cc execution test
FAIL: 27_io/filesystem/operations/weakly_canonical.cc execution test
FAIL: 27_io/manipulators/extended/get_time/char/2.cc execution test
FAIL: decimal/binary-arith.cc (test for excess errors)
UNRESOLVED: decimal/binary-arith.cc compilation failed to produce executable
FAIL: decimal/comparison.cc (test for excess errors)
UNRESOLVED: decimal/comparison.cc compilation failed to produce executable
FAIL: decimal/compound-assignment-memfunc.cc (test for excess errors)
UNRESOLVED: decimal/compound-assignment-memfunc.cc compilation failed to produce executable
FAIL: decimal/compound-assignment.cc (test for excess errors)
UNRESOLVED: decimal/compound-assignment.cc compilation failed to produce executable
FAIL: decimal/make-decimal.cc (test for excess errors)
UNRESOLVED: decimal/make-decimal.cc compilation failed to produce executable
FAIL: decimal/pr54036-1.cc (test for excess errors)
UNRESOLVED: decimal/pr54036-1.cc compilation failed to produce executable
FAIL: decimal/pr54036-2.cc (test for excess errors)
UNRESOLVED: decimal/pr54036-2.cc compilation failed to produce executable
FAIL: decimal/pr54036-3.cc (test for excess errors)
UNRESOLVED: decimal/pr54036-3.cc compilation failed to produce executable
FAIL: decimal/unary-arith.cc (test for excess errors)
UNRESOLVED: decimal/unary-arith.cc compilation failed to produce executable
FAIL: experimental/filesystem/iterators/directory_iterator.cc execution test
FAIL: experimental/filesystem/iterators/recursive_directory_iterator.cc execution test
FAIL: experimental/filesystem/operations/exists.cc execution test
FAIL: experimental/filesystem/operations/is_empty.cc execution test
FAIL: experimental/filesystem/operations/remove.cc execution test
FAIL: experimental/filesystem/operations/remove_all.cc execution test
FAIL: experimental/filesystem/operations/temp_directory_path.cc execution test
FAIL: ext/codecvt/wchar_t.cc execution test

                === libstdc++ Summary ===

# of expected passes            13692
# of unexpected failures        44
# of expected failures          114
# of unresolved testcases       15
# of unsupported tests          559


If you can, can you show me the result for FreeBSD, I might have already
encountered some of the failures while developing AIX version.

Thanks,
Clément




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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-07-22 12:09                                                                 ` CHIGOT, CLEMENT
@ 2021-07-22 12:19                                                                   ` Rainer Orth
  2021-07-30 14:02                                                                     ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: Rainer Orth @ 2021-07-22 12:19 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: libstdc++, Jonathan Wakely, David Edelsohn

Hi Clement,

>>> A part from that it would be good if someone familiar with
>>> freebsd or dragonfly can take a look at it. There shouldn't be
>>> any problems but it needs to be tested and a few #ifdef remain
>>> for these two targets.
>>
>> I'd tried DragonflyBSD quite some time ago, but couldn't even get it to
>> boot in VirtualBox and didn't want to spend too much time on it.
>>
>> However, the last i586-unknown-freebsd11.4 test results for unmodified
>> trunk are still terrible, showing 101 FAILs in libstdc++, a large number
>> among those being locale tests.  I had seen (not unexpectedly) similarly
>> abysmal results when I tried an earlier version of your patch on (I
>> believe) FreeBSD 12 in VirtualBox some time ago, which made me question
>> if that clocale implementation is a good basis for xpg7 if it doesn't
>> even work on the target it's supposed to support.
>>
>> Could you please share the libstdc++-v3 mail-report.log snippet you get
>> on AIX with your latest patch as a point of comparison?
>
> Here are the result for AIX 32bit. Those are a bit different in 64bit but
> not much.
> However, I don't have all the locale installed so some are skipped.
>
> Native configuration is powerpc-ibm-aix7.2.3.0
>
>                 === libstdc++ tests ===
[...]
>                 === libstdc++ Summary ===
>
> # of expected passes            13692
> # of unexpected failures        44
> # of expected failures          114
> # of unresolved testcases       15
> # of unsupported tests          559

Those are even worse than the Solaris ones:

                === libstdc++ Summary for unix ===

# of expected passes            15153
# of unexpected failures        29
# of expected failures          97
# of unsupported tests          504

> If you can, can you show me the result for FreeBSD, I might have already
> encountered some of the failures while developing AIX version.

The latest I see on gcc-testresults are here:

https://gcc.gnu.org/pipermail/gcc-testresults/2021-July/708163.html

I haven't fired up my FreeBSD VM in a long time, but I expect Gerald
will easily be able to provide more details.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-07-22 12:19                                                                   ` Rainer Orth
@ 2021-07-30 14:02                                                                     ` CHIGOT, CLEMENT
  2022-03-16  9:57                                                                       ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2021-07-30 14:02 UTC (permalink / raw)
  To: Rainer Orth, gerald; +Cc: libstdc++, Jonathan Wakely, David Edelsohn

Hi guys, 

> Those are even worse than the Solaris ones
Yes, but many of them aren't related to my patch. 
And the ones related will have to wait for futures patches.
Most of them are just details of AIX being not standard, or 
I don't have a single idea about what's wrong. 

> I haven't fired up my FreeBSD VM in a long time, but I expect Gerald
> will easily be able to provide more details.
I see that Gerald have been put in CC. 
Gerald would it be possible to know why most of the 22_locale tests 
are failing on FreeBSD and if my patch provide worst or better 
results than now ? 

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

* Re: [PATCH] libstdc++: implement locale support for AIX
  2021-07-30 14:02                                                                     ` CHIGOT, CLEMENT
@ 2022-03-16  9:57                                                                       ` CHIGOT, CLEMENT
  0 siblings, 0 replies; 43+ messages in thread
From: CHIGOT, CLEMENT @ 2022-03-16  9:57 UTC (permalink / raw)
  To: Rainer Orth, gerald
  Cc: libstdc++, Jonathan Wakely, David Edelsohn, Sangamesh Mallayya, pro

Hi everyone,

It's been a while since I haven't made an update on this patch. 
I didn't had much time to work on it and fully finalize it especially by testing Freebsd support. 
However, I won't work for AIX anymore but this end of this month. Thus Sangamesh will take care of this patch and complete it so it can be merged to GCC. 

I'm adding my personal mail in order to answer a few questions and follow it. But I won't have access to AIX anymore and will work on other subjects. 

Thanks and sorry to having been able to merge it before leaving. 
Clement

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

end of thread, other threads:[~2022-03-16  9:58 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <PA4PR02MB6686075C6C254E583B72BC2AEAAB0@PA4PR02MB6686.eurprd02.prod.outlook.com>
     [not found] ` <CAGWvny=XpcWGnyb=MWg5ziYSND7O1AnQ6-NAX811p1b5urH0YA@mail.gmail.com>
2021-01-11 15:35   ` [PATCH] libstdc++: implement locale support for AIX Rainer Orth
2021-01-11 15:40     ` Jonathan Wakely
2021-01-11 15:56       ` CHIGOT, CLEMENT
2021-01-11 22:20         ` David Edelsohn
2021-01-12 15:14           ` CHIGOT, CLEMENT
2021-01-12 15:23             ` CHIGOT, CLEMENT
2021-01-12 15:25             ` Jonathan Wakely
2021-01-12 15:40               ` CHIGOT, CLEMENT
2021-01-12 15:44               ` David Edelsohn
2021-01-12 17:34                 ` Jonathan Wakely
2021-01-12 15:52               ` Rainer Orth
2021-01-12 17:41                 ` Rainer Orth
2021-01-12 17:44                   ` David Edelsohn
2021-01-12 19:58                     ` Rainer Orth
2021-01-13 11:57                       ` Rainer Orth
2021-01-13 12:23                         ` CHIGOT, CLEMENT
2021-01-13 12:31                           ` Rainer Orth
2021-01-13 12:41                             ` CHIGOT, CLEMENT
2021-01-13 12:47                               ` Rainer Orth
2021-01-21 12:48                                 ` CHIGOT, CLEMENT
2021-01-21 16:36                                   ` Rainer Orth
2021-01-22  9:57                                     ` CHIGOT, CLEMENT
2021-01-22 11:04                                       ` Rainer Orth
2021-01-22 11:29                                         ` Jonathan Wakely
2021-01-22 11:54                                           ` Rainer Orth
2021-01-22 12:23                                             ` CHIGOT, CLEMENT
2021-01-27 12:52                                               ` CHIGOT, CLEMENT
2021-01-27 14:26                                                 ` Rainer Orth
2021-01-27 14:44                                                   ` CHIGOT, CLEMENT
2021-01-28 10:09                                                     ` CHIGOT, CLEMENT
2021-05-17  9:17                                                       ` CHIGOT, CLEMENT
2021-06-08  6:59                                                         ` CHIGOT, CLEMENT
2021-06-09 14:50                                                           ` Rainer Orth
2021-07-21 12:00                                                             ` CHIGOT, CLEMENT
2021-07-21 13:04                                                               ` Rainer Orth
2021-07-22 12:09                                                                 ` CHIGOT, CLEMENT
2021-07-22 12:19                                                                   ` Rainer Orth
2021-07-30 14:02                                                                     ` CHIGOT, CLEMENT
2022-03-16  9:57                                                                       ` CHIGOT, CLEMENT
2021-01-22 11:12                                       ` Jonathan Wakely
2021-01-22 11:02                                     ` Jonathan Wakely
2021-01-12 16:00             ` Rainer Orth
     [not found]   ` <PA4PR02MB6686C2022E2B42D82DC9F269EAAB0@PA4PR02MB6686.eurprd02.prod.outlook.com>
2021-01-11 15:38     ` Rainer Orth

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