Skip to content

Commit 6a9f2d6

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 20f4518 commit 6a9f2d6

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
|...
@@ -2422,7 +2422,7 @@ AMPTdp |char * |ninstr |NN const char *big \
24222422

24232423
p |void |no_bareword_filehandle \
24242424
|NN const char *fhname
2425-
Tefprv |void |noperl_die |NN const char *pat \
2425+
Tefpr |void |noperl_die |NN const char *pat \
24262426
|...
24272427
CTdp |void |noshutdownhook
24282428
Adp |int |nothreadhook
@@ -2623,7 +2623,7 @@ Cdp |void |pop_scope
26232623
Cipx |void |pop_stackinfo
26242624

26252625
: Used in perl.c and toke.c
2626-
Fopv |void |populate_isa |NN const char *name \
2626+
Fop |void |populate_isa |NN const char *name \
26272627
|STRLEN len \
26282628
|...
26292629
Adhp |REGEXP *|pregcomp |NN SV * const pattern \
@@ -2694,7 +2694,7 @@ Adp |REGEXP *|re_compile |NN SV * const pattern \
26942694
|U32 orig_rx_flags
26952695
Cp |void |reentrant_free
26962696
Cp |void |reentrant_init
2697-
CFTpv |void * |reentrant_retry|NN const char *f \
2697+
CFTp |void * |reentrant_retry|NN const char *f \
26982698
|...
26992699

27002700
Cp |void |reentrant_size
@@ -3645,7 +3645,7 @@ Cdp |void |taint_env
36453645
Cdp |void |taint_proper |NULLOK const char *f \
36463646
|NN const char * const s
36473647

3648-
Fpv |OP * |tied_method |NN SV *methname \
3648+
Fp |OP * |tied_method |NN SV *methname \
36493649
|NN SV **mark \
36503650
|NN SV * const sv \
36513651
|NN const MAGIC * const mg \
@@ -3980,7 +3980,7 @@ Adp |void |wrap_op_checker|Optype opcode \
39803980
p |void |write_to_stderr|NN SV *msv
39813981
Xp |void |xs_boot_epilog |const SSize_t ax
39823982

3983-
FTXopv |Stack_off_t|xs_handshake \
3983+
FTXop |Stack_off_t|xs_handshake \
39843984
|const U32 key \
39853985
|NN void *v_my_perl \
39863986
|NN const char *file \
@@ -5491,7 +5491,7 @@ ES |SV * |parse_uniprop_string \
54915491
|NN bool *user_defined_ptr \
54925492
|NN SV *msg \
54935493
|const STRLEN level
5494-
Sfrv |void |re_croak |bool utf8 \
5494+
Sfr |void |re_croak |bool utf8 \
54955495
|NN const char *pat \
54965496
|...
54975497
ES |regnode_offset|reg |NN RExC_state_t *pRExC_state \
@@ -5840,7 +5840,7 @@ ES |void |dump_exec_pos |NN const char *locinput \
58405840
|const bool do_utf8 \
58415841
|const U32 depth
58425842

