Skip to content

Commit 9bb2fdd

Browse files
committed
Get -DNO_SHORT_NAMES to work again
This option has been broken for a long time, since at least when we started having inline functions. This commit gets it working again, but further efforts are needed for it to be useful. In part, I have adapated an idea from Tony Cook that is a new angle on an approach I had previously considered and found unworkable. But his does. It works by creating a new file long_names.c that is automatically generated by regen/embed.pl. This file contains the API elements that normally are macros that don't have a separate long name. This replaces the use of mathoms.c for the same purpose, but which was of use only in limited circumstances. If someone wants to use a long name, and it isn't already in the source, embed.pl makes sure it is here, and hence can be linked to. The more interesting case is when NO_SHORT_NAMES is defined, this file serves as the place for the linker to find the long names. perl.h is changed to #include "embed.h" in two places. The first one works as previously. For the second #include, it defines a symbol that embed.h looks for. If PERL_NO_SHORT_NAMES is not defined, embed.h is a no-op. But if both symbols are defined, embed.h works the opposite of the way it worked in the first include. It undefines the symbols that it previously defined. When not a no-op, after the second include those symbols are inaccessible to the code. The trick is that the second #include comes just after the includes of the inline functions headers. That means the inlined functions always have full access to the short names. But those definitions are gone for code that comes after perl.h finishes. This p.r. addresses a comment from @Leont in #23458 (comment) This commit, however hides too many short named functions. Right now, you have to say Perl_newSV(aTHX) instead of newSV(). There has to be some core of old API elements that everyone wants to continue using as short names. A new embed.fnc flag, say 'L', could be added to their entries in that file to indicate to not hide its short name. The other thing it doesn't address is short names that have to be macros because of problematic parameters. hv_stores() is one such, because one of its parameters is a literal string, which just doesn't work with a function prototype. There are ways to automatically handle these cases, but this p.r. doesn't do that. A future direction would be to parse all the top-level header files and to cause all the definitions that are not part of the public API to be removed from the user's namespace regardless of PERL_NO_SHORT_NAMES. Thus we would stop inadvertently polluting it.
1 parent 2c45168 commit 9bb2fdd

File tree

15 files changed

+3372
-608
lines changed

15 files changed

+3372
-608
lines changed

Cross/Makefile-cross-SH

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ h = $(h1) $(h2) $(h3) $(h4) $(h5)
342342
c1 = av.c scope.c op.c doop.c doio.c dquote.c dump.c gv.c hv.c mg.c reentr.c mro_core.c perl.c
343343
c2 = perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c sv.c
344344
c3 = taint.c time64.c toke.c util.c deb.c run.c universal.c pad.c globals.c keywords.c
345-
c4 = perlio.c numeric.c mathoms.c locale.c pp_pack.c pp_sort.c
345+
c4 = perlio.c numeric.c mathoms.c locale.c long_names.c pp_pack.c pp_sort.c
346346
c5 = $(mallocsrc)
347347
348348
c = $(c1) $(c2) $(c3) $(c4) $(c5) miniperlmain.c perlmain.c opmini.c
349349
350350
obj1 = $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) op$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dquote$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT) mro_core$(OBJ_EXT)
351351
obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) perl$(OBJ_EXT) run$(OBJ_EXT) pp_hot$(OBJ_EXT) sv$(OBJ_EXT) pp$(OBJ_EXT) scope$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_sys$(OBJ_EXT)
352-
obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT) time64$(OBJ_EXT)
352+
obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) long_names($OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT) time64$(OBJ_EXT)
353353
354354
obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
355355

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ keywords.h The keyword numbers
6161
l1_char_class_tab.h 256 word bit table of character classes (for handy.h)
6262
locale.c locale-specific utility functions
6363
locale_table.h header for locale.c
64+
long_names.c for use when NO_SHORT_NAMES is defined
6465
make_ext.pl Used by Makefile to execute extension Makefiles
6566
make_patchnum.pl Script to generate git_version.h and lib/Config_git.pl files for all OS'es
6667
makedef.pl Create symbol export lists for linking

