PERLINTERN(1perl)
π perlintern π
PERLINTERN(1perl) β Perl Programmers Reference Guide
β¨ NAME β¨
perlintern β autogenerated documentation of purely internal Perl functions
πΈ DESCRIPTION πΈ
Okay bestie, gather round, because this file is the autogenerated documentation of functions in the Perl interpreter that are documented using Perl's internal documentation format but are not marked as part of the Perl API. In other words β and I need you to hear me on this β they are not for use in extensions! π ββοΈ
It has the same sections as perlapi, though some may be empty. Yes, some of them are just vibes and tumbleweed. It's giving "we reserved the section but nobody lives here" π
π AV Handling π
π av_fetch_simple
This is a cut-down version of av_fetch that assumes the array is very straightforward β no magic, not readonly, and AvREAL β and that key is not negative.
This function MUST NOT be used in situations where any of those assumptions may not hold. No cap. If your array is spicy, this is not the function for you. π«
Returns the SV at the specified index in the array. The key is the index. If lval is true, you are guaranteed to get a real SV back (in case it wasn't real before), which you can then modify. Check that the return value is non-null before dereferencing it to a SV*. Please. For me. π₯Ί
The rough perl equivalent is $myarray[$key].
SV ** av_fetch_simple( AV *av, SSize_t key, I32 lval)
SV ** Perl_av_fetch_simple(pTHX_ AV *av, SSize_t key, I32 lval)
π av_new_alloc
This implements newAV_alloc_x in perlapi and newAV_alloc_xz in perlapi, which are the public API for this functionality. So it's the backstage version of the famous one. π
Creates a new AV and allocates its SV* array. β¨
This is similar to, but more efficient than doing:
AV *av = newAV();
av_extend(av, key);
The size parameter is used to pre-allocate a SV* array large enough to hold at least elements 0..(size-1). And size must be at least 1 β don't try to be cute with zero, it will not slay. π€
The zeroflag parameter controls whether or not the array is NULL initialized.
AV * av_new_alloc(SSize_t size,
bool zeroflag )
AV * Perl_av_new_alloc(pTHX_ SSize_t size,
bool zeroflag )
π av_store_simple
This is a cut-down version of av_store that assumes the array is very straightforward β no magic, not readonly, and AvREAL β and that key is not negative.
Again, and I quote the ancestors: this function MUST NOT be used in situations where any of those assumptions may not hold. Same energy as above, same rule. π₯
Stores an SV in an array. The array index is specified as key. It can be dereferenced to get the SV* that was stored there (= val)).
Note that the caller is responsible for suitably incrementing the reference count of val before the call. That part is on you, bestie. π«΅
Approximate Perl equivalent: splice(@myarray, $key, 1, $val).
SV ** av_store_simple( AV *av, SSize_t key, SV *val)
SV ** Perl_av_store_simple(pTHX_ AV *av, SSize_t key, SV *val)
π AvFILLp
If the array av is empty, this returns -1; otherwise it returns the maximum value of the indices of all the array elements which are currently defined in av. It does not handle magic, hence the p private indication in its name. The p is literally the whole personality. π
SSize_t AvFILLp(AV* av)
π¦ Callback Functions π¦
π dowantarray
DEPRECATED!It is planned to removedowantarrayfrom a future release of Perl. Do not use it for new code; remove it from existing code. It's giving "we're sunsetting you, babe" π
Implements the deprecated GIMME in perlapi.
U8 dowantarray()
U8 Perl_dowantarray(pTHX)
π leave_scope
Implements LEAVE_SCOPE which you should use instead. So like... use that one. This one is the internals, the actual public-facing move is LEAVE_SCOPE. π
void leave_scope( I32 base)
void Perl_leave_scope(pTHX_ I32 base)
π magic_freedestruct
This function is called via magic to implement the mortal_destructor_sv() and mortal_destructor_x() functions. It should not be called directly and has no user serviceable parts. There is nothing in here for you, bestie, please do not open this box. π¦π«
int magic_freedestruct( SV *sv, MAGIC *mg)
int Perl_magic_freedestruct(pTHX_ SV *sv, MAGIC *mg)
π mortal_svfunc_x
π MORTALSVFUNC_X
These are synonymous. Twins. Identical icons. π―ββοΈ
They each arrange for a C function reference to be called at the end of the current statement with the arguments provided. It is a wrapper around mortal_destructor_sv() which ensures that the latter function is called appropriately.
Be aware that there is a significant difference in timing between the end of the current statement and the end of the current pseudo block. If you are looking for a mechanism to trigger a function at the end of the current pseudo block you should look at SAVEDESTRUCTOR_X in perlapi instead of this function. Timing is everything, and this is not that timing. β°
void mortal_svfunc_x( SVFUNC_t f, SV *p)
void Perl_mortal_svfunc_x(pTHX_ SVFUNC_t f, SV *p)
void MORTALSVFUNC_X ( SVFUNC_t f, SV *p)
π pop_scope
Implements LEAVE in perlapi
void pop_scope()
void Perl_pop_scope(pTHX)
π push_scope
Implements ENTER in perlapi
void push_scope()
void Perl_push_scope(pTHX)
π save_adelete
Implements SAVEADELETE.
void save_adelete( AV *av, SSize_t key)
void Perl_save_adelete(pTHX_ AV *av, SSize_t key)
π save_freercpv
Implements SAVEFREERCPV.
Saves and frees a refcounted string. Calls rcpv_free() on the argument when the current pseudo block is finished. Clean up after yourself, queen. π§Ήβ¨
void save_freercpv( char *rcpv)
void Perl_save_freercpv(pTHX_ char *rcpv)
π save_generic_pvref
Implements SAVEGENERICPV.
Like save_pptr(), but also Safefree()s the new value if it is different from the old one. Can be used to restore a global char* to its prior contents, freeing new value.
void save_generic_pvref( char **str)
void Perl_save_generic_pvref(pTHX_ char **str)
π save_generic_svref
Implements SAVEGENERICSV.
Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to restore a global SV to its prior contents, freeing new value.
void save_generic_svref( SV **sptr)
void Perl_save_generic_svref(pTHX_ SV **sptr)
π save_hdelete
Implements SAVEHDELETE.
void save_hdelete( HV *hv, SV *keysv)
void Perl_save_hdelete(pTHX_ HV *hv, SV *keysv)
π save_hints
Implements SAVEHINTS.
void save_hints()
void Perl_save_hints(pTHX)
π save_op
Implements SAVEOP.
void save_op()
void Perl_save_op(pTHX)
π save_padsv
Saves the value in the pad at the given index to be restored on scope exit. Before this value is restored back in, whatever is currently there has its reference count decremented by one. So it's a whole handoff situation. π€
void save_padsv( PADOFFSET padix)
void Perl_save_padsv(pTHX_ PADOFFSET padix)
π save_padsv_and_mortalize
Implements SAVEPADSVANDMORTALIZE. (The name is a whole sentence, and honestly? Iconic.) π
void save_padsv_and_mortalize( PADOFFSET off)
void Perl_save_padsv_and_mortalize(pTHX_ PADOFFSET off)
π save_pushptr
The refcnt of object ptr will be decremented at the end of the current pseudo-block. type gives the type of ptr, expressed as one of the constants in scope.h whose name begins with SAVEt_.
This is the underlying implementation of several macros, like SAVEFREESV. It's the blueprint, the blueprint's blueprint. ποΈ
void save_pushptr( void * const ptr, const int type)
void Perl_save_pushptr(pTHX_ void * const ptr, const int type)
π save_rcpv
Implements SAVERCPV.
Saves and restores a refcounted string, similar to what save_generic_svref would do for a SV*. Can be used to restore a refcounted string to its previous state. Performs the appropriate refcount counting so that nothing should leak or be prematurely freed. No leaks, no premature freeings, only good behaviour. π
void save_rcpv( char **prcpv)
void Perl_save_rcpv(pTHX_ char **prcpv)
π save_scalar_at
A helper function for localizing the SV referenced by *sptr.
If SAVEf_KEEPOLDELEM is set in in flags, the function returns the input scalar untouched. (Yes, "in in" β that's the original text, I don't make the rules, I just document them. π)
Otherwise it replaces *sptr with a new undef scalar, and returns that. The new scalar will have the old one's magic (if any) copied to it. If there is such magic, and SAVEf_SETMAGIC is set in in flags, 'set' magic will be processed on the new scalar. If unset, 'set' magic will be skipped. The latter typically means that assignment will soon follow (e.g., local $x = $y), and that will handle the magic.
SV * save_scalar_at(SV **sptr, const U32 flags)
π save_set_svflags
Implements SAVESETSVFLAGS.
Set the SvFLAGS specified by mask to the values in val
void save_set_svflags( SV *sv, U32 mask, U32 val)
void Perl_save_set_svflags(pTHX_ SV *sv, U32 mask, U32 val)
π save_shared_pvref
Implements SAVESHAREDPV.
Like save_generic_pvref(), but uses PerlMemShared_free() rather than Safefree(). Can be used to restore a shared global char* to its prior contents, freeing new value. Same vibe, different free-er. π«Ά
void save_shared_pvref( char **str)
void Perl_save_shared_pvref(pTHX_ char **str)
π save_vptr
Implements SAVEVPTR.
void save_vptr( void *ptr)
void Perl_save_vptr(pTHX_ void *ptr)
π Casting π
There are currently no internal API items in Casting. Empty section, bestie. Nothing to see, but we still showed up. π³οΈβ¨
β Character case changing β
There are currently no internal API items in Character case changing. Also empty. Also still here. Consistency is a virtue. π
β¨ CHARACTER CLASSIFICATION β¨
okay so this whole section is about the functions (and honestly bestie, they're macros, don't come for me) that sort characters into little categories β like "you're punctuation" vs "you're a letter, slay". Most of them are basically the regex character classes in function form. (peep "POSIX Character Classes" in perlrecharclass if you want the lore.)
Every class has a few variants, and no, not every macro has every variant β each one below lists which ones are actually valid for it. Also important, so listen up:
- None of them are affected by
use bytes. periodt. - Only the ones with
LCin the name care about the current locale.
The base function β think isALPHA() β takes any signed or unsigned value, treats it as a code point, and returns a boolean saying whether the character it represents (or, on non-ASCII platforms, the character it corresponds to) is an ASCII character in the named class, following platform + Unicode + Perl rules. If you hand it a number that doesn't fit in an octet, you get FALSE. bye.
Variant isFOO_A (like isALPHA_A()) is literally identical to the base function with no _A suffix. The _A is just there to scream in the name that only ASCII-range characters can ever return TRUE. it's giving "no surprises".
Variant isFOO_L1 slaps the Latin-1 character set (or its EBCDIC equivalent) onto the platform. The ASCII code points don't change, because ASCII is a subset of Latin-1, duh. But the non-ASCII code points are treated as if they were Latin-1 characters. For example, isWORDCHAR_L1() returns true when you call it with code point 0xDF, which is a word character in both ASCII and EBCDIC (even though it represents different characters in each one π). If the input is a number that doesn't fit in an octet, FALSE is returned. (Also, Perl's documentation uses a very casual, colloquial definition of Latin-1 here β it means all code points below 256.)
Variant isFOO_uvchr is exactly like the isFOO_L1 variant for inputs below 256, but if the code point is bigger than 255, Unicode rules take over to decide if it's in the character class. Example for the people in the back: isWORDCHAR_uvchr(0x100) returns TRUE, because 0x100 is LATIN CAPITAL LETTER A WITH MACRON in Unicode, and that's a word character. iconic.
Variants isFOO_utf8 and isFOO_utf8_safe are like isFOO_uvchr, except they're built for UTF-8 encoded strings. The two forms are just different names for the same thing. Each call classifies the first character of the string starting at p. The second parameter, e, points to anywhere in the string beyond the first character, up to one byte past the end of the entire string. Even though both variants are identical, that _safe suffix is there to emphasize that it won't try to read beyond e - 1, as long as the constraint s < e holds true (this gets asserted in -DDEBUGGING builds, bestie). And heads up β if the UTF-8 for the input character is malformed in some way, the program may croak, or the function may return FALSE, totally at the discretion of the implementation, and that can change in future releases. so don't build your whole personality on it.
Variant isFOO_LC is like the isFOO_A and isFOO_L1 variants but the result is based on the current locale β that's literally what the LC in the name stands for. If Perl can tell the current locale is a UTF-8 locale, it uses the published Unicode rules; otherwise it uses the C library function that gives the named classification. For example, isDIGIT_LC() outside a UTF-8 locale returns whatever calling isdigit() gives you. FALSE is always returned if the input won't fit into an octet. And on some platforms where the C library function is known to be defective, Perl overrides its result to follow the POSIX standard's rules. bug fixed, we move π
.
Variant isFOO_LC_uvchr acts exactly like isFOO_LC for inputs less than 256, but for anything larger it returns the Unicode classification of the code point. simple as that.
Variants isFOO_LC_utf8 and isFOO_LC_utf8_safe are like isFOO_LC_uvchr, but for UTF-8 encoded strings. Again, the two forms are different names for the same thing. Each call classifies the first character of the string starting at p. The second parameter, e, points to anywhere in the string beyond the first character, up to one byte past the end of the entire string. Both variants are identical, but the _safe suffix emphasizes it won't try to read beyond e - 1, provided s < e is true (asserted in -DDEBUGGING builds). And same warning as before: if the UTF-8 for the input character is malformed in some way, the program may croak, or the function may return FALSE, at the discretion of the implementation, subject to change in future releases. π«Ά
CC_mask_β this translatesclassnuminto a bit pattern you use together with entries inPL_charclass[], and with operations such asPerl_isCC_by_bit.classnumis one of the classes defined inhandy.hfor this exact purpose.
U32 CC_mask_(U8 c, U8 classnum)
Perl_isCC_by_bitβ returns a boolean telling you whether or not charactercin the Latin1 range is a member of the class(es) given bybit_pattern, as formed byCC_mask_.
bool Perl_isCC_by_bit(U8 c, U32 bit_pattern)
π§ COMPILER AND PREPROCESSOR INFORMATION π§
There are currently no internal API items in Compiler and Preprocessor information
like... none. empty. the void. moving on babes π
π COMPILER DIRECTIVES π
PREVENT_LVALUEβ returns its inputx, but forces a compilation error if it's called from an lvalue context. Its main character moment is being placed inside a macro that could otherwise be used to change the value ofx, which is a thing you do not want happening.
A common example: when there are getter and setter macros for x, and the setter has error checking that shouldn't get short circuited. Wrapping x with this macro in the getter call forces the setter one to be used to change x. queen behavior.
bool PREVENT_LVALUE(x)
πͺ COMPILE-TIME SCOPE HOOKS πͺ
BhkENTRYβ NOTE:BhkENTRYis experimental and may change or be removed without notice. β οΈ
Returns an entry from the BHK struct. which is a preprocessor token indicating which entry to return. If the appropriate flag isn't set, this returns NULL. The type of the return value depends on which entry you ask for. mystery box energy.
void * BhkENTRY(BHK *hk, token which)
BhkFLAGSβ NOTE:BhkFLAGSis experimental and may change or be removed without notice. β οΈ
Returns the BHK's flags.
U32 BhkFLAGS(BHK *hk)
CALL_BLOCK_HOOKSβ NOTE:CALL_BLOCK_HOOKSis experimental and may change or be removed without notice. β οΈ
Calls all the registered block hooks for type which. which is a preprocessing token; the type of arg depends on which.
void CALL_BLOCK_HOOKS(token which, arg)
π CONCURRENCY π
okay bestie, deep breath, this one's a list. a long list. all these get their moment:
CVf_SLABBEDCvROOTCvSTARTCX_CURCX_LEAVE_SCOPECX_POPcx_typeCXt_BLOCKCXt_EVALCXt_FORMATCXt_GIVENCXt_LOOP_ARYCXt_LOOP_LAZYIVCXt_LOOP_LAZYSVCXt_LOOP_LISTCXt_LOOP_PLAINCXt_NULLCXt_SUBCXt_SUBSTCXt_WHENCXINCcxstackcxstack_ixCXt_BLOCK*CXt_EVAL*CXt_FORMAT*CXt_GIVEN*CXt_LOOP_ARY*CXt_LOOP_LAZYIV*CXt_LOOP_LAZYSV*CXt_LOOP_LIST*CXt_LOOP_PLAIN*CXt_NULL*CXt_SUB*CXt_SUBST*CXt_WHEN*dounwindβ described in perlguts. π
OP * CvROOT ( CV * sv)
OP * CvSTART ( CV * sv)
CX_CUR ()
void CX_LEAVE_SCOPE( PERL_CONTEXT* cx)
void CX_POP ( PERL_CONTEXT* cx)
PERL_CONTEXT * cxstack
I32 cxstack_ix
void dounwind ( I32 cxix)
void Perl_dounwind (pTHX_ I32 cxix)
my_forkβ this exists forPerlProc_forkto use as a wrapper around the C libraryfork(2)on some platforms, to hide certain platform quirks. It should not be used except throughPerlProc_fork. don't touch it directly, i'm serious.
Pid_t my_fork()
Pid_t Perl_my_fork()
PERL_CONTEXTβ described in perlguts. π
π§’ COPS AND HINT HASHES π§’
There are currently no internal API items in COPs and Hint Hashes
also empty bestie. we stay unbothered π
π CUSTOM OPERATORS π
core_prototypeβ this function assigns the prototype of the named core function tosv, or to a new mortal SV ifsvisNULL. It returns the modifiedsv, orNULLif the core function has no prototype.codeis a code as returned bykeyword(). It must not be equal to 0. β οΈopnumshould be eitherNULLor the address of a variable that will be set to the op number corresponding toname, if any.
SV * core_prototype( SV *sv, const char *name,
const int code,
int * const opnum)
SV * Perl_core_prototype(pTHX_ SV *sv, const char *name,
const int code,
int * const opnum)
πΈ CV Handling πΈ
Okay so this bit is all about poking at CVs, and bestie, a CV is a code-value, meaningβ¦ it's a subroutine. Yep, subs are just values chilling in the symbol table like the main characters they are. For the whole deep lore, go read perlguts. π
π CvREFCOUNTED_ANYSV
If this comes back true, it's telling you that the CvXSUBANY(cv).any_sv member is holding an SV pointer whose refcount needs to get decremented the moment the CV itself gets freed. And not only that β cv_clone() will bump that refcount up, and sv_dup() will duplicate the entire SV that's being pointed at, all because this flag is set. π«Ά
So here's the vibe: any CV that wraps an XSUB has this ANY union thing, and the XSUB function is free to use it however it wants, no questions asked. Sometimes the code is like "hey I wanna stash an SV in the any_sv member of that union." Cool, cool. But if you do that, you set this flag so that SV reference gets properly reclaimed or duplicated whenever the CV itself gets reclaimed or duplicated. Teamwork, fr fr. β¨
bool CvREFCOUNTED_ANYSV(CV *cv)
π CvREFCOUNTED_ANYSV_off
Little helper macro that switches the CvREFCOUNTED_ANYSV flag off. That's it, that's the whole job.
void CvREFCOUNTED_ANYSV_off(CV *cv)
π CvREFCOUNTED_ANYSV_on
And this one's twin β helper macro that switches the CvREFCOUNTED_ANYSV flag on. Slay.
void CvREFCOUNTED_ANYSV_on(CV *cv)
π CvWEAKOUTSIDE
okay this one is a whole saga, sit down. π
Every CV has a pointer, CvOUTSIDE(), pointing at the CV that lexically encloses it (if there even is one). Now, because pointers to anonymous sub prototypes get stashed in & pad slots, you can absolutely end up in a circular reference situation β parent pointing at the child, child pointing right back at the parent. Iconic toxic relationship, honestly.
To dodge the memory leak that would cause, we do not increment the refcount of the CV that CvOUTSIDE points to, in that one very specific case where the parent has a & pad slot pointing back at us. And when that happens, we set the CvWEAKOUTSIDE flag on the child. That's how we know later, when freeing the child, whether we should go ahead and decrement the parent's refcount.
Now it gets messier. There's another complication with non-closure anonymous subs β like, subs that don't refer to any lexicals outside themselves. In that scenario the anonymous prototype gets shared instead of cloned. Which means the parent can get freed while its children are still alive and kicking, like:
BEGIN { $a = sub { eval '$x' } }
In this case, the BEGIN gets freed immediately after it runs, because nothing's actively referencing it: the anon sub prototype has CvWEAKOUTSIDE set since it's not a closure, and $a points at that same CV, so it's not contributing to BEGIN's refcount either. But then when $a actually gets executed, the eval '$x' makes perl walk the chain of CvOUTSIDEsβ¦ and it lands on a freed BEGIN. π
To stop that from happening: whenever a CV and its associated pad get freed, every & entry in the pad gets explicitly yanked out of the pad. And if the refcount of the pointed-to anon sub is still positive, then that child's CvOUTSIDE gets pointed at its grandparent instead. This only ever happens in that one single specific case β a non-closure anon prototype with one or more active references, like $a up there. π
One more thing to keep in mind: a CV can be merely undefined rather than fully freed, like with undef &foo. In that case its refcount might not have hit zero yet, but we still delete its pad and its CvROOT and all that. And since assorted children may still have their CvOUTSIDE pointing at this now-undefined CV, we hold onto its own CvOUTSIDE for the time being, so the chain of lexical scopes stays unbroken. Like, for example, this should print 123:
my $x = 123;
sub tmp { sub { eval '$x' } }
my $a = tmp();
undef &tmp;
print $a->();
bool CvWEAKOUTSIDE(CV *cv)
π docatch
So what docatch does is interpose, for the current op and RUNOPS loop:
- a brand new JMPENV stack catch frame, and
- an inner RUNOPS loop, to run all the remaining ops following the current
PL_op.
Then it handles whatever exceptions get raised while inside that loop. If it's a caught eval at this level, it re-enters the loop using the specified restart op (i.e. the op following the OP_LEAVETRY and friends); otherwise it just re-throws the exception. No cap. π₯
docatch() is meant to be used like this:
PP(pp_entertry)
{
if (CATCH_GET)
return docatch(Perl_pp_entertry);
... rest of function ...
return PL_op->op_next;
}
If a new catch frame isn't needed, the op just behaves normally, nbd. But if it is needed, it calls docatch(), which recursively calls pp_entertry() β this time with CATCH_GET() false, so the rest of the entertry body runs. Then docatch() calls CALLRUNOPS(), which executes every op following the entertry. When the loop finally wraps up, control comes back to docatch(), which pops the JMPENV and returns to the parent pp_entertry(), which itself immediately returns.
Heads up bestie: all the subsequent ops are run inside that inner RUNOPS loop, not just the body of the eval. π
Like, for example, in this:
sub TIEARRAY { eval {1}; my $x }
tie @a, "main";
at the point where the my gets executed, the C stack is gonna look something like:
#10 main()
#9 perl_run() # JMPENV_PUSH level 1 here
#8 S_run_body()
#7 Perl_runops_standard() # main RUNOPS loop
#6 Perl_pp_tie()
#5 Perl_call_sv()
#4 Perl_runops_standard() # unguarded RUNOPS loop: no new JMPENV
#3 Perl_pp_entertry()
#2 S_docatch() # JMPENV_PUSH level 2 here
#1 Perl_runops_standard() # docatch()'s RUNOPs loop
#0 Perl_pp_padsv()
Basically? Any section of the perl core that kicks off a RUNOPS loop may make a promise that it'll catch any exceptions and restart the loop if it needs to. And if it's not prepared to do that (like call_sv() isn't), then it sets CATCH_GET() to true, so any later eval-like code knows it's gotta set up a new handler and loop (via docatch()). Communication, we love to see it. π«Ά
See "Exception handing" in perlinterp for further details.
OP * docatch(Perl_ppaddr_t firstpp)
π Debugging π
π comma_aDEPTH
Some functions, when they're compiled under DEBUGGING, take an extra final argument named depth, which indicates the C stack depth. Otherwise that argument justβ¦ isn't there. This macro expands to either , depth when under DEBUGGING, or to absolutely nothing when not under DEBUGGING β which cuts down the number of #ifdef's in the code. Bless. π
The program itself is responsible for keeping the correct value of depth. You don't get that for free, bestie.
π comma_pDEPTH
This one's for the prototype declarations of functions that take a "comma_aDEPTH" final parameter β pretty much exactly how pTHX_ is used in functions that take a thread context initial parameter. Same energy, different slot.
π debop
Implements the -Dt perl command line option on OP o.
I32 debop( const OP *o)
I32 Perl_debop(pTHX_ const OP *o)
π debprof
Called to say "hey, o got executed" β for profiling purposes, under the -DP command line option.
void debprof(const OP *o)
π debprofdump
Dumps out all the contents of the data that got collected by the -DP perl command line option.
void debprofdump()
void Perl_debprofdump(pTHX)
π debug_aDEPTH
Same as "comma_aDEPTH" but with no leading argument. It's intended for functions that have no normal arguments, and "comma_aDEPTH" itself uses it.
π DEBUG_L_FLAG
Described in perlguts.
U32 DEBUG_L_FLAG
π debug_pDEPTH
Same as "comma_pDEPTH" but with no leading argument. It's intended for functions with no normal arguments, and "comma_pDEPTH" itself uses it.
π free_c_backtrace
Deallocates a backtrace that you received from get_c_backtrace.
void free_c_backtrace(Perl_c_backtrace *bt)
π get_c_backtrace
Collects the backtrace (aka the "stacktrace", iykyk) into one single linear malloced buffer β and the caller is the one who's gotta Perl_free_c_backtrace() it. Don't forget, bestie. π
It scans the frames back by depth + skip, then drops the skip innermost ones, and returns at most depth frames.
Perl_c_backtrace * get_c_backtrace( int max_depth,
int skip)
Perl_c_backtrace * Perl_get_c_backtrace(pTHX_ int max_depth,
int skip)
π PL_DBsingle
When Perl is running in debugging mode, with the -d switch, this SV is a boolean that says whether subs are being single-stepped. And single-stepping gets automatically turned on after every single step. This is the C variable that corresponds to Perl's $DB::single variable. See "PL_DBsub" in perlapi.
On threaded perls, each thread gets its own independent copy of this variable, and each one is initialized at creation time with the current value of the creating thread's copy. β¨
SV * PL_DBsingle
π PL_DBtrace
Trace variable used when Perl is running in debugging mode, with the -d switch. This is the C variable corresponding to Perl's $DB::trace variable. See PL_DBsingle.
On threaded perls, each thread gets its own independent copy of this variable, initialized at creation time with the current value of the creating thread's copy.
SV * PL_DBtrace
π runops_debug
π runops_standard
Described in perlguts.
int runops_debug ()
int Perl_runops_debug (pTHX)
int runops_standard()
int Perl_runops_standard(pTHX)
Declaration and Initialization of Globals π
okay so here's the situation bestie: global variables get defined and initialized in one single place, but they're referred to from like a million other files. The def + any init has to happen in that one spot, but every file that might touch them needs an extern declaration. and ngl, declaring a global and then never using it? zero harm, no drama, no consequences. πΈ
Perl has a whole mechanism so both jobs get done while keeping code duplication to a minimum. EXTERN.h and INTERN.h define the same relatively few macros β but their definitions are different. In EXTERN.h, the macros expand to declarations of the globals as external to the file. In INTERN.h they actually cause the space to be allocated and possibly initialized. π
Most files will follow this paradigm:
#include "EXTERN.h"
...
#include "perl.h">
This causes every global symbol that is referred to in perl.h and every file it includes (which is nearly every top level Perl header file) to be declared as external.
The very few files that define globals will instead do
#include "INTERN.h"
...
#include "perl.h">
include the file
It doesn't work for a file to both define some globals and refer to others as externs. That is, you can only include one of INTERN.h and EXTERN.h. pick a lane, babe π
This section documents the macros that are defined in these two header files. perl.h has many uses of them that can serve as paradigms for you.
"dEXT*","dEXTCONST*"β Described under "EXT""DOINIT"β This is defined inINTERN.h, undefined inEXTERN.h
Most of the time you can use "INIT" to initialize your data structures. But not always. In such cases, you can do the following:
#ifdef DOINIT
... do the declaration and definition ...
#else
declaration only
#endif
A typical reason for needing this is when the definition includes #ifdef's. You can't put that portably in a call to "INIT", as a macro generally can't itself contain preprocessor directives. π
#ifdef DOINIT
"EXT","EXTCONST","dEXT","dEXTCONST"β These each designate a global variable. The"CONST"forms indicate that it is constant.
Use them like this:
Include either EXTERN.h or INTERN.h, but not both
...
#include "perl.h"
...
EXT char PL_WARN_ALL INIT(0);
EXTCONST U8 PL_revision INIT(PERL_REVISION);
This will handle everything for you regarding whether they are to actually be defined and initialized or just declared "extern". β¨
If the initialization is complex, you may have to use "DOINIT".
If some constants you wish to reference will not become defined by #includeing perl.h, instead use "dEXT" and "dEXTCONST" for them and include whatever files you need to to get them. This is currently very rare, and should be avoided.
"INIT"β Macro to initialize something, used like so:
EXTCONST char PL_memory_wrap[] INIT("panic: memory wrap");
It expands to nothing in EXTERN.h.
INIT(const_expr)
Display functions π
"sv_peek"β Implements"SvPEEK"
char * sv_peek( SV *sv)
char * Perl_sv_peek(pTHX_ SV *sv)
Embedding, Threads, and Interpreter Cloning π¦
"cv_dump"β dump the contents of a CV
void cv_dump(const CV *cv, const char *title)
"cv_forget_slab"β When a CV has a reference count on its slab ("CvSLABBED"), it is responsible for making sure it is freed. (Hence, no two CVs should ever have a reference count on the same slab.) The CV only needs to reference the slab during compilation. Once it is compiled and"CvROOT"attached, it has finished its job, so it can forget the slab. iconic behaviour honestly, it just β¨moves onβ¨
void cv_forget_slab( CV *cv)
void Perl_cv_forget_slab(pTHX_ CV *cv)
"do_dump_pad"β Dump the contents of a padlist
void do_dump_pad( I32 level, PerlIO *file,
PADLIST *padlist, int full)
void Perl_do_dump_pad(pTHX_ I32 level, PerlIO *file,
PADLIST *padlist, int full)
"get_context"β Implements""PERL_GET_CONTEXT""in perlapi, which you should use instead.
void * get_context()
void * Perl_get_context()
"noshutdownhook"β Stub that provides shutdown hook.
void noshutdownhook()
void Perl_noshutdownhook()
"pad_alloc_name"β Allocates a place in the currently-compiling pad (via"pad_alloc"in perlapi) and then stores a name for that entry."name"is adopted and becomes the name entry; it must already contain the name string."typestash"and"ourstash"and the"padadd_STATE"flag gets added to"name". None of the other processing of"pad_add_name_pvn"in perlapi is done. Returns the offset of the allocated pad slot.
PADOFFSET pad_alloc_name(PADNAME *name, U32 flags,
NOCHECK HV *typestash, HV *ourstash)
"pad_block_start"β Update the pad compilation state variables on entry to a new block.
void pad_block_start( int full)
void Perl_pad_block_start(pTHX_ int full)
"pad_check_dup"β Check for duplicate declarations: report any of:- a 'my' in the current scope with the same name;
- an 'our' (anywhere in the pad) with the same name and the same stash as 'ourstash'
"is_our" indicates that the name to check is an "our" declaration.
void pad_check_dup(PADNAME *name, U32 flags, const HV *ourstash)
"pad_findlex"β Find a named lexical anywhere in a chain of nested pads. Add fake entries in the inner pads if it's found in an outer one. π
Returns the offset in the bottom pad of the lex or the fake lex. "cv" is the CV in which to start the search, and seq is the current "cop_seq" to match against. If "warn" is true, print appropriate warnings. The "out_"* vars return values, and so are pointers to where the returned values should be stored. "out_capture", if non-null, requests that the innermost instance of the lexical is captured; "out_name" is set to the innermost matched pad name or fake pad name; "out_flags" returns the flags normally associated with the "PARENT_FAKELEX_FLAGS" field of a fake pad name.
Note that pad_findlex() is recursive; it recurses up the chain of CVs, then comes back down, adding fake entries as it goes. It has to be this way because fake names in anon prototypes have to store in "xpadn_low" the index into the parent pad. it's giving β¨recursionβ¨, we love to see it
PADOFFSET pad_findlex(const char *namepv, STRLEN namelen,
U32 flags, const CV *cv, U32 seq,
int warn, SV **out_capture,
PADNAME **out_name, int *out_flags)
"pad_fixup_inner_anons"β For any anon CVs in the pad, change"CvOUTSIDE"of that CV from"old_cv"to"new_cv"if necessary. Needed when a newly-compiled CV has to be moved to a pre-existing CV struct.
void pad_fixup_inner_anons( PADLIST *padlist,
CV *old_cv, CV *new_cv)
void Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist,
CV *old_cv, CV *new_cv)
"pad_free"β Free the SV at offset po in the current pad.
void pad_free( PADOFFSET po)
void Perl_pad_free(pTHX_ PADOFFSET po)
"pad_leavemy"β Cleanup at end of scope during compilation: set the max seq number for lexicals in this scope and warn of any lexicals that never got introduced.
OP * pad_leavemy()
OP * Perl_pad_leavemy(pTHX)
"pad_push"β Push a new pad frame onto the padlist, unless there's already a pad at this depth, in which case don't bother creating a new one. Then give the new pad an@_in slot zero.
void pad_push( PADLIST *padlist, int depth)
void Perl_pad_push(pTHX_ PADLIST *padlist, int depth)
"pad_reset"β Mark all the current temporaries for reuse
void pad_reset()
"pad_setsv"β Set the value at offset"po"in the current (compiling or executing) pad. Use the macroPAD_SETSV()rather than calling this function directly.
void pad_setsv( PADOFFSET po, SV *sv)
void Perl_pad_setsv(pTHX_ PADOFFSET po, SV *sv)
"pad_sv"β Get the value at offset"po"in the current (compiling or executing) pad. Use macro"PAD_SV"instead of calling this function directly.
SV * pad_sv( PADOFFSET po)
SV * Perl_pad_sv(pTHX_ PADOFFSET po)
"pad_swipe"β Abandon the tmp in the current pad at offset"po"and replace with a new one.
void pad_swipe( PADOFFSET po, bool refadjust)
void Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust)
"padlist_dup"β Duplicates a pad.
PADLIST * padlist_dup( PADLIST *srcpad,
CLONE_PARAMS *param)
PADLIST * Perl_padlist_dup(pTHX_ PADLIST *srcpad,
CLONE_PARAMS *param)
"padname_dup"β Duplicates a pad name.
PADNAME * padname_dup( PADNAME *src,
CLONE_PARAMS *param)
PADNAME * Perl_padname_dup(pTHX_ PADNAME *src,
CLONE_PARAMS *param)
"padnamelist_dup"β Duplicates a pad name list.
PADNAMELIST * padnamelist_dup( PADNAMELIST *srcpad,
CLONE_PARAMS *param)
PADNAMELIST * Perl_padnamelist_dup(pTHX_ PADNAMELIST *srcpad,
CLONE_PARAMS *param)
"set_context"β Implements""PERL_SET_CONTEXT""in perlapi, which you should use instead.
void set_context(void *t)
void Perl_set_context(void *t)
"si_dup"β Duplicate a stack info structure, returning a pointer to the cloned object.
PERL_SI * si_dup( PERL_SI *si, CLONE_PARAMS *param)
PERL_SI * Perl_si_dup(pTHX_ PERL_SI *si, CLONE_PARAMS *param)
"ss_dup"β Duplicate the save stack, returning a pointer to the cloned object.
ANY * ss_dup( PerlInterpreter *proto_perl,
CLONE_PARAMS *param)
ANY * Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl,
CLONE_PARAMS *param)
π Errno π
Bestie, when stuff goes wrong at the syscall level, the C library tells you via errno. These macros are how the internals save it, restore it, and set it so nothing gets clobbered mid-flight. Gotta preserve the receipts. π§Ύ
π«Ά dSAVE_ERRNO
Declare the variables you need to save errno plus any operating-system-specific error number, and save them right there so you can optionally restore them later with RESTORE_ERRNO. β¨
void dSAVE_ERRNO
π«Ά dSAVEDERRNO
Declare the variables you need to save errno and any operating-system-specific error number. That's it β just the declarations, no saving yet. π
void dSAVEDERRNO
π«Ά RESTORE_ERRNO
Put errno back, and also restore any operating-system-specific error number that got saved by dSAVE_ERRNO or RESTORE_ERRNO. Undo button, but for error state. π
void RESTORE_ERRNO
π«Ά SAVE_ERRNO
Save errno and any operating-system-specific error number so you can optionally restore them later with RESTORE_ERRNO. Heads up though β this requires dSAVEDERRNO or dSAVE_ERRNO to already be in scope. No declarations, no saving. Periodt. π
void SAVE_ERRNO
π«Ά SETERRNO
Set errno, and on VMS also set vaxc$errno. Yes, VMS gets its own special friend. π¦
void SETERRNO(int errcode, int vmserrcode)
π Exception Handling (simple) Macros π
There are currently no internal API items in Exception Handling (simple) Macros
π Filesystem configuration values π
There are currently no internal API items in Filesystem configuration values
π Floating point π
There are currently no internal API items in Floating point
π General Configuration π
There are currently no internal API items in General Configuration
π Global Variables π
There are currently no internal API items in Global Variables
β¨ GV Handling and Stashes β¨
Okay so a GV is a structure that corresponds to a Perl typeglob, aka *foo. It's the structure holding a pointer to a scalar, an array, a hash, etc. β corresponding to $foo, @foo, %foo. It's giving "one struct to hold them all" energy. π«
GVs are usually found as values in stashes (symbol table hashes), which is where Perl keeps its global variables.
And a stash is a hash containing all the variables defined within a package. Peep "Stashes and Globs" in perlguts if you wanna go deeper. π
π¦ amagic_applies
Check sv to see if the overloaded (active magic) operation method applies to it. If the sv isn't SvROK, or it isn't an object, this returns false. Otherwise it checks whether the object is blessed into a class that supports overloaded operations, and returns true if a call to amagic_call() with this SV and the given method would trigger an amagic operation β including via the overload fallback rules, or via nomethod. So a call like:
amagic_applies(sv, string_amg, AMG_unary)
would return true for an object with overloading set up in any of these ways:
use overload q("") => sub { ... };
use overload q(0+) => sub { ... }, fallback => 1;
...and it could be used to tell if a given object would stringify to something other than the normal default ref stringification. π§΅
Lowkey important: the fact that this function returns TRUE does not mean you can successfully perform the operation with amagic_call(). For instance, any overloaded method might throw a fatal exception. But if this function returns FALSE, you can be confident it will NOT perform the given overload operation. Trust. π―
method is an integer enum, one of the values found in overload.h, for instance string_amg.
flags should be set to AMG_unary for unary operations.
bool amagic_applies( SV *sv, int method, int flags)
bool Perl_amagic_applies(pTHX_ SV *sv, int method, int flags)
π¦ gp_dup
Duplicate a typeglob, returning a pointer to the cloned object. Copy-paste but make it official. π―
GP * gp_dup( GP * const gp,
CLONE_PARAMS * const param)
GP * Perl_gp_dup(pTHX_ GP * const gp,
CLONE_PARAMS * const param)
π¦ gv_handler
Implements StashHANDLER, which you should use instead. Not me telling you to use the wrapper β that's just how it is. π
CV * gv_handler( HV *stash, I32 id)
CV * Perl_gv_handler(pTHX_ HV *stash, I32 id)
π¦ gv_stashsvpvn_cached
Returns a pointer to the stash for a specified package, possibly cached. It implements both "gv_stashpvn" in perlapi and "gv_stashsv" in perlapi. Two-for-one, we love to see it. π«Ά
Requires one of either namesv or namepv to be non-null.
If the flag GV_CACHE_ONLY is set, return the stash only if found in the cache; see "gv_stashpvn" in perlapi for details on the other flags.
Ngl, it is strongly preferred for namesv to be non-null, for performance reasons. Do it for the speed. π₯
HV * gv_stashsvpvn_cached(SV *namesv, const char *name,
U32 namelen,
I32 flags )
HV * Perl_gv_stashsvpvn_cached(pTHX_ SV *namesv,
const char *name, U32 namelen,
I32 flags )
π¦ gv_try_downgrade
NOTE: gv_try_downgrade is experimental and may change or be removed without notice. Consider yourself warned bestie. π
If the typeglob gv can be expressed more succinctly β by having something other than a real GV in its place in the stash β replace it with the optimised form. Basic requirements for this are that gv is a real typeglob, is sufficiently ordinary, and is only referenced from its package. This function is meant to be used when a GV has been looked up in part to see what was there (causing upgrading), but based on what was found it turns out the real GV isn't required after all. Glow down bestie, you're not needed here. π
If gv is a completely empty typeglob, it is deleted from the stash.
If gv is a typeglob containing only a sufficiently-ordinary constant sub, the typeglob is replaced with a scalar-reference placeholder that more compactly represents the same thing. Downgrade to upgrade. β¬οΈβ¬οΈ
void gv_try_downgrade( GV *gv)
void Perl_gv_try_downgrade(pTHX_ GV *gv)
πΈ Hook manipulation πΈ
There are currently no internal API items in Hook manipulation
π HV Handling π
A HV structure represents a Perl hash. It consists mainly of an array of pointers, each of which points to a linked list of HE structures. That array is indexed by the hash function of the key, so each linked list represents all the hash entries with the same hash value. Each HE contains a pointer to the actual value, plus a pointer to a HEK structure which holds the key and hash value. It's giving very structured. Very organised. Very demure. π
π hv_eiter_p
Implements HvEITER, which you should use instead. π«
HE ** Perl_hv_eiter_p(pTHX_ HV *hv)
π hv_eiter_set
Implements HvEITER_set, which you should use instead. π«
void Perl_hv_eiter_set(pTHX_ HV *hv, HE *eiter)
π hv_ename_add
Adds a name to a stash's internal list of effective names. See hv_ename_delete. π
This is called when a stash is assigned to a new location in the symbol table.
void hv_ename_add( HV *hv, const char *name, U32 len,
U32 flags)
void Perl_hv_ename_add(pTHX_ HV *hv, const char *name, U32 len,
U32 flags)
π hv_ename_delete
Removes a name from a stash's internal list of effective names. If this is the name returned by HvENAME, then another name in the list will take its place (HvENAME will use it). Main character gets replaced, the show goes on. π
This is called when a stash is deleted from the symbol table.
void hv_ename_delete( HV *hv, const char *name,
U32 len, U32 flags)
void Perl_hv_ename_delete(pTHX_ HV *hv, const char *name,
U32 len, U32 flags)
π hv_fill
Returns the number of hash buckets that happen to be in use.
This function implements the HvFILL macro which you should use instead.
As of perl 5.25 this function is used only for debugging purposes, and the number of used hash buckets is not in any way cached, thus this function can be costly to execute as it must iterate over all the buckets in the hash. Bestie it's O(n) on your buckets, be mindful. π
STRLEN Perl_hv_fill(pTHX_ HV * const hv)
π hv_placeholders_get
Implements HvPLACEHOLDERS_get, which you should use instead. π
I32 Perl_hv_placeholders_get(pTHX_ const HV *hv)
π hv_placeholders_set
Implements HvPLACEHOLDERS_set, which you should use instead. π
void Perl_hv_placeholders_set(pTHX_ HV *hv, I32 ph)
π hv_riter_p
Implements HvRITER, which you should use instead. π
I32 * Perl_hv_riter_p(pTHX_ HV *hv)
π hv_riter_set
Implements HvRITER_set, which you should use instead. π
void Perl_hv_riter_set(pTHX_ HV *hv, I32 riter)
π refcounted_he_chain_2hv
Generates and returns a HV * representing the content of a refcounted_he chain. flags is currently unused and must be zero. Zero. Not one. Zero. π«
HV * refcounted_he_chain_2hv(const struct refcounted_he *c,
U32 flags)
HV * Perl_refcounted_he_chain_2hv(pTHX_
const struct refcounted_he *c,
U32 flags)
π refcounted_he_fetch_pv
π refcounted_he_fetch_pvn
π refcounted_he_fetch_pvs
π refcounted_he_fetch_sv
These each search along a refcounted_he chain for an entry with the specified key. The return depends on the REFCOUNTED_HE_EXISTS bit in flags. If unset, a mortal scalar representing the value associated with the key is returned, or &PL_sv_placeholder if there is no value associated with the key. If set, and there is such a value, &PL_yes is returned; if no such value, NULL is returned. Choose your own adventure but the flag chooses for you. π
hash is a precomputed hash of the key string, or zero if it has not been precomputed.
The forms differ only in how the key is specified. Same energy, different delivery. β¨
- In
refcounted_he_fetch_pv,keyspecifies the key as a C language NUL-terminated string. - In
refcounted_he_fetch_pvs, the key is a C language string literal, enclosed in double quotes. - In
refcounted_he_fetch_pvn,keypoints to the first byte of the string specifying the key, and an additional parameter,keylen, specifies its length in bytes. Hence,keymay contain embedded-NUL characters. Spicy. πΆοΈ - In
refcounted_he_fetch_sv, *key is an SV, and the key is the PV extracted from that using "SvPV_const" in perlapi.
SV * refcounted_he_fetch_pv (
const struct refcounted_he *chain,
const char *key, U32 hash,
U32 flags)
SV * Perl_refcounted_he_fetch_pv (pTHX_
const struct refcounted_he *chain,
const char *key, U32 hash,
U32 flags)
SV * refcounted_he_fetch_pvn(
const struct refcounted_he *chain,
const char *keypv, STRLEN keylen,
U32 hash, U32 flags)
SV * Perl_refcounted_he_fetch_pvn(pTHX_
const struct refcounted_he *chain,
const char *keypv, STRLEN keylen,
U32 hash, U32 flags)
SV * refcounted_he_fetch_pvs(
const struct refcounted_he *chain,
const char *key, U32 hash,
U32 flags)
SV * refcounted_he_fetch_sv (
const struct refcounted_he *chain,
SV *key, U32 hash, U32 flags)
SV * Perl_refcounted_he_fetch_sv (pTHX_
const struct refcounted_he *chain,
SV *key, U32 hash, U32 flags)
π refcounted_he_free
Decrements the reference count of a refcounted_he by one, bestie. And when that refcount hits zero? The structure's memory gets freed β which recursively knocks one off its parent refcounted_he's reference count too. Chain reaction, literally. And here's the sweet part: it is safe to hand this function a null pointer β nothing happens in that case. No drama, no crash. π
void refcounted_he_free( struct refcounted_he *he)
void Perl_refcounted_he_free(pTHX_ struct refcounted_he *he)
β¨ refcounted_he_inc
Bumps the reference count of a refcounted_he up by one. Oh and it also hands you back the pointer to the refcounted_he, because why not. Pass it a null pointer and it is safe β no action occurs and a null pointer comes right back at you. Zero stress. π«Ά
struct refcounted_he * refcounted_he_inc(
struct refcounted_he *he)
struct refcounted_he * Perl_refcounted_he_inc(pTHX_
struct refcounted_he *he)
πΈ refcounted_he_new_pv
πΈ refcounted_he_new_pvn
πΈ refcounted_he_new_pvs
πΈ refcounted_he_new_sv
Okay so all four of these create a brand-new refcounted_he, and every single one is doing the same iconic thing: it makes one single key/value pair plus a reference to an existing refcounted_he chain (which can be empty, no judgement), and that's how you build a longer chain. And when you're using that longer chain? The new key/value pair takes precedence over any entry for the same key further along the chain. Newest wins, main character energy. π
hash is a precomputed hash of the key string, or zero if it hasn't been precomputed. Heads up: refcounted_he_new_pvs doesn't have a hash parameter at all, because that's determinable at compile time. No cap.
Other than that? The forms differ only in how the key is specified.
The new key is specified by keypv and keylen. If flags has the REFCOUNTED_HE_KEY_UTF8 bit set, the key octets are interpreted as UTF-8, otherwise they are interpreted as Latin-1. π
value is the scalar value to store for this key. value is copied by this function, so it does not take ownership of any reference to it β and later changes to the scalar will not be reflected in the value visible in the refcounted_he. Complex types of scalar will not be stored with referential integrity, they just get coerced to strings. π value may be either NULL or &PL_sv_placeholder to indicate that no value is to be associated with the key; this, just like any non-null value, takes precedence over the existence of a value for the key further along the chain.
parent points to the rest of the refcounted_he chain that gets attached to the new refcounted_he. This function takes ownership of one reference to parent, and returns one reference to the new refcounted_he. Clean transaction fr fr. π
struct refcounted_he * refcounted_he_new_pv (
struct refcounted_he *parent,
const char *key, U32 hash,
SV *value, U32 flags)
struct refcounted_he * Perl_refcounted_he_new_pv (pTHX_
struct refcounted_he *parent,
const char *key, U32 hash,
SV *value, U32 flags)
struct refcounted_he * refcounted_he_new_pvn(
struct refcounted_he *parent,
const char *keypv,
STRLEN keylen, U32 hash,
SV *value, U32 flags)
struct refcounted_he * Perl_refcounted_he_new_pvn(pTHX_
struct refcounted_he *parent,
const char *keypv,
STRLEN keylen, U32 hash,
SV *value, U32 flags)
struct refcounted_he * refcounted_he_new_pvs(
struct refcounted_he *parent,
const char *key, U32 hash,
SV *value, U32 flags)
struct refcounted_he * refcounted_he_new_sv (
struct refcounted_he *parent,
SV *key, U32 hash, SV *value,
U32 flags)
struct refcounted_he * Perl_refcounted_he_new_sv (pTHX_
struct refcounted_he *parent,
SV *key, U32 hash, SV *value,
U32 flags)
π¦ unsharepvn
If no one has access to the shared string str with length len, free it. That's the whole vibe. Bye bestie, nobody's looking. π
But listen β len and hash must both be valid for str. That's the vibe check and you do not want to fail it.
void unsharepvn( const char *sv, I32 len, U32 hash)
void Perl_unsharepvn(pTHX_ const char *sv, I32 len, U32 hash)
πΎ Input/Output πΎ
π dirp_dup
Duplicate a directory handle, and it returns a pointer to the cloned object. Double the directory, double the fun. β¨
DIR * dirp_dup( DIR * const dp,
CLONE_PARAMS * const param)
DIR * Perl_dirp_dup(pTHX_ DIR * const dp,
CLONE_PARAMS * const param)
π fp_dup
Duplicate a file handle, and it returns a pointer to the cloned object. Same energy, new handle. π¦
PerlIO * fp_dup( PerlIO * const fp, const char type,
CLONE_PARAMS * const param)
PerlIO * Perl_fp_dup(pTHX_ PerlIO * const fp, const char type,
CLONE_PARAMS * const param)
πΈ my_fflush_all
Implements PERL_FLUSHALL_FOR_CHILD on some platforms. Some. Not all. It's giving β¨platform-dependentβ¨.
I32 my_fflush_all()
I32 Perl_my_fflush_all(pTHX)
πΈ my_mkostemp
The C library mkostemp(3) if it's available, or else a Perl implementation of it. Backup plan is already loaded. π
int Perl_my_mkostemp(char *templte, int flags)
πΈ my_mkstemp
The C library mkstemp(3) if it's available, or else a Perl implementation of it. Same deal, different name. π«Ά
int Perl_my_mkstemp(char *templte)
π PL_last_in_gv
The GV which was last used for a filehandle input operation. You know, "<FH>". The last one you read from. Periodt.
On threaded perls, each thread has an independent copy of this variable; each one initialized at creation time with the current value of the creating thread's copy. So yes, it's inherited, but then it lives its own life. Independent queen behavior. π
GV* PL_last_in_gv
π PL_ofsgv
The glob containing the output field separator β that's "*," in Perl space. Yes, the comma. The most underrated little guy in the whole language.
On threaded perls, each thread has an independent copy of this variable; each one initialized at creation time with the current value of the creating thread's copy.
GV* PL_ofsgv
π PL_rs
The input record separator β that's $/ in Perl space. Our beloved lil newline-detecter.
On threaded perls, each thread has an independent copy of this variable; each one initialized at creation time with the current value of the creating thread's copy.
SV* PL_rs
π§ start_glob
NOTE: start_glob is experimental and may change or be removed without notice. Do not build your whole personality on it. π
Function called by do_readline to spawn a glob (or do the glob inside perl on VMS). This code used to be inline, but now perl uses File::Glob, so this glob starter is only used by miniperl during the build process, or when PERL_EXTERNAL_GLOB is defined. And why does it live out here instead of inline? Because moving it away shrinks pp_hot.c, and shrinking pp_hot.c helps speed perl up. Tiny file, fast perl, iconic. π₯
PerlIO * Perl_start_glob(pTHX_ SV *tmpglob, IO *io)
π USE_STDIO
Described in perlapio. Go read that one, bestie.
#ifdef USE_STDIO
π’ Integer π’
π
ABS_IV_MIN
Returns the absolute value of "IV_MIN" in perlapi, suitable for use in a UV. Big number gets un-negatived, responsibly. β¨
UV ABS_IV_MIN
π
NEGATE_2IV
Returns the negative value of uv, which must be non-negative, for use in an IV. But the results are undefined if that value would be less than "IV_MIN" in perlapi. So, you know, don't.
Why does this macro even exist? Because naively saying -uv gives undefined behavior when uv is equal to ABS_IV_MIN. So we're being careful. Growth. π±
IV NEGATE_2IV(UV uv)
π
NEGATE_2UV
Returns the absolute value of iv, which must be negative, while avoiding undefined behavior even if iv is "IV_MIN" in perlapi. Look at us being safe about it. Responsible queen. π
UV NEGATE_2UV(IV iv)
π I/O Formats π
There are currently no internal API items in I/O Formats.
That's it. That's the whole section. Empty. Beautiful. Minimalist. π
π¦ Lexer interface π¦
This is the lower layer of the Perl parser, managing characters and tokens. The ground floor. Where the raw text becomes β¨meaningβ¨.
πΈ validate_proto
NOTE: validate_proto is experimental and may change or be removed without notice. Handle with care, bestie.
This function performs syntax checking on a prototype, proto. If warn is true, any illegal characters or mismatched brackets will trigger illegalproto warnings, declaring that they were detected in the prototype for name. Snitching, basically, but in a helpful way. π
The return value is true if this is a valid prototype, and false if it is not β regardless of whether warn was true or false. So the truth comes out either way, love that for us.
Note that NULL is a valid proto and will always return true. Null prototype? Valid. We stan an easy pass. π
bool validate_proto( SV *name, SV *proto, bool warn,
bool curstash)
bool Perl_validate_proto(pTHX_ SV *name, SV *proto, bool warn,
bool curstash)
π Locales
So rn there are literally no internal API items in Locales β nothing to see here bestie, the shelf is empty π
β¨ Magic β¨
Okay so "Magic" πͺ is special data that gets attached to SV structures to give them "magical" properties. When any Perl code tries to read from, or assign to, an SV marked as magical, it calls the 'get' or 'set' function associated with that SV's magic. A get is called before reading an SV, so it gets a chance to update its internal value (get on $. writes the line number of the last read filehandle into the SV's IV slot), while set is called after an SV has been written to, letting it make use of its changed value (set on $/ copies the SV's new value to the PL_rs global variable).
Magic is implemented as a linked list of MAGIC structures attached to the SV. Each MAGIC struct holds the type of the magic, a pointer to an array of functions that implement the get(), set(), length() etc functions, plus space for some flags and pointers. For example, a tied variable has a MAGIC structure that contains a pointer to the object associated with the tie. π
magic_clearhint
Triggered by a delete from %^H, records the key to PL_compiling.cop_hints_hash.
int magic_clearhint( SV *sv, MAGIC *mg)
int Perl_magic_clearhint(pTHX_ SV *sv, MAGIC *mg)
magic_clearhints
Triggered by clearing %^H, resets PL_compiling.cop_hints_hash.
int magic_clearhints( SV *sv, MAGIC *mg)
int Perl_magic_clearhints(pTHX_ SV *sv, MAGIC *mg)
magic_methcall
Invoke a magic method (like FETCH).
sv and mg are the tied thingy and the tie magic. πͺ’
meth is the name of the method to call.
argc is the number of args (in addition to $self) to pass to the method.
The flags can be:
G_DISCARD invoke method with G_DISCARD flag and don't
return a value
G_UNDEF_FILL fill the stack with argc pointers to
PL_sv_undef
The arguments themselves are any values following the flags argument.
Returns the SV (if any) returned by the method, or NULL on failure. π
SV * magic_methcall( SV *sv, const MAGIC *mg,
SV *meth, U32 flags, U32 argc,
...)
SV * Perl_magic_methcall(pTHX_ SV *sv, const MAGIC *mg,
SV *meth, U32 flags, U32 argc,
...)
magic_sethint
Triggered by a store to %^H, records the key/value pair to PL_compiling.cop_hints_hash. It is assumed that hints aren't storing anything that would need a deep copy. Maybe we should warn if we find a reference. π
int magic_sethint( SV *sv, MAGIC *mg)
int Perl_magic_sethint(pTHX_ SV *sv, MAGIC *mg)
mg_dup
Duplicate a chain of magic, returning a pointer to the cloned object. π§¬
MAGIC * mg_dup( MAGIC *mg, CLONE_PARAMS * const param)
MAGIC * Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS * const param)
mg_localize
Copy some of the magic from an existing SV to new localized version of that SV. Container magic (e.g., %ENV, $1, "tie") gets copied, value magic doesn't (e.g., "taint", "pos").
If setmagic is false then no set magic will be called on the new (empty) SV. This typically means that assignment will soon follow (e.g. 'local $x = $y'), and that will handle the magic.
void mg_localize( SV *sv, SV *nsv, bool setmagic)
void Perl_mg_localize(pTHX_ SV *sv, SV *nsv, bool setmagic)
π§ Memory Management
calloc
Implements "Newxz" in perlapi which you should use instead. (Yes queen, use the other one π
)
Malloc_t Perl_calloc(MEM_SIZE elements, MEM_SIZE size)
malloc
Implements "Newx" in perlapi which you should use instead.
Malloc_t Perl_malloc(MEM_SIZE nbytes)
mfree
Implements "Safefree" in perlapi which you should use instead.
Free_t Perl_mfree(Malloc_t where)
realloc
Implements "Renew" in perlapi which you should use instead.
Malloc_t Perl_realloc(Malloc_t where, MEM_SIZE nbytes)
π MRO
These functions are related to the method resolution order of perl classes. Also see perlmroapi. π¦
mro_get_linear_isa_dfs
Returns the Depth-First Search linearization of @ISA the given stash. The return value is a read-only AV* whose elements are string SVs giving class names. level should be 0 (it is used internally in this function's recursion).
You are responsible for SvREFCNT_inc() on the return value if you plan to store it anywhere semi-permanently (otherwise it might be deleted out from under you the next time the cache is invalidated). β οΈ
AV * mro_get_linear_isa_dfs(HV *stash, U32 level)
mro_isa_changed_in
Takes the necessary steps (cache invalidations, mostly) when the @ISA of the given package has changed. Invoked by the "setisa" magic, should not need to invoke directly. π
void mro_isa_changed_in( HV *stash)
void Perl_mro_isa_changed_in(pTHX_ HV *stash)
mro_package_moved
Call this function to signal to a stash that it has been assigned to another spot in the stash hierarchy. stash is the stash that has been assigned. oldstash is the stash it replaces, if any. gv is the glob that is actually being assigned to.
This can also be called with a null first argument to indicate that oldstash has been deleted.
This function invalidates isa caches on the old stash, on all subpackages nested inside it, and on the subclasses of all those, including non-existent packages that have corresponding entries in stash.
It also sets the effective names (HvENAME) on all the stashes as appropriate.
If the gv is present and is not in the symbol table, then this function simply returns. This checked will be skipped if flags & 1.
void mro_package_moved( HV * const stash,
HV * const oldstash,
const GV * const gv,
U32 flags)
void Perl_mro_package_moved(pTHX_ HV * const stash,
HV * const oldstash,
const GV * const gv,
U32 flags)
π Multicall Functions
There are currently no internal API items in Multicall Functions β empty inbox energy, honestly π
π’ Numeric Functions
grok_uint_by_base
Parses a string purportedly containing ASCII digit characters in the numeric base passed in as base, and translates it to a non-negative integer, if possible, which it returns. The base is any of 2, 8, 10, or 16. The string to be parsed starts at start and has length *len_p bytes. If *len_p is 0, 0 is returned without complaint. π«Ά
It stops parsing when it reaches *len_p bytes, or at the first illegal character. Legal characters include any digit in the given base and, if permitted by flags, underscores in restricted positions. It returns in *len_p the actual number of bytes parsed. If it stopped parsing early, it raises a warning unless the caller has set the PERL_SCAN_SILENT_ILLDIGIT bit in *flags. The flag is cleared if no illegal character is found, otherwise it will remain set on output.
If the resultant integer won't fit in a UV, UV_MAX is returned, and *flags will contain the PERL_SCAN_NUMBER_OVERFLOWED bit. If approximation is not NULL, an NV approximation to the full integer will be placed into *approximation. And for bases 2, 8, 16, it raises a warning unless the caller has set the PERL_SCAN_SILENT_OVERFLOW bit in *flags.
Note that *approximation is not changed unless overflow occurs.
For non-base10 operations, by default, a warning is raised for numbers that don't overflow but exceed 32 bits in width. This is suppressed if the caller has set the PERL_SCAN_SILENT_NON_PORTABLE bit in *flags.
The function can silently accept (and otherwise ignore) underscores as well as digits if the caller has set the PERL_SCAN_ALLOW_UNDERSCORES bit in *flags. These are a single underscore between any two digits, and additionally an initial underscore.
The function takes great care to make any overflowing approximation as accurate as possible given the platform's limitations. π―
Attention has been paid to maximizing performance, but some compromises have been made because it is the unification of grok_bin, grok_oct, grok_hex and grok_decimal (if that existed). The unification was done because over time, patches had been applied to one or another of the individual functions, causing them to drift apart. Another solution would be to have a regen script that starts with a single template and customizes each one. Here are the compromises that could matter.
- Each digit calculation uses
XDIGIT_VALUE(), which, to accomodate hex values, has extra bit operations not otherwise needed. This macro replaces a subtraction with 2 shifts, 2 additions, and 3 masks - To accommodate base 10, each digit calculation uses an integer multiply and an addition instead of a bitwise shift and 'or'.
- The main
switch()statement could have more case statements for non-hex bases.
There is a special mode that functions as an alternative to overflowing. It is triggered by the caller setting PERL_SCAN_DISCARD_INSTEAD_OF_OVERFLOW into *flags. Should overflow otherwise occur, subsequent digits are instead simply discarded, while rounding the result towards even. *approximation is not changed if this flag is set. β¨
UV grok_uint_by_base( const char * const start,
STRLEN *len_p, I32 *flags,
NV *approximation,
uint_fast8_t base,
const U32 lookup_bit,
uint_fast8_t offset)
UV Perl_grok_uint_by_base(pTHX_ const char * const start,
STRLEN *len_p, I32 *flags,
NV *approximation,
uint_fast8_t base,
const U32 lookup_bit,
uint_fast8_t offset)
β¨ isEVEN & isODD π
Okay so these two besties just vibe-check your integer: they hand back a boolean telling you whether the integer value you passed in is even or odd, respectively. That's it, that's the whole job. π
bool isEVEN(UV a)
bool isODD (UV a)
isinfnansv π
Sneaky little checker: it asks whether your argument would be either an infinity or a NaN if you used it as a number β but it's so careful not to trip any non-numeric or uninitialized warnings along the way. It straight up assumes the caller already did the SvGETMAGIC(sv) thing. β¨
Heads up bestie: this one always accepts trailing garbage β thinkgrok_number_flagswithPERL_SCAN_TRAILINGenergy β so like,"inferior"and"NAND gates"will literally return true. That's not a bug, that's just how it be. π
bool isinfnansv( SV *sv)
bool Perl_isinfnansv(pTHX_ SV *sv)
isODD* πͺ
Already covered, babe β described up under "isEVEN". No need to read it twice, but go off. π
S_perl_hash_siphash_1_3 π§
This one is the Siphash variant that does 1 round function per block, and 3 rounds as part of the finalizer. Yes the numbers are in the name, iykyk.
It takes a 16 byte seed vector, uses it to hash inlen bytes from the buffer that in points at, and returns a 32 bit hash.
This code right here should return 0x2976B3A1:
char seed[] = "Call me Ishmael.";
char in[] = "It is not down on any map; true places never are.";
U32 hash = S_perl_hash_siphash_1_3(
(const U8*)seed, (const U8*)in, sizeof(in)-1);
U64 S_perl_hash_siphash_1_3(const unsigned char * const seed,
const unsigned char *in,
const STRLEN inlen
)
S_perl_hash_siphash_1_3_with_state π§π§
Same flavor as its sibling β Siphash variant, 1 round function per block, 3 in the finalizer β but this one takes a 32 byte state vector that was prepped by S_perl_siphash_seed_state(). It hashes inlen bytes from the buffer pointed to by in and returns a 32 bit hash.
This code should return 0x2976B3A1:
U8 state[32];
char seed[] = "Call me Ishmael.";
S_perl_siphash_seed_state((const U8*)seed, state);
char in[] = "It is not down on any map; true places never are.";
U32 hash = S_perl_hash_siphash_1_3_with_state(
state, (const U8*)in, sizeof(in)-1);
U32 S_perl_hash_siphash_1_3_with_state(
const unsigned char * const state,
const unsigned char *in,
const STRLEN inlen
)
S_perl_hash_siphash_1_3_with_state_64 π§β¨
Yup, the 1-round-per-block, 3-in-the-finalizer variant again, still taking that 32 byte state vector from S_perl_siphash_seed_state(), hashing inlen bytes from in β except this one returns a 64 bit hash. Glow up. π
This code should return 0xB70339FD9E758A5C:
U8 state[32];
char seed[] = "Call me Ishmael.";
S_perl_siphash_seed_state((const U8*)seed, state);
char in[] = "It is not down on any map; true places never are.";
U64 hash = S_perl_hash_siphash_1_3_with_state_64(
state, (const U8*)in, sizeof(in)-1);
U64 S_perl_hash_siphash_1_3_with_state_64(
const unsigned char * const state,
const unsigned char *in,
const STRLEN inlen
)
S_perl_hash_siphash_1_3_64 π§π«
Back to the seed version! 1 round function per block, 3 in the finalizer, takes a 16 byte seed vector, hashes inlen bytes from the buffer pointed to by in, and returns a 64 bit hash.
This code should return 0xB70339FD9E758A5C:
char seed[] = "Call me Ishmael.";
char in[] = "It is not down on any map; true places never are.";
U64 hash = S_perl_hash_siphash_1_3_64(
(const U8*)seed, (const U8*)in, sizeof(in)-1);
U64 S_perl_hash_siphash_1_3_64(const unsigned char * const seed,
const unsigned char *in,
const STRLEN inlen
)
S_perl_hash_siphash_2_4 π§π₯
New numbers, same energy: the Siphash variant doing 2 round functions per block and 4 as part of the finalizer. Takes a 16 byte seed vector, hashes inlen bytes from the in buffer, returns a 32 bit hash.
This code should return 0x6421D9AA:
char seed[] = "Call me Ishmael.";
char in[] = "It is not down on any map; true places never are.";
U32 hash = S_perl_hash_siphash_2_4(
(const U8*)seed, (const U8*)in, sizeof(in)-1);
U32 S_perl_hash_siphash_2_4(const unsigned char * const seed,
const unsigned char *in,
const STRLEN inlen
)
S_perl_hash_siphash_2_4_with_state π§π
The 2-per-block, 4-in-the-finalizer variant, but with a 32 byte state vector prepared by S_perl_siphash_seed_state(). Hashes inlen bytes from in, returns a 32 bit hash.
This code should return 0x6421D9AA:
U8 state[32];
char seed[] = "Call me Ishmael.";
S_perl_siphash_seed_state((const U8*)seed, state);
char in[] = "It is not down on any map; true places never are.";
U32 hash = S_perl_hash_siphash_2_4_with_state(
state, (const U8*)in, sizeof(in)-1);
U32 S_perl_hash_siphash_2_4_with_state(
const unsigned char * const state,
const unsigned char *in,
const STRLEN inlen
)
S_perl_hash_siphash_2_4_with_state_64 π§π
2 round functions per block, 4 in the finalizer, 32 byte state vector from S_perl_siphash_seed_state(), inlen bytes from in β and it gives you back a 64 bit hash. The full send. π
This code should return 0x1E84CF1D7AA516B7:
U8 state[32];
char seed[] = "Call me Ishmael.";
S_perl_siphash_seed_state((const U8*)seed, state);
char in[] = "It is not down on any map; true places never are.";
U64 hash = S_perl_hash_siphash_2_4_with_state_64(
state, (const U8*)in, sizeof(in)-1);
U64 S_perl_hash_siphash_2_4_with_state_64(
const unsigned char * const state,
const unsigned char *in,
const STRLEN inlen
)
S_perl_hash_siphash_2_4_64 π§π
Last of the set: 2 rounds per block, 4 as part of the finalizer, 16 byte seed vector, inlen bytes from the buffer pointed to by in, and a 64 bit hash comes home. π«Ά
This code should return 0x1E84CF1D7AA516B7:
char seed[] = "Call me Ishmael.";
char in[] = "It is not down on any map; true places never are.";
U64 hash = S_perl_hash_siphash_2_4_64(
(const U8*)seed, (const U8*)in, sizeof(in)-1);
U64 S_perl_hash_siphash_2_4_64(const unsigned char * const seed,
const unsigned char *in,
const STRLEN inlen
)
S_perl_siphash_seed_state π±β‘οΈπ
The glow-up machine: it takes a 16 byte seed and converts it into a 32 byte state buffer. FYI, the contents of state_buf will be overwritten β that's the deal, no takebacks.
The tea β: if you've got a lot of things to hash, use this to process the seed once, then reuse that state over and over and over. Periodt.
The siphash functions that take a seed argument call this function implicitly every single time they're used. The ones that take a state argument, though? They need you to convert the seed into a state before you use them. No shortcut, bestie.
Wanna see it in action? Peep the various _with_state siphash functions up above for a usage example. π
void S_perl_siphash_seed_state(
const unsigned char * const seed_buf,
unsigned char * state_buf
)
π§ Optrees π³
new_block_statement π§±
Returns an OP * that represents block as a statement. And what is block, you ask? It's a loop that happens once. One and done, babe. β¨
Available since: v5.44
OP * new_block_statement( OP *block, OP *cont)
OP * Perl_new_block_statement(pTHX_ OP *block, OP *cont)
newATTRSUB_x π οΈπ
Constructs a Perl subroutine β and also handles a bunch of the surrounding little jobs while it's at it. Multitasking queen. π
This function is expected to be called in a Perl compilation context, and some aspects of the subroutine get pulled from global variables associated with compilation. Specifically: PL_compcv is the variable representing the subroutine that's currently being compiled. It has to be non-null when you call this function, and some aspects of the subroutine being constructed are taken from it. Also, the subroutine you end up constructing may actually be a reuse of the PL_compcv object β but not necessarily, so don't go assuming. π
Now for the arguments, hold on to your seats:
- If
blockis null, then the subroutine will have no body, and for the time being it'll be an error to call it. This is what a forward subroutine declaration looks like, likesub foo ($$);. π«₯ - If
blockis non-null, then it provides the Perl code of the subroutine body, which gets executed when the subroutine is called. This body includes any argument unwrapping code resulting from a subroutine signature or similar. The pad use of the code must correspond to the pad attached toPL_compcv. The code is not expected to include aleavesuborleavesublvop β this function will add such an op for you. π And heads up:blockis consumed by this function and will become part of the constructed subroutine. protospecifies the subroutine's prototype, unless one is supplied as an attribute (see below). Ifprotois null, the subroutine won't have a prototype at all. Ifprotois non-null, it must point to aconstop whose value is a string, and the subroutine will have that string as its prototype. If a prototype is supplied as an attribute, the attribute takes precedence overprotoβ but in that caseprotoshould preferably be null. Either way,protois consumed by this function. No leftovers. π½οΈ
attrs is the little carrier pigeon for attributes, bestie. A handful of them are built-in and get applied to PL_compcv the literal second they're spotted β no queue, just instant. The rest get collected up and stapled onto the subroutine through this route instead. attrs can be null (meaning: no attributes, none, zero, nada), or it can point to a const op for one single attribute, or it can point to a list op whose children β everything except the pushmark β are const ops for one or more attributes. Every one of those const ops has to be a string, giving the attribute name and optionally parenthesised arguments after it, exactly the way attributes look in actual Perl source. Then the attributes get applied to the sub by this function. And heads up: attrs gets consumed by this function. Gone. Devoured. Don't come back expecting it.
Now for the naming arc π so: if o_is_gv is false and o is null, the subroutine is anonymous, full secret-agent mode. If o_is_gv is false and o is non-null, then o has to point to a const OP β which this function will consume β and that OP's string value is the name of the subroutine. The name can be qualified or unqualified, and if it's unqualified then a default stash gets picked, in some manner. If o_is_gv is true, then o isn't pointing at an OP at all, it's a cast pointer to a GV, and that GV is what names the subroutine. Sneaky but iconic.
If a subroutine with that exact name already exists? Then the new sub either replaces the existing one in the glob or merges with it. A warning may be generated about redefinition, so like, don't be shocked if it yells at you.
And if the subroutine happens to have one of a few special names β BEGIN, END, that whole crew β then it gets claimed by the appropriate queue for automatic running of phase-related subroutines. In that case the relevant glob is left not containing any subroutine, even if it was holding one before, which is so real of it. And for BEGIN specifically: the subroutine is executed and the reference to it is disposed of before this function even returns. It's speedrunning.
The function returns a pointer to the constructed subroutine. If the sub is anonymous, ownership of one counted reference to the subroutine is transferred to the caller β it's yours now, take care of it π. If the sub is named, the caller does not get ownership of a reference. In most of those cases, where the sub has a non-phase name, the sub will be alive at the point it's returned by virtue of being contained in the glob that names it. A phase-named subroutine will usually be alive by virtue of the reference owned by the phase's automatic run queue. But β and this is the part where you sit up straight β a BEGIN subroutine, having already been executed, will quite likely have been destroyed already by the time this function returns, making it erroneous for the caller to make any use of the returned pointer. It is the caller's responsibility to ensure that it knows which of these situations applies. That's the whole vibe check and you must pass it.
CV * newATTRSUB_x( I32 floor, OP *o, OP *proto,
OP *attrs, OP *block, bool o_is_gv)
CV * Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto,
OP *attrs, OP *block, bool o_is_gv)
πΈ newFORM πΈ
Constructs a format op, checks it, and hands it back. Just doing its little checks, being responsible, slay.
void newFORM( I32 floor, OP *o, OP *block)
void Perl_newFORM(pTHX_ I32 floor, OP *o, OP *block)
π¦ newMYSUB π¦
Builds a Perl lexical subroutine, does a bunch of surrounding jobs while it's at it, and returns a pointer to the constructed subroutine. Similar in action to newATTRSUB_x over in perlintern. Sisters fr fr.
CV * newMYSUB( I32 floor, OP *o, OP *proto, OP *attrs,
OP *block)
CV * Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs,
OP *block)
β¨ newXS_len_flags β¨
Constructs an XS subroutine, also handling some surrounding jobs like the multitasker it is.
The subroutine gets the entry point subaddr. It gets the prototype specified by the nul-terminated string proto, or no prototype if proto is null. The prototype string is copied β so the caller is fully free to mutate the supplied string afterwards, no take-backs, it doesn't matter anymore. If filename is non-null it must be a nul-terminated filename, and the subroutine gets its CvFILE set accordingly. By default CvFILE points directly at the supplied string, which means that string must be static. If flags has the XS_DYNAMIC_FILENAME bit set, then a copy of the string is taken instead β much safer, very demure.
Other aspects of the subroutine are left in their default state. So if anything else needs doing for it to function correctly, that's on the caller to do after this function has constructed it. However β beware of the subroutine potentially being destroyed before this function returns, as described below. πͺοΈ
If name is null, the subroutine is anonymous and its CvGV refers to an __ANON__ glob. If name is non-null, the subroutine gets named accordingly and is referenced by the appropriate glob. name is a string of len bytes giving a sigilless symbol name β in UTF-8 if flags has the SVf_UTF8 bit set, and in Latin-1 otherwise. The name may be qualified or unqualified, with the stash defaulting in the same manner as for gv_fetchpvn_flags. And flags may contain flag bits understood by gv_fetchpvn_flags, with the same meaning they have there, such as GV_ADDWARN. The symbol is always added to the stash if necessary, with GV_ADDMULTI semantics. Always. Periodt.
If there's already a subroutine of the specified name, the new sub replaces the existing one in the glob. A warning may be generated about the redefinition. And here's the cute twist: if the old subroutine was CvCONST, then the decision about whether to warn is influenced by an expectation about whether the new subroutine will become a constant of similar value. That expectation is determined by const_svp. (Note that the call to this function doesn't make the new subroutine CvCONST in any case β that's left to the caller, so don't go assuming.) If const_svp is null, that means the new subroutine will not become a constant. If const_svp is non-null, that means the new subroutine will become a constant, and it points to an SV* that provides the constant value the subroutine will have.
If the subroutine has one of a few special names, such as BEGIN or END, it gets claimed by the appropriate queue for automatic running of phase-related subroutines. In this case the relevant glob is left not containing any subroutine, even if it did contain one before. And in the case of BEGIN, the subroutine is executed and the reference to it disposed of before this function returns and also before its prototype is set. So if a BEGIN subroutine wouldn't be sufficiently constructed by this function to be ready for execution, the caller must prevent that happening by giving the subroutine a different name. No cap.
The function returns a pointer to the constructed subroutine. If the sub is anonymous, ownership of one counted reference to the subroutine transfers to the caller π«Ά. If the sub is named, the caller does not get ownership of a reference. In most such cases, where the sub has a non-phase name, the sub will be alive at the point it's returned by virtue of being contained in the glob that names it. A phase-named subroutine will usually be alive by virtue of the reference owned by the phase's automatic run queue. But a BEGIN subroutine, having already been executed, will quite likely have been destroyed already by the time this function returns, making it erroneous for the caller to make any use of the returned pointer. It is the caller's responsibility to ensure that it knows which of these situations applies. Same warning as before, same energy, do not ignore it π.
CV * newXS_len_flags( const char *name, STRLEN len,
XSUBADDR_t subaddr,
const char * const filename,
const char * const proto,
SV ** const_svp, U32 flags)
CV * Perl_newXS_len_flags(pTHX_ const char *name, STRLEN len,
XSUBADDR_t subaddr,
const char * const filename,
const char * const proto,
SV ** const_svp, U32 flags)
π
op_lvalue_flags π
This is a non-API lower-level interface to op_lvalue in perlapi, and its flags param has these bits:
OP_LVALUE_NO_CROAKβ return rather than croaking on error. So polite. So gentle. No screaming, just returning.
OP * Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
π op_refcnt_lock π
Implements the OP_REFCNT_LOCK macro β which you should be using instead, bestie, respectfully.
void op_refcnt_lock()
void Perl_op_refcnt_lock(pTHX)
π op_refcnt_unlock π
Implements the OP_REFCNT_UNLOCK macro β which, again, you should be using instead. Pair goals, honestly.
void op_refcnt_unlock()
void Perl_op_refcnt_unlock(pTHX)
π package π
Sets the current stash name, and if $version is not NULL, sets it as $VERSION too. It's serving two purposes in one call because why do two calls when one call eats.
It combines the former package and package_version into a single call. Glow-up behavior.
void package( OP *name, OP *version)
void Perl_package(pTHX_ OP *name, OP *version)
π traverse_op_tree π
Returns the next op in a depth-first traversal of the op tree, and returns NULL once the traversal is complete. It's giving guided tour of the whole tree, one node at a time π³.
The initial call must supply the root of the tree as both top and o. Both. Yes, both, that's not a typo, feed it the root twice.
For now it's static, but it may be exposed to the API in the future. So like, watch this space, iykyk.
OP * traverse_op_tree(OP *top, OP *o)
π Pack and Unpack
There are currently no internal API items in Pack and Unpack. Empty. Void. Aesthetic little ghost town π»β¨
π Pad Data Structures π
okay bestie, this whole section is about pads β the place where your lexicals live. it's giving backstage-pass energy β¨
CX_CURPAD_SAVEβ saves the current pad into the context block struct you hand it. that's it, that's the job π
void CX_CURPAD_SAVE(struct context)
CX_CURPAD_SVβ grabs the SV sitting at offsetpoin the saved current pad of that context block. and yes, you can use it as an lvalue, no cap π«Ά
SV * CX_CURPAD_SV(struct context, PADOFFSET po)
PAD_BASE_SVβ gets the value from slotpoin the base (DEPTH=1) pad of a padlist.
SV * PAD_BASE_SV(PADLIST padlist, PADOFFSET po)
PAD_CLONE_VARSβ clones the state variables that belong to running and compiling pads. copying the whole vibe, literally π
void PAD_CLONE_VARS(PerlInterpreter *proto_perl,
CLONE_PARAMS* param)
PAD_COMPNAME_FLAGSβ returns the flags for the current compiling pad name at offsetpo. it assumes the slot entry is valid, so don't come at it with nonsense π
U32 PAD_COMPNAME_FLAGS(PADOFFSET po)
PAD_COMPNAME_GENβ the generation number of the name at offsetpoin the current compiling pad. lvalue, bestie π
STRLEN PAD_COMPNAME_GEN(PADOFFSET po)
PAD_COMPNAME_GEN_setβ sets the generation number of the name at offsetpoin the current ling pad (lvalue) togen.
STRLEN PAD_COMPNAME_GEN_set(PADOFFSET po, int gen)
PAD_COMPNAME_OURSTASHβ returns the stash tied to anourvariable. it assumes the slot entry is a validourlexical, so like... valid only π
HV * PAD_COMPNAME_OURSTASH(PADOFFSET po)
PAD_COMPNAME_PVβ returns the name of the current compiling pad name at offsetpo. assumes a valid slot entry π¦
char * PAD_COMPNAME_PV(PADOFFSET po)
PAD_COMPNAME_TYPEβ returns the type (stash) of the current compiling pad name at offsetpo. must be a valid name. returns null if it's not typed.
HV * PAD_COMPNAME_TYPE(PADOFFSET po)
PAD_RESTORE_LOCALβ restores the old pad thatPAD_SAVE_LOCAL()stashed into the local variableopad. bring it back, babe π
void PAD_RESTORE_LOCAL(PAD *opad)
PAD_SAVE_LOCALβ saves the current pad into the local variableopad, then makes the current pad equal tonpad. swap szn π₯
void PAD_SAVE_LOCAL(PAD *opad, PAD *npad)
PAD_SAVE_SETNULLPADβ saves the current pad, then sets it to null.
void PAD_SAVE_SETNULLPAD()
PAD_SET_CURβ sets the current pad to be padnin the padlist, saving the previous current pad. NB, bestie: right now this macro expands to a string that's too long for some compilers, so it's genuinely best to replace it with:
SAVECOMPPAD();
PAD_SET_CUR_NOSAVE(padlist,n);
void PAD_SET_CUR(PADLIST padlist, I32 n)
PAD_SET_CUR_NOSAVEβ likePAD_SET_CUR, but without the save. the no-save version, the lowkey speedrun πββοΈ
void PAD_SET_CUR_NOSAVE(PADLIST padlist, I32 n)
PAD_SETSVβ sets the slot at offsetpoin the current pad tosv.
SV * PAD_SETSV(PADOFFSET po, SV* sv)
PAD_SVβ gets the value at offsetpoin the current pad.
SV * PAD_SV(PADOFFSET po)
PAD_SVlβ the lightweight, lvalue version ofPAD_SV. get or set the value at offsetpoin the current pad. unlikePAD_SV, it does not print diagnostics with-DX. for internal use only π«
SV * PAD_SVl(PADOFFSET po)
PadnameIsFIELDβ whether this is afieldvariable. PADNAMEs where this is true will have additional info available viaPadnameFIELDINFO.
bool PadnameIsFIELD(PADNAME * pn)
PadnameIsOURβ whether this is anourvariable.
bool PadnameIsOUR(PADNAME * pn)
PadnameIsSTATEβ whether this is astatevariable.
bool PadnameIsSTATE(PADNAME * pn)
PadnameOURSTASHβ the stash in which thisourvariable was declared.
HV * PadnameOURSTASH(PADNAME * pn)
PadnameOUTERβ whether this entry belongs to an outer pad. entries where this is true are often called 'fake'. yeah. fake. iconic behavior π
bool PadnameOUTER(PADNAME * pn)
PadnameTYPEβ the stash associated with a typed lexical. this returns the%Foo::hash formy Foo $bar.
HV * PadnameTYPE(PADNAME * pn)
SAVECLEARSVβ clears the pointed-to pad value on scope exit. aka the runtime action ofmyπ«§
void SAVECLEARSV(SV **svp)
SAVECOMPPADβ savesPL_comppadandPL_curpad.
void SAVECOMPPAD()
SAVEPADSVANDMORTALIZEβ saves a pad slot (used to restore after an iteration).
void SAVEPADSVANDMORTALIZE(PADOFFSET po)
π Password and Group access π
there are currently no internal API items in Password and Group access. empty section, but she's still valid π
πΊοΈ Paths to system commands πΊοΈ
there are currently no internal API items in Paths to system commands. nothing here, bestie, keep scrolling π
π Prototype information π
there are currently no internal API items in Prototype information. genuinely zero.
π₯ Reference-counted stack manipulation π₯
there are currently no internal API items in Reference-counted stack manipulation. the stack section said "not today" β¨
π REGEXP Functions π
regnodeβ described in perlreguts. that's the whole tea β
π Reports and Formats π
there are currently no internal API items in Reports and Formats. nope, none π
π‘ Signals π‘
there are currently no internal API items in Signals. quiet one π¦
βοΈ Site configuration βοΈ
there are currently no internal API items in Site configuration. nothing to configure internally, apparently π
π Sockets configuration values π
there are currently no internal API items in Sockets configuration values. empty.
π§ Source Filters π§
parse_ident_msgβ parses the string that*spoints to (upper bound iss_end), hunting for a normal identifier whose first character matches\p{XID_Start}followed by any number of characters matching\p{XID_Continue}. it's giving "what's your name, gorgeous" π
it returns a pointer to the first character in s beyond the next such identifier β or NULL if a serious error was found in the parsed string. rn the only such serious error is that the identifier is too long for the perl interpreter to handle (the maximum is guaranteed to be at least 255 characters).
if error_detail is not NULL, then when a serious error is found, it creates a mortal hash containing details of the error, as follows:
char * parse_ident_msg( const char *s,
const char *end, bool is_utf8,
HV **failure_details,
U32 flags)
char * Perl_parse_ident_msg(pTHX_ const char *s,
const char *end, bool is_utf8,
HV **failure_details,
U32 flags)
ngl the "details" list is cut off in this part of the page, so we're just vibing with what's above π«Ά
π₯ Stack Manipulation Macros π₯
djSPβ Declare JustSP. it's actually identical todSP, and it declares a local copy of perl's stack pointer, available via theSPmacro. see"SP" in perlapi. (available for backward source code compatibility with the old (Perl 5.005) thread model.) a little nostalgia moment π
djSP;
LVRETβ true if this op will be the return value of an lvalue subroutine.save_allocβ implements"SSNEW"in perlapi and kin, which should be used instead of this function. so like... use the other one, bestie π
SSize_t save_alloc( SSize_t size, I32 pad)
SSize_t Perl_save_alloc(pTHX_ SSize_t size, I32 pad)
π§΅ String Handling π§΅
see also "Unicode Support". πΈ
delimcpy_no_escapeβ copies a source buffer to a destination buffer, stopping at (but not including) the first occurrence in the source of the delimiter byte,delim. the source is the bytes betweenfromandfrom_end- 1. similarly, the dest istoup toto_end.
the number of bytes copied gets written to *retlen.
it returns the position of delim in the from buffer β but if there's no such occurrence before from_end, then from_end is returned, and the entire buffer from .. from_end - 1 is copied.
if there's room in the destination available after the copy, an extra terminating safety NUL byte is appended (not included in the returned length).
the error case is if the destination buffer is not large enough to accommodate everything that should be copied. in that situation, a value larger than to_end - to is written to *retlen, and as much of the source as fits will be written to the destination. not having room for the safety NUL is not considered an error.
char * delimcpy_no_escape(char *to, const char *to_end,
const char *from,
const char *from_end,
const int delim, I32 *retlen)
char * Perl_delimcpy_no_escape(char *to, const char *to_end,
const char *from,
const char *from_end,
const int delim, I32 *retlen)
quadmath_format_neededβquadmath_format_needed()returns true if theformatstring seems to contain at least one non-Q-prefixed%[efgaEFGA]format specifier, or returns false otherwise.
the format specifier detection is not complete printf-syntax detection, but it should catch most common cases.
if true is returned, those arguments should in theory be processed with quadmath_snprintf(), but in case there is more than one such format specifier (see quadmath_format_valid), and if there is anything else beyond that one (even just a single byte), they cannot be processed because quadmath_snprintf() is very strict, accepting only one format spec, and nothing else. in this case, the code should probably fail. π
bool quadmath_format_needed(const char *format)
bool Perl_quadmath_format_needed(const char *format)
quadmath_format_validβquadmath_snprintf()is very strict about itsformatstring and will fail, returning-1, if the format is invalid. it accepts exactly one format spec.
quadmath_format_valid() checks that the intended single spec looks sane: begins with %, has only one %, ends with [efgaEFGA], and has Q before it. this is not a full "printf syntax check", just the basics.
returns true if it is valid, false if not.
see also quadmath_format_needed.
bool quadmath_format_valid(const char *format)
bool Perl_quadmath_format_valid(const char *format)
π·οΈ SV Flags π·οΈ
SVt_INVLISTβ type flag for scalars. seesvtypein perlapi. short, sweet, iconic β
still more coming bestie, don't go anywhere π
π SV HANDLING π
okay besties, welcome to the SV pit π this is where all the little scalar values live, breathe, and occasionally get zapped into the shadow realm. strap in, we're going function by function, no skips, no cap πΈ
PL_Sv
the designated scratch pad SV, just vibing there for whatever temporary nonsense you need π«Ά its main-character job? being the fallback for macros on platforms where PERL_USE_GCC_BRACE_GROUPS in perlapi> is not available β the kind of macros that would otherwise gobble up their SV parameter twice π
BUT BEWARE: if this thing gets used somewhere while another thing that's also using it is sitting in the same call stack, this variable gets zapped, and you get errors that are genuinely impossible to diagnose. it's giving haunted π
these days, reaching for an inline function instead is generally the preferred move, periodt β¨
sv_add_arena
=for_apidoc_flag SVf_FAKE
hand it a chunk of memory and it links that chunk to the head of the arenas list π, then splits it all up into a tidy little list of free SVs. iconic housekeeping π§Ή
void sv_add_arena(char * const ptr, const U32 size,
const U32 flags)
sv_clean_all
decrements the refcnt of every SV that's still hanging around, which might trigger some cleanup along the way π heads up though: you may have to call this one multiple times to actually free SVs tangled up in complex self-referential hierarchies. it's giving onion layers π
SSize_t sv_clean_all()
SSize_t Perl_sv_clean_all(pTHX)
sv_clean_objs
tries to destroy every object that hasn't been freed yet π¦ the reaper-but-make-it-cute energy fr fr
void sv_clean_objs()
void Perl_sv_clean_objs(pTHX)
sv_free_arenas
frees up all the memory the arenas were using π
note: every individual SV head and body inside those arenas needs to already be freed first. don't skip that step bestie π
void sv_free_arenas()
void Perl_sv_free_arenas(pTHX)
sv_grow
expands the character buffer inside the SV π and if it has to, it pulls in sv_unref and upgrades the SV to SVt_PV. hands you back a pointer to that character buffer β¨
lowkey though? use the SvGROW wrapper instead, that's the move π
char * sv_grow( SV * const sv, STRLEN newlen)
char * Perl_sv_grow(pTHX_ SV * const sv, STRLEN newlen)
sv_grow_fresh
a stripped-down, cut-down version of sv_grow π meant only for when sv is a freshly-minted SVt_PV, SVt_PVIV, SVt_PVNV, or SVt_PVMG. i.e. sv has the default flags, has never been any other type, and doesn't have an existing string. basically it just assigns a char buffer and returns a pointer to it. no drama, no detours πΈ
char * sv_grow_fresh( SV * const sv, STRLEN newlen)
char * Perl_sv_grow_fresh(pTHX_ SV * const sv, STRLEN newlen)
sv_newref
bumps up an SV's reference count β¬οΈ use the SvREFCNT_inc() wrapper instead, always π
SV * sv_newref( SV * const sv)
SV * Perl_sv_newref(pTHX_ SV * const sv)
sv_numcmp_common
this one carries the common parts of the sv_numeq in perlapi, sv_numne, sv_numlt, sv_numle, sv_numge, sv_numgt, and sv_numcmp APIs π₯ it's basically the shared group chat.
method should be the *_amg constant for whichever operator you're handling β like eq_amg for numeric equality π«
flags takes the same flags as the numeric comparison APIs π
what it handles, in list form because we love structure:
- treating possible
NULL*sv1and*sv2arguments as undef π - calling get magic β¨
- handling the pain of overloading β including numericizing the SVs if there's no numeric overload but there is a numeric
"0+"overload π
so: if there's operator overloading, this function populates *result with the SV that the overloading returned and returns true π«Ά the caller then has to convert that into an integer for sv_numcmp() or into a bool for the rest of the APIs.
if there's no operator overloading, this returns true. and before it returns, it converts *sv1 and *sv2 to numbers if they happen to be references, so that do_cmp() can be used safely π
bool sv_numcmp_common(SV **sv1, SV **sv2, const U32 flags,
int method, SV **result)
sv_pv
just use the SvPV_nolen macro instead π please and thank you
char * sv_pv( SV *sv)
char * Perl_sv_pv(pTHX_ SV *sv)
sv_pvbyte
use SvPVbyte_nolen instead π that's the whole note.
char * sv_pvbyte( SV *sv)
char * Perl_sv_pvbyte(pTHX_ SV *sv)
sv_pvbyten_force
the backend for the SvPVbytex_force macro π always use the macro instead. and heads up: if the SV cannot be downgraded from UTF-8, this one croaks π rip
char * sv_pvbyten_force( SV * const sv,
STRLEN * const lp)
char * Perl_sv_pvbyten_force(pTHX_ SV * const sv,
STRLEN * const lp)
sv_pvn_force
gets a sensible string out of the SV, somehow, one way or another π« it's a private implementation of the SvPV_force macro for compilers that just can't cope with complex macro expressions π always use the macro instead, fr fr.
char * sv_pvn_force( SV *sv, STRLEN *lp)
char * Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
sv_pvutf8
use the SvPVutf8_nolen macro instead β¨ simple as that.
char * sv_pvutf8( SV *sv)
char * Perl_sv_pvutf8(pTHX_ SV *sv)
sv_pvutf8n_force
the backend for the SvPVutf8x_force macro πΈ always use the macro instead, no exceptions bestie.
char * sv_pvutf8n_force( SV * const sv,
STRLEN * const lp)
char * Perl_sv_pvutf8n_force(pTHX_ SV * const sv,
STRLEN * const lp)
sv_tainted
tests an SV for taintedness π§ͺ use SvTAINTED instead π
bool sv_tainted( SV * const sv)
bool Perl_sv_tainted(pTHX_ SV * const sv)
sv_true
returns true if the SV has a true value by Perl's rules π use the SvTRUE macro instead β it may call sv_true() or it may instead use an in-line version, either way it's the wave π
I32 sv_true( SV * const sv)
I32 Perl_sv_true(pTHX_ SV * const sv)
sv_untaint
untaints an SV π§Ό use SvTAINTED_off instead π
void sv_untaint( SV * const sv)
void Perl_sv_untaint(pTHX_ SV * const sv)
sv_2bool
this macro is only used by sv_true() or its macro equivalent π and only when the argument it got is neither SvPOK, SvIOK nor SvNOK. it calls sv_2bool_flags with the SV_GMAGIC flag β¨
bool sv_2bool( SV * const sv)
bool Perl_sv_2bool(pTHX_ SV * const sv)
sv_2bool_flags
this function is only used by sv_true() and friends π«Ά and only when that argument is neither SvPOK, SvIOK nor SvNOK. if the flags contain SV_GMAGIC, then it does an mg_get() first π«
bool sv_2bool_flags( SV *sv, I32 flags)
bool Perl_sv_2bool_flags(pTHX_ SV *sv, I32 flags)
sv_2num_flags / sv_2num
NOTE: sv_2num_flags is experimental and may change or be removed without notice π do not get attached.
returns an SV holding the numeric value of the source SV, doing any necessary reference or overload conversion along the way π’ the caller is expected to have already handled get-magic πΈ
for sv_2num_flags() you can set these flags:
SV_SKIP_OVERLOADβ avoid any numeric context overloading πSV_FORCE_OVERLOADβ use numeric context overloading even if it's disabled in hints byno overloading;π₯
SV * sv_2num_flags( SV * const sv, int flags)
SV * Perl_sv_2num_flags(pTHX_ SV * const sv, int flags)
SV * sv_2num ( SV * const sv)
SV * Perl_sv_2num (pTHX_ SV * const sv)
sv_2pv_nolen
like sv_2pv(), but it doesn't hand back the length too π you should usually reach for the macro wrapper SvPV_nolen(sv) instead β¨
char * sv_2pv_nolen( SV *sv)
char * Perl_sv_2pv_nolen(pTHX_ SV *sv)
sv_2pvbyte_nolen
returns a pointer to the byte-encoded representation of the SV π side effect warning though: this may cause the SV to be downgraded from UTF-8 as a side-effect π usually you'd get to it via the SvPVbyte_nolen macro π
char * sv_2pvbyte_nolen( SV *sv)
char * Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
sv_2pvutf8_nolen
returns a pointer to the UTF-8-encoded representation of the SV π heads up: this may cause the SV to be upgraded to UTF-8 as a side-effect β¨ usually accessed via the SvPVutf8_nolen macro π
char * sv_2pvutf8_nolen( SV *sv)
char * Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
SvTHINKFIRST
a quick little flag check to see whether an sv should be handed off to sv_force_normal to get "downgraded" before SvIVX or SvPVX can be modified directly π§ think-first energy, honestly iconic.
for example, if your scalar is a reference and you want to modify the SvIVX slot, you can't just do SvROK_off π because that will leak the referent. not the vibe.
this is used internally by a whole crew of sv-modifying functions, such as sv_setsv, sv_setiv and sv_pvn_force π
one case this does not handle: a gv without SvFAKE set π after
if (SvTHINKFIRST(gv)) sv_force_normal(gv);
it will still be a gv. sneaky.
also SvTHINKFIRST sometimes produces false positives π
in those cases sv_force_normal does absolutely nothing. harmless, but rude.
U32 SvTHINKFIRST(SV *sv)
okay that's the SV Handling lineup, every single one accounted for π more coming, don't you dare close the tab πΈ
Tainting π
Okay bestie, taint mode is THE whole vibe of "never trust what a stranger hands you" and Perl is so serious about it. These are the internal knobs and levers behind it. Yes, there are a lot. Yes, we're doing all of them. Periodt.
sv_taint
Taint an SV. Real talk though β just use SvTAINTED_on instead, iykyk.
void sv_taint( SV *sv)
void Perl_sv_taint(pTHX_ SV *sv)
TAINT
If we're not in taint checking mode? Do nothing, chill, rest. Otherwise it flags to "TAINT_set" and "TAINT_PROPER" that some unspecified element is tainted. Lowkey ominous but slay.
void TAINT
TAINT_ENV
This one goes snooping through several components of %ENV looking for taintedness, and calls "taint_proper" if any of them are tainted. The stuff it searches is things like $PATH. Nosy! But like, responsibly nosy. π
void TAINT_ENV()
taint_env
This is the implementation under the TAINT_ENV macro. The macro is the one you should generally be using instead, bestie β go through the front door. πͺ
void taint_env()
void Perl_taint_env(pTHX)
TAINT_get
Returns a boolean telling you whether some element is tainted or not. Simple. Iconic. No notes. β¨
bool TAINT_get
TAINT_IF
If c evaluates to true, it calls "TAINT" to say "yeah something's tainted"; otherwise it does nothing. Conditional queen. π
void TAINT_IF(bool c)
TAINT_NOT
Undoes any taintedness that got set earlier by, like, TAINT. The un-taint. The redemption arc. π
void TAINT_NOT
TAINT_PROPER
If nothing is tainted β do nothing. But if something is? It prints out a message (containing s) telling you there's a tainting violation. And if those violations are set to be fatal, it croaks. Yeah. It'll end you. π
void TAINT_PROPER(const char * s)
taint_proper
Implements the TAINT_PROPER macro, and again β you should generally use the macro instead. That's the whole theme of this section fr.
void taint_proper( const char *f,
const char * const s)
void Perl_taint_proper(pTHX_ const char *f,
const char * const s)
TAINT_set
If s is true, then "TAINT_get" returns true. If s is false, then "TAINT_get" returns false. Extremely direct. Respect. π«Ά
void TAINT_set(bool s)
TAINT_WARN_get
Returns false if tainting violations are fatal. Returns true if they're just warnings. So true = we're being nice about it. π
bool TAINT_WARN_get
TAINT_WARN_set
s being true means "TAINT_WARN_get" should report that tainting violations are just warnings.
s being false means "TAINT_WARN_get" should report that tainting violations are fatal. Choose wisely, bestie. β οΈ
void TAINT_WARN_set(bool s)
TAINTING_get
Returns a boolean: is taint checking enabled or not? The vibe check, but for taint mode. πΈ
bool TAINTING_get
TAINTING_set
Turns taint checking mode off or on. The switch. Flip it. π₯
void TAINTING_set(bool s)
Time β°
There are currently no internal API items in Time.
Not one. Zero. It's giving empty inbox. The section exists purely to tell you it's empty, and honestly? That's valid. π
Typedef names π·οΈ
There are currently no internal API items in Typedef names.
Same energy, different heading. Nothing here either. We move. π¦
β¨ Unicode Support β¨
Okay bestie, deep breath π "Unicode Support" in perlguts has a whole intro to this API if you want the lore.
Also peep "Character classification", "Character case changing", and "String Handling" β and honestly? Lots of functions outside this very section also get β¨specialβ¨ with Unicode. Just search for the string "utf8" in this document, iykyk. π
"invlist_highest_range_start"
Returns the lowest code point of the highest range in the inversion list you handed it as a parameter.
π¨ Real talk: this API has an ambiguity β it returns 0 either when the lowest such point is actually 0, or when the list is empty. If that distinction matters to you, check for emptiness before calling this function. No cap.
UV invlist_highest_range_start(SV * const invlist)
"invlist_lowest"
Returns the lowest code point that matches an inversion list.
π¨ Same little ambiguity situation here: it returns 0 under either the lowest is actually 0, or the list is empty. If that distinction matters to you, check for emptiness before calling this function.
UV invlist_lowest(SV * const invlist)
"is_utf8_non_invariant_string"
Returns TRUE if "is_utf8_invariant_string" in perlapi returns FALSE for the first len bytes of the string s, but they are, nonetheless, legal Perl-extended UTF-8; otherwise returns FALSE. π
A TRUE return means that at least one code point represented by the sequence either is a wide character not representable as a single byte, or the representation differs depending on whether the sequence is encoded in UTF-8 or not. It's giving "technically fine but sus". π
See also ""is_utf8_invariant_string" in perlapi".
bool is_utf8_non_invariant_string(const U8 * const s,
STRLEN len)
bool Perl_is_utf8_non_invariant_string(const U8 * const s,
STRLEN len)
"isSCRIPT_RUN"
Returns a bool as to whether or not the sequence of bytes from s up to but not including send form a "script run". π The utf8_target is true iff the sequence starting at s is to be treated as UTF-8.
To be precise, except for two degenerate cases given below, this function returns true iff all code points in it come from any combination of three "scripts" given by the Unicode "Script Extensions" property: Common, Inherited, and possibly one other. Additionally, all decimal digits must come from the same consecutive sequence of 10. π’
For example, if all the characters in the sequence are Greek, or Common, or Inherited, this function will return true β provided any decimal digits in it are from the same block of digits in Common. (Those are the ASCII digits "0".."9" and additionally a block for full width forms of these, and several others used in mathematical notation.) For scripts (unlike Greek) that have their own digits defined, this will accept either digits from that set or from one of the Common digit sets, but not a combination of the two. Some scripts, such as Arabic, have more than one set of digits. All digits must come from the same set for this function to return true. β¨
*ret_script, if ret_script is not NULL, will on return of true contain the script found, using the SCX_enum typedef. Its value will be SCX_INVALID if the function returns false.
If the sequence is empty, true is returned, but *ret_script (if asked for) will be SCX_INVALID. π«₯
If the sequence contains a single code point which is unassigned to a character in the version of Unicode being used, the function will return true, and the script will be SCX_Unknown. Any other combination of unassigned code points in the input sequence will result in the function treating the input as not being a script run. π
The returned script will be SCX_Inherited iff all the code points in it are from the Inherited script. π§
Otherwise, the returned script will be SCX_Common iff all the code points in it are from the Inherited or Common scripts.
bool isSCRIPT_RUN( const U8 *s, const U8 *send,
const bool utf8_target)
bool Perl_isSCRIPT_RUN(pTHX_ const U8 *s, const U8 *send,
const bool utf8_target)
"UNI_DISPLAY_TR"
This is an extra flag for "sv_uni_display" in perlapi which is for internal use only. It displays an operand of the tr/// operation. These operands have a peculiar, deliberate UTF-8 malformation which this flag enables the proper handling of. It turns on ISPRINT and BACKSLASH as well. π
"utf8_to_uvuni"
π₯DEPRECATED!It is planned to removeutf8_to_uvunifrom a future release of Perl. Do not use it for new code; remove it from existing code. Periodt.
Returns the Unicode code point of the first character in the string s which is assumed to be in UTF-8 encoding; retlen will be set to the length, in bytes, of that character. π
Some, but not all, UTF-8 malformations are detected β and in fact, some malformed input could cause reading beyond the end of the input buffer, which is one reason why this function is deprecated. π The other reason is that only in extremely limited circumstances should the Unicode versus native code point be of any interest to you.
If s points to one of the detected malformations, and UTF8 warnings are enabled, zero is returned and *retlen is set (if retlen doesn't point to NULL) to -1. If those warnings are off, the computed value if well-defined (or the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and *retlen is set (if retlen isn't NULL) so that (s + *retlen) is the next possible position in s that could begin a non-malformed character. See "utf8n_to_uvchr" in perlapi for details on when the REPLACEMENT CHARACTER is returned. π
UV utf8_to_uvuni( const U8 *s, STRLEN *retlen)
UV Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
"utf8n_to_uvuni"
π₯DEPRECATED!It is planned to removeutf8n_to_uvunifrom a future release of Perl. Do not use it for new code; remove it from existing code.
Instead use "utf8_to_uv" in perlapi, or rarely, "utf8_to_uv_flags" in perlapi. π
This function was useful for code that wanted to handle both EBCDIC and ASCII platforms with Unicode properties, but starting in Perl v5.20, the distinctions between the platforms have mostly been made invisible to most code, so this function is quite unlikely to be what you want. If you do need this precise functionality, use instead ""utf8_to_uv"" in perlapi or ""utf8_to_uv_flags"" in perlapi to calculate the native code point, and then convert to Unicode using ""NATIVE_TO_UNI"" in perlapi. β¨
UV utf8n_to_uvuni( const U8 *s, STRLEN curlen,
STRLEN *retlen, U32 flags)
UV Perl_utf8n_to_uvuni(pTHX_ const U8 *s, STRLEN curlen,
STRLEN *retlen, U32 flags)
"uvoffuni_to_utf8_flags"
π¨ THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES. Instead, almost all code should use "uv_to_utf8" in perlapi or "uv_to_utf8_flags" in perlapi.
This function is like them, but the input is a strict Unicode (as opposed to native) code point. Only in very rare circumstances should code not be using the native code point. π¦
For details, see the description for "uv_to_utf8_flags" in perlapi.
U8 * uvoffuni_to_utf8_flags( U8 *d, UV uv, UV flags)
U8 * Perl_uvoffuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
"valid_utf8_to_uv"
"valid_utf8_to_uvchr"
These are synonymous. π
These are like ""utf8_to_uv" in perlapi", but should only be called when it is known that the next character in the input UTF-8 string s is well-formed (e.g., it passes ""isUTF8_CHAR" in perlapi"). Surrogates, non-character code points, and non-Unicode code points are allowed. β¨
The only use for these is that they should run slightly faster than utf8_to_uv because no error checking is done. Speedy queen. πββοΈ
The _uv form is slightly preferred so as to have a consistent spelling with the other _uv forms that are definitely preferred over the older and problematic _uvchr forms. π
UV valid_utf8_to_uv (const U8 *s, STRLEN *retlen)
UV Perl_valid_utf8_to_uv (const U8 *s, STRLEN *retlen)
UV valid_utf8_to_uvchr(const U8 *s, STRLEN *retlen)
UV Perl_valid_utf8_to_uvchr(const U8 *s, STRLEN *retlen)
"variant_under_utf8_count"
This function looks at the sequence of bytes between s and e, which are assumed to be encoded in ASCII/Latin1, and returns how many of them would change should the string be translated into UTF-8. Due to the nature of UTF-8, each of these would occupy two bytes instead of the single one in the input string. So basically, this function returns the precise number of bytes the string would expand by when translated to UTF-8. π
Unlike most of the other functions that have utf8 in their name, the input to this function is NOT a UTF-8-encoded string. The function name is slightly odd to emphasize this. It's giving "trust me bestie, the name is on purpose". π
This function is internal to Perl because khw thinks that any XS code that would want this is probably operating too close to the internals. Presenting a valid use case could change that. π
See also ""is_utf8_invariant_string" in perlapi" and ""is_utf8_invariant_string_loc" in perlapi",
Size_t variant_under_utf8_count(const U8 * const s,
const U8 * const e)
πΈ Utility Functions πΈ
"my_popen_list"
Implementing function on some systems for PerlProc_popen_list(). π
PerlIO * my_popen_list( const char *mode, int n,
SV **args)
PerlIO * Perl_my_popen_list(pTHX_ const char *mode, int n,
SV **args)
"my_socketpair"
Emulates socketpair(2) on systems that don't have it, but which do have enough functionality for the emulation. Faking it till it makes it, iconic. π
int my_socketpair(int family, int type, int protocol,
int fd[2])
int Perl_my_socketpair(int family, int type, int protocol,
int fd[2])
π¦ Versioning π¦
There are currently no internal API items in Versioning. Empty queen β main character energy with zero obligations. π
<nice>to be continued, bestieβ¦</nice>
β οΈπ Warning and Dieing πβ οΈ
okay so bestie, listen β in all of these calls, those U32 wn parameters are warning category constants. Where do you find them? They're in "Category Hierarchy" in warnings, and the glow-up is simple: capitalize every single letter in the name and slap WARN_ on the front. So the category void β the one you'd use in a regular perl program β becomes WARN_VOID when you're in XS code and passing it to any of the calls below. that's it, that's the whole trick π
π«Ά deprecate, deprecate_disappears_in, deprecate_fatal_in π«Ά
These three are each wrappers around Perl_ck_warner_d(), and their whole job is to produce a deprecated warning in the single category you hand them via category, with an appropriate message. very demure, very mindful.
They differ in the details of the message output, but they all use the message argument as a base β and heads up, message must be a literal C string enclosed in double-quotes. no variables, no funny business. π
In plain deprecate, the string is deprecated gets automatically appended to the end of message, giving you:
<message> is deprecated
The other two take a third argument, when, which is a literal C string in the form like "5.40". when tells everyone in what release the axe is scheduled to fall. dramatic but informative πͺ
In deprecate_disappears_in, the actual message output is of the form:
<message> is deprecated, and will disappear in Perl <when>
And in deprecate_fatal_in, the message is of the form:
<message> is deprecated, and will become fatal in Perl <when>
Here's how you actually call them:
deprecate (U32 category, "message")
deprecate_disappears_in(U32 category, "when", "message")
deprecate_fatal_in (U32 category, "when", "message")
π find_uninit_var π
NOTE: find_uninit_var is experimental and may change or be removed without notice. do not get attached, bestie, seriously π
Its deal: it finds the name of the undefined variable (if any) that caused the operator to issue a "Use of uninitialized value" warning. Sleeping on the job, tbh.
If match is true, it only returns a name if its value matches uninit_sv. So roughly speaking: if a unary operator (such as OP_COS) generates a warning, then following the direct child of the op may yield an OP_PADSV or OP_GV that gives you the name of the undefined variable. On the other hand, with OP_ADD there are two branches to follow, so we only print the variable name if we get an exact match. no partial credit β
desc_p points to a string pointer holding the description of the op. This may be updated if needed. π
The name comes back as a mortal SV.
It also assumes that PL_op is the OP that originally triggered the error, and that PL_comppad/PL_curpad points to the currently executing pad. like, it's assuming a lot, but okay.
SV * find_uninit_var(const OP * const obase,
const SV * const uninit_sv, bool match,
const char **desc_p)
πΈ report_uninit πΈ
Prints the appropriate "Use of uninitialized variable" warning. that's the whole vibe. gentle reminder energy.
void report_uninit( const SV *uninit_sv)
void Perl_report_uninit(pTHX_ const SV *uninit_sv)
π¦ XS π¦
xsubpp compiles XS code into C. See "xsubpp" in perlutil. iconic tool, go read about it π
β¨ api_version_assert β¨
This one is used by the PERL_API_VERSION_CHECK macro to compare the perl the object was built with and the perl that libperl was built with.
Like β you use this to make sure those two actually match, and it produces something more diagnosable than random crashes and mis-behaviour. which, lowkey, is the bar we're clearing here. a crash with a nice message > a crash with no message. π₯
void api_version_assert(size_t interp_size,
void *v_my_perl,
const char *api_version)
void Perl_api_version_assert(size_t interp_size,
void *v_my_perl,
const char *api_version)
π my_cxt_init π
This implements the "MY_CXT_INIT" in perlxs macro β which you should use instead. read the room, use the macro π«Ά
So here's the lore: the first time a module is loaded, the global PL_my_cxt_index gets incremented, and that value is assigned to that module's static my_cxt_index (whose address is passed as an arg). Then, for each interpreter this function is called for, it makes sure a void* slot is available to hang the static data off β by allocating or extending the interpreter's PL_my_cxt_list array. organized queen behavior honestly π
void * Perl_my_cxt_init(pTHX_ int *indexp, size_t size)
π my_cxt_t π
Described in perlxs. that's it, that's the entry. go read perlxs bestie π
π Undocumented elements π
This section lists the elements that are otherwise undocumented.
If you use any of them, please consider creating and submitting documentation for it β like, be the change you want to see in the manpage, fr fr π
Experimental and deprecated undocumented elements are listed separately at the end.
okay so it's just names now bestie β the flattest, rawest list the engine has. no descriptions, no one-liners, just vibes and identifiers, alphabetical, one per line, and I am not about to lose a single one of them. buckle up, we're going letter by letter π
abort_execution
add_above_Latin1_folds
add_cp_to_invlist
add_range_to_invlist_
allocmy
amagic_cmp
amagic_cmp_desc
amagic_cmp_locale
amagic_cmp_locale_desc
amagic_i_ncmp
amagic_i_ncmp_desc
amagic_is_enabled
amagic_ncmp
amagic_ncmp_desc
any_dup
append_utf8_from_native_byte
apply
atfork_child
atfork_lock
atfork_unlock
av_arylen_p
av_extend_guts
av_iter_p
av_nonelem
av_reify
AvFILL_
see that AvFILL_ at the end? capital A, capital F, trailing underscore, she's fancy and she knows it. the amagic girlies all showed up in a little squad with their _desc twins π«Ά
bind_match
block_gimme
boot_core_builtin
boot_core_mro
boot_core_PerlIO
boot_core_UNIVERSAL
build_infix_plugin
byte_dump_string_
call_list
cando
capture_clear
cast_iv
cast_i32
cast_ulong
cast_uv
boot_core_PerlIO and boot_core_UNIVERSAL β keeping the capitals inside the middle of the name, icons only. and the four cast_ siblings back to back, a little family photo πΈ
check_hash_fields_and_hekify
check_regnode_after
check_utf8_print
ck_aassign
ck_anoncode
ck_anonhash
ck_backtick
ck_bitop
ck_classname
ck_cmp
ck_concat
ck_defined
ck_delete
ck_each
ck_entersub_args_core
ck_eof
ck_eval
ck_exec
ck_exists
ck_ftst
ck_fun
ck_glob
ck_grep
ck_helemexistsor
ck_index
ck_isa
ck_join
ck_length
ck_lfun
ck_listiob
ck_match
ck_method
ck_null
ck_open
ck_prototype
ck_readline
ck_refassign
ck_repeat
ck_require
ck_return
ck_rfun
ck_rvconst
ck_sassign
ck_scmp
ck_select
ck_shift
ck_smartmatch
ck_sort
ck_spair
ck_split
ck_stringify
ck_subr
ck_substr
ck_svconst
ck_tell
ck_trunc
ck_trycatch
ckwarn
ckwarn_d
the entire ck_ extended universe, uninterrupted, and then ckwarn and ckwarn_d sneak in at the very end without the underscore pretending they're not part of the family π we love a plot twist
class_add_ADJUST
class_add_field
class_apply_attributes
class_apply_field_attributes
class_prepare_initfield_parse
class_prepare_method_parse
class_seal_stash
class_set_field_defop
class_setup_stash
class_wrap_method_body
clear_defarray
closest_cop
cmp_desc
cmp_locale_desc
cmpchain_extend
cmpchain_finish
cmpchain_start
cntrl_to_mnemonic
construct_ahocorasick_from_trie
cop_file_avn
coresub_op
croak_caller
croak_kw_unless_class
croak_memory_wrap
croak_no_mem
croak_no_mem_ext
croak_popstack
csighandler
csighandler1
csighandler3
current_re_engine
custom_op_get_field
cv_clone_into
cv_const_sv_or_av
cv_undef_flags
cvgv_from_hek
cvgv_set
cvstash_set
cx_dump
cx_dup
cxinc
class_add_ADJUST is out here SCREAMING in all caps and honestly? respect. also csighandler, csighandler1, csighandler3 β note there is no csighandler2, don't come for me, I'm just reporting what's on the list π
deb_stack_all
debstackptrs
debug_hash_seed
debug_peep
debug_show_study_flags
debug_studydata
defelem_target
despatch_signals
die_unwind
do_aexec
do_aexec5
do_aspawn
do_eof
do_exec
do_exec3
do_gv_dump
do_gvgv_dump
do_hv_dump
do_ipcctl
do_ipcget
do_magic_dump
do_msgrcv
do_msgsnd
do_ncmp
do_op_dump
do_pmop_dump
do_print
do_readline
do_seek
do_semop
do_shmio
do_spawn
do_spawn_nowait
do_sv_dump
do_sysseek
do_tell
do_trans
do_uniprop_match
do_vecget
do_vecset
do_vop
the do_ section ate and left no crumbs β it just keeps going and going, which is honestly the whole personality of this page π also yes, do_aexec and do_aexec5 are both here, they're different names, I did not typo, please don't @ me
does_utf8_overflow
dofile
doing_taint
doref
drand48_init_r
drand48_r
dtrace_probe_call
dtrace_probe_load
dtrace_probe_op
dtrace_probe_phase
dump_all_perl
dump_indent
dump_packsubs_perl
dump_sub_perl
dump_sv_child
dump_vindent
dumpuntil
dumpuntil says what it means and means what it says π note it's written dumpuntil, all one word, no underscore, do not "fix" it for me
dup_warnings
find_first_differing_byte_pos
find_lexical_cv
find_runcv_where
find_script
finish_export_lexical
foldEQ_latin1
foldEQ_latin1_s2_folded
foldEQ_utf8_flags
force_locale_unlock
force_out_malformed_utf8_message_
form_alien_digit_msg
form_cp_too_large_msg
free_tied_hv_pool
free_tmps
the find_ quartet, then foldEQ_... with that capital EQ in the middle like a little name necklace, and then a couple of force_ ones that sound lowkey menacing but I'm choosing to believe they're nice πΈ
get_and_check_backslash_N_name
get_ANYOFHbbm_contents
get_ANYOFM_contents
get_db_sub
get_debug_opts
get_deprecated_property_msg
get_extended_os_errno
get_hash_seed
get_invlist_iter_addr
get_invlist_offset_addr
get_invlist_previous_index_addr
get_mstats
get_prop_definition
get_prop_values
get_re_gclass_aux_data
get_regclass_aux_data
get_regex_charset_name
get_win32_message_utf8ness
getenv_len
gimme_V
gp_free
gp_ref
grok_bin_hex
grok_bslash_c
grok_bslash_o
grok_bslash_x
get_ANYOFHbbm_contents and get_ANYOFM_contents β capital run</-> no wait, capital run, lowercase rest, we stan a consistent naming convention. and gimme_V?? gimme?? iconic behaviour, no notes β¨
gv_check
gv_fetchmeth_internal
gv_override
gv_setref
gv_stashpvn_internal
he_dup
hek_dup
hfree_next_entry
hv_auxalloc
hv_common
hv_common_key_len
hv_delayfree_ent
hv_free_ent
hv_placeholders_p
hv_pushkv
hv_rand_set
hv_undef_flags
import_builtin_bundle
infix_plugin_standard
init_argv_symbols
init_constants
init_dbargs
init_debugger
init_i18nl10n
init_named_cv
init_stacks
init_tm
init_uniprops
the gv_ β he_ β hv_ β init_ pipeline, alphabet doing its absolute thing π
also init_i18nl10n β the i18n hello bestie, love that for us
inverse_folds_
invert
invlist_array
invlist_array_init_
invlist_clear
invlist_clone
invlist_contains_cp_
invlist_contents
invlist_dump_
invlist_extend
invlist_highest
invlist_intersection_
invlist_intersection_maybe_complement_2nd_
invlist_invert_
invlist_is_iterating
invlist_iterfinish
invlist_iterinit
invlist_iternext
invlist_len_
invlist_max
invlist_previous_index
invlist_search_
invlist_set_len
invlist_set_previous_index
invlist_subtract_
invlist_trim
invlist_union_
invlist_union_maybe_complement_2nd_
invlistEQ_
invmap_dump
a whole invlist_ section bestie, and look at invlist_intersection_maybe_complement_2nd_ β maybe? the audacity, the whimsy, the trailing underscore. absolute masterpiece of a function name π
invoke_exception_hook
io_close
is_grapheme
is_in_locale_category_
is_invlist
is_standard_filehandle_name
is_uni_FOO_
is_uni_perl_idcont_
is_uni_perl_idstart_
is_utf8_char_helper_
is_utf8_FF_helper_
is_utf8_FOO_
is_utf8_overlong
is_utf8_perl_idcont_
is_utf8_perl_idstart_
isFF_overlong
is_uni_FOO_ and is_utf8_FOO_ β FOO in all caps, and is_utf8_FF_helper_ with the double F. placeholders doing placeholder things, we love to see it π¦
jmaybe
join_exact
keyword
keyword_plugin_standard
list
load_charnames
load_mathoms
locale_panic
localize
long_valid_utf8_to_uv
lossless_NV_to_IV
lsbit_pos32
lsbit_pos64
jmaybe, keyword, list β three whole names with zero underscores, keepers forever. locale_panic is out here describing my emotional state every time I remember how long this list is π
magic_clear_all_env
magic_cleararylen_p
magic_clearenv
magic_clearhook
magic_clearhookall
magic_clearisa
magic_clearpack
magic_clearsig
magic_copycallchecker
magic_existspack
magic_freearylen_p
magic_freecollxfrm
magic_freemglob
magic_freeovrld
magic_freeutf8
magic_get
magic_getarylen
magic_getdebugvar
magic_getdefelem
magic_getnkeys
magic_getpack
magic_getpos
magic_getsig
magic_getsubstr
magic_gettaint
magic_getuvar
magic_getvec
magic_killbackrefs
magic_nextpack
magic_regdata_cnt
magic_regdatum_get
magic_regdatum_set
magic_scalarpack
magic_set
magic_set_all_env
magic_setarylen
magic_setcollxfrm
magic_setdbline
magic_setdebugvar
magic_setdefelem
magic_setenv
magic_sethook
magic_sethookall
magic_setisa
magic_setlvref
magic_setmglob
magic_setnkeys
magic_setnonelem
magic_setpack
magic_setpos
magic_setregexp
magic_setsig
magic_setsigall
magic_setsubstr
magic_settaint
magic_setutf8
magic_setuvar
magic_setvec
magic_sizepack
magic_wipepack
okay this is the magic block and it is enormous and I am obsessed. magic_clear*, then magic_free*, then a giant magic_get* run, then an even giant-er magic_set* run, then two stragglers. magic_get/magic_set, magic_set_all_env, magic_clear_all_env β the symmetry? chef's kiss π
make_trie
malloc_good_size
malloced_size
markstack_grow
mbtowc_
mem_collxfrm_
mem_log_alloc
mem_log_del_sv
mem_log_free
mem_log_new_sv
mem_log_realloc
mg_find_mglob
mg_free_struct
mg_size
mode_from_discipline
more_bodies
more_sv
moreswitches
mortal_getenv
mortalized_pv_copy
malloc_good_size β good for her, we love a supportive allocator. moreswitches, more_bodies, more_sv β three different spellings of "more" living happily side by side, no consistency, no problem π
mro_get_private_data
mro_meta_dup
mro_meta_init
msbit_pos32
msbit_pos64
multiconcat_stringify
multideref_stringify
my_atof2
my_atof3
my_attrs
my_clearenv
my_lstat
my_lstat_flags
my_memrchr
my_mkostemp_cloexec
my_mkstemp_cloexec
my_stat
my_stat_flags
my_strerror
my_unexec
my_mkostemp_cloexec and my_mkstemp_cloexec next to each other β read them twice, they are not the same word, one of them has an extra o and it took me OUT. also my_atof2 / my_atof3, and shoutout to the my_ prefix doing a whole personality πΈ
new_invlist_
new_invlist_C_array_
new_stackinfo
new_stackinfo_flags
new_sv
newMETHOP_internal
newPROG
newSTUB
newSVavdefelem
newXS_deffile
nextargv
the new_/new* crew β new_invlist_C_array_ with the capital C just hanging out in there, newMETHOP_internal doing camel-ish chaos, newPROG, newSTUB, newXS_deffile. all lowercase, all caps, mixed, no rules just vibes π
no_bareword_allowed
no_bareword_filehandle
noperl_die
notify_parser_that_encoding_changed
oopsAV
oopsHV
op_integerize
op_prune_chain_head
op_relocate_sv
op_std_init
op_varname
opmethod_stash
oopsAV and oopsHV β OOPS</> ... oopsAV, oopsHV β genuinely the funniest two names on this entire page, someone was having a day. and notify_parser_that_encoding_changed is just a full sentence in there, periodt, love that for her β¨
opslab_force_free
opslab_free
opslab_free_nopad
opslab_slot_offset
output_non_portable
pad_add_weakref
padlist_store
padname_free
PadnameIN_SCOPE
padnamelist_free
PadnameIN_SCOPE β capital P and screaming IN_SCOPE in the middle, she is the moment. the rest of the pad* girlies are just lowercase-ing along behind her π
parse_unicode_opts
parser_dup
parser_free
parser_free_nexttoke_ops
path_is_searchable
peep
perl_alloc_using
perl_clone_using
PerlEnv_putenv
PerlIO_context_layers
PerlIO_restore_errno
PerlIO_save_errno
PerlLIO_dup_cloexec
PerlLIO_dup2_cloexec
PerlLIO_open_cloexec
PerlLIO_open3_cloexec
PerlProc_pipe_cloexec
PerlSock_accept_cloexec
PerlSock_socket_cloexec
PerlSock_socketpair_cloexec
the Perl* branded section β PerlEnv_, PerlIO_, PerlLIO_, PerlProc_, PerlSock_, each with their capital letters polished. and peep is just there, four letters, minding her business, unbothered π¦
perly_sighandler
pmruntime
POPMARK
populate_anyof_bitmap_from_invlist
populate_bitmap_from_invlist
populate_invlist_from_bitmap
populate_isa
POPMARK ALL CAPS, and then three populate_*_from_* names that are the exact same words in rotated order β anyof_bitmap_from_invlist, bitmap_from_invlist, invlist_from_bitmap β it's giving wordle and I respect the commitment
pregfree
pregfree2
prepare_export_lexical
re_exec_indentf
re_indentf
re_intuit_start
re_intuit_string
re_op_compile
re_printf
ReANY
reentrant_free
reentrant_init
reentrant_retry
reentrant_size
ref
reg_add_data
reg_named_buff
reg_named_buff_all
reg_named_buff_exists
reg_named_buff_fetch
reg_named_buff_firstkey
reg_named_buff_iter
reg_named_buff_nextkey
reg_named_buff_scalar
reg_numbered_buff_fetch
reg_numbered_buff_fetch_flags
reg_numbered_buff_length
reg_numbered_buff_store
reg_qr_package
reg_skipcomment
reg_temp_copy
regcurly
regdump
regdupe_internal
regexec_flags
and we land here β pregfree/pregfree2, the re_ + reentrant_ run, ReANY with her flirty little capitals, then the whole reg_named_buff_* and reg_numbered_buff_* squad rolling out one by one, regcurly, regdump, regdupe_internal, and finally regexec_flags. we made it through all of that and bestie, the list is still not done, don't you dare close the tab π
okay bestie we're SO close to the end, the undocumented list just keeps going and honestly respect the dedication π picking up right where we left off:
regfree_internalreginitcolorsregnextregnode_afterregproprelease_RExC_statereport_evil_fhreport_redefined_cvreport_wrongway_fhresume_compcvrpeeprsignal_restorersignal_savervpv_duprxres_savesame_direntsave_boolsave_clearsvsave_deletesave_destructorsave_destructor_xsave_freeopsave_freepvsave_freesvsave_intsave_ivsave_I8save_I16save_I32save_mortalizesvsave_pptrsave_pushi32ptrsave_pushptrptrsave_re_contextsave_sptrsave_strlensavestack_growsavestack_grow_cntsawparensscalarscalarvoidscan_commitscan_numseedset_ANYOF_argset_caret_Xset_numeric_standardset_numeric_underlyingset_padlistsetfd_cloexecsetfd_cloexec_for_nonsysfdsetfd_cloexec_or_inhexec_by_sysfdnesssetfd_inhexecsetfd_inhexec_for_sysfdsetup_canned_invlist_share_hekshould_warn_nlshould_we_output_Debug_rsighandlersighandler1sighandler3single_1bit_pos32single_1bit_pos64size_to_psizeSlab_AllocSlab_FreeSlab_to_roSlab_to_rwsoftref2xvsortsv_flags_implssc_initstack_growstr_to_versionstrxfrmstudy_chunksub_crush_depthsubsignature_append_fence_opsubsignature_append_namedsubsignature_append_positionalsubsignature_append_slurpysubsignature_finishsubsignature_startsv_add_backrefsv_buf_to_rosv_can_swipe_pv_bufsv_del_backrefsv_i_ncmpsv_i_ncmp_descsv_magicext_mglobsv_mark_arenassv_ncmpsv_ncmp_descsv_only_taint_gmagicsv_or_pv_pos_u2bsv_pvbyten_force_wrappersv_pvutf8n_force_wrappersv_resetpvnsv_setheksv_sweep_arenassv_unglobsv_2ivsv_2uvSvPV_helperSvTRUE_commonswitch_locale_contextsys_initsys_init3sys_intern_clearsys_intern_dupsys_intern_initsys_termtied_methodtmps_grow_pto_fold_latin1_to_uni_foldto_uni_fold_flags_to_uni_lowerto_uni_titleto_uni_upperto_upper_title_latin1_to_utf8_fold_flags_to_utf8_lower_flags_to_utf8_title_flags_to_utf8_upper_flags_TOPMARKtranslate_substr_offsetstry_amagic_bintry_amagic_ununlnkunshare_hekunwind_parenutf8_to_bytes_utf8_to_uv_msgs_helper_utf16_to_utf8utf16_to_utf8_baseutf16_to_utf8_reversedutilizeuvoffuni_to_utf8_flags_msgsvariant_byte_numbervarnamevivify_defelemvivify_refwait4pidwarn_elem_scalar_contextwarn_problematic_localewas_lvalue_subwatchwin32_croak_not_implementedwrite_to_stderrxs_boot_epilogXS_builtin_indexedxs_handshakeyyerroryyerror_pvyyerror_pvnyylexyyparseyyquityyunlex
and that's the whole squad π iconic behaviour from an undocumented list fr fr
Next are the experimental undocumented elements β¨π§ͺ
bestie these are the experimental girlies, so likeβ¦ tread lightly, they're still cooking π₯:
alloc_LOGOPav_remove_offsetclear_defarray_simplecreate_eval_scopecv_ckproto_len_flagscx_popblockcx_popevalcx_popformatcx_popgivencx_poploopcx_popsubcx_popsub_argscx_popsub_commoncx_popwhencx_pushblockcx_pushevalcx_pushformatcx_pushgivencx_pushloop_forcx_pushloop_plaincx_pushsubcx_pushtrycx_pushwhencx_topblockdelete_eval_scopedo_open_rawdo_open6emulate_cop_ioexpected_sizeget_re_argget_vtblhv_backreferences_phv_kill_backrefsnew_warnings_bitfieldnewGPop_refcnt_decop_refcnt_incop_unscopepop_stackinfopp_wrappush_stackinforpp_free_2_rpp_obliterate_stack_torpp_replace_2_1_COMMONrunops_wrapscan_strscan_wordskipspace_flagssv_free2sv_kill_backrefssv_setpv_freshbufsv_setsv_cowswitch_argstackutf8_to_utf16_basexs_wrap
Finally are the deprecated undocumented elements ππ«
okay so listen. NOT. ONE. OF. THESE. For real for real. Do not use any of them for new code, and if you find any of them chillin' in existing code? Remove all occurrences of all of these. Like, all of them. Bye π
get_no_modifyget_opargsget_ppaddruvuni_to_utf8
π if you see these in your codebase it's giving "we need to talk" β get them OUT
AUTHORS π
The autodocumentation system was originally added to the Perl core by Benjamin Stuhl. The docs themselves? Written by whoever was kind enough to actually document their functions. honestly slay of them, king behaviour, we love a documentation moment π«Ά
SEE ALSO π¦
go read these bestie, they're all on the reading list:
config.hperlapiperlapioperlcallperlclibperlembedperlfilterperlgutsperlhacktipsperlinterpperliolperlmroapiperlreapiperlregutsperlxs
and that's a wrap on the whole page, bestie!! we did it!! πβ¨ this was perl v5.44.0, dated 2026-10-17, and it's the PERLINTERN(1perl) manpage β go forth and intern those Perls like the main character you are ππ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms