Skip to content

Commit 9a7559f

Browse files
committed
Expose some short form macros unconditionally
Until C99 we couldn't use the type of macro we have that hides the need for thread context to call a function that needed both a thread context parameter and a format with varying numbers of parameters. Therefore you had to call the function directly with aTHX_. For some such functions, there were parallel functions created that omitted the thread context parameter (re-deriving it themselves). And there were compatibility macros created that called these. So, for example warn() would call Perl_warn_nocontext(). That changed in C99, and the calls in core to such functions were changed to use the macro that now expanded to Perl_warn(). Not all functions with this problem had '_nocontext()' versions. It turns out that the way the macros were #defined in embed.h, a definition existed for core, and non-threaded builds, but not threaded ones. This meant that, likely unknown to you, if you wrote an XS module, and used one of those macros, such as ck_warner(), it would compile and run on a non-threaded system, but would not compile on a threaded build. Commits 13e5ba4 and d933027 did not affect the '_nocontext()' versions. This commit exposes their macros to the public. There is no need to worry about breaking existing code, as these macros existed only on non-threaded builds, and they still work there. They now work on threaded builds as well, as long as you have an aTHX variable available. This is no different than any newly created macro for which we are also requiring aTHX availability.
1 parent 8914207 commit 9a7559f

File tree

2 files changed

+28
-38
lines changed

2 files changed

+28
-38
lines changed

embed.fnc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -875,10 +875,10 @@ Adp |OP * |ck_entersub_args_proto_or_list \
875875

876876
CPop |bool |ckwarn |U32 w
877877
CPop |bool |ckwarn_d |U32 w
878-
Adfpv |void |ck_warner |U32 err \
878+
Adfp |void |ck_warner |U32 err \
879879
|NN const char *pat \
880880
|...
881-
Adfpv |void |ck_warner_d |U32 err \
881+
Adfp |void |ck_warner_d |U32 err \
882882
|NN const char *pat \
883883
|...
884884

@@ -928,7 +928,7 @@ px |void |create_eval_scope \
928928
: croak()'s first parm can be NULL. Otherwise, mod_perl breaks.
929929
Adfprv |void |croak |NULLOK const char *pat \
930930
|...
931-
Tfprv |void |croak_caller |NULLOK const char *pat \
931+
Tfpr |void |croak_caller |NULLOK const char *pat \
932932
|...
933933
CTrs |void |croak_memory_wrap
934934
Tpr |void |croak_no_mem
@@ -1179,7 +1179,7 @@ Adp |void |dump_all
11791179
p |void |dump_all_perl |bool justperl
11801180
Adhp |void |dump_eval
11811181
Adp |void |dump_form |NN const GV *gv
1182-
Cfpv |void |dump_indent |I32 level \
1182+
Cfp |void |dump_indent |I32 level \
11831183
|NN PerlIO *file \
11841184
|NN const char *pat \
11851185
|...
@@ -1210,7 +1210,7 @@ ATdmp |bool |extended_utf8_to_uv \
12101210
|NN const U8 * const e \
12111211
|NN UV *cp_p \
12121212
|NULLOK Size_t *advance_p
1213-
Adfpv |void |fatal_warner |U32 err \
1213+
Adfp |void |fatal_warner |U32 err \
12141214
|NN const char *pat \
12151215
|...
12161216
Adp |void |fbm_compile |NN SV *sv \
@@ -1942,7 +1942,7 @@ p |int |magic_getvec |NN SV *sv \
19421942
p |int |magic_killbackrefs \
19431943
|NN SV *sv \
19441944
|NN MAGIC *mg
1945-
Fdopv |SV * |magic_methcall |NN SV *sv \
1945+
Fdop |SV * |magic_methcall |NN SV *sv \
19461946
|NN const MAGIC *mg \
19471947
|NN SV *meth \
19481948
|U32 flags \
@@ -2141,7 +2141,7 @@ Cdp |PerlIO *|my_popen_list |NN const char *mode \
21412141
Adp |void |my_setenv |NULLOK const char *nam \
21422142
|NULLOK const char *val
21432143

