3 * Copyright (C) 2005, by Larry Wall and others
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "Anything that Hobbits had no immediate use for, but were unwilling to
12 * throw away, they called a mathom. Their dwellings were apt to become
13 * rather crowded with mathoms, and many of the presents that passed from
14 * hand to hand were of that sort."
18 * This file contains mathoms, various binary artifacts from previous
19 * versions of Perl. For binary or source compatibility reasons, though,
20 * we cannot completely remove them from the core code.
27 #define PERL_IN_MATHOMS_C
30 /* ref() is now a macro using Perl_doref;
31 * this version provided for binary compatibility only.
34 Perl_ref(pTHX_ OP *o, I32 type)
36 return doref(o, type, TRUE);
42 Unsets the RV status of the SV, and decrements the reference count of
43 whatever was being referenced by the RV. This can almost be thought of
44 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
45 being zero. See C<SvROK_off>.
51 Perl_sv_unref(pTHX_ SV *sv)
53 sv_unref_flags(sv, 0);
59 Taint an SV. Use C<SvTAINTED_on> instead.
64 Perl_sv_taint(pTHX_ SV *sv)
66 sv_magic((sv), Nullsv, PERL_MAGIC_taint, Nullch, 0);
69 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
70 * this function provided for binary compatibility only
74 Perl_sv_2iv(pTHX_ register SV *sv)
76 return sv_2iv_flags(sv, SV_GMAGIC);
79 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
80 * this function provided for binary compatibility only
84 Perl_sv_2uv(pTHX_ register SV *sv)
86 return sv_2uv_flags(sv, SV_GMAGIC);
89 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
90 * this function provided for binary compatibility only
94 Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp)
96 return sv_2pv_flags(sv, lp, SV_GMAGIC);
100 =for apidoc sv_2pv_nolen
102 Like C<sv_2pv()>, but doesn't return the length too. You should usually
103 use the macro wrapper C<SvPV_nolen(sv)> instead.
108 Perl_sv_2pv_nolen(pTHX_ register SV *sv)
110 return sv_2pv(sv, 0);
114 =for apidoc sv_2pvbyte_nolen
116 Return a pointer to the byte-encoded representation of the SV.
117 May cause the SV to be downgraded from UTF-8 as a side-effect.
119 Usually accessed via the C<SvPVbyte_nolen> macro.
125 Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv)
127 return sv_2pvbyte(sv, 0);
131 =for apidoc sv_2pvutf8_nolen
133 Return a pointer to the UTF-8-encoded representation of the SV.
134 May cause the SV to be upgraded to UTF-8 as a side-effect.
136 Usually accessed via the C<SvPVutf8_nolen> macro.
142 Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv)
144 return sv_2pvutf8(sv, 0);
148 =for apidoc sv_force_normal
150 Undo various types of fakery on an SV: if the PV is a shared string, make
151 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
152 an xpvmg. See also C<sv_force_normal_flags>.
158 Perl_sv_force_normal(pTHX_ register SV *sv)
160 sv_force_normal_flags(sv, 0);
163 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
164 * this function provided for binary compatibility only
168 Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
170 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
173 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
174 * this function provided for binary compatibility only
178 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
180 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
184 =for apidoc sv_catpvn_mg
186 Like C<sv_catpvn>, but also handles 'set' magic.
192 Perl_sv_catpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len)
194 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
197 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
198 * this function provided for binary compatibility only
202 Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr)
204 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
208 =for apidoc sv_catsv_mg
210 Like C<sv_catsv>, but also handles 'set' magic.
216 Perl_sv_catsv_mg(pTHX_ SV *dsv, register SV *ssv)
218 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
224 A private implementation of the C<SvIVx> macro for compilers which can't
225 cope with complex macro expressions. Always use the macro instead.
231 Perl_sv_iv(pTHX_ register SV *sv)
235 return (IV)SvUVX(sv);
244 A private implementation of the C<SvUVx> macro for compilers which can't
245 cope with complex macro expressions. Always use the macro instead.
251 Perl_sv_uv(pTHX_ register SV *sv)
256 return (UV)SvIVX(sv);
264 A private implementation of the C<SvNVx> macro for compilers which can't
265 cope with complex macro expressions. Always use the macro instead.
271 Perl_sv_nv(pTHX_ register SV *sv)
281 Use the C<SvPV_nolen> macro instead
285 A private implementation of the C<SvPV> macro for compilers which can't
286 cope with complex macro expressions. Always use the macro instead.
292 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
298 return sv_2pv(sv, lp);
303 Perl_sv_pvn_nomg(pTHX_ register SV *sv, STRLEN *lp)
309 return sv_2pv_flags(sv, lp, 0);
312 /* sv_pv() is now a macro using SvPV_nolen();
313 * this function provided for binary compatibility only
317 Perl_sv_pv(pTHX_ SV *sv)
322 return sv_2pv(sv, 0);
325 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
326 * this function provided for binary compatibility only
330 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
332 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
335 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
336 * this function provided for binary compatibility only
340 Perl_sv_pvbyte(pTHX_ SV *sv)
342 sv_utf8_downgrade(sv,0);
347 =for apidoc sv_pvbyte
349 Use C<SvPVbyte_nolen> instead.
351 =for apidoc sv_pvbyten
353 A private implementation of the C<SvPVbyte> macro for compilers
354 which can't cope with complex macro expressions. Always use the macro
361 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
363 sv_utf8_downgrade(sv,0);
364 return sv_pvn(sv,lp);
367 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
368 * this function provided for binary compatibility only
372 Perl_sv_pvutf8(pTHX_ SV *sv)
379 =for apidoc sv_pvutf8
381 Use the C<SvPVutf8_nolen> macro instead
383 =for apidoc sv_pvutf8n
385 A private implementation of the C<SvPVutf8> macro for compilers
386 which can't cope with complex macro expressions. Always use the macro
393 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
396 return sv_pvn(sv,lp);
399 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
400 * this function provided for binary compatibility only
404 Perl_sv_utf8_upgrade(pTHX_ register SV *sv)
406 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
410 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
414 va_start(arglist, format);
415 return PerlIO_vprintf(stream, format, arglist);
419 Perl_printf_nocontext(const char *format, ...)
423 va_start(arglist, format);
424 return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
427 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
429 * This hack is to force load of "huge" support from libm.a
430 * So it is in perl for (say) POSIX to use.
431 * Needed for SunOS with Sun's 'acc' for example.
436 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
443 /* compatibility with versions <= 5.003. */
445 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
447 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
450 /* compatibility with versions <= 5.003. */
452 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
454 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
458 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
460 gv_fullname4(sv, gv, prefix, TRUE);
464 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
466 gv_efullname4(sv, gv, prefix, TRUE);
470 =for apidoc gv_fetchmethod
472 See L<gv_fetchmethod_autoload>.
478 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
480 return gv_fetchmethod_autoload(stash, name, TRUE);
484 Perl_hv_iternext(pTHX_ HV *hv)
486 return hv_iternext_flags(hv, 0);
490 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
492 sv_magic((SV*)hv, (SV*)gv, how, Nullch, 0);
495 #if 0 /* use the macro from hv.h instead */
498 Perl_sharepvn(pTHX_ const char *sv, I32 len, U32 hash)
500 return HEK_KEY(share_hek(sv, len, hash));
506 Perl_av_fake(pTHX_ register I32 size, register SV **strp)
509 register AV * const av = (AV*)NEWSV(9,0);
511 sv_upgrade((SV *)av, SVt_PVAV);
512 Newx(ary,size+1,SV*);
514 Copy(strp,ary,size,SV*);
516 SvPV_set(av, (char*)ary);
517 AvFILLp(av) = size - 1;
518 AvMAX(av) = size - 1;
528 Perl_do_open(pTHX_ GV *gv, register const char *name, I32 len, int as_raw,
529 int rawmode, int rawperm, PerlIO *supplied_fp)
531 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
532 supplied_fp, (SV **) NULL, 0);
536 Perl_do_open9(pTHX_ GV *gv, register const char *name, I32 len, int
538 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
541 PERL_UNUSED_ARG(num_svs);
542 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
543 supplied_fp, &svs, 1);
547 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
549 /* The old body of this is now in non-LAYER part of perlio.c
550 * This is a stub for any XS code which might have been calling it.
552 const char *name = ":raw";
553 #ifdef PERLIO_USING_CRLF
554 if (!(mode & O_BINARY))
557 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
562 Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp)
564 return do_aexec5(really, mark, sp, 0, 0);
568 #ifdef PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION
570 Perl_do_exec(pTHX_ const char *cmd)
572 return do_exec3(cmd,0,0);
578 Perl_do_pipe(pTHX_ SV *sv, GV *rgv, GV *wgv)
597 if (PerlProc_pipe(fd) < 0)
599 IoIFP(rstio) = PerlIO_fdopen(fd[0], "r"PIPE_OPEN_MODE);
600 IoOFP(wstio) = PerlIO_fdopen(fd[1], "w"PIPE_OPEN_MODE);
601 IoOFP(rstio) = IoIFP(rstio);
602 IoIFP(wstio) = IoOFP(wstio);
603 IoTYPE(rstio) = IoTYPE_RDONLY;
604 IoTYPE(wstio) = IoTYPE_WRONLY;
605 if (!IoIFP(rstio) || !IoOFP(wstio)) {
606 if (IoIFP(rstio)) PerlIO_close(IoIFP(rstio));
607 else PerlLIO_close(fd[0]);
608 if (IoOFP(wstio)) PerlIO_close(IoOFP(wstio));
609 else PerlLIO_close(fd[1]);
613 sv_setsv(sv,&PL_sv_yes);
617 sv_setsv(sv,&PL_sv_undef);
622 /* Backwards compatibility. */
624 Perl_init_i18nl14n(pTHX_ int printwarn)
626 return init_i18nl10n(printwarn);
629 /* XXX kept for BINCOMPAT only */
631 Perl_save_hints(pTHX)
633 Perl_croak(aTHX_ "internal error: obsolete function save_hints() called");
638 Perl_ck_retarget(pTHX_ OP *o)
640 Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
647 Perl_oopsCV(pTHX_ OP *o)
649 Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
652 NORETURN_FUNCTION_END;
657 DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
662 DIE(aTHX_ "tried to access per-thread data in non-threaded perl");
667 DIE(aTHX_ "panic: mapstart"); /* uses grepstart */
670 /* These ops all have the same body as pp_null. */
691 /* Ops that are calls to do_kv. */
702 /* Ops that are simply calls to other ops. */
741 return pp_ssockopt();
746 return pp_getpeername();
756 return pp_ftrowned();
781 return pp_shmwrite();
796 return pp_ghostent();
801 return pp_ghostent();
816 return pp_gprotoent();
821 return pp_gprotoent();
826 return pp_gservent();
831 return pp_gservent();
876 return pp_ftrowned();
881 return pp_ftrowned();
886 return pp_ftrowned();
891 return pp_ftrowned();
896 return pp_ftrowned();
901 return pp_ftrowned();
906 return pp_ftrowned();
911 return pp_ftrowned();
916 return pp_ftrowned();
921 return pp_ftrowned();
976 return pp_shmwrite();
981 return pp_shmwrite();
985 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
987 return Perl_uvuni_to_utf8_flags(aTHX_ d, uv, 0);
991 Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep)
993 return is_utf8_string_loclen(s, len, ep, 0);
997 =for apidoc sv_nolocking
999 Dummy routine which "locks" an SV when there is no locking module present.
1000 Exists to avoid test for a NULL function pointer and because it could
1001 potentially warn under some level of strict-ness.
1003 "Superseded" by sv_nosharing().
1009 Perl_sv_nolocking(pTHX_ SV *sv)
1011 PERL_UNUSED_ARG(sv);
1016 =for apidoc sv_nounlocking
1018 Dummy routine which "unlocks" an SV when there is no locking module present.
1019 Exists to avoid test for a NULL function pointer and because it could
1020 potentially warn under some level of strict-ness.
1022 "Superseded" by sv_nosharing().
1028 Perl_sv_nounlocking(pTHX_ SV *sv)
1030 PERL_UNUSED_ARG(sv);
1035 * c-indentation-style: bsd
1037 * indent-tabs-mode: t
1040 * ex: set ts=8 sts=4 sw=4 noet: