Skip to content

Commit e92fcde

Browse files
committed
Remove v flag from embed.fnc
The flag was used to specify which functions are of a certain class, and used to calculate a list to be sorted. But that list is never going to grow, so we can just specify it, already sorted. The reason for doing this is mainly for a future commit which will want the list in another program, and it's easier to not have to do the calculations there.
1 parent c4da28b commit e92fcde

File tree

3 files changed

+58
-53
lines changed

3 files changed

+58
-53
lines changed

autodoc.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
qr/[ aA bC dD eE fF h iI mM nN oO pP rR sS T uU vW xX y ;@#? ] /xx;
7979

8080
# Flags that don't apply to this program, like implementation details.
81-
my $irrelevant_flags_re = qr/[ab eE iI P rR vX?]/xx;
81+
my $irrelevant_flags_re = qr/[ ab eE iI P rR X? ]/xx;
8282

8383
# Only certain flags dealing with what gets displayed, are acceptable for
8484
# apidoc_item

embed.fnc

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -639,12 +639,6 @@
639639
:
640640
: 'U' autodoc.pl will not output a usage example
641641
:
642-
: 'v' Guard the macro by !MULTIPLICITY || PERL_CORE if it uses __VA_ARGS__.
643-
: This flag exists for backward-compatibility to ensure that code does
644-
: not break when calling older functions without an aTHX in scope. It
645-
: should not be added to newly-added functions as they will have no such
646-
: compatibility issues.
647-
:
648642
: 'W' Add a comma_pDEPTH argument to function prototypes, and a comma_aDEPTH
649643
: argument to the function calls. This means that under DEBUGGING a
650644
: depth argument is added to the functions, which is used for example by
@@ -928,7 +922,7 @@ px |void |create_eval_scope \
928922
|NN SV **sp \
929923
|U32 flags
930924
: croak()'s first parm can be NULL. Otherwise, mod_perl breaks.
931-
Adfprv |void |croak |NULLOK const char *pat \
925+
Adfpr |void |croak |NULLOK const char *pat \
932926
|...
933927
Tfpr |void |croak_caller |NULLOK const char *pat \
934928
|...
@@ -1007,7 +1001,7 @@ p |void |cv_undef_flags |NN CV *cv \
10071001
Cp |void |cx_dump |NN PERL_CONTEXT *cx
10081002
: Used by CXINC, which appears to be in widespread use
10091003
CRp |I32 |cxinc
1010-
Adfpv |void |deb |NN const char *pat \
1004+
Adfp |void |deb |NN const char *pat \
10111005
|...
10121006
Cdp |I32 |debop |NN const OP *o
10131007
Cdp |void |debprofdump
@@ -1035,7 +1029,7 @@ ETXdp |char * |delimcpy_no_escape \
10351029
|const int delim \
10361030
|NN I32 *retlen
10371031
Cp |void |despatch_signals
1038-
Adfprv |OP * |die |NULLOK const char *pat \
1032+
Adfpr |OP * |die |NULLOK const char *pat \
10391033
|...
10401034
Adpr |OP * |die_sv |NN SV *baseex
10411035
: Used in util.c
@@ -1276,7 +1270,7 @@ Cp |void |force_out_malformed_utf8_message_ \
12761270
|NN const U8 * const e \
12771271
|U32 flags \
12781272
|const bool die_here
1279-
Adfpv |char * |form |NN const char *pat \
1273+
Adfp |char * |form |NN const char *pat \
12801274
|...
12811275
: Only used in perl.c
12821276
p |void |free_tied_hv_pool
@@ -1853,7 +1847,7 @@ ERXp |HV * |load_charnames |NN SV *char_name \
18531847
|const STRLEN context_len \
18541848
|NN const char **error_msg
18551849
MTbp |void |load_mathoms
1856-
AFdpv |void |load_module |U32 flags \
1850+
AFdp |void |load_module |U32 flags \
18571851
|NN SV *name \
18581852
|NULLOK SV *ver \
18591853
|...
@@ -2032,7 +2026,7 @@ Cp |Stack_off_t *|markstack_grow
20322026
EXp |int |mbtowc_ |NULLOK const wchar_t *pwc \
20332027
|NULLOK const char *s \
20342028
|const Size_t len
2035-
Adfpv |SV * |mess |NN const char *pat \
2029+
Adfp |SV * |mess |NN const char *pat \
20362030
|...
20372031
Adp |SV * |mess_sv |NN SV *basemsg \
20382032
|bool consume
@@ -2343,7 +2337,7 @@ ARdp |OP * |newSVOP |I32 type \
23432337
|NN SV *sv
23442338
ARdp |SV * |newSVpv |NULLOK const char * const s \
23452339
|const STRLEN len
2346-
ARdfpv |SV * |newSVpvf |NN const char * const pat \
2340+
ARdfp |SV * |newSVpvf |NN const char * const pat \
23472341
|...
23482342
ARdp |SV * |newSVpvn |NULLOK const char * const s \
23492343
|const STRLEN len
@@ -3156,13 +3150,13 @@ Adp |bool |sv_cat_decode |NN SV *dsv \
31563150
|int tlen
31573151
Adp |void |sv_catpv |NN SV * const dsv \
31583152
|NULLOK const char *sstr
3159-
Adfpv |void |sv_catpvf |NN SV * const sv \
3153+
Adfp |void |sv_catpvf |NN SV * const sv \
31603154
|NN const char * const pat \
31613155
|...
31623156
Adp |void |sv_catpv_flags |NN SV * const dsv \
31633157
|NN const char *sstr \
31643158
|const I32 flags
3165-
Adfpv |void |sv_catpvf_mg |NN SV * const sv \
3159+
Adfp |void |sv_catpvf_mg |NN SV * const sv \
31663160
|NN const char * const pat \
31673161
|...
31683162
Adp |void |sv_catpv_mg |NN SV * const dsv \
@@ -3465,10 +3459,10 @@ Adp |char *|sv_setpv_bufsize \
34653459
|NN SV * const sv \
34663460
|const STRLEN cur \
34673461
|const STRLEN len
3468-
Adfpv |void |sv_setpvf |NN SV * const sv \
3462+
Adfp |void |sv_setpvf |NN SV * const sv \
34693463
|NN const char * const pat \
34703464
|...
3471-
Adfpv |void |sv_setpvf_mg |NN SV * const sv \
3465+
Adfp |void |sv_setpvf_mg |NN SV * const sv \
34723466
|NN const char * const pat \
34733467
|...
34743468
Cipx |char *|sv_setpv_freshbuf \
@@ -3961,9 +3955,9 @@ Adp |void |vwarner |U32 err \
39613955
p |I32 |wait4pid |Pid_t pid \
39623956
|NN int *statusp \
39633957
|int flags
3964-
Adfpv |void |warn |NN const char *pat \
3958+
Adfp |void |warn |NN const char *pat \
39653959
|...
3966-
Adfpv |void |warner |U32 err \
3960+
Adfp |void |warner |U32 err \
39673961
|NN const char *pat \
39683962
|...
39693963
Adp |void |warn_sv |NN SV *baseex
@@ -4128,47 +4122,47 @@ pr |int |magic_regdatum_set \
41284122
|NN MAGIC *mg
41294123
#endif
41304124
#if defined(MULTIPLICITY)
4131-
ATdfprv |void |croak_nocontext|NULLOK const char *pat \
4125+
ATdfpr |void |croak_nocontext|NULLOK const char *pat \
41324126
|...
4133-
ATdfpv |void |deb_nocontext |NN const char *pat \
4127+
ATdfp |void |deb_nocontext |NN const char *pat \
41344128
|...
4135-
ATdfprv |OP * |die_nocontext |NULLOK const char *pat \
4129+
ATdfpr |OP * |die_nocontext |NULLOK const char *pat \
41364130
|...
4137-
ATdfpv |char * |form_nocontext |NN const char *pat \
4131+
ATdfp |char * |form_nocontext |NN const char *pat \
41384132
|...
4139-
AFTdpv |void |load_module_nocontext \
4133+
AFTdp |void |load_module_nocontext \
41404134
|U32 flags \
41414135
|NN SV *name \
41424136
|NULLOK SV *ver \
41434137
|...
4144-
ATdfpv |SV * |mess_nocontext |NN const char *pat \
4138+
ATdfp |SV * |mess_nocontext |NN const char *pat \
41454139
|...
41464140
Cdop |void * |my_cxt_init |NN int *indexp \
41474141
|size_t size
4148-
ATdfpv |SV * |newSVpvf_nocontext \
4142+
ATdfp |SV * |newSVpvf_nocontext \
41494143
|NN const char * const pat \
41504144
|...
4151-
ATdfpv |void |sv_catpvf_mg_nocontext \
4145+
ATdfp |void |sv_catpvf_mg_nocontext \
41524146
|NN SV * const sv \
41534147
|NN const char * const pat \
41544148
|...
4155-
ATdfpv |void |sv_catpvf_nocontext \
4149+
ATdfp |void |sv_catpvf_nocontext \
41564150
|NN SV * const sv \
41574151
|NN const char * const pat \
41584152
|...
4159-
ATdfpv |void |sv_setpvf_mg_nocontext \
4153+
ATdfp |void |sv_setpvf_mg_nocontext \
41604154
|NN SV * const sv \
41614155
|NN const char * const pat \
41624156
|...
4163-
ATdfpv |void |sv_setpvf_nocontext \
4157+
ATdfp |void |sv_setpvf_nocontext \
41644158
|NN SV * const sv \
41654159
|NN const char * const pat \
41664160
|...
4167-
ATdfpv |void |warner_nocontext \
4161+
ATdfp |void |warner_nocontext \
41684162
|U32 err \
41694163
|NN const char *pat \
41704164
|...
4171-
ATdfpv |void |warn_nocontext |NN const char *pat \
4165+
ATdfp |void |warn_nocontext |NN const char *pat \
41724166
|...
41734167
#endif /* defined(MULTIPLICITY) */
41744168
#if defined(MYMALLOC)

regen/embed.pl

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@ BEGIN
2828
require './regen/embed_lib.pl';
2929
}
3030

