This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Devel::PPPort 3.06.
[perl5.git] / ext / Devel / PPPort / PPPort.xs
1 /*******************************************************************************
2 *
3 *  !!!!! Do NOT edit this file directly! -- Edit PPPort_xs.PL instead. !!!!!
4 *
5 ********************************************************************************
6 *
7 *  Perl/Pollution/Portability
8 *
9 ********************************************************************************
10 *
11 *  $Revision: 8 $
12 *  $Author: mhx $
13 *  $Date: 2005/01/31 08:10:55 +0100 $
14 *
15 ********************************************************************************
16 *
17 *  Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz.
18 *  Version 2.x, Copyright (C) 2001, Paul Marquess.
19 *  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
20 *
21 *  This program is free software; you can redistribute it and/or
22 *  modify it under the same terms as Perl itself.
23 *
24 *******************************************************************************/
25
26 /* ========== BEGIN XSHEAD ================================================== */
27
28
29
30 /* =========== END XSHEAD =================================================== */
31
32 #include "EXTERN.h"
33 #include "perl.h"
34 #include "XSUB.h"
35
36 /* ========== BEGIN XSINIT ================================================== */
37
38 /* ---- from parts/inc/call ---- */
39 #define NEED_eval_pv
40
41 /* ---- from parts/inc/grok ---- */
42 #define NEED_grok_number
43 #define NEED_grok_numeric_radix
44 #define NEED_grok_bin
45 #define NEED_grok_hex
46 #define NEED_grok_oct
47
48 /* ---- from parts/inc/newCONSTSUB ---- */
49 #define NEED_newCONSTSUB
50
51 /* ---- from parts/inc/newRV ---- */
52 #define NEED_newRV_noinc
53
54 /* ---- from parts/inc/sv_xpvf ---- */
55 #define NEED_vnewSVpvf
56 #define NEED_sv_catpvf_mg
57 #define NEED_sv_catpvf_mg_nocontext
58 #define NEED_sv_setpvf_mg
59 #define NEED_sv_setpvf_mg_nocontext
60
61 /* ---- from parts/inc/SvPV ---- */
62 #define NEED_sv_2pv_nolen
63 #define NEED_sv_2pvbyte
64
65 /* =========== END XSINIT =================================================== */
66
67 #include "ppport.h"
68
69 /* ========== BEGIN XSMISC ================================================== */
70
71 /* ---- from parts/inc/exception ---- */
72 /* defined in module3.c */
73 int exception(int throw_e);
74
75 /* ---- from parts/inc/misc ---- */
76 XS(XS_Devel__PPPort_dXSTARG);  /* prototype */
77 XS(XS_Devel__PPPort_dXSTARG)
78 {
79   dXSARGS;
80   dXSTARG;
81   IV iv;
82   SP -= items;
83   iv = SvIV(ST(0)) + 1;
84   PUSHi(iv);
85   XSRETURN(1);
86 }
87
88 /* ---- from parts/inc/MY_CXT ---- */
89 #define MY_CXT_KEY "Devel::PPPort::_guts" XS_VERSION
90  
91 typedef struct {
92   /* Put Global Data in here */
93   int dummy;          
94 } my_cxt_t;
95  
96 START_MY_CXT     
97
98 /* ---- from parts/inc/newCONSTSUB ---- */
99 void call_newCONSTSUB_1(void)
100 {
101 #ifdef PERL_NO_GET_CONTEXT
102         dTHX;
103 #endif
104         newCONSTSUB(gv_stashpv("Devel::PPPort", FALSE), "test_value_1", newSViv(1));
105 }
106
107 extern void call_newCONSTSUB_2(void);
108 extern void call_newCONSTSUB_3(void);
109
110 /* ---- from parts/inc/sv_xpvf ---- */
111 static SV * test_vnewSVpvf(pTHX_ const char *pat, ...)
112 {
113   SV *sv;
114   va_list args;
115   va_start(args, pat);
116 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
117   sv = vnewSVpvf(pat, &args);
118 #else
119   sv = newSVpv(pat, 0);
120 #endif
121   va_end(args);
122   return sv;
123 }
124
125 static void test_sv_vcatpvf(pTHX_ SV *sv, const char *pat, ...)
126 {
127   va_list args;
128   va_start(args, pat);
129 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
130   sv_vcatpvf(sv, pat, &args);
131 #else
132   sv_catpv(sv, pat);
133 #endif
134   va_end(args);
135 }
136
137 static void test_sv_vsetpvf(pTHX_ SV *sv, const char *pat, ...)
138 {
139   va_list args;
140   va_start(args, pat);
141 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
142   sv_vsetpvf(sv, pat, &args);
143 #else
144   sv_setpv(sv, pat);
145 #endif
146   va_end(args);
147 }
148
149 /* =========== END XSMISC =================================================== */
150
151 MODULE = Devel::PPPort          PACKAGE = Devel::PPPort
152
153 BOOT:
154         /* ---- from parts/inc/misc ---- */
155         newXS("Devel::PPPort::dXSTARG", XS_Devel__PPPort_dXSTARG, file);
156         
157         /* ---- from parts/inc/MY_CXT ---- */
158         {
159           MY_CXT_INIT;
160           /* If any of the fields in the my_cxt_t struct need
161            * to be initialised, do it here.
162            */
163           MY_CXT.dummy = 42;
164         }
165         
166
167 ##----------------------------------------------------------------------
168 ##  XSUBs from parts/inc/call
169 ##----------------------------------------------------------------------
170
171 I32
172 G_SCALAR()
173         CODE:
174                 RETVAL = G_SCALAR;
175         OUTPUT:
176                 RETVAL
177
178 I32
179 G_ARRAY()
180         CODE:
181                 RETVAL = G_ARRAY;
182         OUTPUT:
183                 RETVAL
184
185 I32
186 G_DISCARD()
187         CODE:
188                 RETVAL = G_DISCARD;
189         OUTPUT:
190                 RETVAL
191
192 void
193 eval_sv(sv, flags)
194         SV* sv
195         I32 flags
196         PREINIT:
197                 I32 i;
198         PPCODE:
199                 PUTBACK;
200                 i = eval_sv(sv, flags);
201                 SPAGAIN;
202                 EXTEND(SP, 1);
203                 PUSHs(sv_2mortal(newSViv(i)));
204
205 void
206 eval_pv(p, croak_on_error)
207         char* p
208         I32 croak_on_error
209         PPCODE:
210                 PUTBACK;
211                 EXTEND(SP, 1);
212                 PUSHs(eval_pv(p, croak_on_error));
213
214 void
215 call_sv(sv, flags, ...)
216         SV* sv
217         I32 flags
218         PREINIT:
219                 I32 i;
220         PPCODE:
221                 for (i=0; i<items-2; i++)
222                   ST(i) = ST(i+2); /* pop first two args */
223                 PUSHMARK(SP);
224                 SP += items - 2;
225                 PUTBACK;
226                 i = call_sv(sv, flags);
227                 SPAGAIN;
228                 EXTEND(SP, 1);
229                 PUSHs(sv_2mortal(newSViv(i)));
230
231 void
232 call_pv(subname, flags, ...)
233         char* subname
234         I32 flags
235         PREINIT:
236                 I32 i;
237         PPCODE:
238                 for (i=0; i<items-2; i++)
239                   ST(i) = ST(i+2); /* pop first two args */
240                 PUSHMARK(SP);
241                 SP += items - 2;
242                 PUTBACK;
243                 i = call_pv(subname, flags);
244                 SPAGAIN;
245                 EXTEND(SP, 1);
246                 PUSHs(sv_2mortal(newSViv(i)));
247
248 void
249 call_argv(subname, flags, ...)
250         char* subname
251         I32 flags
252         PREINIT:
253                 I32 i;
254                 char *args[8];
255         PPCODE:
256                 if (items > 8)  /* play safe */
257                   XSRETURN_UNDEF;
258                 for (i=2; i<items; i++)
259                   args[i-2] = SvPV_nolen(ST(i));
260                 args[items-2] = NULL;
261                 PUTBACK;
262                 i = call_argv(subname, flags, args);
263                 SPAGAIN;
264                 EXTEND(SP, 1);
265                 PUSHs(sv_2mortal(newSViv(i)));
266
267 void
268 call_method(methname, flags, ...)
269         char* methname
270         I32 flags
271         PREINIT:
272                 I32 i;
273         PPCODE:
274                 for (i=0; i<items-2; i++)
275                   ST(i) = ST(i+2); /* pop first two args */
276                 PUSHMARK(SP);
277                 SP += items - 2;
278                 PUTBACK;
279                 i = call_method(methname, flags);
280                 SPAGAIN;
281                 EXTEND(SP, 1);
282                 PUSHs(sv_2mortal(newSViv(i)));
283
284 ##----------------------------------------------------------------------
285 ##  XSUBs from parts/inc/cop
286 ##----------------------------------------------------------------------
287
288 char *
289 CopSTASHPV()
290         CODE:
291                 RETVAL = CopSTASHPV(PL_curcop);
292         OUTPUT:
293                 RETVAL
294
295 char *
296 CopFILE()
297         CODE:
298                 RETVAL = CopFILE(PL_curcop);
299         OUTPUT:
300                 RETVAL
301
302 ##----------------------------------------------------------------------
303 ##  XSUBs from parts/inc/exception
304 ##----------------------------------------------------------------------
305
306 int
307 exception(throw_e)
308   int throw_e
309   OUTPUT:
310     RETVAL
311
312 ##----------------------------------------------------------------------
313 ##  XSUBs from parts/inc/grok
314 ##----------------------------------------------------------------------
315
316 UV
317 grok_number(string)
318         SV *string
319         PREINIT:
320                 const char *pv;
321                 STRLEN len;
322         CODE:
323                 pv = SvPV(string, len);
324                 if (!grok_number(pv, len, &RETVAL))
325                   XSRETURN_UNDEF;
326         OUTPUT:
327                 RETVAL
328
329 UV
330 grok_bin(string)
331         SV *string
332         PREINIT:
333                 char *pv;
334                 I32 flags;
335                 STRLEN len;
336         CODE:
337                 pv = SvPV(string, len);
338                 RETVAL = grok_bin(pv, &len, &flags, NULL);
339         OUTPUT:
340                 RETVAL
341
342 UV
343 grok_hex(string)
344         SV *string
345         PREINIT:
346                 char *pv;
347                 I32 flags;
348                 STRLEN len;
349         CODE:
350                 pv = SvPV(string, len);
351                 RETVAL = grok_hex(pv, &len, &flags, NULL);
352         OUTPUT:
353                 RETVAL
354
355 UV
356 grok_oct(string)
357         SV *string
358         PREINIT:
359                 char *pv;
360                 I32 flags;
361                 STRLEN len;
362         CODE:
363                 pv = SvPV(string, len);
364                 RETVAL = grok_oct(pv, &len, &flags, NULL);
365         OUTPUT:
366                 RETVAL
367
368 UV
369 Perl_grok_number(string)
370         SV *string
371         PREINIT:
372                 const char *pv;
373                 STRLEN len;
374         CODE:
375                 pv = SvPV(string, len);
376                 if (!Perl_grok_number(aTHX_ pv, len, &RETVAL))
377                   XSRETURN_UNDEF;
378         OUTPUT:
379                 RETVAL
380
381 UV
382 Perl_grok_bin(string)
383         SV *string
384         PREINIT:
385                 char *pv;
386                 I32 flags;
387                 STRLEN len;
388         CODE:
389                 pv = SvPV(string, len);
390                 RETVAL = Perl_grok_bin(aTHX_ pv, &len, &flags, NULL);
391         OUTPUT:
392                 RETVAL
393
394 UV
395 Perl_grok_hex(string)
396         SV *string
397         PREINIT:
398                 char *pv;
399                 I32 flags;
400                 STRLEN len;
401         CODE:
402                 pv = SvPV(string, len);
403                 RETVAL = Perl_grok_hex(aTHX_ pv, &len, &flags, NULL);
404         OUTPUT:
405                 RETVAL
406
407 UV
408 Perl_grok_oct(string)
409         SV *string
410         PREINIT:
411                 char *pv;
412                 I32 flags;
413                 STRLEN len;
414         CODE:
415                 pv = SvPV(string, len);
416                 RETVAL = Perl_grok_oct(aTHX_ pv, &len, &flags, NULL);
417         OUTPUT:
418                 RETVAL
419
420 ##----------------------------------------------------------------------
421 ##  XSUBs from parts/inc/limits
422 ##----------------------------------------------------------------------
423
424 IV
425 iv_size()
426         CODE:
427                 RETVAL = IVSIZE == sizeof(IV);
428         OUTPUT:
429                 RETVAL
430
431 IV
432 uv_size()
433         CODE:
434                 RETVAL = UVSIZE == sizeof(UV);
435         OUTPUT:
436                 RETVAL
437
438 IV
439 iv_type()
440         CODE:
441                 RETVAL = sizeof(IVTYPE) == sizeof(IV);
442         OUTPUT:
443                 RETVAL
444
445 IV
446 uv_type()
447         CODE:
448                 RETVAL = sizeof(UVTYPE) == sizeof(UV);
449         OUTPUT:
450                 RETVAL
451
452 ##----------------------------------------------------------------------
453 ##  XSUBs from parts/inc/magic
454 ##----------------------------------------------------------------------
455
456 void
457 sv_catpv_mg(sv, string)
458         SV *sv;
459         char *string;
460         CODE:
461                 sv_catpv_mg(sv, string);
462
463 void
464 sv_catpvn_mg(sv, sv2)
465         SV *sv;
466         SV *sv2;
467         PREINIT:
468                 char *str;
469                 STRLEN len;
470         CODE:
471                 str = SvPV(sv2, len);
472                 sv_catpvn_mg(sv, str, len);
473
474 void
475 sv_catsv_mg(sv, sv2)
476         SV *sv;
477         SV *sv2;
478         CODE:
479                 sv_catsv_mg(sv, sv2);
480
481 void
482 sv_setiv_mg(sv, iv)
483         SV *sv;
484         IV iv;
485         CODE:
486                 sv_setiv_mg(sv, iv);
487
488 void
489 sv_setnv_mg(sv, nv)
490         SV *sv;
491         NV nv;
492         CODE:
493                 sv_setnv_mg(sv, nv);
494
495 void
496 sv_setpv_mg(sv, pv)
497         SV *sv;
498         char *pv;
499         CODE:
500                 sv_setpv_mg(sv, pv);
501
502 void
503 sv_setpvn_mg(sv, sv2)
504         SV *sv;
505         SV *sv2;
506         PREINIT:
507                 char *str;
508                 STRLEN len;
509         CODE:
510                 str = SvPV(sv2, len);
511                 sv_setpvn_mg(sv, str, len);
512
513 void
514 sv_setsv_mg(sv, sv2)
515         SV *sv;
516         SV *sv2;
517         CODE:
518                 sv_setsv_mg(sv, sv2);
519
520 void
521 sv_setuv_mg(sv, uv)
522         SV *sv;
523         UV uv;
524         CODE:
525                 sv_setuv_mg(sv, uv);
526
527 void
528 sv_usepvn_mg(sv, sv2)
529         SV *sv;
530         SV *sv2;
531         PREINIT:
532                 char *str, *copy;
533                 STRLEN len;
534         CODE:
535                 str = SvPV(sv2, len);
536                 New(42, copy, len+1, char);
537                 Copy(str, copy, len+1, char);
538                 sv_usepvn_mg(sv, copy, len);
539
540 ##----------------------------------------------------------------------
541 ##  XSUBs from parts/inc/misc
542 ##----------------------------------------------------------------------
543
544 int
545 gv_stashpvn(name, create)
546         char *name
547         I32 create
548         CODE:
549                 RETVAL = gv_stashpvn(name, strlen(name), create) != NULL;
550         OUTPUT:
551                 RETVAL
552
553 int
554 get_sv(name, create)
555         char *name
556         I32 create
557         CODE:
558                 RETVAL = get_sv(name, create) != NULL;
559         OUTPUT:
560                 RETVAL
561
562 int
563 get_av(name, create)
564         char *name
565         I32 create
566         CODE:
567                 RETVAL = get_av(name, create) != NULL;
568         OUTPUT:
569                 RETVAL
570
571 int
572 get_hv(name, create)
573         char *name
574         I32 create
575         CODE:
576                 RETVAL = get_hv(name, create) != NULL;
577         OUTPUT:
578                 RETVAL
579
580 int
581 get_cv(name, create)
582         char *name
583         I32 create
584         CODE:
585                 RETVAL = get_cv(name, create) != NULL;
586         OUTPUT:
587                 RETVAL
588
589 void
590 newSVpvn()
591         PPCODE:
592                 XPUSHs(newSVpvn("test", 4));
593                 XPUSHs(newSVpvn("test", 2));
594                 XPUSHs(newSVpvn("test", 0));
595                 XPUSHs(newSVpvn(NULL, 2));
596                 XPUSHs(newSVpvn(NULL, 0));
597                 XSRETURN(5);
598
599 SV *
600 PL_sv_undef()
601         CODE:
602                 RETVAL = newSVsv(&PL_sv_undef);
603         OUTPUT:
604                 RETVAL
605
606 SV *
607 PL_sv_yes()
608         CODE:
609                 RETVAL = newSVsv(&PL_sv_yes);
610         OUTPUT:
611                 RETVAL
612
613 SV *
614 PL_sv_no()
615         CODE:
616                 RETVAL = newSVsv(&PL_sv_no);
617         OUTPUT:
618                 RETVAL
619
620 int
621 PL_na(string)
622         char *string
623         CODE:
624                 PL_na = strlen(string);
625                 RETVAL = PL_na;
626         OUTPUT:
627                 RETVAL
628
629 SV*
630 boolSV(value)
631         int value
632         CODE:
633                 RETVAL = newSVsv(boolSV(value));
634         OUTPUT:
635                 RETVAL
636
637 SV*
638 DEFSV()
639         CODE:
640                 RETVAL = newSVsv(DEFSV);
641         OUTPUT:
642                 RETVAL
643
644 int
645 ERRSV()
646         CODE:
647                 RETVAL = SvTRUE(ERRSV);
648         OUTPUT:
649                 RETVAL
650
651 SV*
652 UNDERBAR()
653         CODE:
654                 {
655                   dUNDERBAR;
656                   RETVAL = newSVsv(UNDERBAR);
657                 }
658         OUTPUT:
659                 RETVAL
660
661 ##----------------------------------------------------------------------
662 ##  XSUBs from parts/inc/mPUSH
663 ##----------------------------------------------------------------------
664
665 void
666 mPUSHp()
667         PPCODE:
668         EXTEND(SP, 3);
669         mPUSHp("one", 3);
670         mPUSHp("two", 3);
671         mPUSHp("three", 5);
672         XSRETURN(3);
673
674 void
675 mPUSHn()
676         PPCODE:
677         EXTEND(SP, 3);
678         mPUSHn(0.5);
679         mPUSHn(-0.25);
680         mPUSHn(0.125);
681         XSRETURN(3);
682
683 void
684 mPUSHi()
685         PPCODE:
686         EXTEND(SP, 3);
687         mPUSHi(-1);
688         mPUSHi(2);
689         mPUSHi(-3);
690         XSRETURN(3);
691
692 void
693 mPUSHu()
694         PPCODE:
695         EXTEND(SP, 3);
696         mPUSHu(1);
697         mPUSHu(2);
698         mPUSHu(3);
699         XSRETURN(3);
700
701 void
702 mXPUSHp()
703         PPCODE:
704         mXPUSHp("one", 3);
705         mXPUSHp("two", 3);
706         mXPUSHp("three", 5);
707         XSRETURN(3);
708
709 void
710 mXPUSHn()
711         PPCODE:
712         mXPUSHn(0.5);
713         mXPUSHn(-0.25);
714         mXPUSHn(0.125);
715         XSRETURN(3);
716
717 void
718 mXPUSHi()
719         PPCODE:
720         mXPUSHi(-1);
721         mXPUSHi(2);
722         mXPUSHi(-3);
723         XSRETURN(3);
724
725 void
726 mXPUSHu()
727         PPCODE:
728         mXPUSHu(1);
729         mXPUSHu(2);
730         mXPUSHu(3);
731         XSRETURN(3);
732
733 ##----------------------------------------------------------------------
734 ##  XSUBs from parts/inc/MY_CXT
735 ##----------------------------------------------------------------------
736
737 int
738 MY_CXT_1()
739         CODE:
740                 dMY_CXT;
741                 RETVAL = MY_CXT.dummy == 42;
742                 ++MY_CXT.dummy;
743         OUTPUT:
744                 RETVAL
745
746 int
747 MY_CXT_2()
748         CODE:
749                 dMY_CXT;
750                 RETVAL = MY_CXT.dummy == 43;
751         OUTPUT:
752                 RETVAL
753
754 int
755 MY_CXT_CLONE()
756         CODE:
757                 MY_CXT_CLONE;
758                 RETVAL = 42;
759         OUTPUT:
760                 RETVAL
761
762 ##----------------------------------------------------------------------
763 ##  XSUBs from parts/inc/newCONSTSUB
764 ##----------------------------------------------------------------------
765
766 void
767 call_newCONSTSUB_1()
768
769 void
770 call_newCONSTSUB_2()
771
772 void
773 call_newCONSTSUB_3()
774
775 ##----------------------------------------------------------------------
776 ##  XSUBs from parts/inc/newRV
777 ##----------------------------------------------------------------------
778
779 U32
780 newRV_inc_REFCNT()
781         PREINIT:
782                 SV *sv, *rv;
783         CODE:
784                 sv = newSViv(42);
785                 rv = newRV_inc(sv);
786                 SvREFCNT_dec(sv);
787                 RETVAL = SvREFCNT(sv);
788                 sv_2mortal(rv);
789         OUTPUT:
790                 RETVAL
791
792 U32
793 newRV_noinc_REFCNT()
794         PREINIT:
795                 SV *sv, *rv;
796         CODE:
797                 sv = newSViv(42);
798                 rv = newRV_noinc(sv);
799                 RETVAL = SvREFCNT(sv);
800                 sv_2mortal(rv);
801         OUTPUT:
802                 RETVAL
803
804 ##----------------------------------------------------------------------
805 ##  XSUBs from parts/inc/sv_xpvf
806 ##----------------------------------------------------------------------
807
808 SV *
809 vnewSVpvf()
810         CODE:
811                 RETVAL = test_vnewSVpvf(aTHX_ "%s-%d", "Perl", 42);
812         OUTPUT:
813                 RETVAL
814
815 SV *
816 sv_vcatpvf(sv)
817         SV *sv
818         CODE:
819                 RETVAL = newSVsv(sv);
820                 test_sv_vcatpvf(aTHX_ RETVAL, "%s-%d", "Perl", 42);
821         OUTPUT:
822                 RETVAL
823
824 SV *
825 sv_vsetpvf(sv)
826         SV *sv
827         CODE:
828                 RETVAL = newSVsv(sv);
829                 test_sv_vsetpvf(aTHX_ RETVAL, "%s-%d", "Perl", 42);
830         OUTPUT:
831                 RETVAL
832
833 void
834 sv_catpvf_mg(sv)
835         SV *sv
836         CODE:
837 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
838                 sv_catpvf_mg(sv, "%s-%d", "Perl", 42);
839 #endif
840
841 void
842 Perl_sv_catpvf_mg(sv)
843         SV *sv
844         CODE:
845 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
846                 Perl_sv_catpvf_mg(aTHX_ sv, "%s-%d", "-Perl", 43);
847 #endif
848
849 void
850 sv_catpvf_mg_nocontext(sv)
851         SV *sv
852         CODE:
853 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
854 #ifdef PERL_IMPLICIT_CONTEXT
855                 sv_catpvf_mg_nocontext(sv, "%s-%d", "-Perl", 44);
856 #else
857                 sv_catpvf_mg(sv, "%s-%d", "-Perl", 44);
858 #endif
859 #endif
860
861 void
862 sv_setpvf_mg(sv)
863         SV *sv
864         CODE:
865 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
866                 sv_setpvf_mg(sv, "%s-%d", "mhx", 42);
867 #endif
868
869 void
870 Perl_sv_setpvf_mg(sv)
871         SV *sv
872         CODE:
873 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
874                 Perl_sv_setpvf_mg(aTHX_ sv, "%s-%d", "foo", 43);
875 #endif
876
877 void
878 sv_setpvf_mg_nocontext(sv)
879         SV *sv
880         CODE:
881 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0)))
882 #ifdef PERL_IMPLICIT_CONTEXT
883                 sv_setpvf_mg_nocontext(sv, "%s-%d", "bar", 44);
884 #else
885                 sv_setpvf_mg(sv, "%s-%d", "bar", 44);
886 #endif
887 #endif
888
889 ##----------------------------------------------------------------------
890 ##  XSUBs from parts/inc/SvPV
891 ##----------------------------------------------------------------------
892
893 IV
894 SvPVbyte(sv)
895         SV *sv
896         PREINIT:
897                 STRLEN len;
898                 const char *str;
899         CODE:
900                 str = SvPVbyte(sv, len);
901                 RETVAL = strEQ(str, "mhx") ? len : -1;
902         OUTPUT:
903                 RETVAL
904
905 IV
906 SvPV_nolen(sv)
907         SV *sv
908         PREINIT:
909                 const char *str;
910         CODE:
911                 str = SvPV_nolen(sv);
912                 RETVAL = strEQ(str, "mhx") ? 42 : 0;
913         OUTPUT:
914                 RETVAL
915
916 ##----------------------------------------------------------------------
917 ##  XSUBs from parts/inc/threads
918 ##----------------------------------------------------------------------
919
920 IV
921 no_THX_arg(sv)
922         SV *sv
923         CODE:
924                 RETVAL = 1 + sv_2iv(sv);
925         OUTPUT:
926                 RETVAL
927
928 void
929 with_THX_arg(error)
930         char *error
931         PPCODE:
932                 Perl_croak(aTHX_ "%s", error);
933
934 ##----------------------------------------------------------------------
935 ##  XSUBs from parts/inc/uv
936 ##----------------------------------------------------------------------
937
938 SV *
939 sv_setuv(uv)
940         UV uv
941         CODE:
942                 RETVAL = newSViv(1);
943                 sv_setuv(RETVAL, uv);
944         OUTPUT:
945                 RETVAL
946
947 SV *
948 newSVuv(uv)
949         UV uv
950         CODE:
951                 RETVAL = newSVuv(uv);
952         OUTPUT:
953                 RETVAL
954
955 UV
956 sv_2uv(sv)
957         SV *sv
958         CODE:
959                 RETVAL = sv_2uv(sv);
960         OUTPUT:
961                 RETVAL
962
963 UV
964 SvUVx(sv)
965         SV *sv
966         CODE:
967                 sv--;
968                 RETVAL = SvUVx(++sv);
969         OUTPUT:
970                 RETVAL
971
972 void
973 XSRETURN_UV()
974         PPCODE:
975                 XSRETURN_UV(42);
976
977 void
978 PUSHu()
979         PREINIT:
980                 dTARG;
981         PPCODE:
982                 TARG = sv_newmortal();
983                 EXTEND(SP, 1);
984                 PUSHu(42);
985                 XSRETURN(1);
986
987 void
988 XPUSHu()
989         PREINIT:
990                 dTARG;
991         PPCODE:
992                 TARG = sv_newmortal();
993                 XPUSHu(43);
994                 XSRETURN(1);