This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add mingw64 support
[perl5.git] / mathoms.c
CommitLineData
7ee2227d
SP
1/* mathoms.c
2 *
1129b882 3 * Copyright (C) 2005, 2006, 2007, 2008 by Larry Wall and others
7ee2227d
SP
4 *
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.
7 *
8 */
9
10/*
4ac71550
TC
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.
15 *
16 * [p.5 of _The Lord of the Rings_: "Prologue"]
7ee2227d
SP
17 */
18
359d40ba 19
20fac488 20
7ee2227d
SP
21/*
22 * This file contains mathoms, various binary artifacts from previous
f2f0f092
NC
23 * versions of Perl. For binary or source compatibility reasons, though,
24 * we cannot completely remove them from the core code.
7ee2227d
SP
25 *
26 * SMP - Oct. 24, 2005
27 *
28 */
29
30#include "EXTERN.h"
31#define PERL_IN_MATHOMS_C
32#include "perl.h"
33
359d40ba
NC
34#ifdef NO_MATHOMS
35/* ..." warning: ISO C forbids an empty source file"
36 So make sure we have something in here by processing the headers anyway.
37 */
38#else
39
a0c21aa1
JH
40PERL_CALLCONV OP * Perl_ref(pTHX_ OP *o, I32 type);
41PERL_CALLCONV void Perl_sv_unref(pTHX_ SV *sv);
42PERL_CALLCONV void Perl_sv_taint(pTHX_ SV *sv);
43PERL_CALLCONV IV Perl_sv_2iv(pTHX_ register SV *sv);
44PERL_CALLCONV UV Perl_sv_2uv(pTHX_ register SV *sv);
45PERL_CALLCONV char * Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp);
46PERL_CALLCONV char * Perl_sv_2pv_nolen(pTHX_ register SV *sv);
47PERL_CALLCONV char * Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv);
48PERL_CALLCONV char * Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv);
49PERL_CALLCONV void Perl_sv_force_normal(pTHX_ register SV *sv);
50PERL_CALLCONV void Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr);
51PERL_CALLCONV void Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen);
52PERL_CALLCONV void Perl_sv_catpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len);
53PERL_CALLCONV void Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr);
54PERL_CALLCONV void Perl_sv_catsv_mg(pTHX_ SV *dsv, register SV *ssv);
55PERL_CALLCONV char * Perl_sv_pv(pTHX_ SV *sv);
56PERL_CALLCONV char * Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp);
57PERL_CALLCONV char * Perl_sv_pvbyte(pTHX_ SV *sv);
58PERL_CALLCONV char * Perl_sv_pvutf8(pTHX_ SV *sv);
59PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade(pTHX_ register SV *sv);
60PERL_CALLCONV NV Perl_huge(void);
61PERL_CALLCONV void Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix);
62PERL_CALLCONV void Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix);
63PERL_CALLCONV GV * Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name);
64PERL_CALLCONV HE * Perl_hv_iternext(pTHX_ HV *hv);
65PERL_CALLCONV void Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how);
66PERL_CALLCONV bool Perl_do_open(pTHX_ GV *gv, register const char *name, I32 len, int as_raw, int rawmode, int rawperm, PerlIO *supplied_fp);
67PERL_CALLCONV bool Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp);
68PERL_CALLCONV bool Perl_do_exec(pTHX_ const char *cmd);
69PERL_CALLCONV U8 * Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv);
70PERL_CALLCONV bool Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep);
71PERL_CALLCONV void Perl_sv_nolocking(pTHX_ SV *sv);
72PERL_CALLCONV void Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len);
73PERL_CALLCONV void Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len);
74PERL_CALLCONV int Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...);
75PERL_CALLCONV int Perl_printf_nocontext(const char *format, ...);
56d7a086 76PERL_CALLCONV int Perl_magic_setglob(pTHX_ SV* sv, MAGIC* mg);
ac572bf4 77PERL_CALLCONV AV * Perl_newAV(pTHX);
78ac7dd9 78PERL_CALLCONV HV * Perl_newHV(pTHX);
85dca89a 79PERL_CALLCONV IO * Perl_newIO(pTHX);
b5445a23 80
7ee2227d
SP
81/* ref() is now a macro using Perl_doref;
82 * this version provided for binary compatibility only.
83 */
84OP *
85Perl_ref(pTHX_ OP *o, I32 type)
86{
87 return doref(o, type, TRUE);
88}
89
aae9cea0 90/*
174c73e3
NC
91=for apidoc sv_unref
92
93Unsets the RV status of the SV, and decrements the reference count of
94whatever was being referenced by the RV. This can almost be thought of
95as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
96being zero. See C<SvROK_off>.
97
98=cut
99*/
100
101void
102Perl_sv_unref(pTHX_ SV *sv)
103{
7918f24d
NC
104 PERL_ARGS_ASSERT_SV_UNREF;
105
174c73e3
NC
106 sv_unref_flags(sv, 0);
107}
108
109/*
aae9cea0
NC
110=for apidoc sv_taint
111
112Taint an SV. Use C<SvTAINTED_on> instead.
113=cut
114*/
115
116void
117Perl_sv_taint(pTHX_ SV *sv)
118{
7918f24d
NC
119 PERL_ARGS_ASSERT_SV_TAINT;
120
a0714e2c 121 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
aae9cea0
NC
122}
123
7ee2227d
SP
124/* sv_2iv() is now a macro using Perl_sv_2iv_flags();
125 * this function provided for binary compatibility only
126 */
127
128IV
129Perl_sv_2iv(pTHX_ register SV *sv)
130{
131 return sv_2iv_flags(sv, SV_GMAGIC);
132}
133
134/* sv_2uv() is now a macro using Perl_sv_2uv_flags();
135 * this function provided for binary compatibility only
136 */
137
138UV
139Perl_sv_2uv(pTHX_ register SV *sv)
140{
141 return sv_2uv_flags(sv, SV_GMAGIC);
142}
143
144/* sv_2pv() is now a macro using Perl_sv_2pv_flags();
145 * this function provided for binary compatibility only
146 */
147
148char *
149Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp)
150{
151 return sv_2pv_flags(sv, lp, SV_GMAGIC);
152}
153
5abc721d 154/*
cb2f1b7b
NC
155=for apidoc sv_2pv_nolen
156
157Like C<sv_2pv()>, but doesn't return the length too. You should usually
158use the macro wrapper C<SvPV_nolen(sv)> instead.
159=cut
160*/
161
162char *
163Perl_sv_2pv_nolen(pTHX_ register SV *sv)
164{
b5445a23 165 return sv_2pv(sv, NULL);
cb2f1b7b
NC
166}
167
168/*
169=for apidoc sv_2pvbyte_nolen
170
171Return a pointer to the byte-encoded representation of the SV.
172May cause the SV to be downgraded from UTF-8 as a side-effect.
173
174Usually accessed via the C<SvPVbyte_nolen> macro.
175
176=cut
177*/
178
179char *
180Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv)
181{
7918f24d
NC
182 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
183
b5445a23 184 return sv_2pvbyte(sv, NULL);
cb2f1b7b
NC
185}
186
187/*
188=for apidoc sv_2pvutf8_nolen
189
190Return a pointer to the UTF-8-encoded representation of the SV.
191May cause the SV to be upgraded to UTF-8 as a side-effect.
192
193Usually accessed via the C<SvPVutf8_nolen> macro.
194
195=cut
196*/
197
198char *
199Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv)
200{
7918f24d
NC
201 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
202
b5445a23 203 return sv_2pvutf8(sv, NULL);
cb2f1b7b
NC
204}
205
206/*
5abc721d
NC
207=for apidoc sv_force_normal
208
209Undo various types of fakery on an SV: if the PV is a shared string, make
210a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
211an xpvmg. See also C<sv_force_normal_flags>.
212
213=cut
214*/
215
216void
217Perl_sv_force_normal(pTHX_ register SV *sv)
218{
7918f24d
NC
219 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
220
5abc721d
NC
221 sv_force_normal_flags(sv, 0);
222}
7ee2227d
SP
223
224/* sv_setsv() is now a macro using Perl_sv_setsv_flags();
225 * this function provided for binary compatibility only
226 */
227
228void
229Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
230{
7918f24d
NC
231 PERL_ARGS_ASSERT_SV_SETSV;
232
7ee2227d
SP
233 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
234}
235
236/* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
237 * this function provided for binary compatibility only
238 */
239
240void
241Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
242{
7918f24d
NC
243 PERL_ARGS_ASSERT_SV_CATPVN;
244
7ee2227d
SP
245 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
246}
247
b347df82
NC
248/*
249=for apidoc sv_catpvn_mg
250
251Like C<sv_catpvn>, but also handles 'set' magic.
252
253=cut
254*/
255
256void
257Perl_sv_catpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len)
258{
7918f24d
NC
259 PERL_ARGS_ASSERT_SV_CATPVN_MG;
260
b347df82
NC
261 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
262}
263
7ee2227d
SP
264/* sv_catsv() is now a macro using Perl_sv_catsv_flags();
265 * this function provided for binary compatibility only
266 */
267
268void
269Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr)
270{
7918f24d
NC
271 PERL_ARGS_ASSERT_SV_CATSV;
272
7ee2227d
SP
273 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
274}
275
0feed65a 276/*
b347df82
NC
277=for apidoc sv_catsv_mg
278
279Like C<sv_catsv>, but also handles 'set' magic.
280
281=cut
282*/
283
284void
285Perl_sv_catsv_mg(pTHX_ SV *dsv, register SV *ssv)
286{
7918f24d
NC
287 PERL_ARGS_ASSERT_SV_CATSV_MG;
288
b347df82
NC
289 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
290}
291
292/*
0feed65a
NC
293=for apidoc sv_iv
294
295A private implementation of the C<SvIVx> macro for compilers which can't
296cope with complex macro expressions. Always use the macro instead.
297
298=cut
299*/
300
301IV
302Perl_sv_iv(pTHX_ register SV *sv)
303{
7918f24d
NC
304 PERL_ARGS_ASSERT_SV_IV;
305
0feed65a
NC
306 if (SvIOK(sv)) {
307 if (SvIsUV(sv))
308 return (IV)SvUVX(sv);
309 return SvIVX(sv);
310 }
311 return sv_2iv(sv);
312}
313
314/*
315=for apidoc sv_uv
316
317A private implementation of the C<SvUVx> macro for compilers which can't
318cope with complex macro expressions. Always use the macro instead.
319
320=cut
321*/
322
323UV
324Perl_sv_uv(pTHX_ register SV *sv)
325{
7918f24d
NC
326 PERL_ARGS_ASSERT_SV_UV;
327
0feed65a
NC
328 if (SvIOK(sv)) {
329 if (SvIsUV(sv))
330 return SvUVX(sv);
331 return (UV)SvIVX(sv);
332 }
333 return sv_2uv(sv);
334}
335
336/*
337=for apidoc sv_nv
338
339A private implementation of the C<SvNVx> macro for compilers which can't
340cope with complex macro expressions. Always use the macro instead.
341
342=cut
343*/
344
345NV
346Perl_sv_nv(pTHX_ register SV *sv)
347{
7918f24d
NC
348 PERL_ARGS_ASSERT_SV_NV;
349
0feed65a
NC
350 if (SvNOK(sv))
351 return SvNVX(sv);
352 return sv_2nv(sv);
353}
354
355/*
356=for apidoc sv_pv
357
358Use the C<SvPV_nolen> macro instead
359
360=for apidoc sv_pvn
361
362A private implementation of the C<SvPV> macro for compilers which can't
363cope with complex macro expressions. Always use the macro instead.
364
365=cut
366*/
367
368char *
369Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
370{
7918f24d
NC
371 PERL_ARGS_ASSERT_SV_PVN;
372
0feed65a
NC
373 if (SvPOK(sv)) {
374 *lp = SvCUR(sv);
375 return SvPVX(sv);
376 }
377 return sv_2pv(sv, lp);
378}
379
380
381char *
382Perl_sv_pvn_nomg(pTHX_ register SV *sv, STRLEN *lp)
383{
7918f24d
NC
384 PERL_ARGS_ASSERT_SV_PVN_NOMG;
385
0feed65a
NC
386 if (SvPOK(sv)) {
387 *lp = SvCUR(sv);
388 return SvPVX(sv);
389 }
390 return sv_2pv_flags(sv, lp, 0);
391}
392
7ee2227d
SP
393/* sv_pv() is now a macro using SvPV_nolen();
394 * this function provided for binary compatibility only
395 */
396
397char *
398Perl_sv_pv(pTHX_ SV *sv)
399{
7918f24d
NC
400 PERL_ARGS_ASSERT_SV_PV;
401
7ee2227d
SP
402 if (SvPOK(sv))
403 return SvPVX(sv);
404
b5445a23 405 return sv_2pv(sv, NULL);
7ee2227d
SP
406}
407
408/* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
409 * this function provided for binary compatibility only
410 */
411
412char *
413Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
414{
7918f24d
NC
415 PERL_ARGS_ASSERT_SV_PVN_FORCE;
416
7ee2227d
SP
417 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
418}
419
420/* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
421 * this function provided for binary compatibility only
422 */
423
424char *
425Perl_sv_pvbyte(pTHX_ SV *sv)
426{
7918f24d
NC
427 PERL_ARGS_ASSERT_SV_PVBYTE;
428
b5445a23 429 sv_utf8_downgrade(sv, FALSE);
7ee2227d
SP
430 return sv_pv(sv);
431}
432
0feed65a
NC
433/*
434=for apidoc sv_pvbyte
435
436Use C<SvPVbyte_nolen> instead.
437
438=for apidoc sv_pvbyten
439
440A private implementation of the C<SvPVbyte> macro for compilers
441which can't cope with complex macro expressions. Always use the macro
442instead.
443
444=cut
445*/
446
447char *
448Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
449{
7918f24d
NC
450 PERL_ARGS_ASSERT_SV_PVBYTEN;
451
b5445a23 452 sv_utf8_downgrade(sv, FALSE);
0feed65a
NC
453 return sv_pvn(sv,lp);
454}
455
7ee2227d
SP
456/* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
457 * this function provided for binary compatibility only
458 */
459
460char *
461Perl_sv_pvutf8(pTHX_ SV *sv)
462{
7918f24d
NC
463 PERL_ARGS_ASSERT_SV_PVUTF8;
464
7ee2227d
SP
465 sv_utf8_upgrade(sv);
466 return sv_pv(sv);
467}
468
0feed65a
NC
469/*
470=for apidoc sv_pvutf8
471
472Use the C<SvPVutf8_nolen> macro instead
473
474=for apidoc sv_pvutf8n
475
476A private implementation of the C<SvPVutf8> macro for compilers
477which can't cope with complex macro expressions. Always use the macro
478instead.
479
480=cut
481*/
482
483char *
484Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
485{
7918f24d
NC
486 PERL_ARGS_ASSERT_SV_PVUTF8N;
487
0feed65a
NC
488 sv_utf8_upgrade(sv);
489 return sv_pvn(sv,lp);
490}
491
205c02c2
NC
492/* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
493 * this function provided for binary compatibility only
494 */
495
496STRLEN
497Perl_sv_utf8_upgrade(pTHX_ register SV *sv)
498{
7918f24d
NC
499 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
500
205c02c2
NC
501 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
502}
503
7ee2227d
SP
504int
505Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
506{
507 dTHXs;
508 va_list(arglist);
7918f24d
NC
509
510 /* Easier to special case this here than in embed.pl. (Look at what it
511 generates for proto.h) */
512#ifdef PERL_IMPLICIT_CONTEXT
513 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
514#endif
515
7ee2227d
SP
516 va_start(arglist, format);
517 return PerlIO_vprintf(stream, format, arglist);
518}
519
520int
521Perl_printf_nocontext(const char *format, ...)
522{
523 dTHX;
524 va_list(arglist);
7918f24d
NC
525
526#ifdef PERL_IMPLICIT_CONTEXT
527 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
528#endif
529
7ee2227d
SP
530 va_start(arglist, format);
531 return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
532}
533
534#if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
535/*
536 * This hack is to force load of "huge" support from libm.a
537 * So it is in perl for (say) POSIX to use.
538 * Needed for SunOS with Sun's 'acc' for example.
539 */
540NV
541Perl_huge(void)
542{
c773ee7a 543# if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
7ee2227d 544 return HUGE_VALL;
c773ee7a 545# else
7ee2227d 546 return HUGE_VAL;
c773ee7a 547# endif
7ee2227d
SP
548}
549#endif
550
f2f0f092
NC
551/* compatibility with versions <= 5.003. */
552void
553Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
554{
7918f24d
NC
555 PERL_ARGS_ASSERT_GV_FULLNAME;
556
666ea192 557 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
f2f0f092
NC
558}
559
560/* compatibility with versions <= 5.003. */
561void
562Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
563{
7918f24d
NC
564 PERL_ARGS_ASSERT_GV_EFULLNAME;
565
666ea192 566 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
f2f0f092
NC
567}
568
2674aeec
NC
569void
570Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
571{
7918f24d
NC
572 PERL_ARGS_ASSERT_GV_FULLNAME3;
573
2674aeec
NC
574 gv_fullname4(sv, gv, prefix, TRUE);
575}
576
577void
578Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
579{
7918f24d
NC
580 PERL_ARGS_ASSERT_GV_EFULLNAME3;
581
2674aeec
NC
582 gv_efullname4(sv, gv, prefix, TRUE);
583}
584
887986eb
NC
585/*
586=for apidoc gv_fetchmethod
587
588See L<gv_fetchmethod_autoload>.
589
590=cut
591*/
592
593GV *
594Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
595{
7918f24d
NC
596 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
597
887986eb
NC
598 return gv_fetchmethod_autoload(stash, name, TRUE);
599}
600
7a7b9979
NC
601HE *
602Perl_hv_iternext(pTHX_ HV *hv)
603{
7918f24d
NC
604 PERL_ARGS_ASSERT_HV_ITERNEXT;
605
7a7b9979
NC
606 return hv_iternext_flags(hv, 0);
607}
608
bc5cdc23
NC
609void
610Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
611{
7918f24d
NC
612 PERL_ARGS_ASSERT_HV_MAGIC;
613
ad64d0ec 614 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
bc5cdc23
NC
615}
616
34d367cd 617bool
e4dba786
NC
618Perl_do_open(pTHX_ GV *gv, register const char *name, I32 len, int as_raw,
619 int rawmode, int rawperm, PerlIO *supplied_fp)
620{
7918f24d
NC
621 PERL_ARGS_ASSERT_DO_OPEN;
622
e4dba786
NC
623 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
624 supplied_fp, (SV **) NULL, 0);
625}
626
627bool
34d367cd
SP
628Perl_do_open9(pTHX_ GV *gv, register const char *name, I32 len, int
629as_raw,
630 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
631 I32 num_svs)
632{
7918f24d
NC
633 PERL_ARGS_ASSERT_DO_OPEN9;
634
34d367cd
SP
635 PERL_UNUSED_ARG(num_svs);
636 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
637 supplied_fp, &svs, 1);
638}
639
640int
641Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
642{
643 /* The old body of this is now in non-LAYER part of perlio.c
644 * This is a stub for any XS code which might have been calling it.
645 */
646 const char *name = ":raw";
7918f24d
NC
647
648 PERL_ARGS_ASSERT_DO_BINMODE;
649
34d367cd
SP
650#ifdef PERLIO_USING_CRLF
651 if (!(mode & O_BINARY))
652 name = ":crlf";
653#endif
654 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
655}
656
a9f96b3f
NC
657#ifndef OS2
658bool
659Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp)
660{
7918f24d
NC
661 PERL_ARGS_ASSERT_DO_AEXEC;
662
a9f96b3f
NC
663 return do_aexec5(really, mark, sp, 0, 0);
664}
665#endif
666
9555a685
NC
667#ifdef PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION
668bool
669Perl_do_exec(pTHX_ const char *cmd)
670{
7918f24d
NC
671 PERL_ARGS_ASSERT_DO_EXEC;
672
9555a685
NC
673 return do_exec3(cmd,0,0);
674}
675#endif
676
89552e80
NC
677/* Backwards compatibility. */
678int
679Perl_init_i18nl14n(pTHX_ int printwarn)
680{
681 return init_i18nl10n(printwarn);
682}
683
c78ff979
NC
684PP(pp_padany)
685{
686 DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
bb4c52e0 687 return NORMAL;
c78ff979
NC
688}
689
690PP(pp_mapstart)
691{
692 DIE(aTHX_ "panic: mapstart"); /* uses grepstart */
bb4c52e0 693 return NORMAL;
c78ff979
NC
694}
695
0b612f93
NC
696/* These ops all have the same body as pp_null. */
697PP(pp_scalar)
698{
97aff369 699 dVAR;
0b612f93
NC
700 return NORMAL;
701}
702
703PP(pp_regcmaybe)
704{
97aff369 705 dVAR;
0b612f93
NC
706 return NORMAL;
707}
708
709PP(pp_lineseq)
710{
97aff369 711 dVAR;
0b612f93
NC
712 return NORMAL;
713}
714
715PP(pp_scope)
716{
97aff369 717 dVAR;
0b612f93
NC
718 return NORMAL;
719}
720
721/* Ops that are calls to do_kv. */
722PP(pp_values)
723{
724 return do_kv();
725}
726
727PP(pp_keys)
728{
729 return do_kv();
730}
731
732/* Ops that are simply calls to other ops. */
733PP(pp_dump)
734{
735 return pp_goto();
736 /*NOTREACHED*/
737}
738
739PP(pp_dofile)
740{
741 return pp_require();
742}
743
744PP(pp_dbmclose)
745{
746 return pp_untie();
747}
748
749PP(pp_read)
750{
751 return pp_sysread();
752}
753
754PP(pp_recv)
755{
756 return pp_sysread();
757}
758
759PP(pp_seek)
760{
761 return pp_sysseek();
762}
763
764PP(pp_fcntl)
765{
766 return pp_ioctl();
767}
768
769PP(pp_gsockopt)
770{
771 return pp_ssockopt();
772}
773
774PP(pp_getsockname)
775{
776 return pp_getpeername();
777}
778
779PP(pp_lstat)
780{
781 return pp_stat();
782}
783
784PP(pp_fteowned)
785{
786 return pp_ftrowned();
787}
788
789PP(pp_ftbinary)
790{
791 return pp_fttext();
792}
793
794PP(pp_localtime)
795{
796 return pp_gmtime();
797}
798
799PP(pp_shmget)
800{
801 return pp_semget();
802}
803
804PP(pp_shmctl)
805{
806 return pp_semctl();
807}
808
809PP(pp_shmread)
810{
811 return pp_shmwrite();
812}
813
814PP(pp_msgget)
815{
816 return pp_semget();
817}
818
819PP(pp_msgctl)
820{
821 return pp_semctl();
822}
823
824PP(pp_ghbyname)
825{
826 return pp_ghostent();
827}
828
829PP(pp_ghbyaddr)
830{
831 return pp_ghostent();
832}
833
834PP(pp_gnbyname)
835{
836 return pp_gnetent();
837}
838
839PP(pp_gnbyaddr)
840{
841 return pp_gnetent();
842}
843
844PP(pp_gpbyname)
845{
846 return pp_gprotoent();
847}
848
849PP(pp_gpbynumber)
850{
851 return pp_gprotoent();
852}
853
854PP(pp_gsbyname)
855{
856 return pp_gservent();
857}
858
859PP(pp_gsbyport)
860{
861 return pp_gservent();
862}
863
864PP(pp_gpwnam)
865{
866 return pp_gpwent();
867}
868
869PP(pp_gpwuid)
870{
871 return pp_gpwent();
872}
873
874PP(pp_ggrnam)
875{
876 return pp_ggrent();
877}
878
879PP(pp_ggrgid)
880{
881 return pp_ggrent();
882}
883
957b0e1d
NC
884PP(pp_ftsize)
885{
4992681b 886 return pp_ftis();
957b0e1d
NC
887}
888
889PP(pp_ftmtime)
890{
4992681b 891 return pp_ftis();
957b0e1d
NC
892}
893
894PP(pp_ftatime)
895{
4992681b 896 return pp_ftis();
957b0e1d
NC
897}
898
899PP(pp_ftctime)
900{
4992681b 901 return pp_ftis();
957b0e1d
NC
902}
903
f1cb2d48
NC
904PP(pp_ftzero)
905{
906 return pp_ftrowned();
907}
908
909PP(pp_ftsock)
910{
911 return pp_ftrowned();
912}
913
914PP(pp_ftchr)
915{
916 return pp_ftrowned();
917}
918
919PP(pp_ftblk)
920{
921 return pp_ftrowned();
922}
923
924PP(pp_ftfile)
925{
926 return pp_ftrowned();
927}
928
929PP(pp_ftdir)
930{
931 return pp_ftrowned();
932}
933
934PP(pp_ftpipe)
935{
936 return pp_ftrowned();
937}
938
17ad201a
NC
939PP(pp_ftsuid)
940{
941 return pp_ftrowned();
942}
943
944PP(pp_ftsgid)
945{
946 return pp_ftrowned();
947}
948
949PP(pp_ftsvtx)
950{
951 return pp_ftrowned();
952}
953
605b9385
NC
954PP(pp_unlink)
955{
956 return pp_chown();
957}
958
959PP(pp_chmod)
960{
961 return pp_chown();
962}
963
964PP(pp_utime)
965{
966 return pp_chown();
967}
968
969PP(pp_kill)
970{
971 return pp_chown();
972}
973
ce6987d0
NC
974PP(pp_symlink)
975{
976 return pp_link();
977}
978
af9e49b4
NC
979PP(pp_ftrwrite)
980{
981 return pp_ftrread();
982}
983
984PP(pp_ftrexec)
985{
986 return pp_ftrread();
987}
988
989PP(pp_fteread)
990{
991 return pp_ftrread();
992}
993
994PP(pp_ftewrite)
995{
996 return pp_ftrread();
997}
998
999PP(pp_fteexec)
1000{
1001 return pp_ftrread();
1002}
1003
c9f7ac20
NC
1004PP(pp_msgsnd)
1005{
1006 return pp_shmwrite();
1007}
1008
1009PP(pp_msgrcv)
1010{
1011 return pp_shmwrite();
1012}
1013
64a1bc8e
NC
1014PP(pp_syswrite)
1015{
1016 return pp_send();
1017}
1018
ca563b4e
NC
1019PP(pp_semop)
1020{
1021 return pp_shmwrite();
1022}
1023
25a55bd7
SP
1024PP(pp_dor)
1025{
f6a64177 1026 return pp_defined();
25a55bd7
SP
1027}
1028
c960fc3b
SP
1029PP(pp_andassign)
1030{
1031 return pp_and();
1032}
1033
1034PP(pp_orassign)
1035{
1036 return pp_or();
1037}
1038
1039PP(pp_dorassign)
1040{
1041 return pp_defined();
1042}
1043
12e9c124
NC
1044PP(pp_lcfirst)
1045{
1046 return pp_ucfirst();
1047}
1048
afd9910b
NC
1049PP(pp_slt)
1050{
1051 return pp_sle();
1052}
1053
1054PP(pp_sgt)
1055{
1056 return pp_sle();
1057}
1058
1059PP(pp_sge)
1060{
1061 return pp_sle();
1062}
1063
2723d216
NC
1064PP(pp_rindex)
1065{
1066 return pp_index();
1067}
1068
daa2adfd
NC
1069PP(pp_hex)
1070{
1071 return pp_oct();
1072}
1073
789b4bc9
NC
1074PP(pp_pop)
1075{
1076 return pp_shift();
1077}
1078
71302fe3
NC
1079PP(pp_cos)
1080{
1081 return pp_sin();
1082}
1083
1084PP(pp_exp)
1085{
1086 return pp_sin();
1087}
1088
1089PP(pp_log)
1090{
1091 return pp_sin();
1092}
1093
1094PP(pp_sqrt)
1095{
1096 return pp_sin();
1097}
1098
3658c1f1
NC
1099PP(pp_bit_xor)
1100{
1101 return pp_bit_or();
1102}
1103
17ab7946
NC
1104PP(pp_rv2hv)
1105{
1106 return Perl_pp_rv2av(aTHX);
1107}
1108
038e8d3c
NC
1109U8 *
1110Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
1111{
7918f24d
NC
1112 PERL_ARGS_ASSERT_UVUNI_TO_UTF8;
1113
038e8d3c
NC
1114 return Perl_uvuni_to_utf8_flags(aTHX_ d, uv, 0);
1115}
1116
814fafa7
NC
1117bool
1118Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep)
1119{
7918f24d
NC
1120 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
1121
814fafa7
NC
1122 return is_utf8_string_loclen(s, len, ep, 0);
1123}
1124
7ee2227d 1125/*
d5b2b27b
NC
1126=for apidoc sv_nolocking
1127
1128Dummy routine which "locks" an SV when there is no locking module present.
1129Exists to avoid test for a NULL function pointer and because it could
1130potentially warn under some level of strict-ness.
1131
1132"Superseded" by sv_nosharing().
1133
1134=cut
1135*/
1136
1137void
1138Perl_sv_nolocking(pTHX_ SV *sv)
1139{
96a5add6 1140 PERL_UNUSED_CONTEXT;
d5b2b27b
NC
1141 PERL_UNUSED_ARG(sv);
1142}
1143
1144
1145/*
1146=for apidoc sv_nounlocking
1147
1148Dummy routine which "unlocks" an SV when there is no locking module present.
1149Exists to avoid test for a NULL function pointer and because it could
1150potentially warn under some level of strict-ness.
1151
1152"Superseded" by sv_nosharing().
1153
1154=cut
1155*/
1156
1157void
1158Perl_sv_nounlocking(pTHX_ SV *sv)
1159{
96a5add6 1160 PERL_UNUSED_CONTEXT;
d5b2b27b
NC
1161 PERL_UNUSED_ARG(sv);
1162}
1163
2053acbf
NC
1164void
1165Perl_save_long(pTHX_ long int *longp)
1166{
1167 dVAR;
7918f24d
NC
1168
1169 PERL_ARGS_ASSERT_SAVE_LONG;
1170
2053acbf
NC
1171 SSCHECK(3);
1172 SSPUSHLONG(*longp);
1173 SSPUSHPTR(longp);
1174 SSPUSHINT(SAVEt_LONG);
1175}
1176
1177void
2053acbf
NC
1178Perl_save_iv(pTHX_ IV *ivp)
1179{
1180 dVAR;
7918f24d
NC
1181
1182 PERL_ARGS_ASSERT_SAVE_IV;
1183
2053acbf
NC
1184 SSCHECK(3);
1185 SSPUSHIV(*ivp);
1186 SSPUSHPTR(ivp);
1187 SSPUSHINT(SAVEt_IV);
1188}
1189
1190void
1191Perl_save_nogv(pTHX_ GV *gv)
1192{
1193 dVAR;
7918f24d
NC
1194
1195 PERL_ARGS_ASSERT_SAVE_NOGV;
1196
2053acbf
NC
1197 SSCHECK(2);
1198 SSPUSHPTR(gv);
1199 SSPUSHINT(SAVEt_NSTAB);
1200}
1201
1202void
1203Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
1204{
1205 dVAR;
1206 register I32 i;
1207
7918f24d
NC
1208 PERL_ARGS_ASSERT_SAVE_LIST;
1209
2053acbf
NC
1210 for (i = 1; i <= maxsarg; i++) {
1211 register SV * const sv = newSV(0);
1212 sv_setsv(sv,sarg[i]);
1213 SSCHECK(3);
1214 SSPUSHPTR(sarg[i]); /* remember the pointer */
1215 SSPUSHPTR(sv); /* remember the value */
1216 SSPUSHINT(SAVEt_ITEM);
1217 }
1218}
1219
47518d95
NC
1220/*
1221=for apidoc sv_usepvn_mg
1222
1223Like C<sv_usepvn>, but also handles 'set' magic.
1224
1225=cut
1226*/
1227
1228void
1229Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
1230{
7918f24d
NC
1231 PERL_ARGS_ASSERT_SV_USEPVN_MG;
1232
47518d95
NC
1233 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
1234}
1235
1236/*
1237=for apidoc sv_usepvn
1238
1239Tells an SV to use C<ptr> to find its string value. Implemented by
1240calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
1241magic. See C<sv_usepvn_flags>.
1242
1243=cut
1244*/
1245
1246void
1247Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
1248{
7918f24d
NC
1249 PERL_ARGS_ASSERT_SV_USEPVN;
1250
47518d95
NC
1251 sv_usepvn_flags(sv,ptr,len, 0);
1252}
1253
c03e83bf
NC
1254/*
1255=for apidoc unpack_str
1256
1257The engine implementing unpack() Perl function. Note: parameters strbeg, new_s
1258and ocnt are not used. This call should not be used, use unpackstring instead.
1259
1260=cut */
1261
1262I32
1263Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
1264 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
1265 U32 flags)
1266{
7918f24d
NC
1267 PERL_ARGS_ASSERT_UNPACK_STR;
1268
c03e83bf
NC
1269 PERL_UNUSED_ARG(strbeg);
1270 PERL_UNUSED_ARG(new_s);
1271 PERL_UNUSED_ARG(ocnt);
1272
1273 return unpackstring(pat, patend, s, strend, flags);
1274}
b47163a2
NC
1275
1276/*
1277=for apidoc pack_cat
1278
1279The engine implementing pack() Perl function. Note: parameters next_in_list and
1280flags are not used. This call should not be used; use packlist instead.
1281
1282=cut
1283*/
1284
1285void
1286Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, register SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
1287{
7918f24d
NC
1288 PERL_ARGS_ASSERT_PACK_CAT;
1289
b47163a2
NC
1290 PERL_UNUSED_ARG(next_in_list);
1291 PERL_UNUSED_ARG(flags);
1292
1293 packlist(cat, pat, patend, beglist, endlist);
1294}
4c2df08c
NC
1295
1296HE *
1297Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
1298{
59af68cc 1299 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
4c2df08c
NC
1300}
1301
1302bool
1303Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
1304{
7918f24d
NC
1305 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
1306
4c2df08c
NC
1307 return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash)
1308 ? TRUE : FALSE;
1309}
1310
1311HE *
1312Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
1313{
7918f24d
NC
1314 PERL_ARGS_ASSERT_HV_FETCH_ENT;
1315
59af68cc 1316 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
4c2df08c
NC
1317 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
1318}
1319
1320SV *
1321Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
1322{
7918f24d
NC
1323 PERL_ARGS_ASSERT_HV_DELETE_ENT;
1324
ad64d0ec
NC
1325 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
1326 hash));
4c2df08c
NC
1327}
1328
a038e571
NC
1329SV**
1330Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
1331 int flags)
1332{
1333 return (SV**) hv_common(hv, NULL, key, klen, flags,
1334 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
1335}
1336
1337SV**
1338Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
1339{
1340 STRLEN klen;
1341 int flags;
1342
1343 if (klen_i32 < 0) {
1344 klen = -klen_i32;
1345 flags = HVhek_UTF8;
1346 } else {
1347 klen = klen_i32;
1348 flags = 0;
1349 }
1350 return (SV **) hv_common(hv, NULL, key, klen, flags,
1351 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
1352}
1353
1354bool
1355Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
1356{
1357 STRLEN klen;
1358 int flags;
1359
7918f24d
NC
1360 PERL_ARGS_ASSERT_HV_EXISTS;
1361
a038e571
NC
1362 if (klen_i32 < 0) {
1363 klen = -klen_i32;
1364 flags = HVhek_UTF8;
1365 } else {
1366 klen = klen_i32;
1367 flags = 0;
1368 }
1369 return hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0)
1370 ? TRUE : FALSE;
1371}
1372
1373SV**
1374Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
1375{
1376 STRLEN klen;
1377 int flags;
1378
7918f24d
NC
1379 PERL_ARGS_ASSERT_HV_FETCH;
1380
a038e571
NC
1381 if (klen_i32 < 0) {
1382 klen = -klen_i32;
1383 flags = HVhek_UTF8;
1384 } else {
1385 klen = klen_i32;
1386 flags = 0;
1387 }
1388 return (SV **) hv_common(hv, NULL, key, klen, flags,
1389 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
1390 : HV_FETCH_JUST_SV, NULL, 0);
1391}
1392
1393SV *
1394Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
1395{
1396 STRLEN klen;
1397 int k_flags;
1398
7918f24d
NC
1399 PERL_ARGS_ASSERT_HV_DELETE;
1400
a038e571
NC
1401 if (klen_i32 < 0) {
1402 klen = -klen_i32;
1403 k_flags = HVhek_UTF8;
1404 } else {
1405 klen = klen_i32;
1406 k_flags = 0;
1407 }
ad64d0ec
NC
1408 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
1409 NULL, 0));
a038e571
NC
1410}
1411
56d7a086 1412/* Functions after here were made mathoms post 5.10.0 but pre 5.8.9 */
56d7a086 1413
ac572bf4
NC
1414AV *
1415Perl_newAV(pTHX)
1416{
502c6561 1417 return MUTABLE_AV(newSV_type(SVt_PVAV));
ac572bf4
NC
1418 /* sv_upgrade does AvREAL_only():
1419 AvALLOC(av) = 0;
1420 AvARRAY(av) = NULL;
1421 AvMAX(av) = AvFILLp(av) = -1; */
1422}
1423
78ac7dd9
NC
1424HV *
1425Perl_newHV(pTHX)
1426{
85fbaab2 1427 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
78ac7dd9
NC
1428 assert(!SvOK(hv));
1429
1430 return hv;
1431}
1432
84335ee9
NC
1433void
1434Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
1435 const char *const little, const STRLEN littlelen)
1436{
1437 PERL_ARGS_ASSERT_SV_INSERT;
1438 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
1439}
1440
2fd8beea
NC
1441void
1442Perl_save_freesv(pTHX_ SV *sv)
1443{
1444 dVAR;
1445 save_freesv(sv);
1446}
1447
1448void
1449Perl_save_mortalizesv(pTHX_ SV *sv)
1450{
1451 dVAR;
1452
1453 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1454
1455 save_mortalizesv(sv);
1456}
1457
1458void
1459Perl_save_freeop(pTHX_ OP *o)
1460{
1461 dVAR;
1462 save_freeop(o);
1463}
1464
1465void
1466Perl_save_freepv(pTHX_ char *pv)
1467{
1468 dVAR;
1469 save_freepv(pv);
1470}
1471
1472void
1473Perl_save_op(pTHX)
1474{
1475 dVAR;
1476 save_op();
1477}
1478
d5713896
NC
1479#ifdef PERL_DONT_CREATE_GVSV
1480GV *
1481Perl_gv_SVadd(pTHX_ GV *gv)
1482{
d5713896
NC
1483 return gv_SVadd(gv);
1484}
1485#endif
1486
1487GV *
1488Perl_gv_AVadd(pTHX_ GV *gv)
1489{
d5713896
NC
1490 return gv_AVadd(gv);
1491}
1492
1493GV *
1494Perl_gv_HVadd(pTHX_ register GV *gv)
1495{
d5713896
NC
1496 return gv_HVadd(gv);
1497}
1498
bb85b28a
NC
1499GV *
1500Perl_gv_IOadd(pTHX_ register GV *gv)
1501{
1502 return gv_IOadd(gv);
1503}
1504
85dca89a
NC
1505IO *
1506Perl_newIO(pTHX)
1507{
1508 return MUTABLE_IO(newSV_type(SVt_PVIO));
1509}
1510
20fac488
GA
1511#endif /* NO_MATHOMS */
1512
d5b2b27b 1513/*
7ee2227d
SP
1514 * Local variables:
1515 * c-indentation-style: bsd
1516 * c-basic-offset: 4
1517 * indent-tabs-mode: t
1518 * End:
1519 *
1520 * ex: set ts=8 sts=4 sw=4 noet:
1521 */