You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments