497ad9f94a618b810fc83c29479d94139b175584
[p5sagit/p5-mst-13.2.git] / pod / perlapi.pod
1 =head1 NAME
2
3 perlapi - autogenerated documentation for the perl public API
4
5 =head1 DESCRIPTION
6 X<Perl API> X<API> X<api>
7
8 This file contains the documentation of the perl public API generated by
9 embed.pl, specifically a listing of functions, macros, flags, and variables
10 that may be used by extension writers.  The interfaces of any functions that
11 are not listed here are subject to change without notice.  For this reason,
12 blindly using functions listed in proto.h is to be avoided when writing
13 extensions.
14
15 Note that all Perl API global variables must be referenced with the C<PL_>
16 prefix.  Some macros are provided for compatibility with the older,
17 unadorned names, but this support may be disabled in a future release.
18
19 The listing is alphabetical, case insensitive.
20
21
22 =head1 "Gimme" Values
23
24 =over 8
25
26 =item GIMME
27 X<GIMME>
28
29 A backward-compatible version of C<GIMME_V> which can only return
30 C<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>.
31 Deprecated.  Use C<GIMME_V> instead.
32
33         U32     GIMME
34
35 =for hackers
36 Found in file op.h
37
38 =item GIMME_V
39 X<GIMME_V>
40
41 The XSUB-writer's equivalent to Perl's C<wantarray>.  Returns C<G_VOID>,
42 C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context,
43 respectively.
44
45         U32     GIMME_V
46
47 =for hackers
48 Found in file op.h
49
50 =item G_ARRAY
51 X<G_ARRAY>
52
53 Used to indicate list context.  See C<GIMME_V>, C<GIMME> and
54 L<perlcall>.
55
56 =for hackers
57 Found in file cop.h
58
59 =item G_DISCARD
60 X<G_DISCARD>
61
62 Indicates that arguments returned from a callback should be discarded.  See
63 L<perlcall>.
64
65 =for hackers
66 Found in file cop.h
67
68 =item G_EVAL
69 X<G_EVAL>
70
71 Used to force a Perl C<eval> wrapper around a callback.  See
72 L<perlcall>.
73
74 =for hackers
75 Found in file cop.h
76
77 =item G_NOARGS
78 X<G_NOARGS>
79
80 Indicates that no arguments are being sent to a callback.  See
81 L<perlcall>.
82
83 =for hackers
84 Found in file cop.h
85
86 =item G_SCALAR
87 X<G_SCALAR>
88
89 Used to indicate scalar context.  See C<GIMME_V>, C<GIMME>, and
90 L<perlcall>.
91
92 =for hackers
93 Found in file cop.h
94
95 =item G_VOID
96 X<G_VOID>
97
98 Used to indicate void context.  See C<GIMME_V> and L<perlcall>.
99
100 =for hackers
101 Found in file cop.h
102
103
104 =back
105
106 =head1 Array Manipulation Functions
107
108 =over 8
109
110 =item AvFILL
111 X<AvFILL>
112
113 Same as C<av_len()>.  Deprecated, use C<av_len()> instead.
114
115         int     AvFILL(AV* av)
116
117 =for hackers
118 Found in file av.h
119
120 =item av_clear
121 X<av_clear>
122
123 Clears an array, making it empty.  Does not free the memory used by the
124 array itself.
125
126         void    av_clear(AV* ar)
127
128 =for hackers
129 Found in file av.c
130
131 =item av_delete
132 X<av_delete>
133
134 Deletes the element indexed by C<key> from the array.  Returns the
135 deleted element. If C<flags> equals C<G_DISCARD>, the element is freed
136 and null is returned.
137
138         SV*     av_delete(AV* ar, I32 key, I32 flags)
139
140 =for hackers
141 Found in file av.c
142
143 =item av_exists
144 X<av_exists>
145
146 Returns true if the element indexed by C<key> has been initialized.
147
148 This relies on the fact that uninitialized array elements are set to
149 C<&PL_sv_undef>.
150
151         bool    av_exists(AV* ar, I32 key)
152
153 =for hackers
154 Found in file av.c
155
156 =item av_extend
157 X<av_extend>
158
159 Pre-extend an array.  The C<key> is the index to which the array should be
160 extended.
161
162         void    av_extend(AV* ar, I32 key)
163
164 =for hackers
165 Found in file av.c
166
167 =item av_fetch
168 X<av_fetch>
169
170 Returns the SV at the specified index in the array.  The C<key> is the
171 index.  If C<lval> is set then the fetch will be part of a store.  Check
172 that the return value is non-null before dereferencing it to a C<SV*>.
173
174 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
175 more information on how to use this function on tied arrays. 
176
177         SV**    av_fetch(AV* ar, I32 key, I32 lval)
178
179 =for hackers
180 Found in file av.c
181
182 =item av_fill
183 X<av_fill>
184
185 Ensure than an array has a given number of elements, equivalent to
186 Perl's C<$#array = $fill;>.
187
188         void    av_fill(AV* ar, I32 fill)
189
190 =for hackers
191 Found in file av.c
192
193 =item av_len
194 X<av_len>
195
196 Returns the highest index in the array.  Returns -1 if the array is
197 empty.
198
199         I32     av_len(const AV* ar)
200
201 =for hackers
202 Found in file av.c
203
204 =item av_make
205 X<av_make>
206
207 Creates a new AV and populates it with a list of SVs.  The SVs are copied
208 into the array, so they may be freed after the call to av_make.  The new AV
209 will have a reference count of 1.
210
211         AV*     av_make(I32 size, SV** svp)
212
213 =for hackers
214 Found in file av.c
215
216 =item av_pop
217 X<av_pop>
218
219 Pops an SV off the end of the array.  Returns C<&PL_sv_undef> if the array
220 is empty.
221
222         SV*     av_pop(AV* ar)
223
224 =for hackers
225 Found in file av.c
226
227 =item av_push
228 X<av_push>
229
230 Pushes an SV onto the end of the array.  The array will grow automatically
231 to accommodate the addition.
232
233         void    av_push(AV* ar, SV* val)
234
235 =for hackers
236 Found in file av.c
237
238 =item av_shift
239 X<av_shift>
240
241 Shifts an SV off the beginning of the array.
242
243         SV*     av_shift(AV* ar)
244
245 =for hackers
246 Found in file av.c
247
248 =item av_store
249 X<av_store>
250
251 Stores an SV in an array.  The array index is specified as C<key>.  The
252 return value will be NULL if the operation failed or if the value did not
253 need to be actually stored within the array (as in the case of tied
254 arrays). Otherwise it can be dereferenced to get the original C<SV*>.  Note
255 that the caller is responsible for suitably incrementing the reference
256 count of C<val> before the call, and decrementing it if the function
257 returned NULL.
258
259 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
260 more information on how to use this function on tied arrays.
261
262         SV**    av_store(AV* ar, I32 key, SV* val)
263
264 =for hackers
265 Found in file av.c
266
267 =item av_undef
268 X<av_undef>
269
270 Undefines the array.  Frees the memory used by the array itself.
271
272         void    av_undef(AV* ar)
273
274 =for hackers
275 Found in file av.c
276
277 =item av_unshift
278 X<av_unshift>
279
280 Unshift the given number of C<undef> values onto the beginning of the
281 array.  The array will grow automatically to accommodate the addition.  You
282 must then use C<av_store> to assign values to these new elements.
283
284         void    av_unshift(AV* ar, I32 num)
285
286 =for hackers
287 Found in file av.c
288
289 =item get_av
290 X<get_av>
291
292 Returns the AV of the specified Perl array.  If C<create> is set and the
293 Perl variable does not exist then it will be created.  If C<create> is not
294 set and the variable does not exist then NULL is returned.
295
296 NOTE: the perl_ form of this function is deprecated.
297
298         AV*     get_av(const char* name, I32 create)
299
300 =for hackers
301 Found in file perl.c
302
303 =item newAV
304 X<newAV>
305
306 Creates a new AV.  The reference count is set to 1.
307
308         AV*     newAV()
309
310 =for hackers
311 Found in file av.c
312
313 =item sortsv
314 X<sortsv>
315
316 Sort an array. Here is an example:
317
318     sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);
319
320 See lib/sort.pm for details about controlling the sorting algorithm.
321
322         void    sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp)
323
324 =for hackers
325 Found in file pp_sort.c
326
327
328 =back
329
330 =head1 Callback Functions
331
332 =over 8
333
334 =item call_argv
335 X<call_argv>
336
337 Performs a callback to the specified Perl sub.  See L<perlcall>.
338
339 NOTE: the perl_ form of this function is deprecated.
340
341         I32     call_argv(const char* sub_name, I32 flags, char** argv)
342
343 =for hackers
344 Found in file perl.c
345
346 =item call_method
347 X<call_method>
348
349 Performs a callback to the specified Perl method.  The blessed object must
350 be on the stack.  See L<perlcall>.
351
352 NOTE: the perl_ form of this function is deprecated.
353
354         I32     call_method(const char* methname, I32 flags)
355
356 =for hackers
357 Found in file perl.c
358
359 =item call_pv
360 X<call_pv>
361
362 Performs a callback to the specified Perl sub.  See L<perlcall>.
363
364 NOTE: the perl_ form of this function is deprecated.
365
366         I32     call_pv(const char* sub_name, I32 flags)
367
368 =for hackers
369 Found in file perl.c
370
371 =item call_sv
372 X<call_sv>
373
374 Performs a callback to the Perl sub whose name is in the SV.  See
375 L<perlcall>.
376
377 NOTE: the perl_ form of this function is deprecated.
378
379         I32     call_sv(SV* sv, I32 flags)
380
381 =for hackers
382 Found in file perl.c
383
384 =item ENTER
385 X<ENTER>
386
387 Opening bracket on a callback.  See C<LEAVE> and L<perlcall>.
388
389                 ENTER;
390
391 =for hackers
392 Found in file scope.h
393
394 =item eval_pv
395 X<eval_pv>
396
397 Tells Perl to C<eval> the given string and return an SV* result.
398
399 NOTE: the perl_ form of this function is deprecated.
400
401         SV*     eval_pv(const char* p, I32 croak_on_error)
402
403 =for hackers
404 Found in file perl.c
405
406 =item eval_sv
407 X<eval_sv>
408
409 Tells Perl to C<eval> the string in the SV.
410
411 NOTE: the perl_ form of this function is deprecated.
412
413         I32     eval_sv(SV* sv, I32 flags)
414
415 =for hackers
416 Found in file perl.c
417
418 =item FREETMPS
419 X<FREETMPS>
420
421 Closing bracket for temporaries on a callback.  See C<SAVETMPS> and
422 L<perlcall>.
423
424                 FREETMPS;
425
426 =for hackers
427 Found in file scope.h
428
429 =item LEAVE
430 X<LEAVE>
431
432 Closing bracket on a callback.  See C<ENTER> and L<perlcall>.
433
434                 LEAVE;
435
436 =for hackers
437 Found in file scope.h
438
439 =item SAVETMPS
440 X<SAVETMPS>
441
442 Opening bracket for temporaries on a callback.  See C<FREETMPS> and
443 L<perlcall>.
444
445                 SAVETMPS;
446
447 =for hackers
448 Found in file scope.h
449
450
451 =back
452
453 =head1 Character classes
454
455 =over 8
456
457 =item isALNUM
458 X<isALNUM>
459
460 Returns a boolean indicating whether the C C<char> is an ASCII alphanumeric
461 character (including underscore) or digit.
462
463         bool    isALNUM(char ch)
464
465 =for hackers
466 Found in file handy.h
467
468 =item isALPHA
469 X<isALPHA>
470
471 Returns a boolean indicating whether the C C<char> is an ASCII alphabetic
472 character.
473
474         bool    isALPHA(char ch)
475
476 =for hackers
477 Found in file handy.h
478
479 =item isDIGIT
480 X<isDIGIT>
481
482 Returns a boolean indicating whether the C C<char> is an ASCII
483 digit.
484
485         bool    isDIGIT(char ch)
486
487 =for hackers
488 Found in file handy.h
489
490 =item isLOWER
491 X<isLOWER>
492
493 Returns a boolean indicating whether the C C<char> is a lowercase
494 character.
495
496         bool    isLOWER(char ch)
497
498 =for hackers
499 Found in file handy.h
500
501 =item isSPACE
502 X<isSPACE>
503
504 Returns a boolean indicating whether the C C<char> is whitespace.
505
506         bool    isSPACE(char ch)
507
508 =for hackers
509 Found in file handy.h
510
511 =item isUPPER
512 X<isUPPER>
513
514 Returns a boolean indicating whether the C C<char> is an uppercase
515 character.
516
517         bool    isUPPER(char ch)
518
519 =for hackers
520 Found in file handy.h
521
522 =item toLOWER
523 X<toLOWER>
524
525 Converts the specified character to lowercase.
526
527         char    toLOWER(char ch)
528
529 =for hackers
530 Found in file handy.h
531
532 =item toUPPER
533 X<toUPPER>
534
535 Converts the specified character to uppercase.
536
537         char    toUPPER(char ch)
538
539 =for hackers
540 Found in file handy.h
541
542
543 =back
544
545 =head1 Cloning an interpreter
546
547 =over 8
548
549 =item perl_clone
550 X<perl_clone>
551
552 Create and return a new interpreter by cloning the current one.
553
554 perl_clone takes these flags as parameters:
555
556 CLONEf_COPY_STACKS - is used to, well, copy the stacks also,
557 without it we only clone the data and zero the stacks,
558 with it we copy the stacks and the new perl interpreter is
559 ready to run at the exact same point as the previous one.
560 The pseudo-fork code uses COPY_STACKS while the
561 threads->new doesn't.
562
563 CLONEf_KEEP_PTR_TABLE
564 perl_clone keeps a ptr_table with the pointer of the old
565 variable as a key and the new variable as a value,
566 this allows it to check if something has been cloned and not
567 clone it again but rather just use the value and increase the
568 refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill
569 the ptr_table using the function
570 C<ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;>,
571 reason to keep it around is if you want to dup some of your own
572 variable who are outside the graph perl scans, example of this
573 code is in threads.xs create
574
575 CLONEf_CLONE_HOST
576 This is a win32 thing, it is ignored on unix, it tells perls
577 win32host code (which is c++) to clone itself, this is needed on
578 win32 if you want to run two threads at the same time,
579 if you just want to do some stuff in a separate perl interpreter
580 and then throw it away and return to the original one,
581 you don't need to do anything.
582
583         PerlInterpreter*        perl_clone(PerlInterpreter* interp, UV flags)
584
585 =for hackers
586 Found in file sv.c
587
588
589 =back
590
591 =head1 CV Manipulation Functions
592
593 =over 8
594
595 =item CvSTASH
596 X<CvSTASH>
597
598 Returns the stash of the CV.
599
600         HV*     CvSTASH(CV* cv)
601
602 =for hackers
603 Found in file cv.h
604
605 =item get_cv
606 X<get_cv>
607
608 Returns the CV of the specified Perl subroutine.  If C<create> is set and
609 the Perl subroutine does not exist then it will be declared (which has the
610 same effect as saying C<sub name;>).  If C<create> is not set and the
611 subroutine does not exist then NULL is returned.
612
613 NOTE: the perl_ form of this function is deprecated.
614
615         CV*     get_cv(const char* name, I32 create)
616
617 =for hackers
618 Found in file perl.c
619
620
621 =back
622
623 =head1 Embedding Functions
624
625 =over 8
626
627 =item cv_undef
628 X<cv_undef>
629
630 Clear out all the active components of a CV. This can happen either
631 by an explicit C<undef &foo>, or by the reference count going to zero.
632 In the former case, we keep the CvOUTSIDE pointer, so that any anonymous
633 children can still follow the full lexical scope chain.
634
635         void    cv_undef(CV* cv)
636
637 =for hackers
638 Found in file op.c
639
640 =item load_module
641 X<load_module>
642
643 Loads the module whose name is pointed to by the string part of name.
644 Note that the actual module name, not its filename, should be given.
645 Eg, "Foo::Bar" instead of "Foo/Bar.pm".  flags can be any of
646 PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS
647 (or 0 for no flags). ver, if specified, provides version semantics
648 similar to C<use Foo::Bar VERSION>.  The optional trailing SV*
649 arguments can be used to specify arguments to the module's import()
650 method, similar to C<use Foo::Bar VERSION LIST>.
651
652         void    load_module(U32 flags, SV* name, SV* ver, ...)
653
654 =for hackers
655 Found in file op.c
656
657 =item nothreadhook
658 X<nothreadhook>
659
660 Stub that provides thread hook for perl_destruct when there are
661 no threads.
662
663         int     nothreadhook()
664
665 =for hackers
666 Found in file perl.c
667
668 =item perl_alloc
669 X<perl_alloc>
670
671 Allocates a new Perl interpreter.  See L<perlembed>.
672
673         PerlInterpreter*        perl_alloc()
674
675 =for hackers
676 Found in file perl.c
677
678 =item perl_construct
679 X<perl_construct>
680
681 Initializes a new Perl interpreter.  See L<perlembed>.
682
683         void    perl_construct(PerlInterpreter* interp)
684
685 =for hackers
686 Found in file perl.c
687
688 =item perl_destruct
689 X<perl_destruct>
690
691 Shuts down a Perl interpreter.  See L<perlembed>.
692
693         int     perl_destruct(PerlInterpreter* interp)
694
695 =for hackers
696 Found in file perl.c
697
698 =item perl_free
699 X<perl_free>
700
701 Releases a Perl interpreter.  See L<perlembed>.
702
703         void    perl_free(PerlInterpreter* interp)
704
705 =for hackers
706 Found in file perl.c
707
708 =item perl_parse
709 X<perl_parse>
710
711 Tells a Perl interpreter to parse a Perl script.  See L<perlembed>.
712
713         int     perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env)
714
715 =for hackers
716 Found in file perl.c
717
718 =item perl_run
719 X<perl_run>
720
721 Tells a Perl interpreter to run.  See L<perlembed>.
722
723         int     perl_run(PerlInterpreter* interp)
724
725 =for hackers
726 Found in file perl.c
727
728 =item require_pv
729 X<require_pv>
730
731 Tells Perl to C<require> the file named by the string argument.  It is
732 analogous to the Perl code C<eval "require '$file'">.  It's even
733 implemented that way; consider using load_module instead.
734
735 NOTE: the perl_ form of this function is deprecated.
736
737         void    require_pv(const char* pv)
738
739 =for hackers
740 Found in file perl.c
741
742
743 =back
744
745 =head1 Functions in file mathoms.c
746
747
748 =over 8
749
750 =item gv_fetchmethod
751 X<gv_fetchmethod>
752
753 See L<gv_fetchmethod_autoload>.
754
755         GV*     gv_fetchmethod(HV* stash, const char* name)
756
757 =for hackers
758 Found in file mathoms.c
759
760 =item sv_2pvbyte_nolen
761 X<sv_2pvbyte_nolen>
762
763 Return a pointer to the byte-encoded representation of the SV.
764 May cause the SV to be downgraded from UTF-8 as a side-effect.
765
766 Usually accessed via the C<SvPVbyte_nolen> macro.
767
768         char*   sv_2pvbyte_nolen(SV* sv)
769
770 =for hackers
771 Found in file mathoms.c
772
773 =item sv_2pvutf8_nolen
774 X<sv_2pvutf8_nolen>
775
776 Return a pointer to the UTF-8-encoded representation of the SV.
777 May cause the SV to be upgraded to UTF-8 as a side-effect.
778
779 Usually accessed via the C<SvPVutf8_nolen> macro.
780
781         char*   sv_2pvutf8_nolen(SV* sv)
782
783 =for hackers
784 Found in file mathoms.c
785
786 =item sv_2pv_nolen
787 X<sv_2pv_nolen>
788
789 Like C<sv_2pv()>, but doesn't return the length too. You should usually
790 use the macro wrapper C<SvPV_nolen(sv)> instead.
791         char*   sv_2pv_nolen(SV* sv)
792
793 =for hackers
794 Found in file mathoms.c
795
796 =item sv_catpvn_mg
797 X<sv_catpvn_mg>
798
799 Like C<sv_catpvn>, but also handles 'set' magic.
800
801         void    sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)
802
803 =for hackers
804 Found in file mathoms.c
805
806 =item sv_catsv_mg
807 X<sv_catsv_mg>
808
809 Like C<sv_catsv>, but also handles 'set' magic.
810
811         void    sv_catsv_mg(SV *dstr, SV *sstr)
812
813 =for hackers
814 Found in file mathoms.c
815
816 =item sv_force_normal
817 X<sv_force_normal>
818
819 Undo various types of fakery on an SV: if the PV is a shared string, make
820 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
821 an xpvmg. See also C<sv_force_normal_flags>.
822
823         void    sv_force_normal(SV *sv)
824
825 =for hackers
826 Found in file mathoms.c
827
828 =item sv_iv
829 X<sv_iv>
830
831 A private implementation of the C<SvIVx> macro for compilers which can't
832 cope with complex macro expressions. Always use the macro instead.
833
834         IV      sv_iv(SV* sv)
835
836 =for hackers
837 Found in file mathoms.c
838
839 =item sv_nolocking
840 X<sv_nolocking>
841
842 Dummy routine which "locks" an SV when there is no locking module present.
843 Exists to avoid test for a NULL function pointer and because it could
844 potentially warn under some level of strict-ness.
845
846 "Superseded" by sv_nosharing().
847
848         void    sv_nolocking(SV *)
849
850 =for hackers
851 Found in file mathoms.c
852
853 =item sv_nounlocking
854 X<sv_nounlocking>
855
856 Dummy routine which "unlocks" an SV when there is no locking module present.
857 Exists to avoid test for a NULL function pointer and because it could
858 potentially warn under some level of strict-ness.
859
860 "Superseded" by sv_nosharing().
861
862         void    sv_nounlocking(SV *)
863
864 =for hackers
865 Found in file mathoms.c
866
867 =item sv_nv
868 X<sv_nv>
869
870 A private implementation of the C<SvNVx> macro for compilers which can't
871 cope with complex macro expressions. Always use the macro instead.
872
873         NV      sv_nv(SV* sv)
874
875 =for hackers
876 Found in file mathoms.c
877
878 =item sv_pv
879 X<sv_pv>
880
881 Use the C<SvPV_nolen> macro instead
882
883         char*   sv_pv(SV *sv)
884
885 =for hackers
886 Found in file mathoms.c
887
888 =item sv_pvbyte
889 X<sv_pvbyte>
890
891 Use C<SvPVbyte_nolen> instead.
892
893         char*   sv_pvbyte(SV *sv)
894
895 =for hackers
896 Found in file mathoms.c
897
898 =item sv_pvbyten
899 X<sv_pvbyten>
900
901 A private implementation of the C<SvPVbyte> macro for compilers
902 which can't cope with complex macro expressions. Always use the macro
903 instead.
904
905         char*   sv_pvbyten(SV *sv, STRLEN *len)
906
907 =for hackers
908 Found in file mathoms.c
909
910 =item sv_pvn
911 X<sv_pvn>
912
913 A private implementation of the C<SvPV> macro for compilers which can't
914 cope with complex macro expressions. Always use the macro instead.
915
916         char*   sv_pvn(SV *sv, STRLEN *len)
917
918 =for hackers
919 Found in file mathoms.c
920
921 =item sv_pvutf8
922 X<sv_pvutf8>
923
924 Use the C<SvPVutf8_nolen> macro instead
925
926         char*   sv_pvutf8(SV *sv)
927
928 =for hackers
929 Found in file mathoms.c
930
931 =item sv_pvutf8n
932 X<sv_pvutf8n>
933
934 A private implementation of the C<SvPVutf8> macro for compilers
935 which can't cope with complex macro expressions. Always use the macro
936 instead.
937
938         char*   sv_pvutf8n(SV *sv, STRLEN *len)
939
940 =for hackers
941 Found in file mathoms.c
942
943 =item sv_taint
944 X<sv_taint>
945
946 Taint an SV. Use C<SvTAINTED_on> instead.
947         void    sv_taint(SV* sv)
948
949 =for hackers
950 Found in file mathoms.c
951
952 =item sv_unref
953 X<sv_unref>
954
955 Unsets the RV status of the SV, and decrements the reference count of
956 whatever was being referenced by the RV.  This can almost be thought of
957 as a reversal of C<newSVrv>.  This is C<sv_unref_flags> with the C<flag>
958 being zero.  See C<SvROK_off>.
959
960         void    sv_unref(SV* sv)
961
962 =for hackers
963 Found in file mathoms.c
964
965 =item sv_uv
966 X<sv_uv>
967
968 A private implementation of the C<SvUVx> macro for compilers which can't
969 cope with complex macro expressions. Always use the macro instead.
970
971         UV      sv_uv(SV* sv)
972
973 =for hackers
974 Found in file mathoms.c
975
976
977 =back
978
979 =head1 Functions in file pp_pack.c
980
981
982 =over 8
983
984 =item packlist
985 X<packlist>
986
987 The engine implementing pack() Perl function.
988
989         void    packlist(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist)
990
991 =for hackers
992 Found in file pp_pack.c
993
994 =item pack_cat
995 X<pack_cat>
996
997 The engine implementing pack() Perl function. Note: parameters next_in_list and
998 flags are not used. This call should not be used; use packlist instead.
999
1000         void    pack_cat(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
1001
1002 =for hackers
1003 Found in file pp_pack.c
1004
1005 =item unpackstring
1006 X<unpackstring>
1007
1008 The engine implementing unpack() Perl function. C<unpackstring> puts the
1009 extracted list items on the stack and returns the number of elements.
1010 Issue C<PUTBACK> before and C<SPAGAIN> after the call to this function.
1011
1012         I32     unpackstring(const char *pat, const char *patend, const char *s, const char *strend, U32 flags)
1013
1014 =for hackers
1015 Found in file pp_pack.c
1016
1017 =item unpack_str
1018 X<unpack_str>
1019
1020 The engine implementing unpack() Perl function. Note: parameters strbeg, new_s
1021 and ocnt are not used. This call should not be used, use unpackstring instead.
1022
1023         I32     unpack_str(const char *pat, const char *patend, const char *s, const char *strbeg, const char *strend, char **new_s, I32 ocnt, U32 flags)
1024
1025 =for hackers
1026 Found in file pp_pack.c
1027
1028
1029 =back
1030
1031 =head1 Global Variables
1032
1033 =over 8
1034
1035 =item PL_modglobal
1036 X<PL_modglobal>
1037
1038 C<PL_modglobal> is a general purpose, interpreter global HV for use by
1039 extensions that need to keep information on a per-interpreter basis.
1040 In a pinch, it can also be used as a symbol table for extensions
1041 to share data among each other.  It is a good idea to use keys
1042 prefixed by the package name of the extension that owns the data.
1043
1044         HV*     PL_modglobal
1045
1046 =for hackers
1047 Found in file intrpvar.h
1048
1049 =item PL_na
1050 X<PL_na>
1051
1052 A convenience variable which is typically used with C<SvPV> when one
1053 doesn't care about the length of the string.  It is usually more efficient
1054 to either declare a local variable and use that instead or to use the
1055 C<SvPV_nolen> macro.
1056
1057         STRLEN  PL_na
1058
1059 =for hackers
1060 Found in file thrdvar.h
1061
1062 =item PL_sv_no
1063 X<PL_sv_no>
1064
1065 This is the C<false> SV.  See C<PL_sv_yes>.  Always refer to this as
1066 C<&PL_sv_no>.
1067
1068         SV      PL_sv_no
1069
1070 =for hackers
1071 Found in file intrpvar.h
1072
1073 =item PL_sv_undef
1074 X<PL_sv_undef>
1075
1076 This is the C<undef> SV.  Always refer to this as C<&PL_sv_undef>.
1077
1078         SV      PL_sv_undef
1079
1080 =for hackers
1081 Found in file intrpvar.h
1082
1083 =item PL_sv_yes
1084 X<PL_sv_yes>
1085
1086 This is the C<true> SV.  See C<PL_sv_no>.  Always refer to this as
1087 C<&PL_sv_yes>.
1088
1089         SV      PL_sv_yes
1090
1091 =for hackers
1092 Found in file intrpvar.h
1093
1094
1095 =back
1096
1097 =head1 GV Functions
1098
1099 =over 8
1100
1101 =item GvSV
1102 X<GvSV>
1103
1104 Return the SV from the GV.
1105
1106         SV*     GvSV(GV* gv)
1107
1108 =for hackers
1109 Found in file gv.h
1110
1111 =item gv_fetchmeth
1112 X<gv_fetchmeth>
1113
1114 Returns the glob with the given C<name> and a defined subroutine or
1115 C<NULL>.  The glob lives in the given C<stash>, or in the stashes
1116 accessible via @ISA and UNIVERSAL::.
1117
1118 The argument C<level> should be either 0 or -1.  If C<level==0>, as a
1119 side-effect creates a glob with the given C<name> in the given C<stash>
1120 which in the case of success contains an alias for the subroutine, and sets
1121 up caching info for this glob.  Similarly for all the searched stashes.
1122
1123 This function grants C<"SUPER"> token as a postfix of the stash name. The
1124 GV returned from C<gv_fetchmeth> may be a method cache entry, which is not
1125 visible to Perl code.  So when calling C<call_sv>, you should not use
1126 the GV directly; instead, you should use the method's CV, which can be
1127 obtained from the GV with the C<GvCV> macro.
1128
1129         GV*     gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)
1130
1131 =for hackers
1132 Found in file gv.c
1133
1134 =item gv_fetchmethod_autoload
1135 X<gv_fetchmethod_autoload>
1136
1137 Returns the glob which contains the subroutine to call to invoke the method
1138 on the C<stash>.  In fact in the presence of autoloading this may be the
1139 glob for "AUTOLOAD".  In this case the corresponding variable $AUTOLOAD is
1140 already setup.
1141
1142 The third parameter of C<gv_fetchmethod_autoload> determines whether
1143 AUTOLOAD lookup is performed if the given method is not present: non-zero
1144 means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD.
1145 Calling C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload>
1146 with a non-zero C<autoload> parameter.
1147
1148 These functions grant C<"SUPER"> token as a prefix of the method name. Note
1149 that if you want to keep the returned glob for a long time, you need to
1150 check for it being "AUTOLOAD", since at the later time the call may load a
1151 different subroutine due to $AUTOLOAD changing its value. Use the glob
1152 created via a side effect to do this.
1153
1154 These functions have the same side-effects and as C<gv_fetchmeth> with
1155 C<level==0>.  C<name> should be writable if contains C<':'> or C<'
1156 ''>. The warning against passing the GV returned by C<gv_fetchmeth> to
1157 C<call_sv> apply equally to these functions.
1158
1159         GV*     gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)
1160
1161 =for hackers
1162 Found in file gv.c
1163
1164 =item gv_fetchmeth_autoload
1165 X<gv_fetchmeth_autoload>
1166
1167 Same as gv_fetchmeth(), but looks for autoloaded subroutines too.
1168 Returns a glob for the subroutine.
1169
1170 For an autoloaded subroutine without a GV, will create a GV even
1171 if C<level < 0>.  For an autoloaded subroutine without a stub, GvCV()
1172 of the result may be zero.
1173
1174         GV*     gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)
1175
1176 =for hackers
1177 Found in file gv.c
1178
1179 =item gv_stashpv
1180 X<gv_stashpv>
1181
1182 Returns a pointer to the stash for a specified package.  C<name> should
1183 be a valid UTF-8 string and must be null-terminated.  If C<create> is set
1184 then the package will be created if it does not already exist.  If C<create>
1185 is not set and the package does not exist then NULL is returned.
1186
1187         HV*     gv_stashpv(const char* name, I32 create)
1188
1189 =for hackers
1190 Found in file gv.c
1191
1192 =item gv_stashpvn
1193 X<gv_stashpvn>
1194
1195 Returns a pointer to the stash for a specified package.  C<name> should
1196 be a valid UTF-8 string.  The C<namelen> parameter indicates the length of
1197 the C<name>, in bytes.  If C<create> is set then the package will be
1198 created if it does not already exist.  If C<create> is not set and the
1199 package does not exist then NULL is returned.
1200
1201         HV*     gv_stashpvn(const char* name, U32 namelen, I32 create)
1202
1203 =for hackers
1204 Found in file gv.c
1205
1206 =item gv_stashsv
1207 X<gv_stashsv>
1208
1209 Returns a pointer to the stash for a specified package, which must be a
1210 valid UTF-8 string.  See C<gv_stashpv>.
1211
1212         HV*     gv_stashsv(SV* sv, I32 create)
1213
1214 =for hackers
1215 Found in file gv.c
1216
1217
1218 =back
1219
1220 =head1 Handy Values
1221
1222 =over 8
1223
1224 =item Nullav
1225 X<Nullav>
1226
1227 Null AV pointer.
1228
1229 =for hackers
1230 Found in file av.h
1231
1232 =item Nullch
1233 X<Nullch>
1234
1235 Null character pointer.
1236
1237 =for hackers
1238 Found in file handy.h
1239
1240 =item Nullcv
1241 X<Nullcv>
1242
1243 Null CV pointer.
1244
1245 =for hackers
1246 Found in file cv.h
1247
1248 =item Nullhv
1249 X<Nullhv>
1250
1251 Null HV pointer.
1252
1253 =for hackers
1254 Found in file hv.h
1255
1256 =item Nullsv
1257 X<Nullsv>
1258
1259 Null SV pointer.
1260
1261 =for hackers
1262 Found in file handy.h
1263
1264
1265 =back
1266
1267 =head1 Hash Manipulation Functions
1268
1269 =over 8
1270
1271 =item get_hv
1272 X<get_hv>
1273
1274 Returns the HV of the specified Perl hash.  If C<create> is set and the
1275 Perl variable does not exist then it will be created.  If C<create> is not
1276 set and the variable does not exist then NULL is returned.
1277
1278 NOTE: the perl_ form of this function is deprecated.
1279
1280         HV*     get_hv(const char* name, I32 create)
1281
1282 =for hackers
1283 Found in file perl.c
1284
1285 =item HEf_SVKEY
1286 X<HEf_SVKEY>
1287
1288 This flag, used in the length slot of hash entries and magic structures,
1289 specifies the structure contains an C<SV*> pointer where a C<char*> pointer
1290 is to be expected. (For information only--not to be used).
1291
1292 =for hackers
1293 Found in file hv.h
1294
1295 =item HeHASH
1296 X<HeHASH>
1297
1298 Returns the computed hash stored in the hash entry.
1299
1300         U32     HeHASH(HE* he)
1301
1302 =for hackers
1303 Found in file hv.h
1304
1305 =item HeKEY
1306 X<HeKEY>
1307
1308 Returns the actual pointer stored in the key slot of the hash entry. The
1309 pointer may be either C<char*> or C<SV*>, depending on the value of
1310 C<HeKLEN()>.  Can be assigned to.  The C<HePV()> or C<HeSVKEY()> macros are
1311 usually preferable for finding the value of a key.
1312
1313         void*   HeKEY(HE* he)
1314
1315 =for hackers
1316 Found in file hv.h
1317
1318 =item HeKLEN
1319 X<HeKLEN>
1320
1321 If this is negative, and amounts to C<HEf_SVKEY>, it indicates the entry
1322 holds an C<SV*> key.  Otherwise, holds the actual length of the key.  Can
1323 be assigned to. The C<HePV()> macro is usually preferable for finding key
1324 lengths.
1325
1326         STRLEN  HeKLEN(HE* he)
1327
1328 =for hackers
1329 Found in file hv.h
1330
1331 =item HePV
1332 X<HePV>
1333
1334 Returns the key slot of the hash entry as a C<char*> value, doing any
1335 necessary dereferencing of possibly C<SV*> keys.  The length of the string
1336 is placed in C<len> (this is a macro, so do I<not> use C<&len>).  If you do
1337 not care about what the length of the key is, you may use the global
1338 variable C<PL_na>, though this is rather less efficient than using a local
1339 variable.  Remember though, that hash keys in perl are free to contain
1340 embedded nulls, so using C<strlen()> or similar is not a good way to find
1341 the length of hash keys. This is very similar to the C<SvPV()> macro
1342 described elsewhere in this document.
1343
1344         char*   HePV(HE* he, STRLEN len)
1345
1346 =for hackers
1347 Found in file hv.h
1348
1349 =item HeSVKEY
1350 X<HeSVKEY>
1351
1352 Returns the key as an C<SV*>, or C<Nullsv> if the hash entry does not
1353 contain an C<SV*> key.
1354
1355         SV*     HeSVKEY(HE* he)
1356
1357 =for hackers
1358 Found in file hv.h
1359
1360 =item HeSVKEY_force
1361 X<HeSVKEY_force>
1362
1363 Returns the key as an C<SV*>.  Will create and return a temporary mortal
1364 C<SV*> if the hash entry contains only a C<char*> key.
1365
1366         SV*     HeSVKEY_force(HE* he)
1367
1368 =for hackers
1369 Found in file hv.h
1370
1371 =item HeSVKEY_set
1372 X<HeSVKEY_set>
1373
1374 Sets the key to a given C<SV*>, taking care to set the appropriate flags to
1375 indicate the presence of an C<SV*> key, and returns the same
1376 C<SV*>.
1377
1378         SV*     HeSVKEY_set(HE* he, SV* sv)
1379
1380 =for hackers
1381 Found in file hv.h
1382
1383 =item HeVAL
1384 X<HeVAL>
1385
1386 Returns the value slot (type C<SV*>) stored in the hash entry.
1387
1388         SV*     HeVAL(HE* he)
1389
1390 =for hackers
1391 Found in file hv.h
1392
1393 =item HvNAME
1394 X<HvNAME>
1395
1396 Returns the package name of a stash, or NULL if C<stash> isn't a stash.
1397 See C<SvSTASH>, C<CvSTASH>.
1398
1399         char*   HvNAME(HV* stash)
1400
1401 =for hackers
1402 Found in file hv.h
1403
1404 =item hv_assert
1405 X<hv_assert>
1406
1407 Check that a hash is in an internally consistent state.
1408
1409         void    hv_assert(HV* tb)
1410
1411 =for hackers
1412 Found in file hv.c
1413
1414 =item hv_clear
1415 X<hv_clear>
1416
1417 Clears a hash, making it empty.
1418
1419         void    hv_clear(HV* tb)
1420
1421 =for hackers
1422 Found in file hv.c
1423
1424 =item hv_clear_placeholders
1425 X<hv_clear_placeholders>
1426
1427 Clears any placeholders from a hash.  If a restricted hash has any of its keys
1428 marked as readonly and the key is subsequently deleted, the key is not actually
1429 deleted but is marked by assigning it a value of &PL_sv_placeholder.  This tags
1430 it so it will be ignored by future operations such as iterating over the hash,
1431 but will still allow the hash to have a value reassigned to the key at some
1432 future point.  This function clears any such placeholder keys from the hash.
1433 See Hash::Util::lock_keys() for an example of its use.
1434
1435         void    hv_clear_placeholders(HV* hb)
1436
1437 =for hackers
1438 Found in file hv.c
1439
1440 =item hv_delete
1441 X<hv_delete>
1442
1443 Deletes a key/value pair in the hash.  The value SV is removed from the
1444 hash and returned to the caller.  The C<klen> is the length of the key.
1445 The C<flags> value will normally be zero; if set to G_DISCARD then NULL
1446 will be returned.
1447
1448         SV*     hv_delete(HV* tb, const char* key, I32 klen, I32 flags)
1449
1450 =for hackers
1451 Found in file hv.c
1452
1453 =item hv_delete_ent
1454 X<hv_delete_ent>
1455
1456 Deletes a key/value pair in the hash.  The value SV is removed from the
1457 hash and returned to the caller.  The C<flags> value will normally be zero;
1458 if set to G_DISCARD then NULL will be returned.  C<hash> can be a valid
1459 precomputed hash value, or 0 to ask for it to be computed.
1460
1461         SV*     hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)
1462
1463 =for hackers
1464 Found in file hv.c
1465
1466 =item hv_exists
1467 X<hv_exists>
1468
1469 Returns a boolean indicating whether the specified hash key exists.  The
1470 C<klen> is the length of the key.
1471
1472         bool    hv_exists(HV* tb, const char* key, I32 klen)
1473
1474 =for hackers
1475 Found in file hv.c
1476
1477 =item hv_exists_ent
1478 X<hv_exists_ent>
1479
1480 Returns a boolean indicating whether the specified hash key exists. C<hash>
1481 can be a valid precomputed hash value, or 0 to ask for it to be
1482 computed.
1483
1484         bool    hv_exists_ent(HV* tb, SV* key, U32 hash)
1485
1486 =for hackers
1487 Found in file hv.c
1488
1489 =item hv_fetch
1490 X<hv_fetch>
1491
1492 Returns the SV which corresponds to the specified key in the hash.  The
1493 C<klen> is the length of the key.  If C<lval> is set then the fetch will be
1494 part of a store.  Check that the return value is non-null before
1495 dereferencing it to an C<SV*>.
1496
1497 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
1498 information on how to use this function on tied hashes.
1499
1500         SV**    hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)
1501
1502 =for hackers
1503 Found in file hv.c
1504
1505 =item hv_fetch_ent
1506 X<hv_fetch_ent>
1507
1508 Returns the hash entry which corresponds to the specified key in the hash.
1509 C<hash> must be a valid precomputed hash number for the given C<key>, or 0
1510 if you want the function to compute it.  IF C<lval> is set then the fetch
1511 will be part of a store.  Make sure the return value is non-null before
1512 accessing it.  The return value when C<tb> is a tied hash is a pointer to a
1513 static location, so be sure to make a copy of the structure if you need to
1514 store it somewhere.
1515
1516 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
1517 information on how to use this function on tied hashes.
1518
1519         HE*     hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)
1520
1521 =for hackers
1522 Found in file hv.c
1523
1524 =item hv_iterinit
1525 X<hv_iterinit>
1526
1527 Prepares a starting point to traverse a hash table.  Returns the number of
1528 keys in the hash (i.e. the same as C<HvKEYS(tb)>).  The return value is
1529 currently only meaningful for hashes without tie magic.
1530
1531 NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of
1532 hash buckets that happen to be in use.  If you still need that esoteric
1533 value, you can get it through the macro C<HvFILL(tb)>.
1534
1535
1536         I32     hv_iterinit(HV* tb)
1537
1538 =for hackers
1539 Found in file hv.c
1540
1541 =item hv_iterkey
1542 X<hv_iterkey>
1543
1544 Returns the key from the current position of the hash iterator.  See
1545 C<hv_iterinit>.
1546
1547         char*   hv_iterkey(HE* entry, I32* retlen)
1548
1549 =for hackers
1550 Found in file hv.c
1551
1552 =item hv_iterkeysv
1553 X<hv_iterkeysv>
1554
1555 Returns the key as an C<SV*> from the current position of the hash
1556 iterator.  The return value will always be a mortal copy of the key.  Also
1557 see C<hv_iterinit>.
1558
1559         SV*     hv_iterkeysv(HE* entry)
1560
1561 =for hackers
1562 Found in file hv.c
1563
1564 =item hv_iternext
1565 X<hv_iternext>
1566
1567 Returns entries from a hash iterator.  See C<hv_iterinit>.
1568
1569 You may call C<hv_delete> or C<hv_delete_ent> on the hash entry that the
1570 iterator currently points to, without losing your place or invalidating your
1571 iterator.  Note that in this case the current entry is deleted from the hash
1572 with your iterator holding the last reference to it.  Your iterator is flagged
1573 to free the entry on the next call to C<hv_iternext>, so you must not discard
1574 your iterator immediately else the entry will leak - call C<hv_iternext> to
1575 trigger the resource deallocation.
1576
1577         HE*     hv_iternext(HV* tb)
1578
1579 =for hackers
1580 Found in file hv.c
1581
1582 =item hv_iternextsv
1583 X<hv_iternextsv>
1584
1585 Performs an C<hv_iternext>, C<hv_iterkey>, and C<hv_iterval> in one
1586 operation.
1587
1588         SV*     hv_iternextsv(HV* hv, char** key, I32* retlen)
1589
1590 =for hackers
1591 Found in file hv.c
1592
1593 =item hv_iternext_flags
1594 X<hv_iternext_flags>
1595
1596 Returns entries from a hash iterator.  See C<hv_iterinit> and C<hv_iternext>.
1597 The C<flags> value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is
1598 set the placeholders keys (for restricted hashes) will be returned in addition
1599 to normal keys. By default placeholders are automatically skipped over.
1600 Currently a placeholder is implemented with a value that is
1601 C<&Perl_sv_placeholder>. Note that the implementation of placeholders and
1602 restricted hashes may change, and the implementation currently is
1603 insufficiently abstracted for any change to be tidy.
1604
1605 NOTE: this function is experimental and may change or be
1606 removed without notice.
1607
1608         HE*     hv_iternext_flags(HV* tb, I32 flags)
1609
1610 =for hackers
1611 Found in file hv.c
1612
1613 =item hv_iterval
1614 X<hv_iterval>
1615
1616 Returns the value from the current position of the hash iterator.  See
1617 C<hv_iterkey>.
1618
1619         SV*     hv_iterval(HV* tb, HE* entry)
1620
1621 =for hackers
1622 Found in file hv.c
1623
1624 =item hv_magic
1625 X<hv_magic>
1626
1627 Adds magic to a hash.  See C<sv_magic>.
1628
1629         void    hv_magic(HV* hv, GV* gv, int how)
1630
1631 =for hackers
1632 Found in file hv.c
1633
1634 =item hv_scalar
1635 X<hv_scalar>
1636
1637 Evaluates the hash in scalar context and returns the result. Handles magic when the hash is tied.
1638
1639         SV*     hv_scalar(HV* hv)
1640
1641 =for hackers
1642 Found in file hv.c
1643
1644 =item hv_store
1645 X<hv_store>
1646
1647 Stores an SV in a hash.  The hash key is specified as C<key> and C<klen> is
1648 the length of the key.  The C<hash> parameter is the precomputed hash
1649 value; if it is zero then Perl will compute it.  The return value will be
1650 NULL if the operation failed or if the value did not need to be actually
1651 stored within the hash (as in the case of tied hashes).  Otherwise it can
1652 be dereferenced to get the original C<SV*>.  Note that the caller is
1653 responsible for suitably incrementing the reference count of C<val> before
1654 the call, and decrementing it if the function returned NULL.  Effectively
1655 a successful hv_store takes ownership of one reference to C<val>.  This is
1656 usually what you want; a newly created SV has a reference count of one, so
1657 if all your code does is create SVs then store them in a hash, hv_store
1658 will own the only reference to the new SV, and your code doesn't need to do
1659 anything further to tidy up.  hv_store is not implemented as a call to
1660 hv_store_ent, and does not create a temporary SV for the key, so if your
1661 key data is not already in SV form then use hv_store in preference to
1662 hv_store_ent.
1663
1664 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
1665 information on how to use this function on tied hashes.
1666
1667         SV**    hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash)
1668
1669 =for hackers
1670 Found in file hv.c
1671
1672 =item hv_store_ent
1673 X<hv_store_ent>
1674
1675 Stores C<val> in a hash.  The hash key is specified as C<key>.  The C<hash>
1676 parameter is the precomputed hash value; if it is zero then Perl will
1677 compute it.  The return value is the new hash entry so created.  It will be
1678 NULL if the operation failed or if the value did not need to be actually
1679 stored within the hash (as in the case of tied hashes).  Otherwise the
1680 contents of the return value can be accessed using the C<He?> macros
1681 described here.  Note that the caller is responsible for suitably
1682 incrementing the reference count of C<val> before the call, and
1683 decrementing it if the function returned NULL.  Effectively a successful
1684 hv_store_ent takes ownership of one reference to C<val>.  This is
1685 usually what you want; a newly created SV has a reference count of one, so
1686 if all your code does is create SVs then store them in a hash, hv_store
1687 will own the only reference to the new SV, and your code doesn't need to do
1688 anything further to tidy up.  Note that hv_store_ent only reads the C<key>;
1689 unlike C<val> it does not take ownership of it, so maintaining the correct
1690 reference count on C<key> is entirely the caller's responsibility.  hv_store
1691 is not implemented as a call to hv_store_ent, and does not create a temporary
1692 SV for the key, so if your key data is not already in SV form then use
1693 hv_store in preference to hv_store_ent.
1694
1695 See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
1696 information on how to use this function on tied hashes.
1697
1698         HE*     hv_store_ent(HV* tb, SV* key, SV* val, U32 hash)
1699
1700 =for hackers
1701 Found in file hv.c
1702
1703 =item hv_undef
1704 X<hv_undef>
1705
1706 Undefines the hash.
1707
1708         void    hv_undef(HV* tb)
1709
1710 =for hackers
1711 Found in file hv.c
1712
1713 =item newHV
1714 X<newHV>
1715
1716 Creates a new HV.  The reference count is set to 1.
1717
1718         HV*     newHV()
1719
1720 =for hackers
1721 Found in file hv.c
1722
1723
1724 =back
1725
1726 =head1 Magical Functions
1727
1728 =over 8
1729
1730 =item mg_clear
1731 X<mg_clear>
1732
1733 Clear something magical that the SV represents.  See C<sv_magic>.
1734
1735         int     mg_clear(SV* sv)
1736
1737 =for hackers
1738 Found in file mg.c
1739
1740 =item mg_copy
1741 X<mg_copy>
1742
1743 Copies the magic from one SV to another.  See C<sv_magic>.
1744
1745         int     mg_copy(SV* sv, SV* nsv, const char* key, I32 klen)
1746
1747 =for hackers
1748 Found in file mg.c
1749
1750 =item mg_find
1751 X<mg_find>
1752
1753 Finds the magic pointer for type matching the SV.  See C<sv_magic>.
1754
1755         MAGIC*  mg_find(const SV* sv, int type)
1756
1757 =for hackers
1758 Found in file mg.c
1759
1760 =item mg_free
1761 X<mg_free>
1762
1763 Free any magic storage used by the SV.  See C<sv_magic>.
1764
1765         int     mg_free(SV* sv)
1766
1767 =for hackers
1768 Found in file mg.c
1769
1770 =item mg_get
1771 X<mg_get>
1772
1773 Do magic after a value is retrieved from the SV.  See C<sv_magic>.
1774
1775         int     mg_get(SV* sv)
1776
1777 =for hackers
1778 Found in file mg.c
1779
1780 =item mg_length
1781 X<mg_length>
1782
1783 Report on the SV's length.  See C<sv_magic>.
1784
1785         U32     mg_length(SV* sv)
1786
1787 =for hackers
1788 Found in file mg.c
1789
1790 =item mg_magical
1791 X<mg_magical>
1792
1793 Turns on the magical status of an SV.  See C<sv_magic>.
1794
1795         void    mg_magical(SV* sv)
1796
1797 =for hackers
1798 Found in file mg.c
1799
1800 =item mg_set
1801 X<mg_set>
1802
1803 Do magic after a value is assigned to the SV.  See C<sv_magic>.
1804
1805         int     mg_set(SV* sv)
1806
1807 =for hackers
1808 Found in file mg.c
1809
1810 =item SvGETMAGIC
1811 X<SvGETMAGIC>
1812
1813 Invokes C<mg_get> on an SV if it has 'get' magic.  This macro evaluates its
1814 argument more than once.
1815
1816         void    SvGETMAGIC(SV* sv)
1817
1818 =for hackers
1819 Found in file sv.h
1820
1821 =item SvLOCK
1822 X<SvLOCK>
1823
1824 Arranges for a mutual exclusion lock to be obtained on sv if a suitable module
1825 has been loaded.
1826
1827         void    SvLOCK(SV* sv)
1828
1829 =for hackers
1830 Found in file sv.h
1831
1832 =item SvSETMAGIC
1833 X<SvSETMAGIC>
1834
1835 Invokes C<mg_set> on an SV if it has 'set' magic.  This macro evaluates its
1836 argument more than once.
1837
1838         void    SvSETMAGIC(SV* sv)
1839
1840 =for hackers
1841 Found in file sv.h
1842
1843 =item SvSetMagicSV
1844 X<SvSetMagicSV>
1845
1846 Like C<SvSetSV>, but does any set magic required afterwards.
1847
1848         void    SvSetMagicSV(SV* dsb, SV* ssv)
1849
1850 =for hackers
1851 Found in file sv.h
1852
1853 =item SvSetMagicSV_nosteal
1854 X<SvSetMagicSV_nosteal>
1855
1856 Like C<SvSetSV_nosteal>, but does any set magic required afterwards.
1857
1858         void    SvSetMagicSV_nosteal(SV* dsv, SV* ssv)
1859
1860 =for hackers
1861 Found in file sv.h
1862
1863 =item SvSetSV
1864 X<SvSetSV>
1865
1866 Calls C<sv_setsv> if dsv is not the same as ssv.  May evaluate arguments
1867 more than once.
1868
1869         void    SvSetSV(SV* dsb, SV* ssv)
1870
1871 =for hackers
1872 Found in file sv.h
1873
1874 =item SvSetSV_nosteal
1875 X<SvSetSV_nosteal>
1876
1877 Calls a non-destructive version of C<sv_setsv> if dsv is not the same as
1878 ssv. May evaluate arguments more than once.
1879
1880         void    SvSetSV_nosteal(SV* dsv, SV* ssv)
1881
1882 =for hackers
1883 Found in file sv.h
1884
1885 =item SvSHARE
1886 X<SvSHARE>
1887
1888 Arranges for sv to be shared between threads if a suitable module
1889 has been loaded.
1890
1891         void    SvSHARE(SV* sv)
1892
1893 =for hackers
1894 Found in file sv.h
1895
1896 =item SvUNLOCK
1897 X<SvUNLOCK>
1898
1899 Releases a mutual exclusion lock on sv if a suitable module
1900 has been loaded.
1901
1902         void    SvUNLOCK(SV* sv)
1903
1904 =for hackers
1905 Found in file sv.h
1906
1907
1908 =back
1909
1910 =head1 Memory Management
1911
1912 =over 8
1913
1914 =item Copy
1915 X<Copy>
1916
1917 The XSUB-writer's interface to the C C<memcpy> function.  The C<src> is the
1918 source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
1919 the type.  May fail on overlapping copies.  See also C<Move>.
1920
1921         void    Copy(void* src, void* dest, int nitems, type)
1922
1923 =for hackers
1924 Found in file handy.h
1925
1926 =item CopyD
1927 X<CopyD>
1928
1929 Like C<Copy> but returns dest. Useful for encouraging compilers to tail-call
1930 optimise.
1931
1932         void *  CopyD(void* src, void* dest, int nitems, type)
1933
1934 =for hackers
1935 Found in file handy.h
1936
1937 =item Move
1938 X<Move>
1939
1940 The XSUB-writer's interface to the C C<memmove> function.  The C<src> is the
1941 source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
1942 the type.  Can do overlapping moves.  See also C<Copy>.
1943
1944         void    Move(void* src, void* dest, int nitems, type)
1945
1946 =for hackers
1947 Found in file handy.h
1948
1949 =item MoveD
1950 X<MoveD>
1951
1952 Like C<Move> but returns dest. Useful for encouraging compilers to tail-call
1953 optimise.
1954
1955         void *  MoveD(void* src, void* dest, int nitems, type)
1956
1957 =for hackers
1958 Found in file handy.h
1959
1960 =item Newx
1961 X<Newx>
1962
1963 The XSUB-writer's interface to the C C<malloc> function.
1964
1965 In 5.9.3, Newx() and friends replace the older New() API, and drops
1966 the first parameter, I<x>, a debug aid which allowed callers to identify
1967 themselves.  This aid has been superceded by a new build option,
1968 PERL_MEM_LOG (see L<perlhack/PERL_MEM_LOG>).  The older API is still
1969 there for use in XS modules supporting older perls.
1970
1971         void    Newx(void* ptr, int nitems, type)
1972
1973 =for hackers
1974 Found in file handy.h
1975
1976 =item Newxc
1977 X<Newxc>
1978
1979 The XSUB-writer's interface to the C C<malloc> function, with
1980 cast.  See also C<Newx>.
1981
1982         void    Newxc(void* ptr, int nitems, type, cast)
1983
1984 =for hackers
1985 Found in file handy.h
1986
1987 =item Newxz
1988 X<Newxz>
1989
1990 The XSUB-writer's interface to the C C<malloc> function.  The allocated
1991 memory is zeroed with C<memzero>.  See also C<Newx>.
1992
1993         void    Newxz(void* ptr, int nitems, type)
1994
1995 =for hackers
1996 Found in file handy.h
1997
1998 =item Poison
1999 X<Poison>
2000
2001 Fill up memory with a pattern (byte 0xAB over and over again) that
2002 hopefully catches attempts to access uninitialized memory.
2003
2004         void    Poison(void* dest, int nitems, type)
2005
2006 =for hackers
2007 Found in file handy.h
2008
2009 =item Renew
2010 X<Renew>
2011
2012 The XSUB-writer's interface to the C C<realloc> function.
2013
2014         void    Renew(void* ptr, int nitems, type)
2015
2016 =for hackers
2017 Found in file handy.h
2018
2019 =item Renewc
2020 X<Renewc>
2021
2022 The XSUB-writer's interface to the C C<realloc> function, with
2023 cast.
2024
2025         void    Renewc(void* ptr, int nitems, type, cast)
2026
2027 =for hackers
2028 Found in file handy.h
2029
2030 =item Safefree
2031 X<Safefree>
2032
2033 The XSUB-writer's interface to the C C<free> function.
2034
2035         void    Safefree(void* ptr)
2036
2037 =for hackers
2038 Found in file handy.h
2039
2040 =item savepv
2041 X<savepv>
2042
2043 Perl's version of C<strdup()>. Returns a pointer to a newly allocated
2044 string which is a duplicate of C<pv>. The size of the string is
2045 determined by C<strlen()>. The memory allocated for the new string can
2046 be freed with the C<Safefree()> function.
2047
2048         char*   savepv(const char* pv)
2049
2050 =for hackers
2051 Found in file util.c
2052
2053 =item savepvn
2054 X<savepvn>
2055
2056 Perl's version of what C<strndup()> would be if it existed. Returns a
2057 pointer to a newly allocated string which is a duplicate of the first
2058 C<len> bytes from C<pv>. The memory allocated for the new string can be
2059 freed with the C<Safefree()> function.
2060
2061         char*   savepvn(const char* pv, I32 len)
2062
2063 =for hackers
2064 Found in file util.c
2065
2066 =item savesharedpv
2067 X<savesharedpv>
2068
2069 A version of C<savepv()> which allocates the duplicate string in memory
2070 which is shared between threads.
2071
2072         char*   savesharedpv(const char* pv)
2073
2074 =for hackers
2075 Found in file util.c
2076
2077 =item savesvpv
2078 X<savesvpv>
2079
2080 A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from
2081 the passed in SV using C<SvPV()>
2082
2083         char*   savesvpv(SV* sv)
2084
2085 =for hackers
2086 Found in file util.c
2087
2088 =item StructCopy
2089 X<StructCopy>
2090
2091 This is an architecture-independent macro to copy one structure to another.
2092
2093         void    StructCopy(type src, type dest, type)
2094
2095 =for hackers
2096 Found in file handy.h
2097
2098 =item Zero
2099 X<Zero>
2100
2101 The XSUB-writer's interface to the C C<memzero> function.  The C<dest> is the
2102 destination, C<nitems> is the number of items, and C<type> is the type.
2103
2104         void    Zero(void* dest, int nitems, type)
2105
2106 =for hackers
2107 Found in file handy.h
2108
2109 =item ZeroD
2110 X<ZeroD>
2111
2112 Like C<Zero> but returns dest. Useful for encouraging compilers to tail-call
2113 optimise.
2114
2115         void *  ZeroD(void* dest, int nitems, type)
2116
2117 =for hackers
2118 Found in file handy.h
2119
2120
2121 =back
2122
2123 =head1 Miscellaneous Functions
2124
2125 =over 8
2126
2127 =item fbm_compile
2128 X<fbm_compile>
2129
2130 Analyses the string in order to make fast searches on it using fbm_instr()
2131 -- the Boyer-Moore algorithm.
2132
2133         void    fbm_compile(SV* sv, U32 flags)
2134
2135 =for hackers
2136 Found in file util.c
2137
2138 =item fbm_instr
2139 X<fbm_instr>
2140
2141 Returns the location of the SV in the string delimited by C<str> and
2142 C<strend>.  It returns C<Nullch> if the string can't be found.  The C<sv>
2143 does not have to be fbm_compiled, but the search will not be as fast
2144 then.
2145
2146         char*   fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)
2147
2148 =for hackers
2149 Found in file util.c
2150
2151 =item form
2152 X<form>
2153
2154 Takes a sprintf-style format pattern and conventional
2155 (non-SV) arguments and returns the formatted string.
2156
2157     (char *) Perl_form(pTHX_ const char* pat, ...)
2158
2159 can be used any place a string (char *) is required:
2160
2161     char * s = Perl_form("%d.%d",major,minor);
2162
2163 Uses a single private buffer so if you want to format several strings you
2164 must explicitly copy the earlier strings away (and free the copies when you
2165 are done).
2166
2167         char*   form(const char* pat, ...)
2168
2169 =for hackers
2170 Found in file util.c
2171
2172 =item getcwd_sv
2173 X<getcwd_sv>
2174
2175 Fill the sv with current working directory
2176
2177         int     getcwd_sv(SV* sv)
2178
2179 =for hackers
2180 Found in file util.c
2181
2182 =item my_sprintf
2183 X<my_sprintf>
2184
2185 The C library C<sprintf>, wrapped if necessary, to ensure that it will return
2186 the length of the string written to the buffer. Only rare pre-ANSI systems
2187 need the wrapper function - usually this is a direct call to C<sprintf>.
2188
2189         int     my_sprintf(char *buffer, const char *pat, ...)
2190
2191 =for hackers
2192 Found in file util.c
2193
2194 =item new_version
2195 X<new_version>
2196
2197 Returns a new version object based on the passed in SV:
2198
2199     SV *sv = new_version(SV *ver);
2200
2201 Does not alter the passed in ver SV.  See "upg_version" if you
2202 want to upgrade the SV.
2203
2204         SV*     new_version(SV *ver)
2205
2206 =for hackers
2207 Found in file util.c
2208
2209 =item scan_version
2210 X<scan_version>
2211
2212 Returns a pointer to the next character after the parsed
2213 version string, as well as upgrading the passed in SV to
2214 an RV.
2215
2216 Function must be called with an already existing SV like
2217
2218     sv = newSV(0);
2219     s = scan_version(s,SV *sv, bool qv);
2220
2221 Performs some preprocessing to the string to ensure that
2222 it has the correct characteristics of a version.  Flags the
2223 object if it contains an underscore (which denotes this
2224 is a alpha version).  The boolean qv denotes that the version
2225 should be interpreted as if it had multiple decimals, even if
2226 it doesn't.
2227
2228         const char*     scan_version(const char *vstr, SV *sv, bool qv)
2229
2230 =for hackers
2231 Found in file util.c
2232
2233 =item strEQ
2234 X<strEQ>
2235
2236 Test two strings to see if they are equal.  Returns true or false.
2237
2238         bool    strEQ(char* s1, char* s2)
2239
2240 =for hackers
2241 Found in file handy.h
2242
2243 =item strGE
2244 X<strGE>
2245
2246 Test two strings to see if the first, C<s1>, is greater than or equal to
2247 the second, C<s2>.  Returns true or false.
2248
2249         bool    strGE(char* s1, char* s2)
2250
2251 =for hackers
2252 Found in file handy.h
2253
2254 =item strGT
2255 X<strGT>
2256
2257 Test two strings to see if the first, C<s1>, is greater than the second,
2258 C<s2>.  Returns true or false.
2259
2260         bool    strGT(char* s1, char* s2)
2261
2262 =for hackers
2263 Found in file handy.h
2264
2265 =item strLE
2266 X<strLE>
2267
2268 Test two strings to see if the first, C<s1>, is less than or equal to the
2269 second, C<s2>.  Returns true or false.
2270
2271         bool    strLE(char* s1, char* s2)
2272
2273 =for hackers
2274 Found in file handy.h
2275
2276 =item strLT
2277 X<strLT>
2278
2279 Test two strings to see if the first, C<s1>, is less than the second,
2280 C<s2>.  Returns true or false.
2281
2282         bool    strLT(char* s1, char* s2)
2283
2284 =for hackers
2285 Found in file handy.h
2286
2287 =item strNE
2288 X<strNE>
2289
2290 Test two strings to see if they are different.  Returns true or
2291 false.
2292
2293         bool    strNE(char* s1, char* s2)
2294
2295 =for hackers
2296 Found in file handy.h
2297
2298 =item strnEQ
2299 X<strnEQ>
2300
2301 Test two strings to see if they are equal.  The C<len> parameter indicates
2302 the number of bytes to compare.  Returns true or false. (A wrapper for
2303 C<strncmp>).
2304
2305         bool    strnEQ(char* s1, char* s2, STRLEN len)
2306
2307 =for hackers
2308 Found in file handy.h
2309
2310 =item strnNE
2311 X<strnNE>
2312
2313 Test two strings to see if they are different.  The C<len> parameter
2314 indicates the number of bytes to compare.  Returns true or false. (A
2315 wrapper for C<strncmp>).
2316
2317         bool    strnNE(char* s1, char* s2, STRLEN len)
2318
2319 =for hackers
2320 Found in file handy.h
2321
2322 =item sv_nosharing
2323 X<sv_nosharing>
2324
2325 Dummy routine which "shares" an SV when there is no sharing module present.
2326 Or "locks" it. Or "unlocks" it. In other words, ignores its single SV argument.
2327 Exists to avoid test for a NULL function pointer and because it could
2328 potentially warn under some level of strict-ness.
2329
2330         void    sv_nosharing(SV *)
2331
2332 =for hackers
2333 Found in file util.c
2334
2335 =item upg_version
2336 X<upg_version>
2337
2338 In-place upgrade of the supplied SV to a version object.
2339
2340     SV *sv = upg_version(SV *sv);
2341
2342 Returns a pointer to the upgraded SV.
2343
2344         SV*     upg_version(SV *ver)
2345
2346 =for hackers
2347 Found in file util.c
2348
2349 =item vcmp
2350 X<vcmp>
2351
2352 Version object aware cmp.  Both operands must already have been 
2353 converted into version objects.
2354
2355         int     vcmp(SV *lvs, SV *rvs)
2356
2357 =for hackers
2358 Found in file util.c
2359
2360 =item vnormal
2361 X<vnormal>
2362
2363 Accepts a version object and returns the normalized string
2364 representation.  Call like:
2365
2366     sv = vnormal(rv);
2367
2368 NOTE: you can pass either the object directly or the SV
2369 contained within the RV.
2370
2371         SV*     vnormal(SV *vs)
2372
2373 =for hackers
2374 Found in file util.c
2375
2376 =item vnumify
2377 X<vnumify>
2378
2379 Accepts a version object and returns the normalized floating
2380 point representation.  Call like:
2381
2382     sv = vnumify(rv);
2383
2384 NOTE: you can pass either the object directly or the SV
2385 contained within the RV.
2386
2387         SV*     vnumify(SV *vs)
2388
2389 =for hackers
2390 Found in file util.c
2391
2392 =item vstringify
2393 X<vstringify>
2394
2395 In order to maintain maximum compatibility with earlier versions
2396 of Perl, this function will return either the floating point
2397 notation or the multiple dotted notation, depending on whether
2398 the original version contained 1 or more dots, respectively
2399
2400         SV*     vstringify(SV *vs)
2401
2402 =for hackers
2403 Found in file util.c
2404
2405 =item vverify
2406 X<vverify>
2407
2408 Validates that the SV contains a valid version object.
2409
2410     bool vverify(SV *vobj);
2411
2412 Note that it only confirms the bare minimum structure (so as not to get
2413 confused by derived classes which may contain additional hash entries):
2414
2415         bool    vverify(SV *vs)
2416
2417 =for hackers
2418 Found in file util.c
2419
2420
2421 =back
2422
2423 =head1 Multicall Functions
2424
2425 =over 8
2426
2427 =item dMULTICALL
2428 X<dMULTICALL>
2429
2430 Declare local variables for a multicall. See L<perlcall/Lightweight Callbacks>.
2431
2432                 dMULTICALL;
2433
2434 =for hackers
2435 Found in file cop.h
2436
2437 =item MULTICALL
2438 X<MULTICALL>
2439
2440 Make a lightweight callback. See L<perlcall/Lightweight Callbacks>.
2441
2442                 MULTICALL;
2443
2444 =for hackers
2445 Found in file cop.h
2446
2447 =item POP_MULTICALL
2448 X<POP_MULTICALL>
2449
2450 Closing bracket for a lightweight callback.
2451 See L<perlcall/Lightweight Callbacks>.
2452
2453                 POP_MULTICALL;
2454
2455 =for hackers
2456 Found in file cop.h
2457
2458 =item PUSH_MULTICALL
2459 X<PUSH_MULTICALL>
2460
2461 Opening bracket for a lightweight callback.
2462 See L<perlcall/Lightweight Callbacks>.
2463
2464                 PUSH_MULTICALL;
2465
2466 =for hackers
2467 Found in file cop.h
2468
2469
2470 =back
2471
2472 =head1 Numeric functions
2473
2474 =over 8
2475
2476 =item grok_bin
2477 X<grok_bin>
2478
2479 converts a string representing a binary number to numeric form.
2480
2481 On entry I<start> and I<*len> give the string to scan, I<*flags> gives
2482 conversion flags, and I<result> should be NULL or a pointer to an NV.
2483 The scan stops at the end of the string, or the first invalid character.
2484 Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an
2485 invalid character will also trigger a warning.
2486 On return I<*len> is set to the length of the scanned string,
2487 and I<*flags> gives output flags.
2488
2489 If the value is <= C<UV_MAX> it is returned as a UV, the output flags are clear,
2490 and nothing is written to I<*result>. If the value is > UV_MAX C<grok_bin>
2491 returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags,
2492 and writes the value to I<*result> (or the value is discarded if I<result>
2493 is NULL).
2494
2495 The binary number may optionally be prefixed with "0b" or "b" unless
2496 C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If
2497 C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the binary
2498 number may use '_' characters to separate digits.
2499
2500         UV      grok_bin(const char* start, STRLEN* len_p, I32* flags, NV *result)
2501
2502 =for hackers
2503 Found in file numeric.c
2504
2505 =item grok_hex
2506 X<grok_hex>
2507
2508 converts a string representing a hex number to numeric form.
2509
2510 On entry I<start> and I<*len> give the string to scan, I<*flags> gives
2511 conversion flags, and I<result> should be NULL or a pointer to an NV.
2512 The scan stops at the end of the string, or the first invalid character.
2513 Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an
2514 invalid character will also trigger a warning.
2515 On return I<*len> is set to the length of the scanned string,
2516 and I<*flags> gives output flags.
2517
2518 If the value is <= UV_MAX it is returned as a UV, the output flags are clear,
2519 and nothing is written to I<*result>. If the value is > UV_MAX C<grok_hex>
2520 returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags,
2521 and writes the value to I<*result> (or the value is discarded if I<result>
2522 is NULL).
2523
2524 The hex number may optionally be prefixed with "0x" or "x" unless
2525 C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If
2526 C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the hex
2527 number may use '_' characters to separate digits.
2528
2529         UV      grok_hex(const char* start, STRLEN* len_p, I32* flags, NV *result)
2530
2531 =for hackers
2532 Found in file numeric.c
2533
2534 =item grok_number
2535 X<grok_number>
2536
2537 Recognise (or not) a number.  The type of the number is returned
2538 (0 if unrecognised), otherwise it is a bit-ORed combination of
2539 IS_NUMBER_IN_UV, IS_NUMBER_GREATER_THAN_UV_MAX, IS_NUMBER_NOT_INT,
2540 IS_NUMBER_NEG, IS_NUMBER_INFINITY, IS_NUMBER_NAN (defined in perl.h).
2541
2542 If the value of the number can fit an in UV, it is returned in the *valuep
2543 IS_NUMBER_IN_UV will be set to indicate that *valuep is valid, IS_NUMBER_IN_UV
2544 will never be set unless *valuep is valid, but *valuep may have been assigned
2545 to during processing even though IS_NUMBER_IN_UV is not set on return.
2546 If valuep is NULL, IS_NUMBER_IN_UV will be set for the same cases as when
2547 valuep is non-NULL, but no actual assignment (or SEGV) will occur.
2548
2549 IS_NUMBER_NOT_INT will be set with IS_NUMBER_IN_UV if trailing decimals were
2550 seen (in which case *valuep gives the true value truncated to an integer), and
2551 IS_NUMBER_NEG if the number is negative (in which case *valuep holds the
2552 absolute value).  IS_NUMBER_IN_UV is not set if e notation was used or the
2553 number is larger than a UV.
2554
2555         int     grok_number(const char *pv, STRLEN len, UV *valuep)
2556
2557 =for hackers
2558 Found in file numeric.c
2559
2560 =item grok_numeric_radix
2561 X<grok_numeric_radix>
2562
2563 Scan and skip for a numeric decimal separator (radix).
2564
2565         bool    grok_numeric_radix(const char **sp, const char *send)
2566
2567 =for hackers
2568 Found in file numeric.c
2569
2570 =item grok_oct
2571 X<grok_oct>
2572
2573 converts a string representing an octal number to numeric form.
2574
2575 On entry I<start> and I<*len> give the string to scan, I<*flags> gives
2576 conversion flags, and I<result> should be NULL or a pointer to an NV.
2577 The scan stops at the end of the string, or the first invalid character.
2578 Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an
2579 invalid character will also trigger a warning.
2580 On return I<*len> is set to the length of the scanned string,
2581 and I<*flags> gives output flags.
2582
2583 If the value is <= UV_MAX it is returned as a UV, the output flags are clear,
2584 and nothing is written to I<*result>. If the value is > UV_MAX C<grok_oct>
2585 returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags,
2586 and writes the value to I<*result> (or the value is discarded if I<result>
2587 is NULL).
2588
2589 If C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the octal
2590 number may use '_' characters to separate digits.
2591
2592         UV      grok_oct(const char* start, STRLEN* len_p, I32* flags, NV *result)
2593
2594 =for hackers
2595 Found in file numeric.c
2596
2597 =item scan_bin
2598 X<scan_bin>
2599
2600 For backwards compatibility. Use C<grok_bin> instead.
2601
2602         NV      scan_bin(const char* start, STRLEN len, STRLEN* retlen)
2603
2604 =for hackers
2605 Found in file numeric.c
2606
2607 =item scan_hex
2608 X<scan_hex>
2609
2610 For backwards compatibility. Use C<grok_hex> instead.
2611
2612         NV      scan_hex(const char* start, STRLEN len, STRLEN* retlen)
2613
2614 =for hackers
2615 Found in file numeric.c
2616
2617 =item scan_oct
2618 X<scan_oct>
2619
2620 For backwards compatibility. Use C<grok_oct> instead.
2621
2622         NV      scan_oct(const char* start, STRLEN len, STRLEN* retlen)
2623
2624 =for hackers
2625 Found in file numeric.c
2626
2627
2628 =back
2629
2630 =head1 Optree Manipulation Functions
2631
2632 =over 8
2633
2634 =item cv_const_sv
2635 X<cv_const_sv>
2636
2637 If C<cv> is a constant sub eligible for inlining. returns the constant
2638 value returned by the sub.  Otherwise, returns NULL.
2639
2640 Constant subs can be created with C<newCONSTSUB> or as described in
2641 L<perlsub/"Constant Functions">.
2642
2643         SV*     cv_const_sv(CV* cv)
2644
2645 =for hackers
2646 Found in file op.c
2647
2648 =item newCONSTSUB
2649 X<newCONSTSUB>
2650
2651 Creates a constant sub equivalent to Perl C<sub FOO () { 123 }> which is
2652 eligible for inlining at compile-time.
2653
2654         CV*     newCONSTSUB(HV* stash, const char* name, SV* sv)
2655
2656 =for hackers
2657 Found in file op.c
2658
2659 =item newXS
2660 X<newXS>
2661
2662 Used by C<xsubpp> to hook up XSUBs as Perl subs.
2663
2664 =for hackers
2665 Found in file op.c
2666
2667
2668 =back
2669
2670 =head1 Pad Data Structures
2671
2672 =over 8
2673
2674 =item pad_sv
2675 X<pad_sv>
2676
2677 Get the value at offset po in the current pad.
2678 Use macro PAD_SV instead of calling this function directly.
2679
2680         SV*     pad_sv(PADOFFSET po)
2681
2682 =for hackers
2683 Found in file pad.c
2684
2685
2686 =back
2687
2688 =head1 Simple Exception Handling Macros
2689
2690 =over 8
2691
2692 =item dXCPT
2693 X<dXCPT>
2694
2695 Set up necessary local variables for exception handling.
2696 See L<perlguts/"Exception Handling">.
2697
2698                 dXCPT;
2699
2700 =for hackers
2701 Found in file XSUB.h
2702
2703 =item XCPT_CATCH
2704 X<XCPT_CATCH>
2705
2706 Introduces a catch block.  See L<perlguts/"Exception Handling">.
2707
2708 =for hackers
2709 Found in file XSUB.h
2710
2711 =item XCPT_RETHROW
2712 X<XCPT_RETHROW>
2713
2714 Rethrows a previously caught exception.  See L<perlguts/"Exception Handling">.
2715
2716                 XCPT_RETHROW;
2717
2718 =for hackers
2719 Found in file XSUB.h
2720
2721 =item XCPT_TRY_END
2722 X<XCPT_TRY_END>
2723
2724 Ends a try block.  See L<perlguts/"Exception Handling">.
2725
2726 =for hackers
2727 Found in file XSUB.h
2728
2729 =item XCPT_TRY_START
2730 X<XCPT_TRY_START>
2731
2732 Starts a try block.  See L<perlguts/"Exception Handling">.
2733
2734 =for hackers
2735 Found in file XSUB.h
2736
2737
2738 =back
2739
2740 =head1 Stack Manipulation Macros
2741
2742 =over 8
2743
2744 =item dMARK
2745 X<dMARK>
2746
2747 Declare a stack marker variable, C<mark>, for the XSUB.  See C<MARK> and
2748 C<dORIGMARK>.
2749
2750                 dMARK;
2751
2752 =for hackers
2753 Found in file pp.h
2754
2755 =item dORIGMARK
2756 X<dORIGMARK>
2757
2758 Saves the original stack mark for the XSUB.  See C<ORIGMARK>.
2759
2760                 dORIGMARK;
2761
2762 =for hackers
2763 Found in file pp.h
2764
2765 =item dSP
2766 X<dSP>
2767
2768 Declares a local copy of perl's stack pointer for the XSUB, available via
2769 the C<SP> macro.  See C<SP>.
2770
2771                 dSP;
2772
2773 =for hackers
2774 Found in file pp.h
2775
2776 =item EXTEND
2777 X<EXTEND>
2778
2779 Used to extend the argument stack for an XSUB's return values. Once
2780 used, guarantees that there is room for at least C<nitems> to be pushed
2781 onto the stack.
2782
2783         void    EXTEND(SP, int nitems)
2784
2785 =for hackers
2786 Found in file pp.h
2787
2788 =item MARK
2789 X<MARK>
2790
2791 Stack marker variable for the XSUB.  See C<dMARK>.
2792
2793 =for hackers
2794 Found in file pp.h
2795
2796 =item mPUSHi
2797 X<mPUSHi>
2798
2799 Push an integer onto the stack.  The stack must have room for this element.
2800 Handles 'set' magic.  Does not use C<TARG>.  See also C<PUSHi>, C<mXPUSHi>
2801 and C<XPUSHi>.
2802
2803         void    mPUSHi(IV iv)
2804
2805 =for hackers
2806 Found in file pp.h
2807
2808 =item mPUSHn
2809 X<mPUSHn>
2810
2811 Push a double onto the stack.  The stack must have room for this element.
2812 Handles 'set' magic.  Does not use C<TARG>.  See also C<PUSHn>, C<mXPUSHn>
2813 and C<XPUSHn>.
2814
2815         void    mPUSHn(NV nv)
2816
2817 =for hackers
2818 Found in file pp.h
2819
2820 =item mPUSHp
2821 X<mPUSHp>
2822
2823 Push a string onto the stack.  The stack must have room for this element.
2824 The C<len> indicates the length of the string.  Handles 'set' magic.  Does
2825 not use C<TARG>.  See also C<PUSHp>, C<mXPUSHp> and C<XPUSHp>.
2826
2827         void    mPUSHp(char* str, STRLEN len)
2828
2829 =for hackers
2830 Found in file pp.h
2831
2832 =item mPUSHu
2833 X<mPUSHu>
2834
2835 Push an unsigned integer onto the stack.  The stack must have room for this
2836 element.  Handles 'set' magic.  Does not use C<TARG>.  See also C<PUSHu>,
2837 C<mXPUSHu> and C<XPUSHu>.
2838
2839         void    mPUSHu(UV uv)
2840
2841 =for hackers
2842 Found in file pp.h
2843
2844 =item mXPUSHi
2845 X<mXPUSHi>
2846
2847 Push an integer onto the stack, extending the stack if necessary.  Handles
2848 'set' magic.  Does not use C<TARG>.  See also C<XPUSHi>, C<mPUSHi> and
2849 C<PUSHi>.
2850
2851         void    mXPUSHi(IV iv)
2852
2853 =for hackers
2854 Found in file pp.h
2855
2856 =item mXPUSHn
2857 X<mXPUSHn>
2858
2859 Push a double onto the stack, extending the stack if necessary.  Handles
2860 'set' magic.  Does not use C<TARG>.  See also C<XPUSHn>, C<mPUSHn> and
2861 C<PUSHn>.
2862
2863         void    mXPUSHn(NV nv)
2864
2865 =for hackers
2866 Found in file pp.h
2867
2868 =item mXPUSHp
2869 X<mXPUSHp>
2870
2871 Push a string onto the stack, extending the stack if necessary.  The C<len>
2872 indicates the length of the string.  Handles 'set' magic.  Does not use
2873 C<TARG>.  See also C<XPUSHp>, C<mPUSHp> and C<PUSHp>.
2874
2875         void    mXPUSHp(char* str, STRLEN len)
2876
2877 =for hackers
2878 Found in file pp.h
2879
2880 =item mXPUSHu
2881 X<mXPUSHu>
2882
2883 Push an unsigned integer onto the stack, extending the stack if necessary.
2884 Handles 'set' magic.  Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu>
2885 and C<PUSHu>.
2886
2887         void    mXPUSHu(UV uv)
2888
2889 =for hackers
2890 Found in file pp.h
2891
2892 =item ORIGMARK
2893 X<ORIGMARK>
2894
2895 The original stack mark for the XSUB.  See C<dORIGMARK>.
2896
2897 =for hackers
2898 Found in file pp.h
2899
2900 =item POPi
2901 X<POPi>
2902
2903 Pops an integer off the stack.
2904
2905         IV      POPi
2906
2907 =for hackers
2908 Found in file pp.h
2909
2910 =item POPl
2911 X<POPl>
2912
2913 Pops a long off the stack.
2914
2915         long    POPl
2916
2917 =for hackers
2918 Found in file pp.h
2919
2920 =item POPn
2921 X<POPn>
2922
2923 Pops a double off the stack.
2924
2925         NV      POPn
2926
2927 =for hackers
2928 Found in file pp.h
2929
2930 =item POPp
2931 X<POPp>
2932
2933 Pops a string off the stack. Deprecated. New code should use POPpx.
2934
2935         char*   POPp
2936
2937 =for hackers
2938 Found in file pp.h
2939
2940 =item POPpbytex
2941 X<POPpbytex>
2942
2943 Pops a string off the stack which must consist of bytes i.e. characters < 256.
2944
2945         char*   POPpbytex
2946
2947 =for hackers
2948 Found in file pp.h
2949
2950 =item POPpx
2951 X<POPpx>
2952
2953 Pops a string off the stack.
2954
2955         char*   POPpx
2956
2957 =for hackers
2958 Found in file pp.h
2959
2960 =item POPs
2961 X<POPs>
2962
2963 Pops an SV off the stack.
2964
2965         SV*     POPs
2966
2967 =for hackers
2968 Found in file pp.h
2969
2970 =item PUSHi
2971 X<PUSHi>
2972
2973 Push an integer onto the stack.  The stack must have room for this element.
2974 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
2975 called to declare it.  Do not call multiple C<TARG>-oriented macros to 
2976 return lists from XSUB's - see C<mPUSHi> instead.  See also C<XPUSHi> and
2977 C<mXPUSHi>.
2978
2979         void    PUSHi(IV iv)
2980
2981 =for hackers
2982 Found in file pp.h
2983
2984 =item PUSHMARK
2985 X<PUSHMARK>
2986
2987 Opening bracket for arguments on a callback.  See C<PUTBACK> and
2988 L<perlcall>.
2989
2990         void    PUSHMARK(SP)
2991
2992 =for hackers
2993 Found in file pp.h
2994
2995 =item PUSHmortal
2996 X<PUSHmortal>
2997
2998 Push a new mortal SV onto the stack.  The stack must have room for this
2999 element.  Does not handle 'set' magic.  Does not use C<TARG>.  See also
3000 C<PUSHs>, C<XPUSHmortal> and C<XPUSHs>.
3001
3002         void    PUSHmortal()
3003
3004 =for hackers
3005 Found in file pp.h
3006
3007 =item PUSHn
3008 X<PUSHn>
3009
3010 Push a double onto the stack.  The stack must have room for this element.
3011 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
3012 called to declare it.  Do not call multiple C<TARG>-oriented macros to
3013 return lists from XSUB's - see C<mPUSHn> instead.  See also C<XPUSHn> and
3014 C<mXPUSHn>.
3015
3016         void    PUSHn(NV nv)
3017
3018 =for hackers
3019 Found in file pp.h
3020
3021 =item PUSHp
3022 X<PUSHp>
3023
3024 Push a string onto the stack.  The stack must have room for this element.
3025 The C<len> indicates the length of the string.  Handles 'set' magic.  Uses
3026 C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it.  Do not
3027 call multiple C<TARG>-oriented macros to return lists from XSUB's - see
3028 C<mPUSHp> instead.  See also C<XPUSHp> and C<mXPUSHp>.
3029
3030         void    PUSHp(char* str, STRLEN len)
3031
3032 =for hackers
3033 Found in file pp.h
3034
3035 =item PUSHs
3036 X<PUSHs>
3037
3038 Push an SV onto the stack.  The stack must have room for this element.
3039 Does not handle 'set' magic.  Does not use C<TARG>.  See also C<PUSHmortal>,
3040 C<XPUSHs> and C<XPUSHmortal>.
3041
3042         void    PUSHs(SV* sv)
3043
3044 =for hackers
3045 Found in file pp.h
3046
3047 =item PUSHu
3048 X<PUSHu>
3049
3050 Push an unsigned integer onto the stack.  The stack must have room for this
3051 element.  Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG>
3052 should be called to declare it.  Do not call multiple C<TARG>-oriented
3053 macros to return lists from XSUB's - see C<mPUSHu> instead.  See also
3054 C<XPUSHu> and C<mXPUSHu>.
3055
3056         void    PUSHu(UV uv)
3057
3058 =for hackers
3059 Found in file pp.h
3060
3061 =item PUTBACK
3062 X<PUTBACK>
3063
3064 Closing bracket for XSUB arguments.  This is usually handled by C<xsubpp>.
3065 See C<PUSHMARK> and L<perlcall> for other uses.
3066
3067                 PUTBACK;
3068
3069 =for hackers
3070 Found in file pp.h
3071
3072 =item SP
3073 X<SP>
3074
3075 Stack pointer.  This is usually handled by C<xsubpp>.  See C<dSP> and
3076 C<SPAGAIN>.
3077
3078 =for hackers
3079 Found in file pp.h
3080
3081 =item SPAGAIN
3082 X<SPAGAIN>
3083
3084 Refetch the stack pointer.  Used after a callback.  See L<perlcall>.
3085
3086                 SPAGAIN;
3087
3088 =for hackers
3089 Found in file pp.h
3090
3091 =item XPUSHi
3092 X<XPUSHi>
3093
3094 Push an integer onto the stack, extending the stack if necessary.  Handles
3095 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
3096 declare it.  Do not call multiple C<TARG>-oriented macros to return lists
3097 from XSUB's - see C<mXPUSHi> instead.  See also C<PUSHi> and C<mPUSHi>.
3098
3099         void    XPUSHi(IV iv)
3100
3101 =for hackers
3102 Found in file pp.h
3103
3104 =item XPUSHmortal
3105 X<XPUSHmortal>
3106
3107 Push a new mortal SV onto the stack, extending the stack if necessary.  Does
3108 not handle 'set' magic.  Does not use C<TARG>.  See also C<XPUSHs>,
3109 C<PUSHmortal> and C<PUSHs>.
3110
3111         void    XPUSHmortal()
3112
3113 =for hackers
3114 Found in file pp.h
3115
3116 =item XPUSHn
3117 X<XPUSHn>
3118
3119 Push a double onto the stack, extending the stack if necessary.  Handles
3120 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
3121 declare it.  Do not call multiple C<TARG>-oriented macros to return lists
3122 from XSUB's - see C<mXPUSHn> instead.  See also C<PUSHn> and C<mPUSHn>.
3123
3124         void    XPUSHn(NV nv)
3125
3126 =for hackers
3127 Found in file pp.h
3128
3129 =item XPUSHp
3130 X<XPUSHp>
3131
3132 Push a string onto the stack, extending the stack if necessary.  The C<len>
3133 indicates the length of the string.  Handles 'set' magic.  Uses C<TARG>, so
3134 C<dTARGET> or C<dXSTARG> should be called to declare it.  Do not call
3135 multiple C<TARG>-oriented macros to return lists from XSUB's - see
3136 C<mXPUSHp> instead.  See also C<PUSHp> and C<mPUSHp>.
3137
3138         void    XPUSHp(char* str, STRLEN len)
3139
3140 =for hackers
3141 Found in file pp.h
3142
3143 =item XPUSHs
3144 X<XPUSHs>
3145
3146 Push an SV onto the stack, extending the stack if necessary.  Does not
3147 handle 'set' magic.  Does not use C<TARG>.  See also C<XPUSHmortal>,
3148 C<PUSHs> and C<PUSHmortal>.
3149
3150         void    XPUSHs(SV* sv)
3151
3152 =for hackers
3153 Found in file pp.h
3154
3155 =item XPUSHu
3156 X<XPUSHu>
3157
3158 Push an unsigned integer onto the stack, extending the stack if necessary.
3159 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
3160 called to declare it.  Do not call multiple C<TARG>-oriented macros to
3161 return lists from XSUB's - see C<mXPUSHu> instead.  See also C<PUSHu> and
3162 C<mPUSHu>.
3163
3164         void    XPUSHu(UV uv)
3165
3166 =for hackers
3167 Found in file pp.h
3168
3169 =item XSRETURN
3170 X<XSRETURN>
3171
3172 Return from XSUB, indicating number of items on the stack.  This is usually
3173 handled by C<xsubpp>.
3174
3175         void    XSRETURN(int nitems)
3176
3177 =for hackers
3178 Found in file XSUB.h
3179
3180 =item XSRETURN_EMPTY
3181 X<XSRETURN_EMPTY>
3182
3183 Return an empty list from an XSUB immediately.
3184
3185                 XSRETURN_EMPTY;
3186
3187 =for hackers
3188 Found in file XSUB.h
3189
3190 =item XSRETURN_IV
3191 X<XSRETURN_IV>
3192
3193 Return an integer from an XSUB immediately.  Uses C<XST_mIV>.
3194
3195         void    XSRETURN_IV(IV iv)
3196
3197 =for hackers
3198 Found in file XSUB.h
3199
3200 =item XSRETURN_NO
3201 X<XSRETURN_NO>
3202
3203 Return C<&PL_sv_no> from an XSUB immediately.  Uses C<XST_mNO>.
3204
3205                 XSRETURN_NO;
3206
3207 =for hackers
3208 Found in file XSUB.h
3209
3210 =item XSRETURN_NV
3211 X<XSRETURN_NV>
3212
3213 Return a double from an XSUB immediately.  Uses C<XST_mNV>.
3214
3215         void    XSRETURN_NV(NV nv)
3216
3217 =for hackers
3218 Found in file XSUB.h
3219
3220 =item XSRETURN_PV
3221 X<XSRETURN_PV>
3222
3223 Return a copy of a string from an XSUB immediately.  Uses C<XST_mPV>.
3224
3225         void    XSRETURN_PV(char* str)
3226
3227 =for hackers
3228 Found in file XSUB.h
3229
3230 =item XSRETURN_UNDEF
3231 X<XSRETURN_UNDEF>
3232
3233 Return C<&PL_sv_undef> from an XSUB immediately.  Uses C<XST_mUNDEF>.
3234
3235                 XSRETURN_UNDEF;
3236
3237 =for hackers
3238 Found in file XSUB.h
3239
3240 =item XSRETURN_UV
3241 X<XSRETURN_UV>
3242
3243 Return an integer from an XSUB immediately.  Uses C<XST_mUV>.
3244
3245         void    XSRETURN_UV(IV uv)
3246
3247 =for hackers
3248 Found in file XSUB.h
3249
3250 =item XSRETURN_YES
3251 X<XSRETURN_YES>
3252
3253 Return C<&PL_sv_yes> from an XSUB immediately.  Uses C<XST_mYES>.
3254
3255                 XSRETURN_YES;
3256
3257 =for hackers
3258 Found in file XSUB.h
3259
3260 =item XST_mIV
3261 X<XST_mIV>
3262
3263 Place an integer into the specified position C<pos> on the stack.  The
3264 value is stored in a new mortal SV.
3265
3266         void    XST_mIV(int pos, IV iv)
3267
3268 =for hackers
3269 Found in file XSUB.h
3270
3271 =item XST_mNO
3272 X<XST_mNO>
3273
3274 Place C<&PL_sv_no> into the specified position C<pos> on the
3275 stack.
3276
3277         void    XST_mNO(int pos)
3278
3279 =for hackers
3280 Found in file XSUB.h
3281
3282 =item XST_mNV
3283 X<XST_mNV>
3284
3285 Place a double into the specified position C<pos> on the stack.  The value
3286 is stored in a new mortal SV.
3287
3288         void    XST_mNV(int pos, NV nv)
3289
3290 =for hackers
3291 Found in file XSUB.h
3292
3293 =item XST_mPV
3294 X<XST_mPV>
3295
3296 Place a copy of a string into the specified position C<pos> on the stack. 
3297 The value is stored in a new mortal SV.
3298
3299         void    XST_mPV(int pos, char* str)
3300
3301 =for hackers
3302 Found in file XSUB.h
3303
3304 =item XST_mUNDEF
3305 X<XST_mUNDEF>
3306
3307 Place C<&PL_sv_undef> into the specified position C<pos> on the
3308 stack.
3309
3310         void    XST_mUNDEF(int pos)
3311
3312 =for hackers
3313 Found in file XSUB.h
3314
3315 =item XST_mYES
3316 X<XST_mYES>
3317
3318 Place C<&PL_sv_yes> into the specified position C<pos> on the
3319 stack.
3320
3321         void    XST_mYES(int pos)
3322
3323 =for hackers
3324 Found in file XSUB.h
3325
3326
3327 =back
3328
3329 =head1 SV Flags
3330
3331 =over 8
3332
3333 =item svtype
3334 X<svtype>
3335
3336 An enum of flags for Perl types.  These are found in the file B<sv.h>
3337 in the C<svtype> enum.  Test these flags with the C<SvTYPE> macro.
3338
3339 =for hackers
3340 Found in file sv.h
3341
3342 =item SVt_IV
3343 X<SVt_IV>
3344
3345 Integer type flag for scalars.  See C<svtype>.
3346
3347 =for hackers
3348 Found in file sv.h
3349
3350 =item SVt_NV
3351 X<SVt_NV>
3352
3353 Double type flag for scalars.  See C<svtype>.
3354
3355 =for hackers
3356 Found in file sv.h
3357
3358 =item SVt_PV
3359 X<SVt_PV>
3360
3361 Pointer type flag for scalars.  See C<svtype>.
3362
3363 =for hackers
3364 Found in file sv.h
3365
3366 =item SVt_PVAV
3367 X<SVt_PVAV>
3368
3369 Type flag for arrays.  See C<svtype>.
3370
3371 =for hackers
3372 Found in file sv.h
3373
3374 =item SVt_PVCV
3375 X<SVt_PVCV>
3376
3377 Type flag for code refs.  See C<svtype>.
3378
3379 =for hackers
3380 Found in file sv.h
3381
3382 =item SVt_PVHV
3383 X<SVt_PVHV>
3384
3385 Type flag for hashes.  See C<svtype>.
3386
3387 =for hackers
3388 Found in file sv.h
3389
3390 =item SVt_PVMG
3391 X<SVt_PVMG>
3392
3393 Type flag for blessed scalars.  See C<svtype>.
3394
3395 =for hackers
3396 Found in file sv.h
3397
3398
3399 =back
3400
3401 =head1 SV Manipulation Functions
3402
3403 =over 8
3404
3405 =item get_sv
3406 X<get_sv>
3407
3408 Returns the SV of the specified Perl scalar.  If C<create> is set and the
3409 Perl variable does not exist then it will be created.  If C<create> is not
3410 set and the variable does not exist then NULL is returned.
3411
3412 NOTE: the perl_ form of this function is deprecated.
3413
3414         SV*     get_sv(const char* name, I32 create)
3415
3416 =for hackers
3417 Found in file perl.c
3418
3419 =item looks_like_number
3420 X<looks_like_number>
3421
3422 Test if the content of an SV looks like a number (or is a number).
3423 C<Inf> and C<Infinity> are treated as numbers (so will not issue a
3424 non-numeric warning), even if your atof() doesn't grok them.
3425
3426         I32     looks_like_number(SV* sv)
3427
3428 =for hackers
3429 Found in file sv.c
3430
3431 =item newRV_inc
3432 X<newRV_inc>
3433
3434 Creates an RV wrapper for an SV.  The reference count for the original SV is
3435 incremented.
3436
3437         SV*     newRV_inc(SV* sv)
3438
3439 =for hackers
3440 Found in file sv.h
3441
3442 =item newRV_noinc
3443 X<newRV_noinc>
3444
3445 Creates an RV wrapper for an SV.  The reference count for the original
3446 SV is B<not> incremented.
3447
3448         SV*     newRV_noinc(SV *sv)
3449
3450 =for hackers
3451 Found in file sv.c
3452
3453 =item NEWSV
3454 X<NEWSV>
3455
3456 Creates a new SV.  A non-zero C<len> parameter indicates the number of
3457 bytes of preallocated string space the SV should have.  An extra byte for a
3458 tailing NUL is also reserved.  (SvPOK is not set for the SV even if string
3459 space is allocated.)  The reference count for the new SV is set to 1.
3460 C<id> is an integer id between 0 and 1299 (used to identify leaks).
3461
3462         SV*     NEWSV(int id, STRLEN len)
3463
3464 =for hackers
3465 Found in file handy.h
3466
3467 =item newSV
3468 X<newSV>
3469
3470 Create a new null SV, or if len > 0, create a new empty SVt_PV type SV
3471 with an initial PV allocation of len+1. Normally accessed via the C<NEWSV>
3472 macro.
3473
3474         SV*     newSV(STRLEN len)
3475
3476 =for hackers
3477 Found in file sv.c
3478
3479 =item newSVhek
3480 X<newSVhek>
3481
3482 Creates a new SV from the hash key structure.  It will generate scalars that
3483 point to the shared string table where possible. Returns a new (undefined)
3484 SV if the hek is NULL.
3485
3486         SV*     newSVhek(const HEK *hek)
3487
3488 =for hackers
3489 Found in file sv.c
3490
3491 =item newSViv
3492 X<newSViv>
3493
3494 Creates a new SV and copies an integer into it.  The reference count for the
3495 SV is set to 1.
3496
3497         SV*     newSViv(IV i)
3498
3499 =for hackers
3500 Found in file sv.c
3501
3502 =item newSVnv
3503 X<newSVnv>
3504
3505 Creates a new SV and copies a floating point value into it.
3506 The reference count for the SV is set to 1.
3507
3508         SV*     newSVnv(NV n)
3509
3510 =for hackers
3511 Found in file sv.c
3512
3513 =item newSVpv
3514 X<newSVpv>
3515
3516 Creates a new SV and copies a string into it.  The reference count for the
3517 SV is set to 1.  If C<len> is zero, Perl will compute the length using
3518 strlen().  For efficiency, consider using C<newSVpvn> instead.
3519
3520         SV*     newSVpv(const char* s, STRLEN len)
3521
3522 =for hackers
3523 Found in file sv.c
3524
3525 =item newSVpvf
3526 X<newSVpvf>
3527
3528 Creates a new SV and initializes it with the string formatted like
3529 C<sprintf>.
3530
3531         SV*     newSVpvf(const char* pat, ...)
3532
3533 =for hackers
3534 Found in file sv.c
3535
3536 =item newSVpvn
3537 X<newSVpvn>
3538
3539 Creates a new SV and copies a string into it.  The reference count for the
3540 SV is set to 1.  Note that if C<len> is zero, Perl will create a zero length
3541 string.  You are responsible for ensuring that the source string is at least
3542 C<len> bytes long.  If the C<s> argument is NULL the new SV will be undefined.
3543
3544         SV*     newSVpvn(const char* s, STRLEN len)
3545
3546 =for hackers
3547 Found in file sv.c
3548
3549 =item newSVpvn_share
3550 X<newSVpvn_share>
3551
3552 Creates a new SV with its SvPVX_const pointing to a shared string in the string
3553 table. If the string does not already exist in the table, it is created
3554 first.  Turns on READONLY and FAKE.  The string's hash is stored in the UV
3555 slot of the SV; if the C<hash> parameter is non-zero, that value is used;
3556 otherwise the hash is computed.  The idea here is that as the string table
3557 is used for shared hash keys these strings will have SvPVX_const == HeKEY and
3558 hash lookup will avoid string compare.
3559
3560         SV*     newSVpvn_share(const char* s, I32 len, U32 hash)
3561
3562 =for hackers
3563 Found in file sv.c
3564
3565 =item newSVrv
3566 X<newSVrv>
3567
3568 Creates a new SV for the RV, C<rv>, to point to.  If C<rv> is not an RV then
3569 it will be upgraded to one.  If C<classname> is non-null then the new SV will
3570 be blessed in the specified package.  The new SV is returned and its
3571 reference count is 1.
3572
3573         SV*     newSVrv(SV* rv, const char* classname)
3574
3575 =for hackers
3576 Found in file sv.c
3577
3578 =item newSVsv
3579 X<newSVsv>
3580
3581 Creates a new SV which is an exact duplicate of the original SV.
3582 (Uses C<sv_setsv>).
3583
3584         SV*     newSVsv(SV* old)
3585
3586 =for hackers
3587 Found in file sv.c
3588
3589 =item newSVuv
3590 X<newSVuv>
3591
3592 Creates a new SV and copies an unsigned integer into it.
3593 The reference count for the SV is set to 1.
3594
3595         SV*     newSVuv(UV u)
3596
3597 =for hackers
3598 Found in file sv.c
3599
3600 =item SvCUR
3601 X<SvCUR>
3602
3603 Returns the length of the string which is in the SV.  See C<SvLEN>.
3604
3605         STRLEN  SvCUR(SV* sv)
3606
3607 =for hackers
3608 Found in file sv.h
3609
3610 =item SvCUR_set
3611 X<SvCUR_set>
3612
3613 Set the current length of the string which is in the SV.  See C<SvCUR>
3614 and C<SvIV_set>.
3615
3616         void    SvCUR_set(SV* sv, STRLEN len)
3617
3618 =for hackers
3619 Found in file sv.h
3620
3621 =item SvEND
3622 X<SvEND>
3623
3624 Returns a pointer to the last character in the string which is in the SV.
3625 See C<SvCUR>.  Access the character as *(SvEND(sv)).
3626
3627         char*   SvEND(SV* sv)
3628
3629 =for hackers
3630 Found in file sv.h
3631
3632 =item SvGROW
3633 X<SvGROW>
3634
3635 Expands the character buffer in the SV so that it has room for the
3636 indicated number of bytes (remember to reserve space for an extra trailing
3637 NUL character).  Calls C<sv_grow> to perform the expansion if necessary.
3638 Returns a pointer to the character buffer.
3639
3640         char *  SvGROW(SV* sv, STRLEN len)
3641
3642 =for hackers
3643 Found in file sv.h
3644
3645 =item SvIOK
3646 X<SvIOK>
3647
3648 Returns a boolean indicating whether the SV contains an integer.
3649
3650         bool    SvIOK(SV* sv)
3651
3652 =for hackers
3653 Found in file sv.h
3654
3655 =item SvIOKp
3656 X<SvIOKp>
3657
3658 Returns a boolean indicating whether the SV contains an integer.  Checks
3659 the B<private> setting.  Use C<SvIOK>.
3660
3661         bool    SvIOKp(SV* sv)
3662
3663 =for hackers
3664 Found in file sv.h
3665
3666 =item SvIOK_notUV
3667 X<SvIOK_notUV>
3668
3669 Returns a boolean indicating whether the SV contains a signed integer.
3670
3671         bool    SvIOK_notUV(SV* sv)
3672
3673 =for hackers
3674 Found in file sv.h
3675
3676 =item SvIOK_off
3677 X<SvIOK_off>
3678
3679 Unsets the IV status of an SV.
3680
3681         void    SvIOK_off(SV* sv)
3682
3683 =for hackers
3684 Found in file sv.h
3685
3686 =item SvIOK_on
3687 X<SvIOK_on>
3688
3689 Tells an SV that it is an integer.
3690
3691         void    SvIOK_on(SV* sv)
3692
3693 =for hackers
3694 Found in file sv.h
3695
3696 =item SvIOK_only
3697 X<SvIOK_only>
3698
3699 Tells an SV that it is an integer and disables all other OK bits.
3700
3701         void    SvIOK_only(SV* sv)
3702
3703 =for hackers
3704 Found in file sv.h
3705
3706 =item SvIOK_only_UV
3707 X<SvIOK_only_UV>
3708
3709 Tells and SV that it is an unsigned integer and disables all other OK bits.
3710
3711         void    SvIOK_only_UV(SV* sv)
3712
3713 =for hackers
3714 Found in file sv.h
3715
3716 =item SvIOK_UV
3717 X<SvIOK_UV>
3718
3719 Returns a boolean indicating whether the SV contains an unsigned integer.
3720
3721         bool    SvIOK_UV(SV* sv)
3722
3723 =for hackers
3724 Found in file sv.h
3725
3726 =item SvIsCOW
3727 X<SvIsCOW>
3728
3729 Returns a boolean indicating whether the SV is Copy-On-Write. (either shared
3730 hash key scalars, or full Copy On Write scalars if 5.9.0 is configured for
3731 COW)
3732
3733         bool    SvIsCOW(SV* sv)
3734
3735 =for hackers
3736 Found in file sv.h
3737
3738 =item SvIsCOW_shared_hash
3739 X<SvIsCOW_shared_hash>
3740
3741 Returns a boolean indicating whether the SV is Copy-On-Write shared hash key
3742 scalar.
3743
3744         bool    SvIsCOW_shared_hash(SV* sv)
3745
3746 =for hackers
3747 Found in file sv.h
3748
3749 =item SvIV
3750 X<SvIV>
3751
3752 Coerces the given SV to an integer and returns it. See  C<SvIVx> for a
3753 version which guarantees to evaluate sv only once.
3754
3755         IV      SvIV(SV* sv)
3756
3757 =for hackers
3758 Found in file sv.h
3759
3760 =item SvIVX
3761 X<SvIVX>
3762
3763 Returns the raw value in the SV's IV slot, without checks or conversions.
3764 Only use when you are sure SvIOK is true. See also C<SvIV()>.
3765
3766         IV      SvIVX(SV* sv)
3767
3768 =for hackers
3769 Found in file sv.h
3770
3771 =item SvIVx
3772 X<SvIVx>
3773
3774 Coerces the given SV to an integer and returns it. Guarantees to evaluate
3775 sv only once. Use the more efficient C<SvIV> otherwise.
3776
3777         IV      SvIVx(SV* sv)
3778
3779 =for hackers
3780 Found in file sv.h
3781
3782 =item SvIV_nomg
3783 X<SvIV_nomg>
3784
3785 Like C<SvIV> but doesn't process magic.
3786
3787         IV      SvIV_nomg(SV* sv)
3788
3789 =for hackers
3790 Found in file sv.h
3791
3792 =item SvIV_set
3793 X<SvIV_set>
3794
3795 Set the value of the IV pointer in sv to val.  It is possible to perform
3796 the same function of this macro with an lvalue assignment to C<SvIVX>.
3797 With future Perls, however, it will be more efficient to use 
3798 C<SvIV_set> instead of the lvalue assignment to C<SvIVX>.
3799
3800         void    SvIV_set(SV* sv, IV val)
3801
3802 =for hackers
3803 Found in file sv.h
3804
3805 =item SvLEN
3806 X<SvLEN>
3807
3808 Returns the size of the string buffer in the SV, not including any part
3809 attributable to C<SvOOK>.  See C<SvCUR>.
3810
3811         STRLEN  SvLEN(SV* sv)
3812
3813 =for hackers
3814 Found in file sv.h
3815
3816 =item SvLEN_set
3817 X<SvLEN_set>
3818
3819 Set the actual length of the string which is in the SV.  See C<SvIV_set>.
3820
3821         void    SvLEN_set(SV* sv, STRLEN len)
3822
3823 =for hackers
3824 Found in file sv.h
3825
3826 =item SvMAGIC_set
3827 X<SvMAGIC_set>
3828
3829 Set the value of the MAGIC pointer in sv to val.  See C<SvIV_set>.
3830
3831         void    SvMAGIC_set(SV* sv, MAGIC* val)
3832
3833 =for hackers
3834 Found in file sv.h
3835
3836 =item SvNIOK
3837 X<SvNIOK>
3838
3839 Returns a boolean indicating whether the SV contains a number, integer or
3840 double.
3841
3842         bool    SvNIOK(SV* sv)
3843
3844 =for hackers
3845 Found in file sv.h
3846
3847 =item SvNIOKp
3848 X<SvNIOKp>
3849
3850 Returns a boolean indicating whether the SV contains a number, integer or
3851 double.  Checks the B<private> setting.  Use C<SvNIOK>.
3852
3853         bool    SvNIOKp(SV* sv)
3854
3855 =for hackers
3856 Found in file sv.h
3857
3858 =item SvNIOK_off
3859 X<SvNIOK_off>
3860
3861 Unsets the NV/IV status of an SV.
3862
3863         void    SvNIOK_off(SV* sv)
3864
3865 =for hackers
3866 Found in file sv.h
3867
3868 =item SvNOK
3869 X<SvNOK>
3870
3871 Returns a boolean indicating whether the SV contains a double.
3872
3873         bool    SvNOK(SV* sv)
3874
3875 =for hackers
3876 Found in file sv.h
3877
3878 =item SvNOKp
3879 X<SvNOKp>
3880
3881 Returns a boolean indicating whether the SV contains a double.  Checks the
3882 B<private> setting.  Use C<SvNOK>.
3883
3884         bool    SvNOKp(SV* sv)
3885
3886 =for hackers
3887 Found in file sv.h
3888
3889 =item SvNOK_off
3890 X<SvNOK_off>
3891
3892 Unsets the NV status of an SV.
3893
3894         void    SvNOK_off(SV* sv)
3895
3896 =for hackers
3897 Found in file sv.h
3898
3899 =item SvNOK_on
3900 X<SvNOK_on>
3901
3902 Tells an SV that it is a double.
3903
3904         void    SvNOK_on(SV* sv)
3905
3906 =for hackers
3907 Found in file sv.h
3908
3909 =item SvNOK_only
3910 X<SvNOK_only>
3911
3912 Tells an SV that it is a double and disables all other OK bits.
3913
3914         void    SvNOK_only(SV* sv)
3915
3916 =for hackers
3917 Found in file sv.h
3918
3919 =item SvNV
3920 X<SvNV>
3921
3922 Coerce the given SV to a double and return it. See  C<SvNVx> for a version
3923 which guarantees to evaluate sv only once.
3924
3925         NV      SvNV(SV* sv)
3926
3927 =for hackers
3928 Found in file sv.h
3929
3930 =item SvNVX
3931 X<SvNVX>
3932
3933 Returns the raw value in the SV's NV slot, without checks or conversions.
3934 Only use when you are sure SvNOK is true. See also C<SvNV()>.
3935
3936         NV      SvNVX(SV* sv)
3937
3938 =for hackers
3939 Found in file sv.h
3940
3941 =item SvNVx
3942 X<SvNVx>
3943
3944 Coerces the given SV to a double and returns it. Guarantees to evaluate
3945 sv only once. Use the more efficient C<SvNV> otherwise.
3946
3947         NV      SvNVx(SV* sv)
3948
3949 =for hackers
3950 Found in file sv.h
3951
3952 =item SvNV_set
3953 X<SvNV_set>
3954
3955 Set the value of the NV pointer in sv to val.  See C<SvIV_set>.
3956
3957         void    SvNV_set(SV* sv, NV val)
3958
3959 =for hackers
3960 Found in file sv.h
3961
3962 =item SvOK
3963 X<SvOK>
3964
3965 Returns a boolean indicating whether the value is an SV. It also tells
3966 whether the value is defined or not.
3967
3968         bool    SvOK(SV* sv)
3969
3970 =for hackers
3971 Found in file sv.h
3972
3973 =item SvOOK
3974 X<SvOOK>
3975
3976 Returns a boolean indicating whether the SvIVX is a valid offset value for
3977 the SvPVX.  This hack is used internally to speed up removal of characters
3978 from the beginning of a SvPV.  When SvOOK is true, then the start of the
3979 allocated string buffer is really (SvPVX - SvIVX).
3980
3981         bool    SvOOK(SV* sv)
3982
3983 =for hackers
3984 Found in file sv.h
3985
3986 =item SvPOK
3987 X<SvPOK>
3988
3989 Returns a boolean indicating whether the SV contains a character
3990 string.
3991
3992         bool    SvPOK(SV* sv)
3993
3994 =for hackers
3995 Found in file sv.h
3996
3997 =item SvPOKp
3998 X<SvPOKp>
3999
4000 Returns a boolean indicating whether the SV contains a character string.
4001 Checks the B<private> setting.  Use C<SvPOK>.
4002
4003         bool    SvPOKp(SV* sv)
4004
4005 =for hackers
4006 Found in file sv.h
4007
4008 =item SvPOK_off
4009 X<SvPOK_off>
4010
4011 Unsets the PV status of an SV.
4012
4013         void    SvPOK_off(SV* sv)
4014
4015 =for hackers
4016 Found in file sv.h
4017
4018 =item SvPOK_on
4019 X<SvPOK_on>
4020
4021 Tells an SV that it is a string.
4022
4023         void    SvPOK_on(SV* sv)
4024
4025 =for hackers
4026 Found in file sv.h
4027
4028 =item SvPOK_only
4029 X<SvPOK_only>
4030
4031 Tells an SV that it is a string and disables all other OK bits.
4032 Will also turn off the UTF-8 status.
4033
4034         void    SvPOK_only(SV* sv)
4035
4036 =for hackers
4037 Found in file sv.h
4038
4039 =item SvPOK_only_UTF8
4040 X<SvPOK_only_UTF8>
4041
4042 Tells an SV that it is a string and disables all other OK bits,
4043 and leaves the UTF-8 status as it was.
4044
4045         void    SvPOK_only_UTF8(SV* sv)
4046
4047 =for hackers
4048 Found in file sv.h
4049
4050 =item SvPV
4051 X<SvPV>
4052
4053 Returns a pointer to the string in the SV, or a stringified form of
4054 the SV if the SV does not contain a string.  The SV may cache the
4055 stringified version becoming C<SvPOK>.  Handles 'get' magic. See also
4056 C<SvPVx> for a version which guarantees to evaluate sv only once.
4057
4058         char*   SvPV(SV* sv, STRLEN len)
4059
4060 =for hackers
4061 Found in file sv.h
4062
4063 =item SvPVbyte
4064 X<SvPVbyte>
4065
4066 Like C<SvPV>, but converts sv to byte representation first if necessary.
4067
4068         char*   SvPVbyte(SV* sv, STRLEN len)
4069
4070 =for hackers
4071 Found in file sv.h
4072
4073 =item SvPVbytex
4074 X<SvPVbytex>
4075
4076 Like C<SvPV>, but converts sv to byte representation first if necessary.
4077 Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte>
4078 otherwise.
4079
4080         char*   SvPVbytex(SV* sv, STRLEN len)
4081
4082 =for hackers
4083 Found in file sv.h
4084
4085 =item SvPVbytex_force
4086 X<SvPVbytex_force>
4087
4088 Like C<SvPV_force>, but converts sv to byte representation first if necessary.
4089 Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte_force>
4090 otherwise.
4091
4092         char*   SvPVbytex_force(SV* sv, STRLEN len)
4093
4094 =for hackers
4095 Found in file sv.h
4096
4097 =item SvPVbyte_force
4098 X<SvPVbyte_force>
4099
4100 Like C<SvPV_force>, but converts sv to byte representation first if necessary.
4101
4102         char*   SvPVbyte_force(SV* sv, STRLEN len)
4103
4104 =for hackers
4105 Found in file sv.h
4106
4107 =item SvPVbyte_nolen
4108 X<SvPVbyte_nolen>
4109
4110 Like C<SvPV_nolen>, but converts sv to byte representation first if necessary.
4111
4112         char*   SvPVbyte_nolen(SV* sv)
4113
4114 =for hackers
4115 Found in file sv.h
4116
4117 =item SvPVutf8
4118 X<SvPVutf8>
4119
4120 Like C<SvPV>, but converts sv to utf8 first if necessary.
4121
4122         char*   SvPVutf8(SV* sv, STRLEN len)
4123
4124 =for hackers
4125 Found in file sv.h
4126
4127 =item SvPVutf8x
4128 X<SvPVutf8x>
4129
4130 Like C<SvPV>, but converts sv to utf8 first if necessary.
4131 Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8>
4132 otherwise.
4133
4134         char*   SvPVutf8x(SV* sv, STRLEN len)
4135
4136 =for hackers
4137 Found in file sv.h
4138
4139 =item SvPVutf8x_force
4140 X<SvPVutf8x_force>
4141
4142 Like C<SvPV_force>, but converts sv to utf8 first if necessary.
4143 Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8_force>
4144 otherwise.
4145
4146         char*   SvPVutf8x_force(SV* sv, STRLEN len)
4147
4148 =for hackers
4149 Found in file sv.h
4150
4151 =item SvPVutf8_force
4152 X<SvPVutf8_force>
4153
4154 Like C<SvPV_force>, but converts sv to utf8 first if necessary.
4155
4156         char*   SvPVutf8_force(SV* sv, STRLEN len)
4157
4158 =for hackers
4159 Found in file sv.h
4160
4161 =item SvPVutf8_nolen
4162 X<SvPVutf8_nolen>
4163
4164 Like C<SvPV_nolen>, but converts sv to utf8 first if necessary.
4165
4166         char*   SvPVutf8_nolen(SV* sv)
4167
4168 =for hackers
4169 Found in file sv.h
4170
4171 =item SvPVX
4172 X<SvPVX>
4173
4174 Returns a pointer to the physical string in the SV.  The SV must contain a
4175 string.
4176
4177         char*   SvPVX(SV* sv)
4178
4179 =for hackers
4180 Found in file sv.h
4181
4182 =item SvPVx
4183 X<SvPVx>
4184
4185 A version of C<SvPV> which guarantees to evaluate sv only once.
4186
4187         char*   SvPVx(SV* sv, STRLEN len)
4188
4189 =for hackers
4190 Found in file sv.h
4191
4192 =item SvPV_force
4193 X<SvPV_force>
4194
4195 Like C<SvPV> but will force the SV into containing just a string
4196 (C<SvPOK_only>).  You want force if you are going to update the C<SvPVX>
4197 directly.
4198
4199         char*   SvPV_force(SV* sv, STRLEN len)
4200
4201 =for hackers
4202 Found in file sv.h
4203
4204 =item SvPV_force_nomg
4205 X<SvPV_force_nomg>
4206
4207 Like C<SvPV> but will force the SV into containing just a string
4208 (C<SvPOK_only>).  You want force if you are going to update the C<SvPVX>
4209 directly. Doesn't process magic.
4210
4211         char*   SvPV_force_nomg(SV* sv, STRLEN len)
4212
4213 =for hackers
4214 Found in file sv.h
4215
4216 =item SvPV_nolen
4217 X<SvPV_nolen>
4218
4219 Returns a pointer to the string in the SV, or a stringified form of
4220 the SV if the SV does not contain a string.  The SV may cache the
4221 stringified form becoming C<SvPOK>.  Handles 'get' magic.
4222
4223         char*   SvPV_nolen(SV* sv)
4224
4225 =for hackers
4226 Found in file sv.h
4227
4228 =item SvPV_nomg
4229 X<SvPV_nomg>
4230
4231 Like C<SvPV> but doesn't process magic.
4232
4233         char*   SvPV_nomg(SV* sv, STRLEN len)
4234
4235 =for hackers
4236 Found in file sv.h
4237
4238 =item SvPV_set
4239 X<SvPV_set>
4240
4241 Set the value of the PV pointer in sv to val.  See C<SvIV_set>.
4242
4243         void    SvPV_set(SV* sv, char* val)
4244
4245 =for hackers
4246 Found in file sv.h
4247
4248 =item SvREFCNT
4249 X<SvREFCNT>
4250
4251 Returns the value of the object's reference count.
4252
4253         U32     SvREFCNT(SV* sv)
4254
4255 =for hackers
4256 Found in file sv.h
4257
4258 =item SvREFCNT_dec
4259 X<SvREFCNT_dec>
4260
4261 Decrements the reference count of the given SV.
4262
4263         void    SvREFCNT_dec(SV* sv)
4264
4265 =for hackers
4266 Found in file sv.h
4267
4268 =item SvREFCNT_inc
4269 X<SvREFCNT_inc>
4270
4271 Increments the reference count of the given SV.
4272
4273         SV*     SvREFCNT_inc(SV* sv)
4274
4275 =for hackers
4276 Found in file sv.h
4277
4278 =item SvROK
4279 X<SvROK>
4280
4281 Tests if the SV is an RV.
4282
4283         bool    SvROK(SV* sv)
4284
4285 =for hackers
4286 Found in file sv.h
4287
4288 =item SvROK_off
4289 X<SvROK_off>
4290
4291 Unsets the RV status of an SV.
4292
4293         void    SvROK_off(SV* sv)
4294
4295 =for hackers
4296 Found in file sv.h
4297
4298 =item SvROK_on
4299 X<SvROK_on>
4300
4301 Tells an SV that it is an RV.
4302
4303         void    SvROK_on(SV* sv)
4304
4305 =for hackers
4306 Found in file sv.h
4307
4308 =item SvRV
4309 X<SvRV>
4310
4311 Dereferences an RV to return the SV.
4312
4313         SV*     SvRV(SV* sv)
4314
4315 =for hackers
4316 Found in file sv.h
4317
4318 =item SvRV_set
4319 X<SvRV_set>
4320
4321 Set the value of the RV pointer in sv to val.  See C<SvIV_set>.
4322
4323         void    SvRV_set(SV* sv, SV* val)
4324
4325 =for hackers
4326 Found in file sv.h
4327
4328 =item SvSTASH
4329 X<SvSTASH>
4330
4331 Returns the stash of the SV.
4332
4333         HV*     SvSTASH(SV* sv)
4334
4335 =for hackers
4336 Found in file sv.h
4337
4338 =item SvSTASH_set
4339 X<SvSTASH_set>
4340
4341 Set the value of the STASH pointer in sv to val.  See C<SvIV_set>.
4342
4343         void    SvSTASH_set(SV* sv, STASH* val)
4344
4345 =for hackers
4346 Found in file sv.h
4347
4348 =item SvTAINT
4349 X<SvTAINT>
4350
4351 Taints an SV if tainting is enabled.
4352
4353         void    SvTAINT(SV* sv)
4354
4355 =for hackers
4356 Found in file sv.h
4357
4358 =item SvTAINTED
4359 X<SvTAINTED>
4360
4361 Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if
4362 not.
4363
4364         bool    SvTAINTED(SV* sv)
4365
4366 =for hackers
4367 Found in file sv.h
4368
4369 =item SvTAINTED_off
4370 X<SvTAINTED_off>
4371
4372 Untaints an SV. Be I<very> careful with this routine, as it short-circuits
4373 some of Perl's fundamental security features. XS module authors should not
4374 use this function unless they fully understand all the implications of
4375 unconditionally untainting the value. Untainting should be done in the
4376 standard perl fashion, via a carefully crafted regexp, rather than directly
4377 untainting variables.
4378
4379         void    SvTAINTED_off(SV* sv)
4380
4381 =for hackers
4382 Found in file sv.h
4383
4384 =item SvTAINTED_on
4385 X<SvTAINTED_on>
4386
4387 Marks an SV as tainted if tainting is enabled.
4388
4389         void    SvTAINTED_on(SV* sv)
4390
4391 =for hackers
4392 Found in file sv.h
4393
4394 =item SvTRUE
4395 X<SvTRUE>
4396
4397 Returns a boolean indicating whether Perl would evaluate the SV as true or
4398 false, defined or undefined.  Does not handle 'get' magic.
4399
4400         bool    SvTRUE(SV* sv)
4401
4402 =for hackers
4403 Found in file sv.h
4404
4405 =item SvTYPE
4406 X<SvTYPE>
4407
4408 Returns the type of the SV.  See C<svtype>.
4409
4410         svtype  SvTYPE(SV* sv)
4411
4412 =for hackers
4413 Found in file sv.h
4414
4415 =item SvUOK
4416 X<SvUOK>
4417
4418 Returns a boolean indicating whether the SV contains an unsigned integer.
4419
4420         void    SvUOK(SV* sv)
4421
4422 =for hackers
4423 Found in file sv.h
4424
4425 =item SvUPGRADE
4426 X<SvUPGRADE>
4427
4428 Used to upgrade an SV to a more complex form.  Uses C<sv_upgrade> to
4429 perform the upgrade if necessary.  See C<svtype>.
4430
4431         void    SvUPGRADE(SV* sv, svtype type)
4432
4433 =for hackers
4434 Found in file sv.h
4435
4436 =item SvUTF8
4437 X<SvUTF8>
4438
4439 Returns a boolean indicating whether the SV contains UTF-8 encoded data.
4440
4441         bool    SvUTF8(SV* sv)
4442
4443 =for hackers
4444 Found in file sv.h
4445
4446 =item SvUTF8_off
4447 X<SvUTF8_off>
4448
4449 Unsets the UTF-8 status of an SV.
4450
4451         void    SvUTF8_off(SV *sv)
4452
4453 =for hackers
4454 Found in file sv.h
4455
4456 =item SvUTF8_on
4457 X<SvUTF8_on>
4458
4459 Turn on the UTF-8 status of an SV (the data is not changed, just the flag).
4460 Do not use frivolously.
4461
4462         void    SvUTF8_on(SV *sv)
4463
4464 =for hackers
4465 Found in file sv.h
4466
4467 =item SvUV
4468 X<SvUV>
4469
4470 Coerces the given SV to an unsigned integer and returns it.  See C<SvUVx>
4471 for a version which guarantees to evaluate sv only once.
4472
4473         UV      SvUV(SV* sv)
4474
4475 =for hackers
4476 Found in file sv.h
4477
4478 =item SvUVX
4479 X<SvUVX>
4480
4481 Returns the raw value in the SV's UV slot, without checks or conversions.
4482 Only use when you are sure SvIOK is true. See also C<SvUV()>.
4483
4484         UV      SvUVX(SV* sv)
4485
4486 =for hackers
4487 Found in file sv.h
4488
4489 =item SvUVx
4490 X<SvUVx>
4491
4492 Coerces the given SV to an unsigned integer and returns it. Guarantees to
4493 evaluate sv only once. Use the more efficient C<SvUV> otherwise.
4494
4495         UV      SvUVx(SV* sv)
4496
4497 =for hackers
4498 Found in file sv.h
4499
4500 =item SvUV_nomg
4501 X<SvUV_nomg>
4502
4503 Like C<SvUV> but doesn't process magic.
4504
4505         UV      SvUV_nomg(SV* sv)
4506
4507 =for hackers
4508 Found in file sv.h
4509
4510 =item SvUV_set
4511 X<SvUV_set>
4512
4513 Set the value of the UV pointer in sv to val.  See C<SvIV_set>.
4514
4515         void    SvUV_set(SV* sv, UV val)
4516
4517 =for hackers
4518 Found in file sv.h
4519
4520 =item SvVOK
4521 X<SvVOK>
4522
4523 Returns a boolean indicating whether the SV contains a v-string.
4524
4525         bool    SvVOK(SV* sv)
4526
4527 =for hackers
4528 Found in file sv.h
4529
4530 =item sv_2bool
4531 X<sv_2bool>
4532
4533 This function is only called on magical items, and is only used by
4534 sv_true() or its macro equivalent.
4535
4536         bool    sv_2bool(SV* sv)
4537
4538 =for hackers
4539 Found in file sv.c
4540
4541 =item sv_2cv
4542 X<sv_2cv>
4543
4544 Using various gambits, try to get a CV from an SV; in addition, try if
4545 possible to set C<*st> and C<*gvp> to the stash and GV associated with it.
4546
4547         CV*     sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref)
4548
4549 =for hackers
4550 Found in file sv.c
4551
4552 =item sv_2io
4553 X<sv_2io>
4554
4555 Using various gambits, try to get an IO from an SV: the IO slot if its a
4556 GV; or the recursive result if we're an RV; or the IO slot of the symbol
4557 named after the PV if we're a string.
4558
4559         IO*     sv_2io(SV* sv)
4560
4561 =for hackers
4562 Found in file sv.c
4563
4564 =item sv_2iv_flags
4565 X<sv_2iv_flags>
4566
4567 Return the integer value of an SV, doing any necessary string
4568 conversion.  If flags includes SV_GMAGIC, does an mg_get() first.
4569 Normally used via the C<SvIV(sv)> and C<SvIVx(sv)> macros.
4570
4571         IV      sv_2iv_flags(SV* sv, I32 flags)
4572
4573 =for hackers
4574 Found in file sv.c
4575
4576 =item sv_2mortal
4577 X<sv_2mortal>
4578
4579 Marks an existing SV as mortal.  The SV will be destroyed "soon", either
4580 by an explicit call to FREETMPS, or by an implicit call at places such as
4581 statement boundaries.  SvTEMP() is turned on which means that the SV's
4582 string buffer can be "stolen" if this SV is copied. See also C<sv_newmortal>
4583 and C<sv_mortalcopy>.
4584
4585         SV*     sv_2mortal(SV* sv)
4586
4587 =for hackers
4588 Found in file sv.c
4589
4590 =item sv_2nv
4591 X<sv_2nv>
4592
4593 Return the num value of an SV, doing any necessary string or integer
4594 conversion, magic etc. Normally used via the C<SvNV(sv)> and C<SvNVx(sv)>
4595 macros.
4596
4597         NV      sv_2nv(SV* sv)
4598
4599 =for hackers
4600 Found in file sv.c
4601
4602 =item sv_2pvbyte
4603 X<sv_2pvbyte>
4604
4605 Return a pointer to the byte-encoded representation of the SV, and set *lp
4606 to its length.  May cause the SV to be downgraded from UTF-8 as a
4607 side-effect.
4608
4609 Usually accessed via the C<SvPVbyte> macro.
4610
4611         char*   sv_2pvbyte(SV* sv, STRLEN* lp)
4612
4613 =for hackers
4614 Found in file sv.c
4615
4616 =item sv_2pvutf8
4617 X<sv_2pvutf8>
4618
4619 Return a pointer to the UTF-8-encoded representation of the SV, and set *lp
4620 to its length.  May cause the SV to be upgraded to UTF-8 as a side-effect.
4621
4622 Usually accessed via the C<SvPVutf8> macro.
4623
4624         char*   sv_2pvutf8(SV* sv, STRLEN* lp)
4625
4626 =for hackers
4627 Found in file sv.c
4628
4629 =item sv_2pv_flags
4630 X<sv_2pv_flags>
4631
4632 Returns a pointer to the string value of an SV, and sets *lp to its length.
4633 If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a string
4634 if necessary.
4635 Normally invoked via the C<SvPV_flags> macro. C<sv_2pv()> and C<sv_2pv_nomg>
4636 usually end up here too.
4637
4638         char*   sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags)
4639
4640 =for hackers
4641 Found in file sv.c
4642
4643 =item sv_2uv_flags
4644 X<sv_2uv_flags>
4645
4646 Return the unsigned integer value of an SV, doing any necessary string
4647 conversion.  If flags includes SV_GMAGIC, does an mg_get() first.
4648 Normally used via the C<SvUV(sv)> and C<SvUVx(sv)> macros.
4649
4650         UV      sv_2uv_flags(SV* sv, I32 flags)
4651
4652 =for hackers
4653 Found in file sv.c
4654
4655 =item sv_backoff
4656 X<sv_backoff>
4657
4658 Remove any string offset. You should normally use the C<SvOOK_off> macro
4659 wrapper instead.
4660
4661         int     sv_backoff(SV* sv)
4662
4663 =for hackers
4664 Found in file sv.c
4665
4666 =item sv_bless
4667 X<sv_bless>
4668
4669 Blesses an SV into a specified package.  The SV must be an RV.  The package
4670 must be designated by its stash (see C<gv_stashpv()>).  The reference count
4671 of the SV is unaffected.
4672
4673         SV*     sv_bless(SV* sv, HV* stash)
4674
4675 =for hackers
4676 Found in file sv.c
4677
4678 =item sv_catpv
4679 X<sv_catpv>
4680
4681 Concatenates the string onto the end of the string which is in the SV.
4682 If the SV has the UTF-8 status set, then the bytes appended should be
4683 valid UTF-8.  Handles 'get' magic, but not 'set' magic.  See C<sv_catpv_mg>.
4684
4685         void    sv_catpv(SV* sv, const char* ptr)
4686
4687 =for hackers
4688 Found in file sv.c
4689
4690 =item sv_catpvf
4691 X<sv_catpvf>
4692
4693 Processes its arguments like C<sprintf> and appends the formatted
4694 output to an SV.  If the appended data contains "wide" characters
4695 (including, but not limited to, SVs with a UTF-8 PV formatted with %s,
4696 and characters >255 formatted with %c), the original SV might get
4697 upgraded to UTF-8.  Handles 'get' magic, but not 'set' magic.  See
4698 C<sv_catpvf_mg>. If the original SV was UTF-8, the pattern should be
4699 valid UTF-8; if the original SV was bytes, the pattern should be too.
4700
4701         void    sv_catpvf(SV* sv, const char* pat, ...)
4702
4703 =for hackers
4704 Found in file sv.c
4705
4706 =item sv_catpvf_mg
4707 X<sv_catpvf_mg>
4708
4709 Like C<sv_catpvf>, but also handles 'set' magic.
4710
4711         void    sv_catpvf_mg(SV *sv, const char* pat, ...)
4712
4713 =for hackers
4714 Found in file sv.c
4715
4716 =item sv_catpvn
4717 X<sv_catpvn>
4718
4719 Concatenates the string onto the end of the string which is in the SV.  The
4720 C<len> indicates number of bytes to copy.  If the SV has the UTF-8
4721 status set, then the bytes appended should be valid UTF-8.
4722 Handles 'get' magic, but not 'set' magic.  See C<sv_catpvn_mg>.
4723
4724         void    sv_catpvn(SV* sv, const char* ptr, STRLEN len)
4725
4726 =for hackers
4727 Found in file sv.c
4728
4729 =item sv_catpvn_flags
4730 X<sv_catpvn_flags>
4731
4732 Concatenates the string onto the end of the string which is in the SV.  The
4733 C<len> indicates number of bytes to copy.  If the SV has the UTF-8
4734 status set, then the bytes appended should be valid UTF-8.
4735 If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<dsv> if
4736 appropriate, else not. C<sv_catpvn> and C<sv_catpvn_nomg> are implemented
4737 in terms of this function.
4738
4739         void    sv_catpvn_flags(SV* sv, const char* ptr, STRLEN len, I32 flags)
4740
4741 =for hackers
4742 Found in file sv.c
4743
4744 =item sv_catpvn_nomg
4745 X<sv_catpvn_nomg>
4746
4747 Like C<sv_catpvn> but doesn't process magic.
4748
4749         void    sv_catpvn_nomg(SV* sv, const char* ptr, STRLEN len)
4750
4751 =for hackers
4752 Found in file sv.h
4753
4754 =item sv_catpv_mg
4755 X<sv_catpv_mg>
4756
4757 Like C<sv_catpv>, but also handles 'set' magic.
4758
4759         void    sv_catpv_mg(SV *sv, const char *ptr)
4760
4761 =for hackers
4762 Found in file sv.c
4763
4764 =item sv_catsv
4765 X<sv_catsv>
4766
4767 Concatenates the string from SV C<ssv> onto the end of the string in
4768 SV C<dsv>.  Modifies C<dsv> but not C<ssv>.  Handles 'get' magic, but
4769 not 'set' magic.  See C<sv_catsv_mg>.
4770
4771         void    sv_catsv(SV* dsv, SV* ssv)
4772
4773 =for hackers
4774 Found in file sv.c
4775
4776 =item sv_catsv_flags
4777 X<sv_catsv_flags>
4778
4779 Concatenates the string from SV C<ssv> onto the end of the string in
4780 SV C<dsv>.  Modifies C<dsv> but not C<ssv>.  If C<flags> has C<SV_GMAGIC>
4781 bit set, will C<mg_get> on the SVs if appropriate, else not. C<sv_catsv>
4782 and C<sv_catsv_nomg> are implemented in terms of this function.
4783
4784         void    sv_catsv_flags(SV* dsv, SV* ssv, I32 flags)
4785
4786 =for hackers
4787 Found in file sv.c
4788
4789 =item sv_catsv_nomg
4790 X<sv_catsv_nomg>
4791
4792 Like C<sv_catsv> but doesn't process magic.
4793
4794         void    sv_catsv_nomg(SV* dsv, SV* ssv)
4795
4796 =for hackers
4797 Found in file sv.h
4798
4799 =item sv_chop
4800 X<sv_chop>
4801
4802 Efficient removal of characters from the beginning of the string buffer.
4803 SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside
4804 the string buffer.  The C<ptr> becomes the first character of the adjusted
4805 string. Uses the "OOK hack".
4806 Beware: after this function returns, C<ptr> and SvPVX_const(sv) may no longer
4807 refer to the same chunk of data.
4808
4809         void    sv_chop(SV* sv, const char* ptr)
4810
4811 =for hackers
4812 Found in file sv.c
4813
4814 =item sv_clear
4815 X<sv_clear>
4816
4817 Clear an SV: call any destructors, free up any memory used by the body,
4818 and free the body itself. The SV's head is I<not> freed, although
4819 its type is set to all 1's so that it won't inadvertently be assumed
4820 to be live during global destruction etc.
4821 This function should only be called when REFCNT is zero. Most of the time
4822 you'll want to call C<sv_free()> (or its macro wrapper C<SvREFCNT_dec>)
4823 instead.
4824
4825         void    sv_clear(SV* sv)
4826
4827 =for hackers
4828 Found in file sv.c
4829
4830 =item sv_cmp
4831 X<sv_cmp>
4832
4833 Compares the strings in two SVs.  Returns -1, 0, or 1 indicating whether the
4834 string in C<sv1> is less than, equal to, or greater than the string in
4835 C<sv2>. Is UTF-8 and 'use bytes' aware, handles get magic, and will
4836 coerce its args to strings if necessary.  See also C<sv_cmp_locale>.
4837
4838         I32     sv_cmp(SV* sv1, SV* sv2)
4839
4840 =for hackers
4841 Found in file sv.c
4842
4843 =item sv_cmp_locale
4844 X<sv_cmp_locale>
4845
4846 Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and
4847 'use bytes' aware, handles get magic, and will coerce its args to strings
4848 if necessary.  See also C<sv_cmp_locale>.  See also C<sv_cmp>.
4849
4850         I32     sv_cmp_locale(SV* sv1, SV* sv2)
4851
4852 =for hackers
4853 Found in file sv.c
4854
4855 =item sv_collxfrm
4856 X<sv_collxfrm>
4857
4858 Add Collate Transform magic to an SV if it doesn't already have it.
4859
4860 Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the
4861 scalar data of the variable, but transformed to such a format that a normal
4862 memory comparison can be used to compare the data according to the locale
4863 settings.
4864
4865         char*   sv_collxfrm(SV* sv, STRLEN* nxp)
4866
4867 =for hackers
4868 Found in file sv.c
4869
4870 =item sv_copypv
4871 X<sv_copypv>
4872
4873 Copies a stringified representation of the source SV into the
4874 destination SV.  Automatically performs any necessary mg_get and
4875 coercion of numeric values into strings.  Guaranteed to preserve
4876 UTF-8 flag even from overloaded objects.  Similar in nature to
4877 sv_2pv[_flags] but operates directly on an SV instead of just the
4878 string.  Mostly uses sv_2pv_flags to do its work, except when that
4879 would lose the UTF-8'ness of the PV.
4880
4881         void    sv_copypv(SV* dsv, SV* ssv)
4882
4883 =for hackers
4884 Found in file sv.c
4885
4886 =item sv_dec
4887 X<sv_dec>
4888
4889 Auto-decrement of the value in the SV, doing string to numeric conversion
4890 if necessary. Handles 'get' magic.
4891
4892         void    sv_dec(SV* sv)
4893
4894 =for hackers
4895 Found in file sv.c
4896
4897 =item sv_derived_from
4898 X<sv_derived_from>
4899
4900 Returns a boolean indicating whether the SV is derived from the specified
4901 class.  This is the function that implements C<UNIVERSAL::isa>.  It works
4902 for class names as well as for objects.
4903
4904         bool    sv_derived_from(SV* sv, const char* name)
4905
4906 =for hackers
4907 Found in file universal.c
4908
4909 =item sv_eq
4910 X<sv_eq>
4911
4912 Returns a boolean indicating whether the strings in the two SVs are
4913 identical. Is UTF-8 and 'use bytes' aware, handles get magic, and will
4914 coerce its args to strings if necessary.
4915
4916         I32     sv_eq(SV* sv1, SV* sv2)
4917
4918 =for hackers
4919 Found in file sv.c
4920
4921 =item sv_force_normal_flags
4922 X<sv_force_normal_flags>
4923
4924 Undo various types of fakery on an SV: if the PV is a shared string, make
4925 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
4926 an xpvmg; if we're a copy-on-write scalar, this is the on-write time when
4927 we do the copy, and is also used locally. If C<SV_COW_DROP_PV> is set
4928 then a copy-on-write scalar drops its PV buffer (if any) and becomes
4929 SvPOK_off rather than making a copy. (Used where this scalar is about to be
4930 set to some other value.) In addition, the C<flags> parameter gets passed to
4931 C<sv_unref_flags()> when unrefing. C<sv_force_normal> calls this function
4932 with flags set to 0.
4933
4934         void    sv_force_normal_flags(SV *sv, U32 flags)
4935
4936 =for hackers
4937 Found in file sv.c
4938
4939 =item sv_free
4940 X<sv_free>
4941
4942 Decrement an SV's reference count, and if it drops to zero, call
4943 C<sv_clear> to invoke destructors and free up any memory used by
4944 the body; finally, deallocate the SV's head itself.
4945 Normally called via a wrapper macro C<SvREFCNT_dec>.
4946
4947         void    sv_free(SV* sv)
4948
4949 =for hackers
4950 Found in file sv.c
4951
4952 =item sv_gets
4953 X<sv_gets>
4954
4955 Get a line from the filehandle and store it into the SV, optionally
4956 appending to the currently-stored string.
4957
4958         char*   sv_gets(SV* sv, PerlIO* fp, I32 append)
4959
4960 =for hackers
4961 Found in file sv.c
4962
4963 =item sv_grow
4964 X<sv_grow>
4965
4966 Expands the character buffer in the SV.  If necessary, uses C<sv_unref> and
4967 upgrades the SV to C<SVt_PV>.  Returns a pointer to the character buffer.
4968 Use the C<SvGROW> wrapper instead.
4969
4970         char*   sv_grow(SV* sv, STRLEN newlen)
4971
4972 =for hackers
4973 Found in file sv.c
4974
4975 =item sv_inc
4976 X<sv_inc>
4977
4978 Auto-increment of the value in the SV, doing string to numeric conversion
4979 if necessary. Handles 'get' magic.
4980
4981         void    sv_inc(SV* sv)
4982
4983 =for hackers
4984 Found in file sv.c
4985
4986 =item sv_insert
4987 X<sv_insert>
4988
4989 Inserts a string at the specified offset/length within the SV. Similar to
4990 the Perl substr() function.
4991
4992         void    sv_insert(SV* bigsv, STRLEN offset, STRLEN len, const char* little, STRLEN littlelen)
4993
4994 =for hackers
4995 Found in file sv.c
4996
4997 =item sv_isa
4998 X<sv_isa>
4999
5000 Returns a boolean indicating whether the SV is blessed into the specified
5001 class.  This does not check for subtypes; use C<sv_derived_from> to verify
5002 an inheritance relationship.
5003
5004         int     sv_isa(SV* sv, const char* name)
5005
5006 =for hackers
5007 Found in file sv.c
5008
5009 =item sv_isobject
5010 X<sv_isobject>
5011
5012 Returns a boolean indicating whether the SV is an RV pointing to a blessed
5013 object.  If the SV is not an RV, or if the object is not blessed, then this
5014 will return false.
5015
5016         int     sv_isobject(SV* sv)
5017
5018 =for hackers
5019 Found in file sv.c
5020
5021 =item sv_len
5022 X<sv_len>
5023
5024 Returns the length of the string in the SV. Handles magic and type
5025 coercion.  See also C<SvCUR>, which gives raw access to the xpv_cur slot.
5026
5027         STRLEN  sv_len(SV* sv)
5028
5029 =for hackers
5030 Found in file sv.c
5031
5032 =item sv_len_utf8
5033 X<sv_len_utf8>
5034
5035 Returns the number of characters in the string in an SV, counting wide
5036 UTF-8 bytes as a single character. Handles magic and type coercion.
5037
5038         STRLEN  sv_len_utf8(SV* sv)
5039
5040 =for hackers
5041 Found in file sv.c
5042
5043 =item sv_magic
5044 X<sv_magic>
5045
5046 Adds magic to an SV. First upgrades C<sv> to type C<SVt_PVMG> if necessary,
5047 then adds a new magic item of type C<how> to the head of the magic list.
5048
5049 See C<sv_magicext> (which C<sv_magic> now calls) for a description of the
5050 handling of the C<name> and C<namlen> arguments.
5051
5052 You need to use C<sv_magicext> to add magic to SvREADONLY SVs and also
5053 to add more than one instance of the same 'how'.
5054
5055         void    sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen)
5056
5057 =for hackers
5058 Found in file sv.c
5059
5060 =item sv_magicext
5061 X<sv_magicext>
5062
5063 Adds magic to an SV, upgrading it if necessary. Applies the
5064 supplied vtable and returns a pointer to the magic added.
5065
5066 Note that C<sv_magicext> will allow things that C<sv_magic> will not.
5067 In particular, you can add magic to SvREADONLY SVs, and add more than
5068 one instance of the same 'how'.
5069
5070 If C<namlen> is greater than zero then a C<savepvn> I<copy> of C<name> is
5071 stored, if C<namlen> is zero then C<name> is stored as-is and - as another
5072 special case - if C<(name && namlen == HEf_SVKEY)> then C<name> is assumed
5073 to contain an C<SV*> and is stored as-is with its REFCNT incremented.
5074
5075 (This is now used as a subroutine by C<sv_magic>.)
5076
5077         MAGIC * sv_magicext(SV* sv, SV* obj, int how, const MGVTBL *vtbl, const char* name, I32 namlen)
5078
5079 =for hackers
5080 Found in file sv.c
5081
5082 =item sv_mortalcopy
5083 X<sv_mortalcopy>
5084
5085 Creates a new SV which is a copy of the original SV (using C<sv_setsv>).
5086 The new SV is marked as mortal. It will be destroyed "soon", either by an
5087 explicit call to FREETMPS, or by an implicit call at places such as
5088 statement boundaries.  See also C<sv_newmortal> and C<sv_2mortal>.
5089
5090         SV*     sv_mortalcopy(SV* oldsv)
5091
5092 =for hackers
5093 Found in file sv.c
5094
5095 =item sv_newmortal
5096 X<sv_newmortal>
5097
5098 Creates a new null SV which is mortal.  The reference count of the SV is
5099 set to 1. It will be destroyed "soon", either by an explicit call to
5100 FREETMPS, or by an implicit call at places such as statement boundaries.
5101 See also C<sv_mortalcopy> and C<sv_2mortal>.
5102
5103         SV*     sv_newmortal()
5104
5105 =for hackers
5106 Found in file sv.c
5107
5108 =item sv_newref
5109 X<sv_newref>
5110
5111 Increment an SV's reference count. Use the C<SvREFCNT_inc()> wrapper
5112 instead.
5113
5114         SV*     sv_newref(SV* sv)
5115
5116 =for hackers
5117 Found in file sv.c
5118
5119 =item sv_pos_b2u
5120 X<sv_pos_b2u>
5121
5122 Converts the value pointed to by offsetp from a count of bytes from the
5123 start of the string, to a count of the equivalent number of UTF-8 chars.
5124 Handles magic and type coercion.
5125
5126         void    sv_pos_b2u(SV* sv, I32* offsetp)
5127
5128 =for hackers
5129 Found in file sv.c
5130
5131 =item sv_pos_u2b
5132 X<sv_pos_u2b>
5133
5134 Converts the value pointed to by offsetp from a count of UTF-8 chars from
5135 the start of the string, to a count of the equivalent number of bytes; if
5136 lenp is non-zero, it does the same to lenp, but this time starting from
5137 the offset, rather than from the start of the string. Handles magic and
5138 type coercion.
5139
5140         void    sv_pos_u2b(SV* sv, I32* offsetp, I32* lenp)
5141
5142 =for hackers
5143 Found in file sv.c
5144
5145 =item sv_pvbyten_force
5146 X<sv_pvbyten_force>
5147
5148 The backend for the C<SvPVbytex_force> macro. Always use the macro instead.
5149
5150         char*   sv_pvbyten_force(SV* sv, STRLEN* lp)
5151
5152 =for hackers
5153 Found in file sv.c
5154
5155 =item sv_pvn_force
5156 X<sv_pvn_force>
5157
5158 Get a sensible string out of the SV somehow.
5159 A private implementation of the C<SvPV_force> macro for compilers which
5160 can't cope with complex macro expressions. Always use the macro instead.
5161
5162         char*   sv_pvn_force(SV* sv, STRLEN* lp)
5163
5164 =for hackers
5165 Found in file sv.c
5166
5167 =item sv_pvn_force_flags
5168 X<sv_pvn_force_flags>
5169
5170 Get a sensible string out of the SV somehow.
5171 If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<sv> if
5172 appropriate, else not. C<sv_pvn_force> and C<sv_pvn_force_nomg> are
5173 implemented in terms of this function.
5174 You normally want to use the various wrapper macros instead: see
5175 C<SvPV_force> and C<SvPV_force_nomg>
5176
5177         char*   sv_pvn_force_flags(SV* sv, STRLEN* lp, I32 flags)
5178
5179 =for hackers
5180 Found in file sv.c
5181
5182 =item sv_pvutf8n_force
5183 X<sv_pvutf8n_force>
5184
5185 The backend for the C<SvPVutf8x_force> macro. Always use the macro instead.
5186
5187         char*   sv_pvutf8n_force(SV* sv, STRLEN* lp)
5188
5189 =for hackers
5190 Found in file sv.c
5191
5192 =item sv_reftype
5193 X<sv_reftype>
5194
5195 Returns a string describing what the SV is a reference to.
5196
5197         char*   sv_reftype(const SV* sv, int ob)
5198
5199 =for hackers
5200 Found in file sv.c
5201
5202 =item sv_replace
5203 X<sv_replace>
5204
5205 Make the first argument a copy of the second, then delete the original.
5206 The target SV physically takes over ownership of the body of the source SV
5207 and inherits its flags; however, the target keeps any magic it owns,
5208 and any magic in the source is discarded.
5209 Note that this is a rather specialist SV copying operation; most of the
5210 time you'll want to use C<sv_setsv> or one of its many macro front-ends.
5211
5212         void    sv_replace(SV* sv, SV* nsv)
5213
5214 =for hackers
5215 Found in file sv.c
5216
5217 =item sv_report_used
5218 X<sv_report_used>
5219
5220 Dump the contents of all SVs not yet freed. (Debugging aid).
5221
5222         void    sv_report_used()
5223
5224 =for hackers
5225 Found in file sv.c
5226
5227 =item sv_reset
5228 X<sv_reset>
5229
5230 Underlying implementation for the C<reset> Perl function.
5231 Note that the perl-level function is vaguely deprecated.
5232
5233         void    sv_reset(const char* s, HV* stash)
5234
5235 =for hackers
5236 Found in file sv.c
5237
5238 =item sv_rvweaken
5239 X<sv_rvweaken>
5240
5241 Weaken a reference: set the C<SvWEAKREF> flag on this RV; give the
5242 referred-to SV C<PERL_MAGIC_backref> magic if it hasn't already; and
5243 push a back-reference to this RV onto the array of backreferences
5244 associated with that magic.
5245
5246         SV*     sv_rvweaken(SV *sv)
5247
5248 =for hackers
5249 Found in file sv.c
5250
5251 =item sv_setiv
5252 X<sv_setiv>
5253
5254 Copies an integer into the given SV, upgrading first if necessary.
5255 Does not handle 'set' magic.  See also C<sv_setiv_mg>.
5256
5257         void    sv_setiv(SV* sv, IV num)
5258
5259 =for hackers
5260 Found in file sv.c
5261
5262 =item sv_setiv_mg
5263 X<sv_setiv_mg>
5264
5265 Like C<sv_setiv>, but also handles 'set' magic.
5266
5267         void    sv_setiv_mg(SV *sv, IV i)
5268
5269 =for hackers
5270 Found in file sv.c
5271
5272 =item sv_setnv
5273 X<sv_setnv>
5274
5275 Copies a double into the given SV, upgrading first if necessary.
5276 Does not handle 'set' magic.  See also C<sv_setnv_mg>.
5277
5278         void    sv_setnv(SV* sv, NV num)
5279
5280 =for hackers
5281 Found in file sv.c
5282
5283 =item sv_setnv_mg
5284 X<sv_setnv_mg>
5285
5286 Like C<sv_setnv>, but also handles 'set' magic.
5287
5288         void    sv_setnv_mg(SV *sv, NV num)
5289
5290 =for hackers
5291 Found in file sv.c
5292
5293 =item sv_setpv
5294 X<sv_setpv>
5295
5296 Copies a string into an SV.  The string must be null-terminated.  Does not
5297 handle 'set' magic.  See C<sv_setpv_mg>.
5298
5299         void    sv_setpv(SV* sv, const char* ptr)
5300
5301 =for hackers
5302 Found in file sv.c
5303
5304 =item sv_setpvf
5305 X<sv_setpvf>
5306
5307 Works like C<sv_catpvf> but copies the text into the SV instead of
5308 appending it.  Does not handle 'set' magic.  See C<sv_setpvf_mg>.
5309
5310         void    sv_setpvf(SV* sv, const char* pat, ...)
5311
5312 =for hackers
5313 Found in file sv.c
5314
5315 =item sv_setpvf_mg
5316 X<sv_setpvf_mg>
5317
5318 Like C<sv_setpvf>, but also handles 'set' magic.
5319
5320         void    sv_setpvf_mg(SV *sv, const char* pat, ...)
5321
5322 =for hackers
5323 Found in file sv.c
5324
5325 =item sv_setpviv
5326 X<sv_setpviv>
5327
5328 Copies an integer into the given SV, also updating its string value.
5329 Does not handle 'set' magic.  See C<sv_setpviv_mg>.
5330
5331         void    sv_setpviv(SV* sv, IV num)
5332
5333 =for hackers
5334 Found in file sv.c
5335
5336 =item sv_setpviv_mg
5337 X<sv_setpviv_mg>
5338
5339 Like C<sv_setpviv>, but also handles 'set' magic.
5340
5341         void    sv_setpviv_mg(SV *sv, IV iv)
5342
5343 =for hackers
5344 Found in file sv.c
5345
5346 =item sv_setpvn
5347 X<sv_setpvn>
5348
5349 Copies a string into an SV.  The C<len> parameter indicates the number of
5350 bytes to be copied.  If the C<ptr> argument is NULL the SV will become
5351 undefined.  Does not handle 'set' magic.  See C<sv_setpvn_mg>.
5352
5353         void    sv_setpvn(SV* sv, const char* ptr, STRLEN len)
5354
5355 =for hackers
5356 Found in file sv.c
5357
5358 =item sv_setpvn_mg
5359 X<sv_setpvn_mg>
5360
5361 Like C<sv_setpvn>, but also handles 'set' magic.
5362
5363         void    sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len)
5364
5365 =for hackers
5366 Found in file sv.c
5367
5368 =item sv_setpv_mg
5369 X<sv_setpv_mg>
5370
5371 Like C<sv_setpv>, but also handles 'set' magic.
5372
5373         void    sv_setpv_mg(SV *sv, const char *ptr)
5374
5375 =for hackers
5376 Found in file sv.c
5377
5378 =item sv_setref_iv
5379 X<sv_setref_iv>
5380
5381 Copies an integer into a new SV, optionally blessing the SV.  The C<rv>
5382 argument will be upgraded to an RV.  That RV will be modified to point to
5383 the new SV.  The C<classname> argument indicates the package for the
5384 blessing.  Set C<classname> to C<Nullch> to avoid the blessing.  The new SV
5385 will have a reference count of 1, and the RV will be returned.
5386
5387         SV*     sv_setref_iv(SV* rv, const char* classname, IV iv)
5388
5389 =for hackers
5390 Found in file sv.c
5391
5392 =item sv_setref_nv
5393 X<sv_setref_nv>
5394
5395 Copies a double into a new SV, optionally blessing the SV.  The C<rv>
5396 argument will be upgraded to an RV.  That RV will be modified to point to
5397 the new SV.  The C<classname> argument indicates the package for the
5398 blessing.  Set C<classname> to C<Nullch> to avoid the blessing.  The new SV
5399 will have a reference count of 1, and the RV will be returned.
5400
5401         SV*     sv_setref_nv(SV* rv, const char* classname, NV nv)
5402
5403 =for hackers
5404 Found in file sv.c
5405
5406 =item sv_setref_pv
5407 X<sv_setref_pv>
5408
5409 Copies a pointer into a new SV, optionally blessing the SV.  The C<rv>
5410 argument will be upgraded to an RV.  That RV will be modified to point to
5411 the new SV.  If the C<pv> argument is NULL then C<PL_sv_undef> will be placed
5412 into the SV.  The C<classname> argument indicates the package for the
5413 blessing.  Set C<classname> to C<Nullch> to avoid the blessing.  The new SV
5414 will have a reference count of 1, and the RV will be returned.
5415
5416 Do not use with other Perl types such as HV, AV, SV, CV, because those
5417 objects will become corrupted by the pointer copy process.
5418
5419 Note that C<sv_setref_pvn> copies the string while this copies the pointer.
5420
5421         SV*     sv_setref_pv(SV* rv, const char* classname, void* pv)
5422
5423 =for hackers
5424 Found in file sv.c
5425
5426 =item sv_setref_pvn
5427 X<sv_setref_pvn>
5428
5429 Copies a string into a new SV, optionally blessing the SV.  The length of the
5430 string must be specified with C<n>.  The C<rv> argument will be upgraded to
5431 an RV.  That RV will be modified to point to the new SV.  The C<classname>
5432 argument indicates the package for the blessing.  Set C<classname> to
5433 C<Nullch> to avoid the blessing.  The new SV will have a reference count
5434 of 1, and the RV will be returned.
5435
5436 Note that C<sv_setref_pv> copies the pointer while this copies the string.
5437
5438         SV*     sv_setref_pvn(SV* rv, const char* classname, const char* pv, STRLEN n)
5439
5440 =for hackers
5441 Found in file sv.c
5442
5443 =item sv_setref_uv
5444 X<sv_setref_uv>
5445
5446 Copies an unsigned integer into a new SV, optionally blessing the SV.  The C<rv>
5447 argument will be upgraded to an RV.  That RV will be modified to point to
5448 the new SV.  The C<classname> argument indicates the package for the
5449 blessing.  Set C<classname> to C<Nullch> to avoid the blessing.  The new SV
5450 will have a reference count of 1, and the RV will be returned.
5451
5452         SV*     sv_setref_uv(SV* rv, const char* classname, UV uv)
5453
5454 =for hackers
5455 Found in file sv.c
5456
5457 =item sv_setsv
5458 X<sv_setsv>
5459
5460 Copies the contents of the source SV C<ssv> into the destination SV
5461 C<dsv>.  The source SV may be destroyed if it is mortal, so don't use this
5462 function if the source SV needs to be reused. Does not handle 'set' magic.
5463 Loosely speaking, it performs a copy-by-value, obliterating any previous
5464 content of the destination.
5465
5466 You probably want to use one of the assortment of wrappers, such as
5467 C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and
5468 C<SvSetMagicSV_nosteal>.
5469
5470         void    sv_setsv(SV* dsv, SV* ssv)
5471
5472 =for hackers
5473 Found in file sv.c
5474
5475 =item sv_setsv_flags
5476 X<sv_setsv_flags>
5477
5478 Copies the contents of the source SV C<ssv> into the destination SV
5479 C<dsv>.  The source SV may be destroyed if it is mortal, so don't use this
5480 function if the source SV needs to be reused. Does not handle 'set' magic.
5481 Loosely speaking, it performs a copy-by-value, obliterating any previous
5482 content of the destination.
5483 If the C<flags> parameter has the C<SV_GMAGIC> bit set, will C<mg_get> on
5484 C<ssv> if appropriate, else not. If the C<flags> parameter has the
5485 C<NOSTEAL> bit set then the buffers of temps will not be stolen. <sv_setsv>
5486 and C<sv_setsv_nomg> are implemented in terms of this function.
5487
5488 You probably want to use one of the assortment of wrappers, such as
5489 C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and
5490 C<SvSetMagicSV_nosteal>.
5491
5492 This is the primary function for copying scalars, and most other
5493 copy-ish functions and macros use this underneath.
5494
5495         void    sv_setsv_flags(SV* dsv, SV* ssv, I32 flags)
5496
5497 =for hackers
5498 Found in file sv.c
5499
5500 =item sv_setsv_mg
5501 X<sv_setsv_mg>
5502
5503 Like C<sv_setsv>, but also handles 'set' magic.
5504
5505         void    sv_setsv_mg(SV *dstr, SV *sstr)
5506
5507 =for hackers
5508 Found in file sv.c
5509
5510 =item sv_setsv_nomg
5511 X<sv_setsv_nomg>
5512
5513 Like C<sv_setsv> but doesn't process magic.
5514
5515         void    sv_setsv_nomg(SV* dsv, SV* ssv)
5516
5517 =for hackers
5518 Found in file sv.h
5519
5520 =item sv_setuv
5521 X<sv_setuv>
5522
5523 Copies an unsigned integer into the given SV, upgrading first if necessary.
5524 Does not handle 'set' magic.  See also C<sv_setuv_mg>.
5525
5526         void    sv_setuv(SV* sv, UV num)
5527
5528 =for hackers
5529 Found in file sv.c
5530
5531 =item sv_setuv_mg
5532 X<sv_setuv_mg>
5533
5534 Like C<sv_setuv>, but also handles 'set' magic.
5535
5536         void    sv_setuv_mg(SV *sv, UV u)
5537
5538 =for hackers
5539 Found in file sv.c
5540
5541 =item sv_tainted
5542 X<sv_tainted>
5543
5544 Test an SV for taintedness. Use C<SvTAINTED> instead.
5545         bool    sv_tainted(SV* sv)
5546
5547 =for hackers
5548 Found in file sv.c
5549
5550 =item sv_true
5551 X<sv_true>
5552
5553 Returns true if the SV has a true value by Perl's rules.
5554 Use the C<SvTRUE> macro instead, which may call C<sv_true()> or may
5555 instead use an in-line version.
5556
5557         I32     sv_true(SV *sv)
5558
5559 =for hackers
5560 Found in file sv.c
5561
5562 =item sv_unmagic
5563 X<sv_unmagic>
5564
5565 Removes all magic of type C<type> from an SV.
5566
5567         int     sv_unmagic(SV* sv, int type)
5568
5569 =for hackers
5570 Found in file sv.c
5571
5572 =item sv_unref_flags
5573 X<sv_unref_flags>
5574
5575 Unsets the RV status of the SV, and decrements the reference count of
5576 whatever was being referenced by the RV.  This can almost be thought of
5577 as a reversal of C<newSVrv>.  The C<cflags> argument can contain
5578 C<SV_IMMEDIATE_UNREF> to force the reference count to be decremented
5579 (otherwise the decrementing is conditional on the reference count being
5580 different from one or the reference being a readonly SV).
5581 See C<SvROK_off>.
5582
5583         void    sv_unref_flags(SV* sv, U32 flags)
5584
5585 =for hackers
5586 Found in file sv.c
5587
5588 =item sv_untaint
5589 X<sv_untaint>
5590
5591 Untaint an SV. Use C<SvTAINTED_off> instead.
5592         void    sv_untaint(SV* sv)
5593
5594 =for hackers
5595 Found in file sv.c
5596
5597 =item sv_upgrade
5598 X<sv_upgrade>
5599
5600 Upgrade an SV to a more complex form.  Generally adds a new body type to the
5601 SV, then copies across as much information as possible from the old body.
5602 You generally want to use the C<SvUPGRADE> macro wrapper. See also C<svtype>.
5603
5604         void    sv_upgrade(SV* sv, U32 mt)
5605
5606 =for hackers
5607 Found in file sv.c
5608
5609 =item sv_usepvn
5610 X<sv_usepvn>
5611
5612 Tells an SV to use C<ptr> to find its string value.  Normally the string is
5613 stored inside the SV but sv_usepvn allows the SV to use an outside string.
5614 The C<ptr> should point to memory that was allocated by C<malloc>.  The
5615 string length, C<len>, must be supplied.  This function will realloc the
5616 memory pointed to by C<ptr>, so that pointer should not be freed or used by
5617 the programmer after giving it to sv_usepvn.  Does not handle 'set' magic.
5618 See C<sv_usepvn_mg>.
5619
5620         void    sv_usepvn(SV* sv, char* ptr, STRLEN len)
5621
5622 =for hackers
5623 Found in file sv.c
5624
5625 =item sv_usepvn_mg
5626 X<sv_usepvn_mg>
5627
5628 Like C<sv_usepvn>, but also handles 'set' magic.
5629
5630         void    sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)
5631
5632 =for hackers
5633 Found in file sv.c
5634
5635 =item sv_utf8_decode
5636 X<sv_utf8_decode>
5637
5638 If the PV of the SV is an octet sequence in UTF-8
5639 and contains a multiple-byte character, the C<SvUTF8> flag is turned on
5640 so that it looks like a character. If the PV contains only single-byte
5641 characters, the C<SvUTF8> flag stays being off.
5642 Scans PV for validity and returns false if the PV is invalid UTF-8.
5643
5644 NOTE: this function is experimental and may change or be
5645 removed without notice.
5646
5647         bool    sv_utf8_decode(SV *sv)
5648
5649 =for hackers
5650 Found in file sv.c
5651
5652 =item sv_utf8_downgrade
5653 X<sv_utf8_downgrade>
5654
5655 Attempts to convert the PV of an SV from characters to bytes.
5656 If the PV contains a character beyond byte, this conversion will fail;
5657 in this case, either returns false or, if C<fail_ok> is not
5658 true, croaks.
5659
5660 This is not as a general purpose Unicode to byte encoding interface:
5661 use the Encode extension for that.
5662
5663 NOTE: this function is experimental and may change or be
5664 removed without notice.
5665
5666         bool    sv_utf8_downgrade(SV *sv, bool fail_ok)
5667
5668 =for hackers
5669 Found in file sv.c
5670
5671 =item sv_utf8_encode
5672 X<sv_utf8_encode>
5673
5674 Converts the PV of an SV to UTF-8, but then turns the C<SvUTF8>
5675 flag off so that it looks like octets again.
5676
5677         void    sv_utf8_encode(SV *sv)
5678
5679 =for hackers
5680 Found in file sv.c
5681
5682 =item sv_utf8_upgrade
5683 X<sv_utf8_upgrade>
5684
5685 Converts the PV of an SV to its UTF-8-encoded form.
5686 Forces the SV to string form if it is not already.
5687 Always sets the SvUTF8 flag to avoid future validity checks even
5688 if all the bytes have hibit clear.
5689
5690 This is not as a general purpose byte encoding to Unicode interface:
5691 use the Encode extension for that.
5692
5693         STRLEN  sv_utf8_upgrade(SV *sv)
5694
5695 =for hackers
5696 Found in file sv.c
5697
5698 =item sv_utf8_upgrade_flags
5699 X<sv_utf8_upgrade_flags>
5700
5701 Converts the PV of an SV to its UTF-8-encoded form.
5702 Forces the SV to string form if it is not already.
5703 Always sets the SvUTF8 flag to avoid future validity checks even
5704 if all the bytes have hibit clear. If C<flags> has C<SV_GMAGIC> bit set,
5705 will C<mg_get> on C<sv> if appropriate, else not. C<sv_utf8_upgrade> and
5706 C<sv_utf8_upgrade_nomg> are implemented in terms of this function.
5707
5708 This is not as a general purpose byte encoding to Unicode interface:
5709 use the Encode extension for that.
5710
5711         STRLEN  sv_utf8_upgrade_flags(SV *sv, I32 flags)
5712
5713 =for hackers
5714 Found in file sv.c
5715
5716 =item sv_vcatpvf
5717 X<sv_vcatpvf>
5718
5719 Processes its arguments like C<vsprintf> and appends the formatted output
5720 to an SV.  Does not handle 'set' magic.  See C<sv_vcatpvf_mg>.
5721
5722 Usually used via its frontend C<sv_catpvf>.
5723
5724         void    sv_vcatpvf(SV* sv, const char* pat, va_list* args)
5725
5726 =for hackers
5727 Found in file sv.c
5728
5729 =item sv_vcatpvfn
5730 X<sv_vcatpvfn>
5731
5732 Processes its arguments like C<vsprintf> and appends the formatted output
5733 to an SV.  Uses an array of SVs if the C style variable argument list is
5734 missing (NULL).  When running with taint checks enabled, indicates via
5735 C<maybe_tainted> if results are untrustworthy (often due to the use of
5736 locales).
5737
5738 Usually used via one of its frontends C<sv_vcatpvf> and C<sv_vcatpvf_mg>.
5739
5740         void    sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
5741
5742 =for hackers
5743 Found in file sv.c
5744
5745 =item sv_vcatpvf_mg
5746 X<sv_vcatpvf_mg>
5747
5748 Like C<sv_vcatpvf>, but also handles 'set' magic.
5749
5750 Usually used via its frontend C<sv_catpvf_mg>.
5751
5752         void    sv_vcatpvf_mg(SV* sv, const char* pat, va_list* args)
5753
5754 =for hackers
5755 Found in file sv.c
5756
5757 =item sv_vsetpvf
5758 X<sv_vsetpvf>
5759
5760 Works like C<sv_vcatpvf> but copies the text into the SV instead of
5761 appending it.  Does not handle 'set' magic.  See C<sv_vsetpvf_mg>.
5762
5763 Usually used via its frontend C<sv_setpvf>.
5764
5765         void    sv_vsetpvf(SV* sv, const char* pat, va_list* args)
5766
5767 =for hackers
5768 Found in file sv.c
5769
5770 =item sv_vsetpvfn
5771 X<sv_vsetpvfn>
5772
5773 Works like C<sv_vcatpvfn> but copies the text into the SV instead of
5774 appending it.
5775
5776 Usually used via one of its frontends C<sv_vsetpvf> and C<sv_vsetpvf_mg>.
5777
5778         void    sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
5779
5780 =for hackers
5781 Found in file sv.c
5782
5783 =item sv_vsetpvf_mg
5784 X<sv_vsetpvf_mg>
5785
5786 Like C<sv_vsetpvf>, but also handles 'set' magic.
5787
5788 Usually used via its frontend C<sv_setpvf_mg>.
5789
5790         void    sv_vsetpvf_mg(SV* sv, const char* pat, va_list* args)
5791
5792 =for hackers
5793 Found in file sv.c
5794
5795
5796 =back
5797
5798 =head1 Unicode Support
5799
5800 =over 8
5801
5802 =item bytes_from_utf8
5803 X<bytes_from_utf8>
5804
5805 Converts a string C<s> of length C<len> from UTF-8 into byte encoding.
5806 Unlike C<utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to
5807 the newly-created string, and updates C<len> to contain the new
5808 length.  Returns the original string if no conversion occurs, C<len>
5809 is unchanged. Do nothing if C<is_utf8> points to 0. Sets C<is_utf8> to
5810 0 if C<s> is converted or contains all 7bit characters.
5811
5812 NOTE: this function is experimental and may change or be
5813 removed without notice.
5814
5815         U8*     bytes_from_utf8(const U8 *s, STRLEN *len, bool *is_utf8)
5816
5817 =for hackers
5818 Found in file utf8.c
5819
5820 =item bytes_to_utf8
5821 X<bytes_to_utf8>
5822
5823 Converts a string C<s> of length C<len> from ASCII into UTF-8 encoding.
5824 Returns a pointer to the newly-created string, and sets C<len> to
5825 reflect the new length.
5826
5827 If you want to convert to UTF-8 from other encodings than ASCII,
5828 see sv_recode_to_utf8().
5829
5830 NOTE: this function is experimental and may change or be
5831 removed without notice.
5832
5833         U8*     bytes_to_utf8(const U8 *s, STRLEN *len)
5834
5835 =for hackers
5836 Found in file utf8.c
5837
5838 =item ibcmp_utf8
5839 X<ibcmp_utf8>
5840
5841 Return true if the strings s1 and s2 differ case-insensitively, false
5842 if not (if they are equal case-insensitively).  If u1 is true, the
5843 string s1 is assumed to be in UTF-8-encoded Unicode.  If u2 is true,
5844 the string s2 is assumed to be in UTF-8-encoded Unicode.  If u1 or u2
5845 are false, the respective string is assumed to be in native 8-bit
5846 encoding.
5847
5848 If the pe1 and pe2 are non-NULL, the scanning pointers will be copied
5849 in there (they will point at the beginning of the I<next> character).
5850 If the pointers behind pe1 or pe2 are non-NULL, they are the end
5851 pointers beyond which scanning will not continue under any
5852 circumstances.  If the byte lengths l1 and l2 are non-zero, s1+l1 and
5853 s2+l2 will be used as goal end pointers that will also stop the scan,
5854 and which qualify towards defining a successful match: all the scans
5855 that define an explicit length must reach their goal pointers for
5856 a match to succeed).
5857
5858 For case-insensitiveness, the "casefolding" of Unicode is used
5859 instead of upper/lowercasing both the characters, see
5860 http://www.unicode.org/unicode/reports/tr21/ (Case Mappings).
5861
5862         I32     ibcmp_utf8(const char* a, char **pe1, UV l1, bool u1, const char* b, char **pe2, UV l2, bool u2)
5863
5864 =for hackers
5865 Found in file utf8.c
5866
5867 =item is_utf8_char
5868 X<is_utf8_char>
5869
5870 Tests if some arbitrary number of bytes begins in a valid UTF-8
5871 character.  Note that an INVARIANT (i.e. ASCII) character is a valid
5872 UTF-8 character.  The actual number of bytes in the UTF-8 character
5873 will be returned if it is valid, otherwise 0.
5874
5875         STRLEN  is_utf8_char(const U8 *p)
5876
5877 =for hackers
5878 Found in file utf8.c
5879
5880 =item is_utf8_string
5881 X<is_utf8_string>
5882
5883 Returns true if first C<len> bytes of the given string form a valid
5884 UTF-8 string, false otherwise.  Note that 'a valid UTF-8 string' does
5885 not mean 'a string that contains code points above 0x7F encoded in UTF-8'
5886 because a valid ASCII string is a valid UTF-8 string.
5887
5888 See also is_utf8_string_loclen() and is_utf8_string_loc().
5889
5890         bool    is_utf8_string(const U8 *s, STRLEN len)
5891
5892 =for hackers
5893 Found in file utf8.c
5894
5895 =item is_utf8_string_loc
5896 X<is_utf8_string_loc>
5897
5898 Like is_utf8_string() but stores the location of the failure (in the
5899 case of "utf8ness failure") or the location s+len (in the case of
5900 "utf8ness success") in the C<ep>.
5901
5902 See also is_utf8_string_loclen() and is_utf8_string().
5903
5904         bool    is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **p)
5905
5906 =for hackers
5907 Found in file utf8.c
5908
5909 =item is_utf8_string_loclen
5910 X<is_utf8_string_loclen>
5911
5912 Like is_utf8_string() but stores the location of the failure (in the
5913 case of "utf8ness failure") or the location s+len (in the case of
5914 "utf8ness success") in the C<ep>, and the number of UTF-8
5915 encoded characters in the C<el>.
5916
5917 See also is_utf8_string_loc() and is_utf8_string().
5918
5919         bool    is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el)
5920
5921 =for hackers
5922 Found in file utf8.c
5923
5924 =item pv_uni_display
5925 X<pv_uni_display>
5926
5927 Build to the scalar dsv a displayable version of the string spv,
5928 length len, the displayable version being at most pvlim bytes long
5929 (if longer, the rest is truncated and "..." will be appended).
5930
5931 The flags argument can have UNI_DISPLAY_ISPRINT set to display
5932 isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH
5933 to display the \\[nrfta\\] as the backslashed versions (like '\n')
5934 (UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\).
5935 UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both
5936 UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on.
5937
5938 The pointer to the PV of the dsv is returned.
5939
5940         char*   pv_uni_display(SV *dsv, const U8 *spv, STRLEN len, STRLEN pvlim, UV flags)
5941
5942 =for hackers
5943 Found in file utf8.c
5944
5945 =item sv_cat_decode
5946 X<sv_cat_decode>
5947
5948 The encoding is assumed to be an Encode object, the PV of the ssv is
5949 assumed to be octets in that encoding and decoding the input starts
5950 from the position which (PV + *offset) pointed to.  The dsv will be
5951 concatenated the decoded UTF-8 string from ssv.  Decoding will terminate
5952 when the string tstr appears in decoding output or the input ends on
5953 the PV of the ssv. The value which the offset points will be modified
5954 to the last input position on the ssv.
5955
5956 Returns TRUE if the terminator was found, else returns FALSE.
5957
5958         bool    sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen)
5959
5960 =for hackers
5961 Found in file sv.c
5962
5963 =item sv_recode_to_utf8
5964 X<sv_recode_to_utf8>
5965
5966 The encoding is assumed to be an Encode object, on entry the PV
5967 of the sv is assumed to be octets in that encoding, and the sv
5968 will be converted into Unicode (and UTF-8).
5969
5970 If the sv already is UTF-8 (or if it is not POK), or if the encoding
5971 is not a reference, nothing is done to the sv.  If the encoding is not
5972 an C<Encode::XS> Encoding object, bad things will happen.
5973 (See F<lib/encoding.pm> and L<Encode>).
5974
5975 The PV of the sv is returned.
5976
5977         char*   sv_recode_to_utf8(SV* sv, SV *encoding)
5978
5979 =for hackers
5980 Found in file sv.c
5981
5982 =item sv_uni_display
5983 X<sv_uni_display>
5984
5985 Build to the scalar dsv a displayable version of the scalar sv,
5986 the displayable version being at most pvlim bytes long
5987 (if longer, the rest is truncated and "..." will be appended).
5988
5989 The flags argument is as in pv_uni_display().
5990
5991 The pointer to the PV of the dsv is returned.
5992
5993         char*   sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
5994
5995 =for hackers
5996 Found in file utf8.c
5997
5998 =item to_utf8_case
5999 X<to_utf8_case>
6000
6001 The "p" contains the pointer to the UTF-8 string encoding
6002 the character that is being converted.
6003
6004 The "ustrp" is a pointer to the character buffer to put the
6005 conversion result to.  The "lenp" is a pointer to the length
6006 of the result.
6007
6008 The "swashp" is a pointer to the swash to use.
6009
6010 Both the special and normal mappings are stored lib/unicore/To/Foo.pl,
6011 and loaded by SWASHGET, using lib/utf8_heavy.pl.  The special (usually,
6012 but not always, a multicharacter mapping), is tried first.
6013
6014 The "special" is a string like "utf8::ToSpecLower", which means the
6015 hash %utf8::ToSpecLower.  The access to the hash is through
6016 Perl_to_utf8_case().
6017
6018 The "normal" is a string like "ToLower" which means the swash
6019 %utf8::ToLower.
6020
6021         UV      to_utf8_case(const U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, const char *normal, const char *special)
6022
6023 =for hackers
6024 Found in file utf8.c
6025
6026 =item to_utf8_fold
6027 X<to_utf8_fold>
6028
6029 Convert the UTF-8 encoded character at p to its foldcase version and
6030 store that in UTF-8 in ustrp and its length in bytes in lenp.  Note
6031 that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
6032 foldcase version may be longer than the original character (up to
6033 three characters).
6034
6035 The first character of the foldcased version is returned
6036 (but note, as explained above, that there may be more.)
6037
6038         UV      to_utf8_fold(const U8 *p, U8* ustrp, STRLEN *lenp)
6039
6040 =for hackers
6041 Found in file utf8.c
6042
6043 =item to_utf8_lower
6044 X<to_utf8_lower>
6045
6046 Convert the UTF-8 encoded character at p to its lowercase version and
6047 store that in UTF-8 in ustrp and its length in bytes in lenp.  Note
6048 that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
6049 lowercase version may be longer than the original character.
6050
6051 The first character of the lowercased version is returned
6052 (but note, as explained above, that there may be more.)
6053
6054         UV      to_utf8_lower(const U8 *p, U8* ustrp, STRLEN *lenp)
6055
6056 =for hackers
6057 Found in file utf8.c
6058
6059 =item to_utf8_title
6060 X<to_utf8_title>
6061
6062 Convert the UTF-8 encoded character at p to its titlecase version and
6063 store that in UTF-8 in ustrp and its length in bytes in lenp.  Note
6064 that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
6065 titlecase version may be longer than the original character.
6066
6067 The first character of the titlecased version is returned
6068 (but note, as explained above, that there may be more.)
6069
6070         UV      to_utf8_title(const U8 *p, U8* ustrp, STRLEN *lenp)
6071
6072 =for hackers
6073 Found in file utf8.c
6074
6075 =item to_utf8_upper
6076 X<to_utf8_upper>
6077
6078 Convert the UTF-8 encoded character at p to its uppercase version and
6079 store that in UTF-8 in ustrp and its length in bytes in lenp.  Note
6080 that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since
6081 the uppercase version may be longer than the original character.
6082
6083 The first character of the uppercased version is returned
6084 (but note, as explained above, that there may be more.)
6085
6086         UV      to_utf8_upper(const U8 *p, U8* ustrp, STRLEN *lenp)
6087
6088 =for hackers
6089 Found in file utf8.c
6090
6091 =item utf8n_to_uvchr
6092 X<utf8n_to_uvchr>
6093
6094 flags
6095
6096 Returns the native character value of the first character in the string 
6097 C<s>
6098 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
6099 length, in bytes, of that character.
6100
6101 Allows length and flags to be passed to low level routine.
6102
6103         UV      utf8n_to_uvchr(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
6104
6105 =for hackers
6106 Found in file utf8.c
6107
6108 =item utf8n_to_uvuni
6109 X<utf8n_to_uvuni>
6110
6111 Bottom level UTF-8 decode routine.
6112 Returns the unicode code point value of the first character in the string C<s>
6113 which is assumed to be in UTF-8 encoding and no longer than C<curlen>;
6114 C<retlen> will be set to the length, in bytes, of that character.
6115
6116 If C<s> does not point to a well-formed UTF-8 character, the behaviour
6117 is dependent on the value of C<flags>: if it contains UTF8_CHECK_ONLY,
6118 it is assumed that the caller will raise a warning, and this function
6119 will silently just set C<retlen> to C<-1> and return zero.  If the
6120 C<flags> does not contain UTF8_CHECK_ONLY, warnings about
6121 malformations will be given, C<retlen> will be set to the expected
6122 length of the UTF-8 character in bytes, and zero will be returned.
6123
6124 The C<flags> can also contain various flags to allow deviations from
6125 the strict UTF-8 encoding (see F<utf8.h>).
6126
6127 Most code should use utf8_to_uvchr() rather than call this directly.
6128
6129         UV      utf8n_to_uvuni(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
6130
6131 =for hackers
6132 Found in file utf8.c
6133
6134 =item utf8_distance
6135 X<utf8_distance>
6136
6137 Returns the number of UTF-8 characters between the UTF-8 pointers C<a>
6138 and C<b>.
6139
6140 WARNING: use only if you *know* that the pointers point inside the
6141 same UTF-8 buffer.
6142
6143         IV      utf8_distance(const U8 *a, const U8 *b)
6144
6145 =for hackers
6146 Found in file utf8.c
6147
6148 =item utf8_hop
6149 X<utf8_hop>
6150
6151 Return the UTF-8 pointer C<s> displaced by C<off> characters, either
6152 forward or backward.
6153
6154 WARNING: do not use the following unless you *know* C<off> is within
6155 the UTF-8 data pointed to by C<s> *and* that on entry C<s> is aligned
6156 on the first byte of character or just after the last byte of a character.
6157
6158         U8*     utf8_hop(const U8 *s, I32 off)
6159
6160 =for hackers
6161 Found in file utf8.c
6162
6163 =item utf8_length
6164 X<utf8_length>
6165
6166 Return the length of the UTF-8 char encoded string C<s> in characters.
6167 Stops at C<e> (inclusive).  If C<e E<lt> s> or if the scan would end
6168 up past C<e>, croaks.
6169
6170         STRLEN  utf8_length(const U8* s, const U8 *e)
6171
6172 =for hackers
6173 Found in file utf8.c
6174
6175 =item utf8_to_bytes
6176 X<utf8_to_bytes>
6177
6178 Converts a string C<s> of length C<len> from UTF-8 into byte encoding.
6179 Unlike C<bytes_to_utf8>, this over-writes the original string, and
6180 updates len to contain the new length.
6181 Returns zero on failure, setting C<len> to -1.
6182
6183 NOTE: this function is experimental and may change or be
6184 removed without notice.
6185
6186         U8*     utf8_to_bytes(U8 *s, STRLEN *len)
6187
6188 =for hackers
6189 Found in file utf8.c
6190
6191 =item utf8_to_uvchr
6192 X<utf8_to_uvchr>
6193
6194 Returns the native character value of the first character in the string C<s>
6195 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
6196 length, in bytes, of that character.
6197
6198 If C<s> does not point to a well-formed UTF-8 character, zero is
6199 returned and retlen is set, if possible, to -1.
6200
6201         UV      utf8_to_uvchr(const U8 *s, STRLEN *retlen)
6202
6203 =for hackers
6204 Found in file utf8.c
6205
6206 =item utf8_to_uvuni
6207 X<utf8_to_uvuni>
6208
6209 Returns the Unicode code point of the first character in the string C<s>
6210 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
6211 length, in bytes, of that character.
6212
6213 This function should only be used when returned UV is considered
6214 an index into the Unicode semantic tables (e.g. swashes).
6215
6216 If C<s> does not point to a well-formed UTF-8 character, zero is
6217 returned and retlen is set, if possible, to -1.
6218
6219         UV      utf8_to_uvuni(const U8 *s, STRLEN *retlen)
6220
6221 =for hackers
6222 Found in file utf8.c
6223
6224 =item uvchr_to_utf8
6225 X<uvchr_to_utf8>
6226
6227 Adds the UTF-8 representation of the Native codepoint C<uv> to the end
6228 of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free
6229 bytes available. The return value is the pointer to the byte after the
6230 end of the new character. In other words,
6231
6232     d = uvchr_to_utf8(d, uv);
6233
6234 is the recommended wide native character-aware way of saying
6235
6236     *(d++) = uv;
6237
6238         U8*     uvchr_to_utf8(U8 *d, UV uv)
6239
6240 =for hackers
6241 Found in file utf8.c
6242
6243 =item uvuni_to_utf8_flags
6244 X<uvuni_to_utf8_flags>
6245
6246 Adds the UTF-8 representation of the Unicode codepoint C<uv> to the end
6247 of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free
6248 bytes available. The return value is the pointer to the byte after the
6249 end of the new character. In other words,
6250
6251     d = uvuni_to_utf8_flags(d, uv, flags);
6252
6253 or, in most cases,
6254
6255     d = uvuni_to_utf8(d, uv);
6256
6257 (which is equivalent to)
6258
6259     d = uvuni_to_utf8_flags(d, uv, 0);
6260
6261 is the recommended Unicode-aware way of saying
6262
6263     *(d++) = uv;
6264
6265         U8*     uvuni_to_utf8_flags(U8 *d, UV uv, UV flags)
6266
6267 =for hackers
6268 Found in file utf8.c
6269
6270
6271 =back
6272
6273 =head1 Variables created by C<xsubpp> and C<xsubpp> internal functions
6274
6275 =over 8
6276
6277 =item ax
6278 X<ax>
6279
6280 Variable which is setup by C<xsubpp> to indicate the stack base offset,
6281 used by the C<ST>, C<XSprePUSH> and C<XSRETURN> macros.  The C<dMARK> macro
6282 must be called prior to setup the C<MARK> variable.
6283
6284         I32     ax
6285
6286 =for hackers
6287 Found in file XSUB.h
6288
6289 =item CLASS
6290 X<CLASS>
6291
6292 Variable which is setup by C<xsubpp> to indicate the 
6293 class name for a C++ XS constructor.  This is always a C<char*>.  See C<THIS>.
6294
6295         char*   CLASS
6296
6297 =for hackers
6298 Found in file XSUB.h
6299
6300 =item dAX
6301 X<dAX>
6302
6303 Sets up the C<ax> variable.
6304 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
6305
6306                 dAX;
6307
6308 =for hackers
6309 Found in file XSUB.h
6310
6311 =item dAXMARK
6312 X<dAXMARK>
6313
6314 Sets up the C<ax> variable and stack marker variable C<mark>.
6315 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
6316
6317                 dAXMARK;
6318
6319 =for hackers
6320 Found in file XSUB.h
6321
6322 =item dITEMS
6323 X<dITEMS>
6324
6325 Sets up the C<items> variable.
6326 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
6327
6328                 dITEMS;
6329
6330 =for hackers
6331 Found in file XSUB.h
6332
6333 =item dUNDERBAR
6334 X<dUNDERBAR>
6335
6336 Sets up the C<padoff_du> variable for an XSUB that wishes to use
6337 C<UNDERBAR>.
6338
6339                 dUNDERBAR;
6340
6341 =for hackers
6342 Found in file XSUB.h
6343
6344 =item dXSARGS
6345 X<dXSARGS>
6346
6347 Sets up stack and mark pointers for an XSUB, calling dSP and dMARK.
6348 Sets up the C<ax> and C<items> variables by calling C<dAX> and C<dITEMS>.
6349 This is usually handled automatically by C<xsubpp>.
6350
6351                 dXSARGS;
6352
6353 =for hackers
6354 Found in file XSUB.h
6355
6356 =item dXSI32
6357 X<dXSI32>
6358
6359 Sets up the C<ix> variable for an XSUB which has aliases.  This is usually
6360 handled automatically by C<xsubpp>.
6361
6362                 dXSI32;
6363
6364 =for hackers
6365 Found in file XSUB.h
6366
6367 =item items
6368 X<items>
6369
6370 Variable which is setup by C<xsubpp> to indicate the number of 
6371 items on the stack.  See L<perlxs/"Variable-length Parameter Lists">.
6372
6373         I32     items
6374
6375 =for hackers
6376 Found in file XSUB.h
6377
6378 =item ix
6379 X<ix>
6380
6381 Variable which is setup by C<xsubpp> to indicate which of an 
6382 XSUB's aliases was used to invoke it.  See L<perlxs/"The ALIAS: Keyword">.
6383
6384         I32     ix
6385
6386 =for hackers
6387 Found in file XSUB.h
6388
6389 =item newXSproto
6390 X<newXSproto>
6391
6392 Used by C<xsubpp> to hook up XSUBs as Perl subs.  Adds Perl prototypes to
6393 the subs.
6394
6395 =for hackers
6396 Found in file XSUB.h
6397
6398 =item RETVAL
6399 X<RETVAL>
6400
6401 Variable which is setup by C<xsubpp> to hold the return value for an 
6402 XSUB. This is always the proper type for the XSUB. See 
6403 L<perlxs/"The RETVAL Variable">.
6404
6405         (whatever)      RETVAL
6406
6407 =for hackers
6408 Found in file XSUB.h
6409
6410 =item ST
6411 X<ST>
6412
6413 Used to access elements on the XSUB's stack.
6414
6415         SV*     ST(int ix)
6416
6417 =for hackers
6418 Found in file XSUB.h
6419
6420 =item THIS
6421 X<THIS>
6422
6423 Variable which is setup by C<xsubpp> to designate the object in a C++ 
6424 XSUB.  This is always the proper type for the C++ object.  See C<CLASS> and 
6425 L<perlxs/"Using XS With C++">.
6426
6427         (whatever)      THIS
6428
6429 =for hackers
6430 Found in file XSUB.h
6431
6432 =item UNDERBAR
6433 X<UNDERBAR>
6434
6435 The SV* corresponding to the $_ variable. Works even if there
6436 is a lexical $_ in scope.
6437
6438 =for hackers
6439 Found in file XSUB.h
6440
6441 =item XS
6442 X<XS>
6443
6444 Macro to declare an XSUB and its C parameter list.  This is handled by
6445 C<xsubpp>.
6446
6447 =for hackers
6448 Found in file XSUB.h
6449
6450 =item XS_VERSION
6451 X<XS_VERSION>
6452
6453 The version identifier for an XS module.  This is usually
6454 handled automatically by C<ExtUtils::MakeMaker>.  See C<XS_VERSION_BOOTCHECK>.
6455
6456 =for hackers
6457 Found in file XSUB.h
6458
6459 =item XS_VERSION_BOOTCHECK
6460 X<XS_VERSION_BOOTCHECK>
6461
6462 Macro to verify that a PM module's $VERSION variable matches the XS
6463 module's C<XS_VERSION> variable.  This is usually handled automatically by
6464 C<xsubpp>.  See L<perlxs/"The VERSIONCHECK: Keyword">.
6465
6466                 XS_VERSION_BOOTCHECK;
6467
6468 =for hackers
6469 Found in file XSUB.h
6470
6471
6472 =back
6473
6474 =head1 Warning and Dieing
6475
6476 =over 8
6477
6478 =item croak
6479 X<croak>
6480
6481 This is the XSUB-writer's interface to Perl's C<die> function.
6482 Normally call this function the same way you call the C C<printf>
6483 function.  Calling C<croak> returns control directly to Perl,
6484 sidestepping the normal C order of execution. See C<warn>.
6485
6486 If you want to throw an exception object, assign the object to
6487 C<$@> and then pass C<Nullch> to croak():
6488
6489    errsv = get_sv("@", TRUE);
6490    sv_setsv(errsv, exception_object);
6491    croak(Nullch);
6492
6493         void    croak(const char* pat, ...)
6494
6495 =for hackers
6496 Found in file util.c
6497
6498 =item warn
6499 X<warn>
6500
6501 This is the XSUB-writer's interface to Perl's C<warn> function.  Call this
6502 function the same way you call the C C<printf> function.  See C<croak>.
6503
6504         void    warn(const char* pat, ...)
6505
6506 =for hackers
6507 Found in file util.c
6508
6509
6510 =back
6511
6512 =head1 AUTHORS
6513
6514 Until May 1997, this document was maintained by Jeff Okamoto
6515 <okamoto@corp.hp.com>.  It is now maintained as part of Perl itself.
6516
6517 With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
6518 Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
6519 Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
6520 Stephen McCamant, and Gurusamy Sarathy.
6521
6522 API Listing originally by Dean Roehrich <roehrich@cray.com>.
6523
6524 Updated to be autogenerated from comments in the source by Benjamin Stuhl.
6525
6526 =head1 SEE ALSO
6527
6528 perlguts(1), perlxs(1), perlxstut(1), perlintern(1)
6529