5843-
EFpv |int |re_exec_indentf|NN const char *fmt \
5843+
EFp |int |re_exec_indentf|NN const char *fmt \
58445844
|U32 depth \
58455845
|...
58465846
# endif
@@ -5883,10 +5883,10 @@ Ep |void |regprop |NULLOK const regexp *prog \
58835883
|NN const regnode *o \
58845884
|NULLOK const regmatch_info *reginfo \
58855885
|NULLOK const RExC_state_t *pRExC_state
5886-
EFpv |int |re_indentf |NN const char *fmt \
5886+
EFp |int |re_indentf |NN const char *fmt \
58875887
|U32 depth \
58885888
|...
5889-
Efpv |int |re_printf |NN const char *fmt \
5889+
Efp |int |re_printf |NN const char *fmt \
58905890
|...
58915891
# endif
58925892
# 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)
@@ -909,13 +913,9 @@
909913
# endif /* defined(MULTIPLICITY) */
910914
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
911915
defined(PERL_WANT_VARARGS)
912-
# define ck_warner(a,...) Perl_ck_warner(aTHX_ a,__VA_ARGS__)
913-
# define ck_warner_d(a,...) Perl_ck_warner_d(aTHX_ a,__VA_ARGS__)
914916
# define croak(...) Perl_croak(aTHX_ __VA_ARGS__)
915917
# define deb(...) Perl_deb(aTHX_ __VA_ARGS__)
916918
# define die(...) Perl_die(aTHX_ __VA_ARGS__)
917-
# define dump_indent(a,b,...) Perl_dump_indent(aTHX_ a,b,__VA_ARGS__)
918-
# define fatal_warner(a,...) Perl_fatal_warner(aTHX_ a,__VA_ARGS__)
919919
# define form(...) Perl_form(aTHX_ __VA_ARGS__)
920920
# define load_module(a,b,...) Perl_load_module(aTHX_ a,b,__VA_ARGS__)
921921
# define mess(...) Perl_mess(aTHX_ __VA_ARGS__)
@@ -1178,6 +1178,7 @@
11781178
# define sv_pvutf8n_force_wrapper(a,b,c) Perl_sv_pvutf8n_force_wrapper(aTHX_ a,b,c)
11791179
# define sv_resetpvn(a,b,c) Perl_sv_resetpvn(aTHX_ a,b,c)
11801180
# define sv_sethek(a,b) Perl_sv_sethek(aTHX_ a,b)
1181+
# define tied_method(a,b,c,d,e,...) Perl_tied_method(aTHX_ a,b,c,d,e,__VA_ARGS__)
11811182
# define tmps_grow_p(a) Perl_tmps_grow_p(aTHX_ a)
11821183
# define utilize(a,b,c,d,e) Perl_utilize(aTHX_ a,b,c,d,e)
11831184
# define vivify_ref(a,b) Perl_vivify_ref(aTHX_ a,b)
@@ -1234,13 +1235,6 @@
12341235
# else
12351236
# define magic_regdatum_set(a,b) Perl_magic_regdatum_set(aTHX_ a,b)
12361237
# endif
1237-
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
1238-
defined(PERL_WANT_VARARGS)
1239-
# define tied_method(a,b,c,d,e,...) Perl_tied_method(aTHX_ a,b,c,d,e,__VA_ARGS__)
1240-
# if defined(PERL_IN_REGCOMP_C)
1241-
# define re_croak(a,...) S_re_croak(aTHX_ a,__VA_ARGS__)
1242-
# endif
1243-
# endif
12441238
# if defined(PERL_DEBUG_READONLY_COW)
12451239
# define sv_buf_to_ro(a) Perl_sv_buf_to_ro(aTHX_ a)
12461240
# endif
@@ -1666,6 +1660,9 @@
16661660
# define dooneliner(a,b) S_dooneliner(aTHX_ a,b)
16671661
# endif
16681662
# endif
1663+
# if defined(PERL_IN_REGCOMP_C)
1664+
# define re_croak(a,...) S_re_croak(aTHX_ a,__VA_ARGS__)
1665+
# endif
16691666
# if defined(PERL_IN_REGCOMP_INVLIST_C) && !defined(PERL_EXT_RE_BUILD)
16701667
# define initialize_invlist_guts(a,b) S_initialize_invlist_guts(aTHX_ a,b)
16711668
# endif
@@ -2073,10 +2070,7 @@
20732070
# if defined(DEBUGGING)
20742071
# define debug_start_match(a,b,c,d,e) S_debug_start_match(aTHX_ a,b,c,d,e)
20752072
# define dump_exec_pos(a,b,c,d,e,f,g) S_dump_exec_pos(aTHX_ a,b,c,d,e,f,g)
2076-
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
2077-
defined(PERL_WANT_VARARGS)
2078-
# define re_exec_indentf(a,...) Perl_re_exec_indentf(aTHX_ a,__VA_ARGS__)
2079-
# endif
2073+
# define re_exec_indentf(a,...) Perl_re_exec_indentf(aTHX_ a,__VA_ARGS__)
20802074
# endif
20812075
# endif /* defined(PERL_IN_REGEXEC_C) */
20822076
# endif /* defined(PERL_CORE) || defined(PERL_EXT) */
@@ -2114,14 +2108,10 @@
21142108
# define debug_show_study_flags(a,b,c) Perl_debug_show_study_flags(aTHX_ a,b,c)
21152109
# define debug_studydata(a,b,c,d,e,f,g) Perl_debug_studydata(aTHX_ a,b,c,d,e,f,g)
21162110
# define dumpuntil(a,b,c,d,e,f,g,h) Perl_dumpuntil(aTHX_ a,b,c,d,e,f,g,h)
2111+
# define re_indentf(a,...) Perl_re_indentf(aTHX_ a,__VA_ARGS__)
2112+
# define re_printf(...) Perl_re_printf(aTHX_ __VA_ARGS__)
21172113
# define regprop(a,b,c,d,e) Perl_regprop(aTHX_ a,b,c,d,e)
2118-
# if !defined(MULTIPLICITY) || defined(PERL_CORE) || \
2119-
defined(PERL_WANT_VARARGS)
2120-
# define re_indentf(a,...) Perl_re_indentf(aTHX_ a,__VA_ARGS__)
2121-
# define re_printf(...) Perl_re_printf(aTHX_ __VA_ARGS__)
2122-
# endif
2123-
# endif /* defined(DEBUGGING) &&
2124-
( defined(PERL_CORE) || defined(PERL_EXT) ) */
2114+
# endif
21252115
# if defined(PERL_EXT_RE_BUILD)
21262116
# if defined(PERL_CORE) || defined(PERL_EXT)
21272117
# 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)