Makefile.SH

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ h = \
550550
551551
c_base = \
552552
av.c builtin.c caretx.c class.c deb.c doio.c doop.c dquote.c dump.c \
553-
globals.c gv.c hv.c keywords.c locale.c mathoms.c mg.c mro_core.c \
554-
numeric.c op.c pad.c peep.c perl.c perlio.c perly.c \
553+
globals.c gv.c hv.c keywords.c locale.c long_names.c mathoms.c mg.c \
554+
mro_core.c numeric.c op.c pad.c peep.c perl.c perlio.c perly.c \
555555
pp.c pp_ctl.c pp_hot.c pp_pack.c pp_sort.c pp_sys.c \
556556
reentr.c regcomp.c regcomp_debug.c regcomp_invlist.c regcomp_study.c \
557557
regcomp_trie.c regexec.c run.c scope.c sv.c taint.c time64.c toke.c \
@@ -578,15 +578,15 @@ common_objs = \
578578
av$(OBJ_EXT) builtin$(OBJ_EXT) caretx$(OBJ_EXT) class$(OBJ_EXT) \
579579
deb$(OBJ_EXT) doio$(OBJ_EXT) doop$(OBJ_EXT) dquote$(OBJ_EXT) \
580580
dump$(OBJ_EXT) globals$(OBJ_EXT) gv$(OBJ_EXT) hv$(OBJ_EXT) \
581-
keywords$(OBJ_EXT) locale$(OBJ_EXT) mathoms$(OBJ_EXT) mg$(OBJ_EXT) \
582-
mro_core$(OBJ_EXT) numeric$(OBJ_EXT) pad$(OBJ_EXT) peep$(OBJ_EXT) \
583-
perlio$(OBJ_EXT) perly$(OBJ_EXT) pp$(OBJ_EXT) pp_ctl$(OBJ_EXT) \
584-
pp_hot$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT) pp_sys$(OBJ_EXT) \
585-
reentr$(OBJ_EXT) regcomp$(OBJ_EXT) regcomp_debug$(OBJ_EXT) \
586-
regcomp_invlist$(OBJ_EXT) regcomp_study$(OBJ_EXT) regcomp_trie$(OBJ_EXT) \
587-
regexec$(OBJ_EXT) run$(OBJ_EXT) scope$(OBJ_EXT) sv$(OBJ_EXT) \
588-
taint$(OBJ_EXT) time64$(OBJ_EXT) toke$(OBJ_EXT) utf8$(OBJ_EXT) \
589-
util$(OBJ_EXT) \
581+
keywords$(OBJ_EXT) locale$(OBJ_EXT) long_names$(OBJ_EXT) \
582+
mathoms$(OBJ_EXT) mg$(OBJ_EXT) mro_core$(OBJ_EXT) numeric$(OBJ_EXT) \
583+
pad$(OBJ_EXT) peep$(OBJ_EXT) perlio$(OBJ_EXT) perly$(OBJ_EXT) \
584+
pp$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_hot$(OBJ_EXT) pp_pack$(OBJ_EXT) \
585+
pp_sort$(OBJ_EXT) pp_sys$(OBJ_EXT) reentr$(OBJ_EXT) regcomp$(OBJ_EXT) \
586+
regcomp_debug$(OBJ_EXT) regcomp_invlist$(OBJ_EXT) \
587+
regcomp_study$(OBJ_EXT) regcomp_trie$(OBJ_EXT) regexec$(OBJ_EXT) \
588+
run$(OBJ_EXT) scope$(OBJ_EXT) sv$(OBJ_EXT) taint$(OBJ_EXT) \
589+
time64$(OBJ_EXT) toke$(OBJ_EXT) utf8$(OBJ_EXT) util$(OBJ_EXT) \
590590
$(mallocobj) $(ARCHOBJS)
591591
592592
miniperl_objs_nodt = $(mini_only_objs) $(common_objs) miniperlmain$(OBJ_EXT)

0 commit comments

Comments
 (0)