Allow forcing use of POSIX 2008 locale fcns
authorKarl Williamson <khw@cpan.org>
Mon, 19 Nov 2018 20:59:56 +0000 (13:59 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 19 Nov 2018 21:53:11 +0000 (14:53 -0700)
These thread-safe functions are not normally used on unthreaded builds,
retaining the use of the library functions that have long been used.
But, it is now possible to tell Configure to use them on unthreaded
builds.

makedef.pl
perl.h
pod/perldelta.pod
pod/perllocale.pod

index 6b97ad0..3c541d8 100644 (file)
@@ -129,7 +129,7 @@ if ($define{USE_ITHREADS} && $ARGS{PLATFORM} ne 'win32' && $ARGS{PLATFORM} ne 'n
     $define{USE_REENTRANT_API} = 1;
 }
 
-if (     $define{USE_ITHREADS}
+if (    ($define{USE_ITHREADS} || $define{USE_THREAD_SAFE_LOCALE})
     &&   $define{HAS_SETLOCALE}
     && ! $define{NO_LOCALE}
     && ! $define{NO_POSIX_2008_LOCALE})
@@ -386,7 +386,6 @@ unless ($define{'USE_ITHREADS'}) {
     ++$skip{$_} foreach qw(
                     PL_keyword_plugin_mutex
                    PL_check_mutex
-                    PL_curlocales
                    PL_op_mutex
                    PL_regex_pad
                    PL_regex_padav
@@ -425,10 +424,17 @@ unless ($define{'USE_ITHREADS'}) {
                    Perl_stashpv_hvname_match
                    Perl_regdupe_internal
                    Perl_newPADOP
-                    PL_C_locale_obj
                         );
 }
 
+unless ($define{USE_ITHREADS} || $define{USE_THREAD_SAFE_LOCALE})
+{
+    ++$skip{$_} foreach qw(
+        PL_C_locale_obj
+        PL_curlocales
+    );
+}
+
 unless ( $define{'HAS_NEWLOCALE'}
     &&   $define{'HAS_FREELOCALE'}
     &&   $define{'HAS_USELOCALE'}
diff --git a/perl.h b/perl.h
index ffa0e03..e436e03 100644 (file)
--- a/perl.h
+++ b/perl.h
 
 #    define HAS_POSIX_2008_LOCALE
 #  endif
-#  if     defined(USE_ITHREADS)                                             \
+                                   /* If compiled with
+                                    * -DUSE_THREAD_SAFE_LOCALE, will do so even
+                                    * on unthreaded builds */
+#  if    (defined(USE_ITHREADS) || defined(USE_THREAD_SAFE_LOCALE))         \
       && (    defined(HAS_POSIX_2008_LOCALE)                                \
           || (defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400))     \
       && ! defined(NO_THREAD_SAFE_LOCALE)
-#    define USE_THREAD_SAFE_LOCALE
+#    ifndef USE_THREAD_SAFE_LOCALE
+#      define USE_THREAD_SAFE_LOCALE
+#    endif
 #    ifdef HAS_POSIX_2008_LOCALE
 #      define USE_POSIX_2008_LOCALE
 #    endif
index 7332175..62dbd34 100644 (file)
@@ -264,7 +264,10 @@ L</Platform Support> section, instead.
 
 =item *
 
-XXX
+Normally the thread-safe functions used only on threaded builds.
+It is now possible to force their use on unthreaded builds on systems
+that have them available, by including the
+C<-Accflags='-DUSE_THREAD_SAFE_LOCALE'> option to F<Configure>.
 
 =back
 
index 207aea0..63f8947 100644 (file)
@@ -517,6 +517,11 @@ from using thread-safe locales.
 C<${^SAFE_LOCALES}> will be 0 on systems that turn off the thread-safe
 operations.
 
+Normally on unthreaded builds, the traditional C<setlocale()> is used
+and not the thread-safe locale functions.  You can force the use of these
+on systems that have them by adding the
+C<-Accflags='-DUSE_THREAD_SAFE_LOCALE'> to F<Configure>.
+
 The initial program is started up using the locale specified from the
 environment, as currently, described in L</ENVIRONMENT>.   All newly
 created threads start with C<LC_ALL> set to C<"C">>.  Each thread may