31+
# This program has historically generated compatibility macros for a few
32+
# functions of the form Perl_FOO(pTHX_ ...). Those macros would be named
33+
# FOO(...), and would expand outside the core to Perl_FOO_nocontext(...)
34+
# instead of the expected value. This was done so XS code that didn't do a
35+
# PERL_GET_CONTEXT would continue to work unchanged after threading was
36+
# introduced. Any new API functions that came along would require an aTHX_
37+
# parameter; this was just to avoid breaking existing source. Hence no new
38+
# functions need be added to the list of such macros. This is the list.
39+
# All have varargs.
40+
my @have_compatibility_macros = qw(
41+
croak
42+
deb
43+
die
44+
form
45+
load_module
46+
mess
47+
newSVpvf
48+
sv_catpvf
49+
sv_catpvf_mg
50+
sv_setpvf
51+
sv_setpvf_mg
52+
warn
53+
warner
54+
);
55+
my %has_compat_macro;
56+
$has_compat_macro{$_} = 1 for @have_compatibility_macros;
57+
3158
my $unflagged_pointers;
3259
my @az = ('a'..'z');
3360

@@ -123,7 +150,7 @@ sub generate_proto_h {
123150

124151
my ($flags, $retval, $plain_func, $args, $assertions ) =
125152
@{$embed}{qw(flags return_type name args assertions)};
126-
if ($flags =~ / ( [^ AabCDdEefFhIiMmNnOoPpRrSsTUuvWXx;] ) /xx) {
153+
if ($flags =~ / ( [^ AabCDdEefFhIiMmNnOoPpRrSsTUuWXx;] ) /xx) {
127154
die_at_end "flag $1 is not legal (for function $plain_func)";
128155
}
129156

@@ -637,7 +664,7 @@ sub embed_h {
637664
}
638665
}
639666
$ret .= ")\n";
640-
if($use_va_list and $flags =~ /v/) {
667+
if($has_compat_macro{$func}) {
641668
# Make older ones available only when !MULTIPLICITY or PERL_CORE or PERL_WANT_VARARGS
642669
# These should not be done uncondtionally because existing
643670
# code might call e.g. warn() without aTHX in scope.
@@ -718,22 +745,6 @@ sub generate_embed_h {
718745
print $em add_indent($ret,"$func($alist)\n");
719746
}
720747

721-
my @nocontext;
722-
{
723-
my (%has_va, %has_nocontext);
724-
foreach (@$all) {
725-
my $embed= $_->{embed}
726-
or next;
727-
++$has_va{$embed->{name}} if @{$embed->{args}} and $embed->{args}[-1] =~ /\.\.\./;
728-
++$has_nocontext{$1} if $embed->{name} =~ /(.*)_nocontext/;
729-
}
730-
731-
@nocontext = sort grep {
732-
$has_nocontext{$_}
733-
&& !/printf/ # Not clear to me why these are skipped but they are.
734-
} keys %has_va;
735-
}
736-
737748
print $em <<~'END';
738749
739750
/* Before C99, macros could not wrap varargs functions. This
@@ -743,7 +754,7 @@ sub generate_embed_h {
743754
#if defined(MULTIPLICITY) && !defined(PERL_NO_SHORT_NAMES) && !defined(PERL_WANT_VARARGS)
744755
END
745756

746-
foreach (@nocontext) {
757+
foreach (@have_compatibility_macros) {
747758
print $em indent_define($_, "Perl_${_}_nocontext", " ");
748759
}
749760

@@ -756,7 +767,7 @@ sub generate_embed_h {
756767
/* undefined symbols, point them back at the usual ones */
757768
END
758769

759-
foreach (@nocontext) {
770+
foreach (@have_compatibility_macros) {
760771
print $em indent_define("Perl_${_}_nocontext", "Perl_$_", " ");
761772
}
762773

0 commit comments

Comments
 (0)