sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);
+See lib/sort.pm for details about controlling the sorting algorithm.
+
void sortsv(SV ** array, size_t num_elts, SVCOMPARE_t cmp)
=for hackers
=for hackers
Found in file op.c
+=item nothreadhook
+
+Stub that provides thread hook for perl_destruct when there are
+no threads.
+
+ int nothreadhook()
+
+=for hackers
+Found in file perl.c
+
=item perl_alloc
Allocates a new Perl interpreter. See L<perlembed>.
=back
+=head1 Functions in file pp_pack.c
+
+
+=over 8
+
+=item pack_cat
+
+The engine implementing pack() Perl function.
+
+ void pack_cat(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
+
+=for hackers
+Found in file pp_pack.c
+
+=item unpack_str
+
+The engine implementing unpack() Perl function.
+
+ I32 unpack_str(char *pat, char *patend, char *s, char *strbeg, char *strend, char **new_s, I32 ocnt, U32 flags)
+
+=for hackers
+Found in file pp_pack.c
+
+
+=back
+
=head1 Global Variables
=over 8
=for hackers
Found in file gv.c
+=item gv_fetchmeth_autoload
+
+Same as gv_fetchmeth(), but looks for autoloaded subroutines too.
+Returns a glob for the subroutine.
+
+For an autoloaded subroutine without a GV, will create a GV even
+if C<level < 0>. For an autoloaded subroutine without a stub, GvCV()
+of the result may be zero.
+
+ GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)
+
+=for hackers
+Found in file gv.c
+
=item gv_stashpv
Returns a pointer to the stash for a specified package. C<name> should
hash buckets that happen to be in use. If you still need that esoteric
value, you can get it through the macro C<HvFILL(tb)>.
+
I32 hv_iterinit(HV* tb)
=for hackers
Returns entries from a hash iterator. See C<hv_iterinit>.
+You may call C<hv_delete> or C<hv_delete_ent> on the hash entry that the
+iterator currently points to, without losing your place or invalidating your
+iterator. Note that in this case the current entry is deleted from the hash
+with your iterator holding the last reference to it. Your iterator is flagged
+to free the entry on the next call to C<hv_iternext>, so you must not discard
+your iterator immediately else the entry will leak - call C<hv_iternext> to
+trigger the resource deallocation.
+
HE* hv_iternext(HV* tb)
=for hackers
=for hackers
Found in file hv.c
+=item hv_iternext_flags
+
+Returns entries from a hash iterator. See C<hv_iterinit> and C<hv_iternext>.
+The C<flags> value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is
+set the placeholders keys (for restricted hashes) will be returned in addition
+to normal keys. By default placeholders are automatically skipped over.
+Currently a placeholder is implemented with a value that is literally
+<&Perl_sv_undef> (a regular C<undef> value is a normal read-write SV for which
+C<!SvOK> is false). Note that the implementation of placeholders and
+restricted hashes may change, and the implementation currently is
+insufficiently abstracted for any change to be tidy.
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+ HE* hv_iternext_flags(HV* tb, I32 flags)
+
+=for hackers
+Found in file hv.c
+
=item hv_iterval
Returns the value from the current position of the hash iterator. See
=for hackers
Found in file sv.h
+=item SvLOCK
+
+Arranges for a mutual exclusion lock to be obtained on sv if a suitable module
+has been loaded.
+
+ void SvLOCK(SV* sv)
+
+=for hackers
+Found in file sv.h
+
=item SvSETMAGIC
Invokes C<mg_set> on an SV if it has 'set' magic. This macro evaluates its
=for hackers
Found in file sv.h
+=item SvSetMagicSV_nosteal
+
+Like C<SvSetMagicSV>, but does any set magic required afterwards.
+
+ void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)
+
+=for hackers
+Found in file sv.h
+
=item SvSetSV
Calls C<sv_setsv> if dsv is not the same as ssv. May evaluate arguments
=for hackers
Found in file sv.h
+=item SvSHARE
+
+Arranges for sv to be shared between threads if a suitable module
+has been loaded.
+
+ void SvSHARE(SV* sv)
+
+=for hackers
+Found in file sv.h
+
=back
=for hackers
Found in file handy.h
+=item Poison
+
+Fill up memory with a pattern (byte 0xAB over and over again) that
+hopefully catches attempts to access uninitialized memory.
+
+ void Poison(void* dest, int nitems, type)
+
+=for hackers
+Found in file handy.h
+
=item Renew
The XSUB-writer's interface to the C C<realloc> function.
=item savepv
-Copy a string to a safe spot. This does not use an SV.
+Perl's version of C<strdup()>. Returns a pointer to a newly allocated
+string which is a duplicate of C<pv>. The size of the string is
+determined by C<strlen()>. The memory allocated for the new string can
+be freed with the C<Safefree()> function.
- char* savepv(const char* sv)
+ char* savepv(const char* pv)
=for hackers
Found in file util.c
=item savepvn
-Copy a string to a safe spot. The C<len> indicates number of bytes to
-copy. This does not use an SV.
+Perl's version of what C<strndup()> would be if it existed. Returns a
+pointer to a newly allocated string which is a duplicate of the first
+C<len> bytes from C<pv>. The memory allocated for the new string can be
+freed with the C<Safefree()> function.
+
+ char* savepvn(const char* pv, I32 len)
+
+=for hackers
+Found in file util.c
+
+=item savesharedpv
+
+A version of C<savepv()> which allocates the duplicate string in memory
+which is shared between threads.
- char* savepvn(const char* sv, I32 len)
+ char* savesharedpv(const char* pv)
=for hackers
Found in file util.c
=back
-=head1 Shared SV Functions
-
-=over 8
-
-=item sharedsv_find
-
-Tries to find if a given SV has a shared backend, either by
-looking at magic, or by checking if it is tied again threads::shared.
-
- shared_sv* sharedsv_find(SV* sv)
-
-=for hackers
-Found in file sharedsv.c
-
-=item sharedsv_init
-
-Saves a space for keeping SVs wider than an interpreter,
-currently only stores a pointer to the first interpreter.
-
- void sharedsv_init()
-
-=for hackers
-Found in file sharedsv.c
-
-=item sharedsv_lock
-
-Recursive locks on a sharedsv.
-Locks are dynamically scoped at the level of the first lock.
- void sharedsv_lock(shared_sv* ssv)
-
-=for hackers
-Found in file sharedsv.c
-
-=item sharedsv_new
-
-Allocates a new shared sv struct, you must yourself create the SV/AV/HV.
- shared_sv* sharedsv_new()
-
-=for hackers
-Found in file sharedsv.c
-
-=item sharedsv_thrcnt_dec
-
-Decrements the threadcount of a shared sv. When a threads frontend is freed
-this function should be called.
-
- void sharedsv_thrcnt_dec(shared_sv* ssv)
-
-=for hackers
-Found in file sharedsv.c
-
-=item sharedsv_thrcnt_inc
-
-Increments the threadcount of a sharedsv.
- void sharedsv_thrcnt_inc(shared_sv* ssv)
-
-=for hackers
-Found in file sharedsv.c
-
-=item sharedsv_unlock
-
-Recursively unlocks a shared sv.
-
- void sharedsv_unlock(shared_sv* ssv)
-
-=for hackers
-Found in file sharedsv.c
-
-
-=back
-
=head1 Stack Manipulation Macros
=over 8
=for hackers
Found in file sv.c
-=item new_vstring
+=item new_version
+
+Returns a new version object based on the passed in SV:
+
+ SV *sv = new_version(SV *ver);
+
+Does not alter the passed in ver SV. See "upg_version" if you
+want to upgrade the SV.
+
+ SV* new_version(SV *ver)
+
+=for hackers
+Found in file util.c
+
+=item scan_version
+
+Returns a pointer to the next character after the parsed
+version string, as well as upgrading the passed in SV to
+an RV.
+
+Function must be called with an already existing SV like
+
+ sv = NEWSV(92,0);
+ s = scan_version(s,sv);
+
+Performs some preprocessing to the string to ensure that
+it has the correct characteristics of a version. Flags the
+object if it contains an underscore (which denotes this
+is a beta version).
+
+ char* scan_version(char *vstr, SV *sv)
+
+=for hackers
+Found in file util.c
+
+=item scan_vstring
Returns a pointer to the next character after the parsed
vstring, as well as updating the passed in sv.
Function must be called like
- sv = NEWSV(92,5);
- s = new_vstring(s,sv);
+ sv = NEWSV(92,5);
+ s = scan_vstring(s,sv);
-The sv must already be large enough to store the vstring
-passed in.
+The sv should already be large enough to store the vstring
+passed in, for performance reasons.
- char* new_vstring(char *vstr, SV *sv)
+ char* scan_vstring(char *vstr, SV *sv)
=for hackers
Found in file util.c
=item SvPV
-Returns a pointer to the string in the SV, or a stringified form of the SV
-if the SV does not contain a string. Handles 'get' magic. See also
+Returns a pointer to the string in the SV, or a stringified form of
+the SV if the SV does not contain a string. The SV may cache the
+stringified version becoming C<SvPOK>. Handles 'get' magic. See also
C<SvPVx> for a version which guarantees to evaluate sv only once.
char* SvPV(SV* sv, STRLEN len)
=for hackers
Found in file sv.h
-=item SvPVX
+=item SvPVx
-Returns a pointer to the physical string in the SV. The SV must contain a
-string.
+A version of C<SvPV> which guarantees to evaluate sv only once.
- char* SvPVX(SV* sv)
+ char* SvPVx(SV* sv, STRLEN len)
=for hackers
Found in file sv.h
-=item SvPVx
+=item SvPVX
-A version of C<SvPV> which guarantees to evaluate sv only once.
+Returns a pointer to the physical string in the SV. The SV must contain a
+string.
- char* SvPVx(SV* sv, STRLEN len)
+ char* SvPVX(SV* sv)
=for hackers
Found in file sv.h
=item SvPV_force
-Like <SvPV> but will force the SV into becoming a string (SvPOK). You want
-force if you are going to update the SvPVX directly.
+Like C<SvPV> but will force the SV into containing just a string
+(C<SvPOK_only>). You want force if you are going to update the C<SvPVX>
+directly.
char* SvPV_force(SV* sv, STRLEN len)
=item SvPV_force_nomg
-Like <SvPV> but will force the SV into becoming a string (SvPOK). You want
-force if you are going to update the SvPVX directly. Doesn't process magic.
+Like C<SvPV> but will force the SV into containing just a string
+(C<SvPOK_only>). You want force if you are going to update the C<SvPVX>
+directly. Doesn't process magic.
char* SvPV_force_nomg(SV* sv, STRLEN len)
=item SvPV_nolen
-Returns a pointer to the string in the SV, or a stringified form of the SV
-if the SV does not contain a string. Handles 'get' magic.
+Returns a pointer to the string in the SV, or a stringified form of
+the SV if the SV does not contain a string. The SV may cache the
+stringified form becoming C<SvPOK>. Handles 'get' magic.
char* SvPV_nolen(SV* sv)
=for hackers
Found in file sv.h
-=item SvSetMagicSV_nosteal
-
-Like C<SvSetMagicSV>, but does any set magic required afterwards.
-
-
- void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)
-
-=for hackers
-Found in file sv.h
-
=item SvSTASH
Returns the stash of the SV.
=for hackers
Found in file sv.h
+=item SvUNLOCK
+
+Releases a mutual exclusion lock on sv if a suitable module
+has been loaded.
+
+
+ void SvUNLOCK(SV* sv)
+
+=for hackers
+Found in file sv.h
+
=item SvUOK
Returns a boolean indicating whether the SV contains an unsigned integer.
=for hackers
Found in file sv.h
+=item SvUVX
+
+Returns the raw value in the SV's UV slot, without checks or conversions.
+Only use when you are sure SvIOK is true. See also C<SvUV()>.
+
+ UV SvUVX(SV* sv)
+
+=for hackers
+Found in file sv.h
+
=item SvUVx
Coerces the given SV to an unsigned integer and returns it. Guarantees to
=for hackers
Found in file sv.h
-=item SvUVX
+=item SvVOK
-Returns the raw value in the SV's UV slot, without checks or conversions.
-Only use when you are sure SvIOK is true. See also C<SvUV()>.
+Returns a boolean indicating whether the SV contains a v-string.
- UV SvUVX(SV* sv)
+ bool SvVOK(SV* sv)
=for hackers
Found in file sv.h
=for hackers
Found in file sv.c
+=item sv_copypv
+
+Copies a stringified representation of the source SV into the
+destination SV. Automatically performs any necessary mg_get and
+coercion of numeric values into strings. Guaranteed to preserve
+UTF-8 flag even from overloaded objects. Similar in nature to
+sv_2pv[_flags] but operates directly on an SV instead of just the
+string. Mostly uses sv_2pv_flags to do its work, except when that
+would lose the UTF-8'ness of the PV.
+
+ void sv_copypv(SV* dsv, SV* ssv)
+
+=for hackers
+Found in file sv.c
+
=item sv_dec
Auto-decrement of the value in the SV, doing string to numeric conversion
Undo various types of fakery on an SV: if the PV is a shared string, make
a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
-an xpvmg. The C<flags> parameter gets passed to C<sv_unref_flags()>
-when unrefing. C<sv_force_normal> calls this function with flags set to 0.
+an xpvmg; if we're a copy-on-write scalar, this is the on-write time when
+we do the copy, and is also used locally. If C<SV_COW_DROP_PV> is set
+then a copy-on-write scalar drops its PV buffer (if any) and becomes
+SvPOK_off rather than making a copy. (Used where this scalar is about to be
+set to some other value. In addtion, the C<flags> parameter gets passed to
+C<sv_unref_flags()> when unrefing. C<sv_force_normal> calls this function
+with flags set to 0.
void sv_force_normal_flags(SV *sv, U32 flags)
Adds magic to an SV. First upgrades C<sv> to type C<SVt_PVMG> if necessary,
then adds a new magic item of type C<how> to the head of the magic list.
-C<name> is assumed to contain an C<SV*> if C<(name && namelen == HEf_SVKEY)>
-
void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen)
=for hackers
Found in file sv.c
+=item sv_magicext
+
+Adds magic to an SV, upgrading it if necessary. Applies the
+supplied vtable and returns pointer to the magic added.
+
+Note that sv_magicext will allow things that sv_magic will not.
+In particular you can add magic to SvREADONLY SVs and and more than
+one instance of the same 'how'
+
+I C<namelen> is greater then zero then a savepvn() I<copy> of C<name> is stored,
+if C<namelen> is zero then C<name> is stored as-is and - as another special
+case - if C<(name && namelen == HEf_SVKEY)> then C<name> is assumed to contain
+an C<SV*> and has its REFCNT incremented
+
+(This is now used as a subroutine by sv_magic.)
+
+ MAGIC * sv_magicext(SV* sv, SV* obj, int how, MGVTBL *vtbl, const char* name, I32 namlen )
+
+=for hackers
+Found in file sv.c
+
=item sv_mortalcopy
Creates a new SV which is a copy of the original SV (using C<sv_setsv>).
=for hackers
Found in file sv.c
+=item sv_nolocking
+
+Dummy routine which "locks" an SV when there is no locking module present.
+Exists to avoid test for a NULL function pointer and because it could potentially warn under
+some level of strict-ness.
+
+ void sv_nolocking(SV *)
+
+=for hackers
+Found in file util.c
+
+=item sv_nosharing
+
+Dummy routine which "shares" an SV when there is no sharing module present.
+Exists to avoid test for a NULL function pointer and because it could potentially warn under
+some level of strict-ness.
+
+ void sv_nosharing(SV *)
+
+=for hackers
+Found in file util.c
+
+=item sv_nounlocking
+
+Dummy routine which "unlocks" an SV when there is no locking module present.
+Exists to avoid test for a NULL function pointer and because it could potentially warn under
+some level of strict-ness.
+
+ void sv_nounlocking(SV *)
+
+=for hackers
+Found in file util.c
+
=item sv_nv
A private implementation of the C<SvNVx> macro for compilers which can't
=item sv_pv
-A private implementation of the C<SvPV_nolen> macro for compilers which can't
-cope with complex macro expressions. Always use the macro instead.
+Use the C<SvPV_nolen> macro instead
char* sv_pv(SV *sv)
=item sv_pvbyte
-A private implementation of the C<SvPVbyte_nolen> macro for compilers
-which can't cope with complex macro expressions. Always use the macro
-instead.
+Use C<SvPVbyte_nolen> instead.
char* sv_pvbyte(SV *sv)
=item sv_pvutf8
-A private implementation of the C<SvPVutf8_nolen> macro for compilers
-which can't cope with complex macro expressions. Always use the macro
-instead.
+Use the C<SvPVutf8_nolen> macro instead
char* sv_pvutf8(SV *sv)
=for hackers
Found in file sv.c
-=item sv_setpviv
-
-Copies an integer into the given SV, also updating its string value.
-Does not handle 'set' magic. See C<sv_setpviv_mg>.
-
- void sv_setpviv(SV* sv, IV num)
-
-=for hackers
-Found in file sv.c
-
-=item sv_setpviv_mg
-
-Like C<sv_setpviv>, but also handles 'set' magic.
-
- void sv_setpviv_mg(SV *sv, IV iv)
-
-=for hackers
-Found in file sv.c
-
=item sv_setpvn
Copies a string into an SV. The C<len> parameter indicates the number of
C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and
C<SvSetMagicSV_nosteal>.
-
void sv_setsv(SV* dsv, SV* ssv)
=for hackers
if this is the case, either returns false or, if C<fail_ok> is not
true, croaks.
+This is not as a general purpose Unicode to byte encoding interface:
+use the Encode extension for that.
+
NOTE: this function is experimental and may change or be
removed without notice.
Always sets the SvUTF8 flag to avoid future validity checks even
if all the bytes have hibit clear.
+This is not as a general purpose byte encoding to Unicode interface:
+use the Encode extension for that.
+
STRLEN sv_utf8_upgrade(SV *sv)
=for hackers
will C<mg_get> on C<sv> if appropriate, else not. C<sv_utf8_upgrade> and
C<sv_utf8_upgrade_nomg> are implemented in terms of this function.
+This is not as a general purpose byte encoding to Unicode interface:
+use the Encode extension for that.
+
STRLEN sv_utf8_upgrade_flags(SV *sv, I32 flags)
=for hackers
=for hackers
Found in file sv.c
+=item upg_version
+
+In-place upgrade of the supplied SV to a version object.
+
+ SV *sv = upg_version(SV *sv);
+
+Returns a pointer to the upgraded SV.
+
+ SV* upg_version(SV *ver)
+
+=for hackers
+Found in file util.c
+
+=item vnumify
+
+Accepts a version (or vstring) object and returns the
+normalized floating point representation. Call like:
+
+ sv = vnumify(sv,SvRV(rv));
+
+NOTE: no checking is done to see if the object is of the
+correct type (for speed).
+
+ SV* vnumify(SV *sv, SV *vs)
+
+=for hackers
+Found in file util.c
+
+=item vstringify
+
+Accepts a version (or vstring) object and returns the
+normalized representation. Call like:
+
+ sv = vstringify(sv,SvRV(rv));
+
+NOTE: no checking is done to see if the object is of the
+correct type (for speed).
+
+ SV* vstringify(SV *sv, SV *vs)
+
+=for hackers
+Found in file util.c
+
=back
=item is_utf8_char
Tests if some arbitrary number of bytes begins in a valid UTF-8
-character. Note that an INVARIANT (i.e. ASCII) character is a valid UTF-8 character.
-The actual number of bytes in the UTF-8 character will be returned if
-it is valid, otherwise 0.
+character. Note that an INVARIANT (i.e. ASCII) character is a valid
+UTF-8 character. The actual number of bytes in the UTF-8 character
+will be returned if it is valid, otherwise 0.
STRLEN is_utf8_char(U8 *p)
Build to the scalar dsv a displayable version of the string spv,
length len, the displayable version being at most pvlim bytes long
(if longer, the rest is truncated and "..." will be appended).
-The flags argument is currently unused but available for future extensions.
+
+The flags argument can have UNI_DISPLAY_ISPRINT set to display
+isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH
+to display the \\[nrfta\\] as the backslashed versions (like '\n')
+(UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\).
+UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both
+UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on.
+
The pointer to the PV of the dsv is returned.
char* pv_uni_display(SV *dsv, U8 *spv, STRLEN len, STRLEN pvlim, UV flags)
=item sv_uni_display
Build to the scalar dsv a displayable version of the scalar sv,
-he displayable version being at most pvlim bytes long
+the displayable version being at most pvlim bytes long
(if longer, the rest is truncated and "..." will be appended).
-The flags argument is currently unused but available for future extensions.
+
+The flags argument is as in pv_uni_display().
+
The pointer to the PV of the dsv is returned.
char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
conversion result to. The "lenp" is a pointer to the length
of the result.
-The "swash" is a pointer to the swash to use.
+The "swashp" is a pointer to the swash to use.
-The "normal" is a string like "ToLower" which means the swash
-$utf8::ToLower, which is stored in lib/unicore/To/Lower.pl,
-and loaded by SWASHGET, using lib/utf8_heavy.pl.
+Both the special and normal mappings are stored lib/unicore/To/Foo.pl,
+and loaded by SWASHGET, using lib/utf8_heavy.pl. The special (usually,
+but not always, a multicharacter mapping), is tried first.
-The "special" is a string like "utf8::ToSpecLower", which means
-the hash %utf8::ToSpecLower, which is stored in the same file,
-lib/unicore/To/Lower.pl, and also loaded by SWASHGET. The access
-to the hash is by Perl_to_utf8_case().
+The "special" is a string like "utf8::ToSpecLower", which means the
+hash %utf8::ToSpecLower. The access to the hash is through
+Perl_to_utf8_case().
+
+The "normal" is a string like "ToLower" which means the swash
+%utf8::ToLower.
UV to_utf8_case(U8 *p, U8* ustrp, STRLEN *lenp, SV **swash, char *normal, char *special)