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