2144-
AMTdfpv |int |my_snprintf |NN char *buffer \
2144+
AMTdfp |int |my_snprintf |NN char *buffer \
21452145
|const Size_t len \
21462146
|NN const char *format \
21472147
|...
@@ -2419,7 +2419,7 @@ AMPTdp |char * |ninstr |NN const char *big \
24192419

24202420
p |void |no_bareword_filehandle \
24212421
|NN const char *fhname
2422-
Tefprv |void |noperl_die |NN const char *pat \
2422+
Tefpr |void |noperl_die |NN const char *pat \
24232423
|...
24242424
CTdp |void |noshutdownhook
24252425
Adp |int |nothreadhook
@@ -2620,7 +2620,7 @@ Cdp |void |pop_scope
26202620
Cipx |void |pop_stackinfo
26212621

26222622
: Used in perl.c and toke.c
2623-
Fopv |void |populate_isa |NN const char *name \
2623+
Fop |void |populate_isa |NN const char *name \
26242624
|STRLEN len \
26252625
|...
26262626
Adhp |REGEXP *|pregcomp |NN SV * const pattern \
@@ -2691,7 +2691,7 @@ Adp |REGEXP *|re_compile |NN SV * const pattern \
26912691
|U32 orig_rx_flags
26922692
Cp |void |reentrant_free
26932693
Cp |void |reentrant_init
2694-
CFTpv |void * |reentrant_retry|NN const char *f \
2694+
CFTp |void * |reentrant_retry|NN const char *f \
26952695
|...
26962696

26972697
Cp |void |reentrant_size
@@ -3642,7 +3642,7 @@ Cdp |void |taint_env
36423642
Cdp |void |taint_proper |NULLOK const char *f \
36433643
|NN const char * const s
36443644

3645-
Fpv |OP * |tied_method |NN SV *methname \
3645+
Fp |OP * |tied_method |NN SV *methname \
36463646
|NN SV **mark \
36473647
|NN SV * const sv \
36483648
|NN const MAGIC * const mg \
@@ -3974,7 +3974,7 @@ Adp |void |wrap_op_checker|Optype opcode \
39743974
p |void |write_to_stderr|NN SV *msv
39753975
Xp |void |xs_boot_epilog |const SSize_t ax
39763976

3977-
FTXopv |Stack_off_t|xs_handshake \
3977+
FTXop |Stack_off_t|xs_handshake \
39783978
|const U32 key \
39793979
|NN void *v_my_perl \
39803980
|NN const char *file \
@@ -5472,7 +5472,7 @@ ES |SV * |parse_uniprop_string \
54725472
|NN bool *user_defined_ptr \
54735473
|NN SV *msg \
54745474
|const STRLEN level
5475-
Sfrv |void |re_croak |bool utf8 \
5475+
Sfr |void |re_croak |bool utf8 \
54765476
|NN const char *pat \
54775477
|...
54785478
ES |regnode_offset|reg |NN RExC_state_t *pRExC_state \
@@ -5821,7 +5821,7 @@ ES |void |dump_exec_pos |NN const char *locinput \
58215821
|const bool do_utf8 \
58225822
|const U32 depth
58235823

5824-
EFpv |int |re_exec_indentf|NN const char *fmt \
5824+
EFp |int |re_exec_indentf|NN const char *fmt \
58255825
|U32 depth \
58265826
|...
58275827
# endif
@@ -5864,10 +5864,10 @@ Ep |void |regprop |NULLOK const regexp *prog \
58645864
|NN const regnode *o \
58655865
|NULLOK const regmatch_info *reginfo \
58665866
|NULLOK const RExC_state_t *pRExC_state
5867-
EFpv |int |re_indentf |NN const char *fmt \
5867+
EFp |int |re_indentf |NN const char *fmt \
58685868
|U32 depth \
58695869
|...
5870-
Efpv |int |re_printf |NN const char *fmt \
5870+
Efp |int |re_printf |NN const char *fmt \
58715871
|...
58725872
# endif
58735873
# if defined(PERL_EXT_RE_BUILD)

