This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add locale mutex
authorKarl Williamson <khw@cpan.org>
Thu, 7 Apr 2016 03:46:28 +0000 (21:46 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 9 Apr 2016 19:59:24 +0000 (13:59 -0600)
This adds a new mutex for use in the next commit for use with locale
handling.

12 files changed:
dosish.h
embedvar.h
makedef.pl
perl.c
perl.h
perlapi.h
perlvars.h
symbian/symbianish.h
unixish.h
vms/vmsish.h
win32/win32.c
win32/wince.c

index 2e4e745..c1305cd 100644 (file)
--- a/dosish.h
+++ b/dosish.h
@@ -52,9 +52,9 @@
 #endif /* DJGPP */
 
 #ifndef PERL_SYS_TERM_BODY
-#  define PERL_SYS_TERM_BODY() \
-    HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM; \
-    OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM
+#  define PERL_SYS_TERM_BODY()                              \
+    HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM;                 \
+    OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; LOCALE_TERM;
 #endif
 #define dXSUB_SYS
 
index c366d47..7e551be 100644 (file)
 #define PL_Ghints_mutex                (my_vars->Ghints_mutex)
 #define PL_keyword_plugin      (my_vars->Gkeyword_plugin)
 #define PL_Gkeyword_plugin     (my_vars->Gkeyword_plugin)
+#define PL_locale_mutex                (my_vars->Glocale_mutex)
+#define PL_Glocale_mutex       (my_vars->Glocale_mutex)
 #define PL_malloc_mutex                (my_vars->Gmalloc_mutex)
 #define PL_Gmalloc_mutex       (my_vars->Gmalloc_mutex)
 #define PL_mmap_page_size      (my_vars->Gmmap_page_size)
index 78ee0b1..104696c 100644 (file)
@@ -364,6 +364,7 @@ unless ($define{'USE_ITHREADS'}) {
                    PL_regex_padav
                    PL_dollarzero_mutex
                    PL_hints_mutex
+                   PL_locale_mutex
                    PL_my_ctx_mutex
                    PL_perlio_mutex
                    PL_stashpad
diff --git a/perl.c b/perl.c
index 8c8eec1..228a0d8 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -93,6 +93,7 @@ S_init_tls_and_interp(PerlInterpreter *my_perl)
        OP_REFCNT_INIT;
        OP_CHECK_MUTEX_INIT;
        HINTS_REFCNT_INIT;
+        LOCALE_INIT;
        MUTEX_INIT(&PL_dollarzero_mutex);
        MUTEX_INIT(&PL_my_ctx_mutex);
 #  endif
diff --git a/perl.h b/perl.h
index fd716c3..49330d1 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5954,6 +5954,10 @@ typedef struct am_table_short AMTS;
 
 #ifdef USE_LOCALE
 /* These locale things are all subject to change */
+
+#   define LOCALE_INIT   MUTEX_INIT(&PL_locale_mutex)
+#   define LOCALE_TERM   MUTEX_DESTROY(&PL_locale_mutex)
+
 /* Returns TRUE if the plain locale pragma without a parameter is in effect
  */
 #   define IN_LOCALE_RUNTIME   cBOOL(CopHINTS_get(PL_curcop) & HINT_LOCALE)
@@ -6037,6 +6041,8 @@ typedef struct am_table_short AMTS;
 #   endif   /* PERL_CORE or PERL_IN_XSUB_RE */
 
 #else   /* No locale usage */
+#   define LOCALE_INIT
+#   define LOCALE_TERM
 #   define IN_LOCALE_RUNTIME                0
 #   define IN_SOME_LOCALE_FORM_RUNTIME      0
 #   define IN_LOCALE_COMPILETIME            0
index 910f789..7aa4455 100644 (file)
--- a/perlapi.h
+++ b/perlapi.h
@@ -123,6 +123,8 @@ END_EXTERN_C
 #define PL_hints_mutex         (*Perl_Ghints_mutex_ptr(NULL))
 #undef  PL_keyword_plugin
 #define PL_keyword_plugin      (*Perl_Gkeyword_plugin_ptr(NULL))
+#undef  PL_locale_mutex
+#define PL_locale_mutex                (*Perl_Glocale_mutex_ptr(NULL))
 #undef  PL_malloc_mutex
 #define PL_malloc_mutex                (*Perl_Gmalloc_mutex_ptr(NULL))
 #undef  PL_mmap_page_size
index 86a369e..5466294 100644 (file)
@@ -99,6 +99,8 @@ PERLVARI(G, mmap_page_size, IV, 0)
 
 #if defined(USE_ITHREADS)
 PERLVAR(G, hints_mutex, perl_mutex)    /* Mutex for refcounted he refcounting */
+PERLVAR(G, locale_mutex, perl_mutex)   /* Mutex for setlocale() changing */
+
 #endif
 
 #ifdef DEBUGGING
index da5332c..80c580b 100644 (file)
 #define Mkdir(path,mode)   mkdir((path),(mode))
 
 #ifndef PERL_SYS_TERM_BODY
-#define PERL_SYS_TERM_BODY()   HINTS_REFCNT_TERM; OP_REFCNT_TERM; \
-                               PERLIO_TERM; MALLOC_TERM; CloseSTDLIB();
+#define PERL_SYS_TERM_BODY()   HINTS_REFCNT_TERM; OP_REFCNT_TERM;          \
+                               PERLIO_TERM; MALLOC_TERM; CloseSTDLIB();    \
+                                PERL_LOCALE_TERM
+
 #endif
 
 #define BIT_BUCKET "NUL:"
index 5b57138..e05cb6a 100644 (file)
--- a/unixish.h
+++ b/unixish.h
@@ -138,9 +138,10 @@ int afstat(int fd, struct stat *statb);
 #if defined(__amigaos4__)
 #  define PERL_SYS_INIT_BODY(c,v)                                      \
        MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT; amigaos4_init_fork_array(); amigaos4_init_environ_sema();
-#  define PERL_SYS_TERM_BODY() \
-    HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM; \
-    OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; amigaos4_dispose_fork_array(); 
+#  define PERL_SYS_TERM_BODY()                              \
+    HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM;                 \
+    OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; LOCALE_TERM;  \
+    amigaos4_dispose_fork_array();
 #endif
 
 #ifndef PERL_SYS_INIT_BODY
@@ -149,9 +150,10 @@ int afstat(int fd, struct stat *statb);
 #endif
 
 #ifndef PERL_SYS_TERM_BODY
-#  define PERL_SYS_TERM_BODY() \
-    HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM; \
-    OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM;
+#  define PERL_SYS_TERM_BODY()                      \
+    HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM;         \
+    OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM;       \
+    LOCALE_TERM;
 
 #endif
 
index cf1c9a8..1aea829 100644 (file)
@@ -315,7 +315,8 @@ struct interp_intern {
 
 #define BIT_BUCKET "/dev/null"
 #define PERL_SYS_INIT_BODY(c,v)        MALLOC_CHECK_TAINT2(*c,*v) vms_image_init((c),(v)); PERLIO_INIT; MALLOC_INIT
-#define PERL_SYS_TERM_BODY()           HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM
+#define PERL_SYS_TERM_BODY()    HINTS_REFCNT_TERM; OP_REFCNT_TERM;      \
+                                PERLIO_TERM; MALLOC_TERM; LOCALE_TERM
 #define dXSUB_SYS
 #define HAS_KILL
 #define HAS_WAIT
index 651b97b..6ac73e2 100644 (file)
@@ -4529,6 +4529,7 @@ Perl_win32_term(void)
     OP_REFCNT_TERM;
     PERLIO_TERM;
     MALLOC_TERM;
+    LOCALE_TERM;
 #ifndef WIN32_NO_REGISTRY
     /* handles might be NULL, RegCloseKey then returns ERROR_INVALID_HANDLE
        but no point of checking and we can't die() at this point */
index bcc66c8..ce06481 100644 (file)
@@ -2705,6 +2705,7 @@ Perl_win32_term(void)
     OP_REFCNT_TERM;
     PERLIO_TERM;
     MALLOC_TERM;
+    LOCALE_TERM;
 }
 
 void