diff options
author | Karl Williamson <khw@cpan.org> | 2018-08-15 16:11:04 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-02-14 22:12:44 -0700 |
commit | dd52e3cc434f4c6a495379f06a99d35da217eecb (patch) | |
tree | 9ef681fd341f3f879f78d87f14eff767c460aa9e | |
parent | 8310e7fa48c5bce320e9c36df267f587d84cebce (diff) | |
download | perl-dd52e3cc434f4c6a495379f06a99d35da217eecb.tar.gz |
Add global hash to handle \p{user-defined}
A global hash has to be specially handled. The keys can't be shared,
and all the SVs stored into it must be in its thread. This commit adds
the hash, and initialization, and macros for context change, but doesn't
use them. The code to deal with this is entirely confined to regcomp.c.
-rw-r--r-- | embedvar.h | 4 | ||||
-rw-r--r-- | makedef.pl | 1 | ||||
-rw-r--r-- | perlapi.h | 4 | ||||
-rw-r--r-- | perlvars.h | 9 | ||||
-rw-r--r-- | regcomp.c | 25 |
5 files changed, 42 insertions, 1 deletions
diff --git a/embedvar.h b/embedvar.h index 79f5bd04d3..705be5ddf2 100644 --- a/embedvar.h +++ b/embedvar.h @@ -468,6 +468,10 @@ #define PL_Gtimesbase (my_vars->Gtimesbase) #define PL_use_safe_putenv (my_vars->Guse_safe_putenv) #define PL_Guse_safe_putenv (my_vars->Guse_safe_putenv) +#define PL_user_def_props (my_vars->Guser_def_props) +#define PL_Guser_def_props (my_vars->Guser_def_props) +#define PL_user_def_props_aTHX (my_vars->Guser_def_props_aTHX) +#define PL_Guser_def_props_aTHX (my_vars->Guser_def_props_aTHX) #define PL_user_prop_mutex (my_vars->Guser_prop_mutex) #define PL_Guser_prop_mutex (my_vars->Guser_prop_mutex) #define PL_utf8_charname_begin (my_vars->Gutf8_charname_begin) diff --git a/makedef.pl b/makedef.pl index 7e22e02a59..2e4e6dcda0 100644 --- a/makedef.pl +++ b/makedef.pl @@ -353,6 +353,7 @@ if ($define{'PERL_USE_SAFE_PUTENV'}) { unless ($define{'USE_ITHREADS'}) { ++$skip{PL_thr_key}; ++$skip{PL_user_prop_mutex}; + ++$skip{PL_user_def_props_aTHX}; } # USE_5005THREADS symbols. Kept as reference for easier removal @@ -215,6 +215,10 @@ END_EXTERN_C #define PL_timesbase (*Perl_Gtimesbase_ptr(NULL)) #undef PL_use_safe_putenv #define PL_use_safe_putenv (*Perl_Guse_safe_putenv_ptr(NULL)) +#undef PL_user_def_props +#define PL_user_def_props (*Perl_Guser_def_props_ptr(NULL)) +#undef PL_user_def_props_aTHX +#define PL_user_def_props_aTHX (*Perl_Guser_def_props_aTHX_ptr(NULL)) #undef PL_user_prop_mutex #define PL_user_prop_mutex (*Perl_Guser_prop_mutex_ptr(NULL)) #undef PL_utf8_charname_begin diff --git a/perlvars.h b/perlvars.h index 331105e841..51c939e128 100644 --- a/perlvars.h +++ b/perlvars.h @@ -307,8 +307,15 @@ PERLVAR(G, utf8_mark, SV *) PERLVAR(G, InBitmap, SV *) PERLVAR(G, CCC_non0_non230, SV *) +/* Definitions of user-defined \p{} properties, as the subs that define them + * are only called once */ +PERLVARI(G, user_def_props, HV *, NULL) + #if defined(USE_ITHREADS) -PERLVAR(G, user_prop_mutex, perl_mutex) +PERLVAR(G, user_def_props_aTHX, PerlInterpreter *) /* aTHX that user_def_props + was defined in */ +PERLVAR(G, user_prop_mutex, perl_mutex) /* Mutex for manipulating + PL_user_defined_properties */ #endif /* Everything that folds to a given character, for case insensitivity regex @@ -21928,6 +21928,15 @@ S_dumpuntil(pTHX_ const regexp *r, const regnode *start, const regnode *node, void Perl_init_uniprops(pTHX) { + PL_user_def_props = newHV(); + +#ifdef USE_ITHREADS + + HvSHAREKEYS_off(PL_user_def_props); + PL_user_def_props_aTHX = aTHX; + +#endif + /* Set up the inversion list global variables */ PL_XPosix_ptrs[_CC_ASCII] = _new_invlist_C_array(uni_prop_ptrs[UNI_ASCII]); @@ -22007,6 +22016,22 @@ Perl_init_uniprops(pTHX) #endif } +#ifdef USE_ITHREADS +# define DECLARATION_FOR_GLOBAL_CONTEXT \ + PerlInterpreter * save_aTHX = aTHX; +# define SWITCH_TO_GLOBAL_CONTEXT \ + PERL_SET_CONTEXT((aTHX = PL_user_def_props_aTHX)) +# define RESTORE_CONTEXT PERL_SET_CONTEXT((aTHX = save_aTHX)); +# define CUR_CONTEXT aTHX +# define ORIGINAL_CONTEXT save_aTHX +#else +# define DECLARATION_FOR_GLOBAL_CONTEXT +# define SWITCH_TO_GLOBAL_CONTEXT NOOP +# define RESTORE_CONTEXT NOOP +# define CUR_CONTEXT NULL +# define ORIGINAL_CONTEXT NULL +#endif + SV * Perl_parse_uniprop_string(pTHX_ const char * const name, const Size_t name_len, const bool to_fold, bool * invert) |