diff --git a/embed.fnc b/embed.fnc index 7d38ad278b4d..6d806aa38559 100644 --- a/embed.fnc +++ b/embed.fnc @@ -2353,6 +2353,7 @@ p |void |no_bareword_filehandle \ |NN const char *fhname Tefprv |void |noperl_die |NN const char *pat \ |... +CGTdp |void |noshutdownhook Adp |int |nothreadhook p |void |notify_parser_that_encoding_changed : Used in perly.y diff --git a/embed.h b/embed.h index 4877ad370753..8f890fba4df4 100644 --- a/embed.h +++ b/embed.h @@ -452,6 +452,7 @@ # define new_stackinfo(a,b) Perl_new_stackinfo(aTHX_ a,b) # define new_stackinfo_flags(a,b,c) Perl_new_stackinfo_flags(aTHX_ a,b,c) # define new_version(a) Perl_new_version(aTHX_ a) +# define noshutdownhook Perl_noshutdownhook # define nothreadhook() Perl_nothreadhook(aTHX) # define op_append_elem(a,b,c) Perl_op_append_elem(aTHX_ a,b,c) # define op_append_list(a,b,c) Perl_op_append_list(aTHX_ a,b,c) diff --git a/perl.c b/perl.c index 5f51c5d753c5..15127adc50fe 100644 --- a/perl.c +++ b/perl.c @@ -480,6 +480,19 @@ Perl_nothreadhook(pTHX) return 0; } +/* +=for apidoc noshutdownhook + +Stub that provides shutdown hook. + +=cut +*/ + +void +Perl_noshutdownhook() +{ +} + #ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP void Perl_dump_sv_child(pTHX_ SV *sv) diff --git a/perl.h b/perl.h index 3fa6c9526fd4..3a6a6c766753 100644 --- a/perl.h +++ b/perl.h @@ -5350,6 +5350,7 @@ typedef int (*thrhook_proc_t) (pTHX); typedef OP* (*PPADDR_t[]) (pTHX); typedef bool (*destroyable_proc_t) (pTHX_ SV *sv); typedef void (*despatch_signals_proc_t) (pTHX); +typedef void (*shutdown_proc_t)(); #if defined(__DYNAMIC__) && defined(PERL_DARWIN) && defined(PERL_CORE) # include /* for the env array */ diff --git a/perlvars.h b/perlvars.h index 4b49fd06125c..709cd7d19152 100644 --- a/perlvars.h +++ b/perlvars.h @@ -380,6 +380,12 @@ PERLVAR(G, user_prop_mutex, perl_mutex) /* Mutex for manipulating PL_user_defined_properties */ #endif +/* This hook is called during system termination (PERL_SYS_TERM). + * This is needed for tearing down threads::shared and probably + * not be used for anything else. + */ +PERLVARI(G, shutdownhook, shutdown_proc_t, &Perl_noshutdownhook); + /* these record the best way to perform certain IO operations while * atomically setting FD_CLOEXEC. On the first call, a probe is done * and the result recorded for use by subsequent calls. diff --git a/proto.h b/proto.h index cf879162e791..182cce5fe7df 100644 --- a/proto.h +++ b/proto.h @@ -3155,6 +3155,9 @@ Perl_noperl_die(const char *pat, ...) #define PERL_ARGS_ASSERT_NOPERL_DIE \ assert(pat) +PERL_CALLCONV void +Perl_noshutdownhook(void); + PERL_CALLCONV int Perl_nothreadhook(pTHX); #define PERL_ARGS_ASSERT_NOTHREADHOOK