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."
20 * This file contains mathoms, various binary artifacts from previous
21 * versions of Perl. For binary or source compatibility reasons, though,
22 * we cannot completely remove them from the core code.
29 #define PERL_IN_MATHOMS_C
32 void Perl_mathoms(void) {}
34 /* ref() is now a macro using Perl_doref;
35 * this version provided for binary compatibility only.
38 Perl_ref(pTHX_ OP *o, I32 type)
40 return doref(o, type, TRUE);
46 Unsets the RV status of the SV, and decrements the reference count of
47 whatever was being referenced by the RV. This can almost be thought of
48 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
49 being zero. See C<SvROK_off>.
55 Perl_sv_unref(pTHX_ SV *sv)
57 sv_unref_flags(sv, 0);
63 Taint an SV. Use C<SvTAINTED_on> instead.
68 Perl_sv_taint(pTHX_ SV *sv)
70 sv_magic((sv), Nullsv, PERL_MAGIC_taint, Nullch, 0);
73 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
74 * this function provided for binary compatibility only
78 Perl_sv_2iv(pTHX_ register SV *sv)
80 return sv_2iv_flags(sv, SV_GMAGIC);
83 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
84 * this function provided for binary compatibility only
88 Perl_sv_2uv(pTHX_ register SV *sv)
90 return sv_2uv_flags(sv, SV_GMAGIC);
93 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
94 * this function provided for binary compatibility only
98 Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp)
100 return sv_2pv_flags(sv, lp, SV_GMAGIC);
104 =for apidoc sv_2pv_nolen
106 Like C<sv_2pv()>, but doesn't return the length too. You should usually
107 use the macro wrapper C<SvPV_nolen(sv)> instead.
112 Perl_sv_2pv_nolen(pTHX_ register SV *sv)
114 return sv_2pv(sv, 0);
118 =for apidoc sv_2pvbyte_nolen
120 Return a pointer to the byte-encoded representation of the SV.
121 May cause the SV to be downgraded from UTF-8 as a side-effect.
123 Usually accessed via the C<SvPVbyte_nolen> macro.
129 Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv)
131 return sv_2pvbyte(sv, 0);
135 =for apidoc sv_2pvutf8_nolen
137 Return a pointer to the UTF-8-encoded representation of the SV.
138 May cause the SV to be upgraded to UTF-8 as a side-effect.
140 Usually accessed via the C<SvPVutf8_nolen> macro.
146 Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv)
148 return sv_2pvutf8(sv, 0);
152 =for apidoc sv_force_normal
154 Undo various types of fakery on an SV: if the PV is a shared string, make
155 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
156 an xpvmg. See also C<sv_force_normal_flags>.
162 Perl_sv_force_normal(pTHX_ register SV *sv)
164 sv_force_normal_flags(sv, 0);
167 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
168 * this function provided for binary compatibility only
172 Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
174 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
177 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
178 * this function provided for binary compatibility only
182 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
184 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
188 =for apidoc sv_catpvn_mg
190 Like C<sv_catpvn>, but also handles 'set' magic.
196 Perl_sv_catpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len)
198 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
201 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
202 * this function provided for binary compatibility only
206 Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr)
208 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
212 =for apidoc sv_catsv_mg
214 Like C<sv_catsv>, but also handles 'set' magic.
220 Perl_sv_catsv_mg(pTHX_ SV *dsv, register SV *ssv)
222 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
228 A private implementation of the C<SvIVx> macro for compilers which can't
229 cope with complex macro expressions. Always use the macro instead.
235 Perl_sv_iv(pTHX_ register SV *sv)
239 return (IV)SvUVX(sv);
248 A private implementation of the C<SvUVx> macro for compilers which can't
249 cope with complex macro expressions. Always use the macro instead.
255 Perl_sv_uv(pTHX_ register SV *sv)
260 return (UV)SvIVX(sv);
268 A private implementation of the C<SvNVx> macro for compilers which can't
269 cope with complex macro expressions. Always use the macro instead.
275 Perl_sv_nv(pTHX_ register SV *sv)
285 Use the C<SvPV_nolen> macro instead
289 A private implementation of the C<SvPV> macro for compilers which can't
290 cope with complex macro expressions. Always use the macro instead.
296 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
302 return sv_2pv(sv, lp);
307 Perl_sv_pvn_nomg(pTHX_ register SV *sv, STRLEN *lp)
313 return sv_2pv_flags(sv, lp, 0);
316 /* sv_pv() is now a macro using SvPV_nolen();
317 * this function provided for binary compatibility only
321 Perl_sv_pv(pTHX_ SV *sv)
326 return sv_2pv(sv, 0);
329 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
330 * this function provided for binary compatibility only
334 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
336 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
339 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
340 * this function provided for binary compatibility only
344 Perl_sv_pvbyte(pTHX_ SV *sv)
346 sv_utf8_downgrade(sv,0);
351 =for apidoc sv_pvbyte
353 Use C<SvPVbyte_nolen> instead.
355 =for apidoc sv_pvbyten
357 A private implementation of the C<SvPVbyte> macro for compilers
358 which can't cope with complex macro expressions. Always use the macro
365 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
367 sv_utf8_downgrade(sv,0);
368 return sv_pvn(sv,lp);
371 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
372 * this function provided for binary compatibility only
376 Perl_sv_pvutf8(pTHX_ SV *sv)
383 =for apidoc sv_pvutf8
385 Use the C<SvPVutf8_nolen> macro instead
387 =for apidoc sv_pvutf8n
389 A private implementation of the C<SvPVutf8> macro for compilers
390 which can't cope with complex macro expressions. Always use the macro
397 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
400 return sv_pvn(sv,lp);
403 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
404 * this function provided for binary compatibility only
408 Perl_sv_utf8_upgrade(pTHX_ register SV *sv)
410 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
414 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
418 va_start(arglist, format);
419 return PerlIO_vprintf(stream, format, arglist);
423 Perl_printf_nocontext(const char *format, ...)
427 va_start(arglist, format);
428 return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
431 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
433 * This hack is to force load of "huge" support from libm.a
434 * So it is in perl for (say) POSIX to use.
435 * Needed for SunOS with Sun's 'acc' for example.
440 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
447 /* compatibility with versions <= 5.003. */
449 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
451 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
454 /* compatibility with versions <= 5.003. */
456 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
458 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
462 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
464 gv_fullname4(sv, gv, prefix, TRUE);
468 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
470 gv_efullname4(sv, gv, prefix, TRUE);
474 =for apidoc gv_fetchmethod
476 See L<gv_fetchmethod_autoload>.
482 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
484 return gv_fetchmethod_autoload(stash, name, TRUE);
488 Perl_hv_iternext(pTHX_ HV *hv)
490 return hv_iternext_flags(hv, 0);
494 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
496 sv_magic((SV*)hv, (SV*)gv, how, Nullch, 0);
499 #if 0 /* use the macro from hv.h instead */
502 Perl_sharepvn(pTHX_ const char *sv, I32 len, U32 hash)
504 return HEK_KEY(share_hek(sv, len, hash));
510 Perl_av_fake(pTHX_ register I32 size, register SV **strp)
513 register AV * const av = (AV*)NEWSV(9,0);
515 sv_upgrade((SV *)av, SVt_PVAV);
516 Newx(ary,size+1,SV*);
518 Copy(strp,ary,size,SV*);
520 SvPV_set(av, (char*)ary);
521 AvFILLp(av) = size - 1;
522 AvMAX(av) = size - 1;
532 Perl_do_open(pTHX_ GV *gv, register const char *name, I32 len, int as_raw,
533 int rawmode, int rawperm, PerlIO *supplied_fp)
535 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
536 supplied_fp, (SV **) NULL, 0);
540 Perl_do_open9(pTHX_ GV *gv, register const char *name, I32 len, int
542 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
545 PERL_UNUSED_ARG(num_svs);
546 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
547 supplied_fp, &svs, 1);
551 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
553 /* The old body of this is now in non-LAYER part of perlio.c
554 * This is a stub for any XS code which might have been calling it.
556 const char *name = ":raw";
557 #ifdef PERLIO_USING_CRLF
558 if (!(mode & O_BINARY))
561 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
566 Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp)
568 return do_aexec5(really, mark, sp, 0, 0);
572 #ifdef PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION
574 Perl_do_exec(pTHX_ const char *cmd)
576 return do_exec3(cmd,0,0);
582 Perl_do_pipe(pTHX_ SV *sv, GV *rgv, GV *wgv)
601 if (PerlProc_pipe(fd) < 0)
603 IoIFP(rstio) = PerlIO_fdopen(fd[0], "r"PIPE_OPEN_MODE);
604 IoOFP(wstio) = PerlIO_fdopen(fd[1], "w"PIPE_OPEN_MODE);
605 IoOFP(rstio) = IoIFP(rstio);
606 IoIFP(wstio) = IoOFP(wstio);
607 IoTYPE(rstio) = IoTYPE_RDONLY;
608 IoTYPE(wstio) = IoTYPE_WRONLY;
609 if (!IoIFP(rstio) || !IoOFP(wstio)) {
610 if (IoIFP(rstio)) PerlIO_close(IoIFP(rstio));
611 else PerlLIO_close(fd[0]);
612 if (IoOFP(wstio)) PerlIO_close(IoOFP(wstio));
613 else PerlLIO_close(fd[1]);
617 sv_setsv(sv,&PL_sv_yes);
621 sv_setsv(sv,&PL_sv_undef);
626 /* Backwards compatibility. */
628 Perl_init_i18nl14n(pTHX_ int printwarn)
630 return init_i18nl10n(printwarn);
633 /* XXX kept for BINCOMPAT only */
635 Perl_save_hints(pTHX)
637 Perl_croak(aTHX_ "internal error: obsolete function save_hints() called");
642 Perl_ck_retarget(pTHX_ OP *o)
644 Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
651 Perl_oopsCV(pTHX_ OP *o)
653 Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
656 NORETURN_FUNCTION_END;
661 DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
666 DIE(aTHX_ "tried to access per-thread data in non-threaded perl");
671 DIE(aTHX_ "panic: mapstart"); /* uses grepstart */
674 /* These ops all have the same body as pp_null. */
695 /* Ops that are calls to do_kv. */
706 /* Ops that are simply calls to other ops. */
745 return pp_ssockopt();
750 return pp_getpeername();
760 return pp_ftrowned();
785 return pp_shmwrite();
800 return pp_ghostent();
805 return pp_ghostent();
820 return pp_gprotoent();
825 return pp_gprotoent();
830 return pp_gservent();
835 return pp_gservent();
880 return pp_ftrowned();
885 return pp_ftrowned();
890 return pp_ftrowned();
895 return pp_ftrowned();
900 return pp_ftrowned();
905 return pp_ftrowned();
910 return pp_ftrowned();
915 return pp_ftrowned();
920 return pp_ftrowned();
925 return pp_ftrowned();
980 return pp_shmwrite();
985 return pp_shmwrite();
995 return pp_shmwrite();
1000 return pp_defined();
1015 return pp_defined();
1020 return pp_ucfirst();
1039 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
1041 return Perl_uvuni_to_utf8_flags(aTHX_ d, uv, 0);
1045 Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep)
1047 return is_utf8_string_loclen(s, len, ep, 0);
1051 =for apidoc sv_nolocking
1053 Dummy routine which "locks" an SV when there is no locking module present.
1054 Exists to avoid test for a NULL function pointer and because it could
1055 potentially warn under some level of strict-ness.
1057 "Superseded" by sv_nosharing().
1063 Perl_sv_nolocking(pTHX_ SV *sv)
1065 PERL_UNUSED_ARG(sv);
1070 =for apidoc sv_nounlocking
1072 Dummy routine which "unlocks" an SV when there is no locking module present.
1073 Exists to avoid test for a NULL function pointer and because it could
1074 potentially warn under some level of strict-ness.
1076 "Superseded" by sv_nosharing().
1082 Perl_sv_nounlocking(pTHX_ SV *sv)
1084 PERL_UNUSED_ARG(sv);
1087 #endif /* NO_MATHOMS */
1091 * c-indentation-style: bsd
1093 * indent-tabs-mode: t
1096 * ex: set ts=8 sts=4 sw=4 noet: