Skip to content

embed.fnc: Need p flag for non-static public elements #23487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from

Conversation

khwilliamson
Copy link
Contributor

If a function or macro 'foo' is publicly accessible, there should be a 'Perl_foo' form available for callers to use so as to avoid any name collisions with their own names.

Now that we can automatically generate Perl_foo equivalents for macros, make sure that the flags indicate that.

I first thought to add the p flag automatically, but that would require a bunch of restructuring. By requiring the flag, in embed.fnc, the true state of things doesn't get hidden.

  • This set of changes does not require a perldelta entry.

If a function or macro 'foo' is publicly accessible, there should be a
'Perl_foo' form available for callers to use so as to avoid any name
collisions with their own names.

Now that we can automatically generate Perl_foo equivalents for macros,
make sure that the flags indicate that.

I first thought to add the p flag automatically, but that would require
a bunch of restructuring.  By requiring the flag, in embed.fnc, the true
state of things doesn't get hidden.
Comment on lines +2306 to +2311
# define Perl_hv_stores(mTHX,a,b,c) hv_stores(a,b,c)
# define Perl_hv_undef(mTHX,a) hv_undef(a)
# define Perl_ibcmp(mTHX,a,b,c) ibcmp(a,b,c)
# define Perl_ibcmp_locale(mTHX,a,b,c) ibcmp_locale(a,b,c)
# define Perl_ibcmp_utf8(mTHX,a,b,c,d,e,f,g,h) ibcmp_utf8(a,b,c,d,e,f,g,h)
# define Perl_newATTRSUB(mTHX,a,b,c,d,e) newATTRSUB(a,b,c,d,e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the mTHX is or means?
does it drop out on no-threads perls?
does it drop out on thread perls?
is it a dummy argument to capture and NOOP the end users aTHX_ token?
Does lets say this line

#define Perl_hv_stores(mTHX,a,b,c)           hv_stores(a,b,c)
                      ^^^^dropped out

And then later on

#define hv_stores(a,b,c) Perl_hv_storepvn(aTHX_ (a), (b), STRLENs(b), (c))

SO my example shows hv_stores() never used the callers aTHX_ macro arg and ignored it, and after expansion hv_stores(a,b,c) used it own silently made private instance of aTHX_ to execute the real C symbol Perl_hv_storepvn? is this right or am i making a mistake understanding this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mTHX is #ifdef'ed to be used only on threaded perls. It matches the aTHX parameter that it is known should be passed to the macro in this first position. It does nothing with that argument. Since this is a macro, embed.fnc knows that aTHX is available to it (based on the flags arg to its embed.fnc entry). The expansion could use aTHX directly, or the expansion could call a macro which just assumes aTHX is available. In either case, things just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants