embed.pl Create Perl_foo functions for all mp-flagged macros#24279
Merged
khwilliamson merged 4 commits intoPerl:bleadfrom Mar 31, 2026
Merged
embed.pl Create Perl_foo functions for all mp-flagged macros#24279khwilliamson merged 4 commits intoPerl:bleadfrom
khwilliamson merged 4 commits intoPerl:bleadfrom
Conversation
A future commit will, for the first time, call strstr with a
const char *
'haystack parameter. On my Linux box that doesn't compile because, in
spite of the man page, that parameter is declared merely 'char *'.
Looking at string.h, it appears that it can be const under the right
circumstances.
This creates some more mnemonics so that, for example, 'AC' is repeated everywhere for that class of visibility
This allows XS code to #undef a short name macro, and still have access to its functionality via a Perl_foo function. This would go a long way to allowing XS code to cope with namespace collisions. Prior to this commit, macros without a thread context parameter did not have function fallbacks. The current catch is that all such macros must be flagged as 'mp'. It's trivial to add the 'p' flag to any such macro we want. Or maybe there could be a Configure option to add it to all public macros. But that is future work. This lays the foundation for it. One gotcha it took me a while to realize. Suppose there's a name space collision with macro A; so the XS code undefs our 'A' in favor of its own. But if another of our macros, say 'B', calls 'A', it will get the XS version. Hopefully there's a parameter mismatch and the code doesn't compile; and the solution would be to #undef 'B' as well.
The previous commit creates a function for any macro flagged 'mp' that is visible outside the core, so that name collisions for the short form macro name can easily be solved. This isn't needed for perl core use, as we will fix any collisions that come up before shipping the product. But the same is true of extensions to core. Change so that we extend the exception to include those.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This extends the existing mechanism to macros that don't have an aTHX parameter. This allows a module to #undef a macro whose name collides with its version, and still have access to the functionality via the long name.
This is a step towards avoiding name space pollution.
The previous mechanism which didn't create a function is retained for macros not visible outside the core or its extensions, as we don't have to worry about name collisions.