Skip to content

Commit e3f0a12

Browse files
committed
Hide function prototyes from unauthorized callers
0351a62 extended hiding private functions from callers into the gcc world. Some functions are allowed only in extensions; so can not be marked as hidden; this commit discourages their use however, by hiding their prototypes to all but the core and extensions. It turns out that four functions were being used in modules we ship with that were marked as extensions-only; so they had to be made globally accessible.
1 parent 5d263b8 commit e3f0a12

File tree

7 files changed

+755
-619
lines changed

7 files changed

+755
-619
lines changed

embed.fnc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ ERXp |SV * |get_prop_definition \
13121312
ERTXp |const char * const *|get_prop_values \
13131313
|const int table_index
13141314
: Used by SvRX and SvRXOK
1315-
EXopx |REGEXP *|get_re_arg |NULLOK SV *sv
1315+
Xopx |REGEXP *|get_re_arg |NULLOK SV *sv
13161316
AOdp |SV * |get_sv |NN const char *name \
13171317
|I32 flags
13181318
CRipx |MGVTBL *|get_vtbl |int vtbl_id
@@ -3694,9 +3694,9 @@ Cp |UV |_to_utf8_upper_flags \
36943694
|NULLOK STRLEN *lenp \
36953695
|bool flags
36963696

3697-
EXop |bool |try_amagic_bin |int method \
3697+
Xop |bool |try_amagic_bin |int method \
36983698
|int flags
3699-
EXop |bool |try_amagic_un |int method \
3699+
Xop |bool |try_amagic_un |int method \
37003700
|int flags
37013701
ARTdp |char * |uiv_2buf |NN char * const buf \
37023702
|const IV iv \
@@ -3906,7 +3906,10 @@ Adp |bool |valid_identifier_pvn \
39063906
|U32 flags
39073907
Adp |bool |valid_identifier_sv \
39083908
|NULLOK SV *sv
3909-
CRTdip |UV |valid_utf8_to_uvchr \
3909+
CRTdip |UV |valid_utf8_to_uv \
3910+
|NN const U8 *s \
3911+
|NULLOK STRLEN *retlen
3912+
CRTdmp |UV |valid_utf8_to_uvchr \
39103913
|NN const U8 *s \
39113914
|NULLOK STRLEN *retlen
39123915
Adp |int |vcmp |NN SV *lhv \
@@ -6303,7 +6306,7 @@ EXopx |OP * |pp_wrap |NN Perl_ppaddr_t real_pp_fn \
63036306
|I32 nargs \
63046307
|int nlists
63056308
Cpx |int |runops_wrap
6306-
EXopx |void |xs_wrap |NN XSUBADDR_t xsub \
6309+
Copx |void |xs_wrap |NN XSUBADDR_t xsub \
63076310
|NN CV *cv
63086311
#endif
63096312
#if defined(PERL_USE_3ARG_SIGHANDLER)

embed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@
841841
# define valid_identifier_pve(a,b,c) Perl_valid_identifier_pve(aTHX_ a,b,c)
842842
# define valid_identifier_pvn(a,b,c) Perl_valid_identifier_pvn(aTHX_ a,b,c)
843843
# define valid_identifier_sv(a) Perl_valid_identifier_sv(aTHX_ a)
844-
# define valid_utf8_to_uvchr Perl_valid_utf8_to_uvchr
844+
# define valid_utf8_to_uv Perl_valid_utf8_to_uv
845+
# define Perl_valid_utf8_to_uvchr valid_utf8_to_uvchr
845846
# define vcmp(a,b) Perl_vcmp(aTHX_ a,b)
846847
# define vcroak(a,b) Perl_vcroak(aTHX_ a,b)
847848
# define vdeb(a,b) Perl_vdeb(aTHX_ a,b)

inline.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,25 +1306,36 @@ Perl_utf8_to_bytes_overwrite(pTHX_ U8 **s_ptr, STRLEN *lenp)
13061306
}
13071307

13081308
/*
1309-
=for apidoc valid_utf8_to_uvchr
1310-
Like C<L<perlapi/utf8_to_uv>>, but should only be called when it is
1309+
=for apidoc valid_utf8_to_uv
1310+
=for apidoc_item valid_utf8_to_uvchr
1311+
1312+
These are synonymous.
1313+
1314+
These are like C<L<perlapi/utf8_to_uv>>, but should only be called when it is
13111315
known that the next character in the input UTF-8 string C<s> is well-formed
13121316
(I<e.g.>, it passes C<L<perlapi/isUTF8_CHAR>>. Surrogates, non-character code
13131317
points, and non-Unicode code points are allowed.
13141318
1319+
The only use for these is that they should run slightly faster than
1320+
C<utf8_to_uv> because no error checking is done.
1321+
1322+
The C<_uv> form is slightly preferred so as to have a consistent spelling with
1323+
the other C<_uv> forms that are definitely preferred over the older and
1324+
problematic C<_uvchr> forms.
1325+
13151326
=cut
13161327
13171328
*/
13181329

13191330
PERL_STATIC_INLINE UV
1320-
Perl_valid_utf8_to_uvchr(const U8 *s, STRLEN *retlen)
1331+
Perl_valid_utf8_to_uv(const U8 *s, STRLEN *retlen)
13211332
{
1333+
PERL_ARGS_ASSERT_VALID_UTF8_TO_UV;
1334+
13221335
const UV expectlen = UTF8SKIP(s);
13231336
const U8* send = s + expectlen;
13241337
UV uv = *s;
13251338

1326-
PERL_ARGS_ASSERT_VALID_UTF8_TO_UVCHR;
1327-
13281339
if (retlen) {
13291340
*retlen = expectlen;
13301341
}

pod/perldelta.pod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ C<assert()> statements yourself to F<embed.fnc> that will be
460460
incorporated into the generated macro, beyond the system-generated ones.
461461
Comments and examples in F<embed.fnc> give details.
462462

463+
=item *
464+
465+
A new function C<valid_utf8_to_uv> has been added. This is synonymous
466+
with C<valid_utf8_to_uvchr>; its reason for existence is to have
467+
consistent spelling with the names of the other functions that translate
468+
from UTF-8, so you don't have to remember a different spelling.
469+
463470
=back
464471

465472
=head1 Selected Bug Fixes

0 commit comments

Comments
 (0)