embed.h

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@
177177
# define ck_entersub_args_list(a) Perl_ck_entersub_args_list(aTHX_ a)
178178
# define ck_entersub_args_proto(a,b,c) Perl_ck_entersub_args_proto(aTHX_ a,b,c)
179179
# define ck_entersub_args_proto_or_list(a,b,c) Perl_ck_entersub_args_proto_or_list(aTHX_ a,b,c)
180+
# define ck_warner(a,...) Perl_ck_warner(aTHX_ a,__VA_ARGS__)
181+
# define ck_warner_d(a,...) Perl_ck_warner_d(aTHX_ a,__VA_ARGS__)
180182
# define clear_defarray(a,b) Perl_clear_defarray(aTHX_ a,b)
181183
# define clear_defarray_simple(a) Perl_clear_defarray_simple(aTHX_ a)
182184
# define cop_fetch_label(a,b,c) Perl_cop_fetch_label(aTHX_ a,b,c)
@@ -222,12 +224,14 @@
222224
# define dump_all() Perl_dump_all(aTHX)
223225
# define dump_eval() Perl_dump_eval(aTHX)
224226
# define dump_form(a) Perl_dump_form(aTHX_ a)
227+
# define dump_indent(a,b,...) Perl_dump_indent(aTHX_ a,b,__VA_ARGS__)
225228
# define dump_packsubs(a) Perl_dump_packsubs(aTHX_ a)
226229
# define dump_sub(a) Perl_dump_sub(aTHX_ a)
227230
# define dump_vindent(a,b,c,d) Perl_dump_vindent(aTHX_ a,b,c,d)
228231
# define eval_pv(a,b) Perl_eval_pv(aTHX_ a,b)
229232
# define eval_sv(a,b) Perl_eval_sv(aTHX_ a,b)
230233
# define Perl_extended_utf8_to_uv extended_utf8_to_uv
234+
# define fatal_warner(a,...) Perl_fatal_warner(aTHX_ a,__VA_ARGS__)
231235
# define fbm_compile(a,b) Perl_fbm_compile(aTHX_ a,b)
232236
# define fbm_instr(a,b,c,d) Perl_fbm_instr(aTHX_ a,b,c,d)
233237
# define filter_add(a,b) Perl_filter_add(aTHX_ a,b)
@@ -907,13 +911,9 @@
907911
# endif /* defined(MULTIPLICITY) */
908912
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
909913
defined(PERL_WANT_VARARGS)
910-
# define ck_warner(a,...) Perl_ck_warner(aTHX_ a,__VA_ARGS__)
911-
# define ck_warner_d(a,...) Perl_ck_warner_d(aTHX_ a,__VA_ARGS__)
912914
# define croak(...) Perl_croak(aTHX_ __VA_ARGS__)
913915
# define deb(...) Perl_deb(aTHX_ __VA_ARGS__)
914916
# define die(...) Perl_die(aTHX_ __VA_ARGS__)
915-
# define dump_indent(a,b,...) Perl_dump_indent(aTHX_ a,b,__VA_ARGS__)
916-
# define fatal_warner(a,...) Perl_fatal_warner(aTHX_ a,__VA_ARGS__)
917917
# define form(...) Perl_form(aTHX_ __VA_ARGS__)
918918
# define load_module(a,b,...) Perl_load_module(aTHX_ a,b,__VA_ARGS__)
919919
# define mess(...) Perl_mess(aTHX_ __VA_ARGS__)
@@ -1176,6 +1176,7 @@
11761176
# define sv_pvutf8n_force_wrapper(a,b,c) Perl_sv_pvutf8n_force_wrapper(aTHX_ a,b,c)
11771177
# define sv_resetpvn(a,b,c) Perl_sv_resetpvn(aTHX_ a,b,c)
11781178
# define sv_sethek(a,b) Perl_sv_sethek(aTHX_ a,b)
1179+
# define tied_method(a,b,c,d,e,...) Perl_tied_method(aTHX_ a,b,c,d,e,__VA_ARGS__)
11791180
# define tmps_grow_p(a) Perl_tmps_grow_p(aTHX_ a)
11801181
# define utilize(a,b,c,d,e) Perl_utilize(aTHX_ a,b,c,d,e)
11811182
# define vivify_ref(a,b) Perl_vivify_ref(aTHX_ a,b)
@@ -1232,13 +1233,6 @@
12321233
# else
12331234
# define magic_regdatum_set(a,b) Perl_magic_regdatum_set(aTHX_ a,b)
12341235
# endif
1235-
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
1236-
defined(PERL_WANT_VARARGS)
1237-
# define tied_method(a,b,c,d,e,...) Perl_tied_method(aTHX_ a,b,c,d,e,__VA_ARGS__)
1238-
# if defined(PERL_IN_REGCOMP_C)
1239-
# define re_croak(a,...) S_re_croak(aTHX_ a,__VA_ARGS__)
1240-
# endif
1241-
# endif
12421236
# if defined(PERL_DEBUG_READONLY_COW)
12431237
# define sv_buf_to_ro(a) Perl_sv_buf_to_ro(aTHX_ a)
12441238
# endif
@@ -1660,6 +1654,9 @@
16601654
# define dooneliner(a,b) S_dooneliner(aTHX_ a,b)
16611655
# endif
16621656
# endif
1657+
# if defined(PERL_IN_REGCOMP_C)
1658+
# define re_croak(a,...) S_re_croak(aTHX_ a,__VA_ARGS__)
1659+
# endif
16631660
# if defined(PERL_IN_REGCOMP_INVLIST_C) && !defined(PERL_EXT_RE_BUILD)
16641661
# define initialize_invlist_guts(a,b) S_initialize_invlist_guts(aTHX_ a,b)
16651662
# endif
@@ -2067,10 +2064,7 @@
20672064
# if defined(DEBUGGING)
20682065
# define debug_start_match(a,b,c,d,e) S_debug_start_match(aTHX_ a,b,c,d,e)
20692066
# define dump_exec_pos(a,b,c,d,e,f,g) S_dump_exec_pos(aTHX_ a,b,c,d,e,f,g)
2070-
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
2071-
defined(PERL_WANT_VARARGS)
2072-
# define re_exec_indentf(a,...) Perl_re_exec_indentf(aTHX_ a,__VA_ARGS__)
2073-
# endif
2067+
# define re_exec_indentf(a,...) Perl_re_exec_indentf(aTHX_ a,__VA_ARGS__)
20742068
# endif
20752069
# endif /* defined(PERL_IN_REGEXEC_C) */
20762070
# endif /* defined(PERL_CORE) || defined(PERL_EXT) */
@@ -2108,14 +2102,10 @@
21082102
# define debug_show_study_flags(a,b,c) Perl_debug_show_study_flags(aTHX_ a,b,c)
21092103
# define debug_studydata(a,b,c,d,e,f,g) Perl_debug_studydata(aTHX_ a,b,c,d,e,f,g)
21102104
# define dumpuntil(a,b,c,d,e,f,g,h) Perl_dumpuntil(aTHX_ a,b,c,d,e,f,g,h)
2105+
# define re_indentf(a,...) Perl_re_indentf(aTHX_ a,__VA_ARGS__)
2106+
# define re_printf(...) Perl_re_printf(aTHX_ __VA_ARGS__)
21112107
# define regprop(a,b,c,d,e) Perl_regprop(aTHX_ a,b,c,d,e)
2112-
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
2113-
defined(PERL_WANT_VARARGS)
2114-
# define re_indentf(a,...) Perl_re_indentf(aTHX_ a,__VA_ARGS__)
2115-
# define re_printf(...) Perl_re_printf(aTHX_ __VA_ARGS__)
2116-
# endif
2117-
# endif /* defined(DEBUGGING) &&
2118-
( defined(PERL_CORE) || defined(PERL_EXT) ) */
2108+
# endif
21192109
# if defined(PERL_EXT_RE_BUILD)
21202110
# if defined(PERL_CORE) || defined(PERL_EXT)
21212111
# define get_re_gclass_aux_data(a,b,c,d,e,f) Perl_get_re_gclass_aux_data(aTHX_ a,b,c,d,e,f)

0 commit comments

Comments
 (0)