Commit e00de7d
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.
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 it finds it works the opposite of the other way.
It undefines the symbols that it previously defined, provided
PERL_NO_SHORT_NAMES is defined. It it isn't defined, the second include
is a no-op.
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.1 parent 525cb1c commit e00de7d
File tree
13 files changed
+3360
-597
lines changed- Cross
- lib/ExtUtils/t
- regen
- t/porting
- vms
- win32
13 files changed
+3360
-597
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
| 345 | + | |
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
554 | | - | |
| 553 | + | |
| 554 | + | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
| 581 | + | |
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
| |||
0 commit comments