This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.003_06: perl.c
[perl5.git] / perl.h
CommitLineData
a0d0e21e 1/* perl.h
a687059c 2 *
a0d0e21e 3 * Copyright (c) 1987-1994, Larry Wall
a687059c 4 *
352d5a3a
LW
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.
8d063cd8 7 *
8d063cd8 8 */
85e6fe83
LW
9#ifndef H_PERL
10#define H_PERL 1
a0d0e21e 11#define OVERLOAD
8d063cd8 12
760ac839
LW
13#ifdef PERL_FOR_X2P
14/*
15 * This file is being used for x2p stuff.
16 * Above symbol is defined via -D in 'x2p/Makefile.SH'
17 * Decouple x2p stuff from some of perls more extreme eccentricities.
18 */
19#undef MULTIPLICITY
20#undef EMBED
21#undef USE_STDIO
22#define USE_STDIO
23#endif /* PERL_FOR_X2P */
24
728e2803
PP
25/*
26 * STMT_START { statements; } STMT_END;
27 * can be used as a single statement, as in
28 * if (x) STMT_START { ... } STMT_END; else ...
29 *
30 * Trying to select a version that gives no warnings...
31 */
32#if !(defined(STMT_START) && defined(STMT_END))
33# if defined(__GNUC__) && !defined(__STRICT_ANSI__)
34# define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
35# define STMT_END )
36# else
37 /* Now which other defined()s do we need here ??? */
38# if (VOIDFLAGS) && (defined(sun) || defined(__sun__))
39# define STMT_START if (1)
40# define STMT_END else (void)0
41# else
42# define STMT_START do
43# define STMT_END while (0)
44# endif
45# endif
46#endif
47
79072805
LW
48#include "embed.h"
49
85e6fe83 50#define VOIDUSED 1
ac58e20f 51#include "config.h"
79072805
LW
52
53#ifndef BYTEORDER
54# define BYTEORDER 0x1234
55#endif
56
57/* Overall memory policy? */
58#ifndef CONSERVATIVE
59# define LIBERAL 1
60#endif
61
62/*
63 * The following contortions are brought to you on behalf of all the
64 * standards, semi-standards, de facto standards, not-so-de-facto standards
65 * of the world, as well as all the other botches anyone ever thought of.
66 * The basic theory is that if we work hard enough here, the rest of the
67 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
68 */
ac58e20f 69
ee0007ab
LW
70/* define this once if either system, instead of cluttering up the src */
71#if defined(MSDOS) || defined(atarist)
72#define DOSISH 1
73#endif
74
a0d0e21e 75#if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
352d5a3a
LW
76# define STANDARD_C 1
77#endif
78
79#if defined(HASVOLATILE) || defined(STANDARD_C)
79072805
LW
80# ifdef __cplusplus
81# define VOL // to temporarily suppress warnings
82# else
83# define VOL volatile
84# endif
663a0e37 85#else
79072805 86# define VOL
663a0e37
LW
87#endif
88
463ee0b2
LW
89#define TAINT_IF(c) (tainted |= (c))
90#define TAINT_NOT (tainted = 0)
91#define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
92#define TAINT_ENV() if (tainting) taint_env()
a687059c 93
a6e633de
PP
94/* XXX All process group stuff is handled in pp_sys.c. Should these
95 defines move there? If so, I could simplify this a lot. --AD 9/96.
96*/
97/* Process group stuff changed from traditional BSD to POSIX.
98 perlfunc.pod documents the traditional BSD-style syntax, so we'll
99 try to preserve that, if possible.
100*/
101#ifdef HAS_SETPGID
102# define BSD_SETPGRP(pid, pgrp) setpgid((pid), (pgrp))
c07a80fd 103#else
a6e633de
PP
104# if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
105# define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
106# else
107# ifdef HAS_SETPGRP2 /* DG/UX */
108# define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
109# endif
110# endif
111#endif
112#if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
113# define HAS_SETPGRP /* Well, effectively it does . . . */
114#endif
115
116/* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
117 our life easier :-) so we'll try it.
118*/
119#ifdef HAS_GETPGID
120# define BSD_GETPGRP(pid) getpgid((pid))
121#else
122# if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
123# define BSD_GETPGRP(pid) getpgrp((pid))
124# else
125# ifdef HAS_GETPGRP2 /* DG/UX */
126# define BSD_GETPGRP(pid) getpgrp2((pid))
127# endif
128# endif
129#endif
130#if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
131# define HAS_GETPGRP /* Well, effectively it does . . . */
132#endif
133
134/* These are not exact synonyms, since setpgrp() and getpgrp() may
135 have different behaviors, but perl.h used to define USE_BSDPGRP
136 (prior to 5.003_05) so some extension might depend on it.
137*/
138#if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
139# ifndef USE_BSDPGRP
140# define USE_BSDPGRP
141# endif
663a0e37
LW
142#endif
143
760ac839
LW
144#ifndef _TYPES_ /* If types.h defines this it's easy. */
145# ifndef major /* Does everyone's types.h define this? */
146# include <sys/types.h>
147# endif
148#endif
149
150#ifdef __cplusplus
151# ifndef I_STDARG
152# define I_STDARG 1
153# endif
154#endif
155
156#ifdef I_STDARG
157# include <stdarg.h>
158#else
159# ifdef I_VARARGS
160# include <varargs.h>
161# endif
162#endif
163
164#include "perlio.h"
0c30d9ec 165
4633a7c4 166#ifdef USE_NEXT_CTYPE
0c30d9ec
PP
167
168#if NX_CURRENT_COMPILER_RELEASE >= 400
169#include <objc/NXCType.h>
170#else /* NX_CURRENT_COMPILER_RELEASE < 400 */
a0d0e21e 171#include <appkit/NXCType.h>
0c30d9ec
PP
172#endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
173
174#else /* !USE_NEXT_CTYPE */
fe14fcc3 175#include <ctype.h>
0c30d9ec 176#endif /* USE_NEXT_CTYPE */
a0d0e21e 177
4633a7c4
LW
178#ifdef I_LOCALE
179#include <locale.h>
180#endif
181
a0d0e21e
LW
182#ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
183#undef METHOD
184#endif
185
fe14fcc3 186#include <setjmp.h>
79072805 187
a0d0e21e 188#ifdef I_SYS_PARAM
79072805
LW
189# ifdef PARAM_NEEDS_TYPES
190# include <sys/types.h>
191# endif
192# include <sys/param.h>
352d5a3a 193#endif
79072805
LW
194
195
196/* Use all the "standard" definitions? */
a0d0e21e 197#if defined(STANDARD_C) && defined(I_STDLIB)
79072805 198# include <stdlib.h>
352d5a3a 199#endif /* STANDARD_C */
03a14243 200
4633a7c4
LW
201/* Maybe this comes after <stdlib.h> so we don't try to change
202 the standard library prototypes?. We'll use our own in
203 proto.h instead. I guess. The patch had no explanation.
204*/
205#ifdef MYMALLOC
760ac839
LW
206# ifdef HIDEMYMALLOC
207# define malloc Perl_malloc
208# define realloc Perl_realloc
209# define free Perl_free
210# define calloc Perl_calloc
4633a7c4
LW
211# endif
212# define safemalloc malloc
213# define saferealloc realloc
214# define safefree free
0c30d9ec 215# define safecalloc calloc
4633a7c4
LW
216#endif
217
a0d0e21e
LW
218#define MEM_SIZE Size_t
219
220#if defined(I_STRING) || defined(__cplusplus)
221# include <string.h>
222#else
223# include <strings.h>
224#endif
225
226#if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
227#define strchr index
228#define strrchr rindex
229#endif
230
231#if defined(mips) && defined(ultrix) && !defined(__STDC__)
79072805 232# undef HAS_MEMCMP
663a0e37 233#endif
fe14fcc3 234
16d20bd9
AD
235#ifdef I_MEMORY
236# include <memory.h>
237#endif
238
fe14fcc3 239#ifdef HAS_MEMCPY
85e6fe83 240# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
fe14fcc3 241# ifndef memcpy
a0d0e21e 242 extern char * memcpy _((char*, char*, int));
ee0007ab
LW
243# endif
244# endif
245#else
246# ifndef memcpy
247# ifdef HAS_BCOPY
248# define memcpy(d,s,l) bcopy(s,d,l)
249# else
250# define memcpy(d,s,l) my_bcopy(s,d,l)
251# endif
252# endif
253#endif /* HAS_MEMCPY */
fe14fcc3 254
ee0007ab 255#ifdef HAS_MEMSET
85e6fe83 256# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 257# ifndef memset
a0d0e21e 258 extern char *memset _((char*, int, int));
ee0007ab
LW
259# endif
260# endif
261# define memzero(d,l) memset(d,0,l)
262#else
263# ifndef memzero
264# ifdef HAS_BZERO
265# define memzero(d,l) bzero(d,l)
266# else
267# define memzero(d,l) my_bzero(d,l)
268# endif
352d5a3a 269# endif
ee0007ab
LW
270#endif /* HAS_MEMSET */
271
272#ifdef HAS_MEMCMP
85e6fe83 273# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 274# ifndef memcmp
a0d0e21e 275 extern int memcmp _((char*, char*, int));
ee0007ab
LW
276# endif
277# endif
278#else
279# ifndef memcmp
ecfc5424 280# define memcmp my_memcmp
352d5a3a 281# endif
ee0007ab 282#endif /* HAS_MEMCMP */
8d063cd8 283
85e6fe83 284#if !defined(HAS_MEMMOVE) && !defined(memmove)
2304df62 285# if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
79072805
LW
286# define memmove(d,s,l) bcopy(s,d,l)
287# else
2304df62 288# if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
79072805
LW
289# define memmove(d,s,l) memcpy(d,s,l)
290# else
291# define memmove(d,s,l) my_bcopy(s,d,l)
292# endif
293# endif
d9d8d8de 294#endif
378cc40b 295
ae986130 296#ifdef I_NETINET_IN
79072805 297# include <netinet/in.h>
ae986130
LW
298#endif
299
1aef975c 300#ifdef I_SYS_STAT
8d063cd8 301#include <sys/stat.h>
1aef975c 302#endif
79072805 303
a0d0e21e
LW
304/* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
305 like UTekV) are broken, sometimes giving false positives. Undefine
306 them here and let the code below set them to proper values.
307
308 The ghs macro stands for GreenHills Software C-1.8.5 which
309 is the C compiler for sysV88 and the various derivatives.
310 This header file bug is corrected in gcc-2.5.8 and later versions.
311 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
312
313#if defined(uts) || (defined(m88k) && defined(ghs))
79072805
LW
314# undef S_ISDIR
315# undef S_ISCHR
316# undef S_ISBLK
317# undef S_ISREG
318# undef S_ISFIFO
319# undef S_ISLNK
ee0007ab 320#endif
135863df 321
663a0e37
LW
322#ifdef I_TIME
323# include <time.h>
ffed7fef 324#endif
663a0e37 325
fe14fcc3 326#ifdef I_SYS_TIME
85e6fe83 327# ifdef I_SYS_TIME_KERNEL
663a0e37
LW
328# define KERNEL
329# endif
330# include <sys/time.h>
85e6fe83 331# ifdef I_SYS_TIME_KERNEL
663a0e37
LW
332# undef KERNEL
333# endif
a687059c 334#endif
135863df 335
d9d8d8de 336#ifndef MSDOS
a0d0e21e 337# if defined(HAS_TIMES) && defined(I_SYS_TIMES)
85e6fe83
LW
338# include <sys/times.h>
339# endif
d9d8d8de 340#endif
8d063cd8 341
fe14fcc3 342#if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
79072805 343# undef HAS_STRERROR
663a0e37
LW
344#endif
345
a0d0e21e
LW
346#ifndef HAS_MKFIFO
347# ifndef mkfifo
348# define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
349# endif
350#endif /* !HAS_MKFIFO */
351
663a0e37 352#include <errno.h>
ed6116ce 353#ifdef HAS_SOCKET
85e6fe83 354# ifdef I_NET_ERRNO
ed6116ce
LW
355# include <net/errno.h>
356# endif
357#endif
748a9306
LW
358#ifndef VMS
359# define FIXSTATUS(sts) (U_L((sts) & 0xffff))
360# define SHIFTSTATUS(sts) ((sts) >> 8)
361# define SETERRNO(errcode,vmserrcode) errno = (errcode)
362#else
363# define FIXSTATUS(sts) (U_L(sts))
364# define SHIFTSTATUS(sts) (sts)
728e2803 365# define SETERRNO(errcode,vmserrcode) STMT_START {set_errno(errcode); set_vaxc_errno(vmserrcode);} STMT_END
748a9306 366#endif
ed6116ce 367
d9d8d8de 368#ifndef MSDOS
79072805
LW
369# ifndef errno
370 extern int errno; /* ANSI allows errno to be an lvalue expr */
371# endif
d9d8d8de 372#endif
663a0e37 373
2304df62 374#ifdef HAS_STRERROR
a0d0e21e
LW
375# ifdef VMS
376 char *strerror _((int,...));
377# else
378 char *strerror _((int));
379# endif
2304df62
AD
380# ifndef Strerror
381# define Strerror strerror
382# endif
383#else
384# ifdef HAS_SYS_ERRLIST
79072805
LW
385 extern int sys_nerr;
386 extern char *sys_errlist[];
2304df62
AD
387# ifndef Strerror
388# define Strerror(e) \
79072805 389 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
2304df62 390# endif
79072805 391# endif
35c8bce7 392#endif
663a0e37 393
2304df62 394#ifdef I_SYS_IOCTL
79072805
LW
395# ifndef _IOCTL_
396# include <sys/ioctl.h>
397# endif
a687059c
LW
398#endif
399
ee0007ab 400#if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
79072805
LW
401# ifdef HAS_SOCKETPAIR
402# undef HAS_SOCKETPAIR
403# endif
2304df62
AD
404# ifdef I_NDBM
405# undef I_NDBM
79072805 406# endif
a687059c
LW
407#endif
408
a687059c 409#if INTSIZE == 2
79072805
LW
410# define htoni htons
411# define ntohi ntohs
a687059c 412#else
79072805
LW
413# define htoni htonl
414# define ntohi ntohl
a687059c
LW
415#endif
416
a0d0e21e 417/* Configure already sets Direntry_t */
35c8bce7 418#if defined(I_DIRENT)
663a0e37 419# include <dirent.h>
a0d0e21e
LW
420# if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
421# include <sys/dir.h>
422# endif
ae986130 423#else
fe14fcc3 424# ifdef I_SYS_NDIR
79a0689e 425# include <sys/ndir.h>
663a0e37 426# else
fe14fcc3 427# ifdef I_SYS_DIR
79a0689e
LW
428# ifdef hp9000s500
429# include <ndir.h> /* may be wrong in the future */
430# else
431# include <sys/dir.h>
432# endif
663a0e37
LW
433# endif
434# endif
4633a7c4 435#endif
a687059c 436
352d5a3a
LW
437#ifdef FPUTS_BOTCH
438/* work around botch in SunOS 4.0.1 and 4.0.2 */
439# ifndef fputs
79072805 440# define fputs(sv,fp) fprintf(fp,"%s",sv)
352d5a3a
LW
441# endif
442#endif
443
c623bd54
LW
444/*
445 * The following gobbledygook brought to you on behalf of __STDC__.
446 * (I could just use #ifndef __STDC__, but this is more bulletproof
447 * in the face of half-implementations.)
448 */
449
450#ifndef S_IFMT
451# ifdef _S_IFMT
452# define S_IFMT _S_IFMT
453# else
454# define S_IFMT 0170000
455# endif
456#endif
457
458#ifndef S_ISDIR
459# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
460#endif
461
462#ifndef S_ISCHR
463# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
464#endif
465
466#ifndef S_ISBLK
fe14fcc3
LW
467# ifdef S_IFBLK
468# define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
469# else
470# define S_ISBLK(m) (0)
471# endif
c623bd54
LW
472#endif
473
474#ifndef S_ISREG
475# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
476#endif
477
478#ifndef S_ISFIFO
fe14fcc3
LW
479# ifdef S_IFIFO
480# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
481# else
482# define S_ISFIFO(m) (0)
483# endif
c623bd54
LW
484#endif
485
486#ifndef S_ISLNK
487# ifdef _S_ISLNK
488# define S_ISLNK(m) _S_ISLNK(m)
489# else
490# ifdef _S_IFLNK
491# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
492# else
493# ifdef S_IFLNK
494# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
495# else
496# define S_ISLNK(m) (0)
497# endif
498# endif
499# endif
500#endif
501
502#ifndef S_ISSOCK
503# ifdef _S_ISSOCK
504# define S_ISSOCK(m) _S_ISSOCK(m)
505# else
506# ifdef _S_IFSOCK
507# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
508# else
509# ifdef S_IFSOCK
510# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
511# else
512# define S_ISSOCK(m) (0)
513# endif
514# endif
515# endif
516#endif
517
518#ifndef S_IRUSR
519# ifdef S_IREAD
520# define S_IRUSR S_IREAD
521# define S_IWUSR S_IWRITE
522# define S_IXUSR S_IEXEC
523# else
524# define S_IRUSR 0400
525# define S_IWUSR 0200
526# define S_IXUSR 0100
527# endif
528# define S_IRGRP (S_IRUSR>>3)
529# define S_IWGRP (S_IWUSR>>3)
530# define S_IXGRP (S_IXUSR>>3)
531# define S_IROTH (S_IRUSR>>6)
532# define S_IWOTH (S_IWUSR>>6)
533# define S_IXOTH (S_IXUSR>>6)
534#endif
535
536#ifndef S_ISUID
537# define S_ISUID 04000
538#endif
539
540#ifndef S_ISGID
541# define S_ISGID 02000
542#endif
543
79072805
LW
544#ifdef ff_next
545# undef ff_next
352d5a3a
LW
546#endif
547
a0d0e21e 548#if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
45d8adaa
LW
549# define SLOPPYDIVIDE
550#endif
551
0c30d9ec 552#if defined(cray) || defined(convex) || BYTEORDER > 0xffff
ecfc5424 553# define HAS_QUAD
45d8adaa
LW
554#endif
555
748a9306
LW
556#ifdef UV
557#undef UV
558#endif
559
27d4fb96
PP
560/* XXX QUAD stuff is not currently supported on most systems.
561 Specifically, perl internals don't support long long. Among
562 the many problems is that some compilers support long long,
563 but the underlying library functions (such as sprintf) don't.
564 Some things do work (such as quad pack/unpack on convex);
565 also some systems use long long for the fpos_t typedef. That
566 seems to work too.
567
568 The IV type is supposed to be long enough to hold any integral
569 value or a pointer.
570 --Andy Dougherty August 1996
571*/
572
ecfc5424 573#ifdef HAS_QUAD
45d8adaa 574# ifdef cray
ecfc5424 575# define Quad_t int
45d8adaa 576# else
0c30d9ec 577# if defined(convex)
ecfc5424 578# define Quad_t long long
45d8adaa 579# else
ecfc5424 580# define Quad_t long
45d8adaa
LW
581# endif
582# endif
748a9306
LW
583 typedef Quad_t IV;
584 typedef unsigned Quad_t UV;
27d4fb96
PP
585# define IV_MAX PERL_QUAD_MAX
586# define IV_MIN PERL_QUAD_MIN
587# define UV_MAX PERL_UQUAD_MAX
588# define UV_MIN PERL_UQUAD_MIN
79072805 589#else
748a9306
LW
590 typedef long IV;
591 typedef unsigned long UV;
27d4fb96
PP
592# define IV_MAX PERL_LONG_MAX
593# define IV_MIN PERL_LONG_MIN
594# define UV_MAX PERL_ULONG_MAX
595# define UV_MIN PERL_ULONG_MIN
79072805
LW
596#endif
597
760ac839
LW
598/* Previously these definitions used hardcoded figures.
599 * It is hoped these formula are more portable, although
600 * no data one way or another is presently known to me.
601 * The "PERL_" names are used because these calculated constants
602 * do not meet the ANSI requirements for LONG_MAX, etc., which
603 * need to be constants acceptable to #if - kja
604 * define PERL_LONG_MAX 2147483647L
605 * define PERL_LONG_MIN (-LONG_MAX - 1)
606 * define PERL ULONG_MAX 4294967295L
607 */
608
609#ifdef I_LIMITS /* Needed for cast_xxx() functions below. */
610# include <limits.h>
611#else
612#ifdef I_VALUES
613# include <values.h>
614#endif
615#endif
616
27d4fb96
PP
617#ifdef CHAR_MAX
618# define PERL_CHAR_MAX CHAR_MAX
619#else
620# ifdef MAXCHAR /* Often used in <values.h> */
621# define PERL_CHAR_MAX MAXCHAR
622# else
623# define PERL_CHAR_MAX ((char) ((~(unsigned char)0) >> 1))
624# endif
625#endif
626
627#ifdef CHAR_MIN
628# define PERL_CHAR_MIN CHAR_MIN
629#else
630# ifdef MINCHAR
631# define PERL_CHAR_MIN MINCHAR
632# else
633# define PERL_CHAR_MIN (-PERL_CHAR_MAX - ((3 & -1) == 3))
634# endif
635#endif
636
637#ifdef UCHAR_MAX
638# define PERL_UCHAR_MAX UCHAR_MAX
639#else
640# ifdef MAXUCHAR
641# define PERL_UCHAR_MAX MAXUCHAR
642# else
643# define PERL_UCHAR_MAX (~(unsigned char)0)
644# endif
645#endif
646
647#define PERL_UCHAR_MIN 0
648
649#ifdef SHORT_MAX
650# define PERL_SHORT_MAX SHORT_MAX
651#else
652# ifdef MAXSHORT /* Often used in <values.h> */
653# define PERL_SHORT_MAX MAXSHORT
654# else
655# define PERL_SHORT_MAX ((short) ((~(unsigned short)0) >> 1))
656# endif
657#endif
658
659#ifdef SHORT_MIN
660# define PERL_SHORT_MIN SHORT_MIN
661#else
662# ifdef MINSHORT
663# define PERL_SHORT_MIN MINSHORT
664# else
665# define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
666# endif
667#endif
668
669#ifdef USHORT_MAX
670# define PERL_USHORT_MAX USHORT_MAX
671#else
672# ifdef MAXUSHORT
673# define PERL_USHORT_MAX MAXUSHORT
674# else
675# define PERL_USHORT_MAX (~(unsigned short)0)
676# endif
677#endif
678
679#define PERL_USHORT_MIN 0
680
681#ifdef INT_MAX
682# define PERL_INT_MAX INT_MAX
683#else
684# ifdef MAXINT /* Often used in <values.h> */
685# define PERL_INT_MAX MAXINT
686# else
687# define PERL_INT_MAX ((int) ((~(unsigned int)0) >> 1))
688# endif
689#endif
690
691#ifdef INT_MIN
692# define PERL_INT_MIN INT_MIN
693#else
694# ifdef MININT
695# define PERL_INT_MIN MININT
696# else
697# define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
698# endif
699#endif
700
701#ifdef UINT_MAX
702# define PERL_UINT_MAX UINT_MAX
703#else
704# ifdef MAXUINT
705# define PERL_UINT_MAX MAXUINT
706# else
707# define PERL_UINT_MAX (~(unsigned int)0)
708# endif
709#endif
710
711#define PERL_UINT_MIN 0
712
760ac839 713#ifdef LONG_MAX
27d4fb96 714# define PERL_LONG_MAX LONG_MAX
760ac839
LW
715#else
716# ifdef MAXLONG /* Often used in <values.h> */
717# define PERL_LONG_MAX MAXLONG
718# else
719# define PERL_LONG_MAX ((long) ((~(unsigned long)0) >> 1))
720# endif
721#endif
722
723#ifdef LONG_MIN
27d4fb96 724# define PERL_LONG_MIN LONG_MIN
760ac839
LW
725#else
726# ifdef MINLONG
727# define PERL_LONG_MIN MINLONG
728# else
27d4fb96 729# define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
760ac839
LW
730# endif
731#endif
732
733#ifdef ULONG_MAX
27d4fb96 734# define PERL_ULONG_MAX ULONG_MAX
760ac839
LW
735#else
736# ifdef MAXULONG
737# define PERL_ULONG_MAX MAXULONG
738# else
739# define PERL_ULONG_MAX (~(unsigned long)0)
740# endif
741#endif
742
27d4fb96
PP
743#define PERL_ULONG_MIN 0L
744
745#ifdef HAS_QUAD
746# ifdef QUAD_MAX
747# define PERL_QUAD_MAX QUAD_MAX
748# else
749# define PERL_QUAD_MAX ((IV) ((~(UV)0) >> 1))
750# endif
751
752# ifdef QUAD_MIN
753# define PERL_QUAD_MIN QUAD_MIN
754# else
a6e633de 755# define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
27d4fb96
PP
756# endif
757
758# ifdef UQUAD_MAX
759# define PERL_UQUAD_MAX UQUAD_MAX
760# else
761# define PERL_UQUAD_MAX (~(UV)0)
762# endif
763
764# define PERL_UQUAD_MIN 0
760ac839
LW
765#endif
766
ee0007ab 767typedef MEM_SIZE STRLEN;
450a55e4 768
79072805
LW
769typedef struct op OP;
770typedef struct cop COP;
771typedef struct unop UNOP;
772typedef struct binop BINOP;
773typedef struct listop LISTOP;
774typedef struct logop LOGOP;
775typedef struct condop CONDOP;
776typedef struct pmop PMOP;
777typedef struct svop SVOP;
778typedef struct gvop GVOP;
779typedef struct pvop PVOP;
79072805
LW
780typedef struct loop LOOP;
781
782typedef struct Outrec Outrec;
93a17b20 783typedef struct interpreter PerlInterpreter;
79072805 784typedef struct ff FF;
79072805
LW
785typedef struct sv SV;
786typedef struct av AV;
787typedef struct hv HV;
788typedef struct cv CV;
378cc40b 789typedef struct regexp REGEXP;
79072805 790typedef struct gp GP;
0c30d9ec 791typedef struct gv GV;
8990e307 792typedef struct io IO;
79072805
LW
793typedef struct context CONTEXT;
794typedef struct block BLOCK;
795
796typedef struct magic MAGIC;
ed6116ce 797typedef struct xrv XRV;
79072805
LW
798typedef struct xpv XPV;
799typedef struct xpviv XPVIV;
800typedef struct xpvnv XPVNV;
801typedef struct xpvmg XPVMG;
802typedef struct xpvlv XPVLV;
803typedef struct xpvav XPVAV;
804typedef struct xpvhv XPVHV;
805typedef struct xpvgv XPVGV;
806typedef struct xpvcv XPVCV;
807typedef struct xpvbm XPVBM;
808typedef struct xpvfm XPVFM;
8990e307 809typedef struct xpvio XPVIO;
79072805
LW
810typedef struct mgvtbl MGVTBL;
811typedef union any ANY;
8d063cd8 812
378cc40b 813#include "handy.h"
a0d0e21e 814
16d20bd9
AD
815typedef I32 (*filter_t) _((int, SV *, int));
816#define FILTER_READ(idx, sv, len) filter_read(idx, sv, len)
817#define FILTER_DATA(idx) (AvARRAY(rsfp_filters)[idx])
818#define FILTER_ISREADER(idx) (idx >= AvFILL(rsfp_filters))
819
748a9306 820#ifdef DOSISH
4633a7c4
LW
821# if defined(OS2)
822# include "os2ish.h"
823# else
748a9306 824# include "dosish.h"
4633a7c4 825# endif
a0d0e21e 826#else
748a9306
LW
827# if defined(VMS)
828# include "vmsish.h"
829# else
0c30d9ec
PP
830# if defined(PLAN9)
831# include "./plan9/plan9ish.h"
832# else
833# include "unixish.h"
834# endif
748a9306
LW
835# endif
836#endif
3fc1aec6
PP
837
838/* Some unistd.h's give a prototype for pause() even though
839 HAS_PAUSE ends up undefined. This causes the #define
840 below to be rejected by the compmiler. Sigh.
841*/
842#ifdef HAS_PAUSE
843#define Pause pause
844#else
845#define Pause() sleep((32767<<16)+32767)
748a9306
LW
846#endif
847
848#ifndef IOCPARM_LEN
849# ifdef IOCPARM_MASK
850 /* on BSDish systes we're safe */
851# define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
852# else
853 /* otherwise guess at what's safe */
854# define IOCPARM_LEN(x) 256
855# endif
a0d0e21e
LW
856#endif
857
79072805
LW
858union any {
859 void* any_ptr;
860 I32 any_i32;
a0d0e21e 861 IV any_iv;
85e6fe83 862 long any_long;
a0d0e21e 863 void (*any_dptr) _((void*));
79072805
LW
864};
865
378cc40b 866#include "regexp.h"
79072805 867#include "sv.h"
378cc40b 868#include "util.h"
8d063cd8 869#include "form.h"
79072805
LW
870#include "gv.h"
871#include "cv.h"
872#include "opcode.h"
873#include "op.h"
874#include "cop.h"
875#include "av.h"
876#include "hv.h"
877#include "mg.h"
878#include "scope.h"
8d063cd8 879
4633a7c4
LW
880/* work around some libPW problems */
881#ifdef DOINIT
882EXT char Error[1];
883#endif
884
450a55e4 885#if defined(iAPX286) || defined(M_I286) || defined(I80286)
a687059c
LW
886# define I286
887#endif
888
fe14fcc3
LW
889#if defined(htonl) && !defined(HAS_HTONL)
890#define HAS_HTONL
ae986130 891#endif
fe14fcc3
LW
892#if defined(htons) && !defined(HAS_HTONS)
893#define HAS_HTONS
ae986130 894#endif
fe14fcc3
LW
895#if defined(ntohl) && !defined(HAS_NTOHL)
896#define HAS_NTOHL
ae986130 897#endif
fe14fcc3
LW
898#if defined(ntohs) && !defined(HAS_NTOHS)
899#define HAS_NTOHS
ae986130 900#endif
fe14fcc3 901#ifndef HAS_HTONL
d9d8d8de 902#if (BYTEORDER & 0xffff) != 0x4321
fe14fcc3
LW
903#define HAS_HTONS
904#define HAS_HTONL
905#define HAS_NTOHS
906#define HAS_NTOHL
a687059c
LW
907#define MYSWAP
908#define htons my_swap
909#define htonl my_htonl
910#define ntohs my_swap
911#define ntohl my_ntohl
912#endif
913#else
d9d8d8de 914#if (BYTEORDER & 0xffff) == 0x4321
fe14fcc3
LW
915#undef HAS_HTONS
916#undef HAS_HTONL
917#undef HAS_NTOHS
918#undef HAS_NTOHL
a687059c
LW
919#endif
920#endif
921
988174c1
LW
922/*
923 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
924 * -DWS
925 */
926#if BYTEORDER != 0x1234
927# define HAS_VTOHL
928# define HAS_VTOHS
929# define HAS_HTOVL
930# define HAS_HTOVS
931# if BYTEORDER == 0x4321
932# define vtohl(x) ((((x)&0xFF)<<24) \
933 +(((x)>>24)&0xFF) \
934 +(((x)&0x0000FF00)<<8) \
935 +(((x)&0x00FF0000)>>8) )
936# define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
937# define htovl(x) vtohl(x)
938# define htovs(x) vtohs(x)
939# endif
940 /* otherwise default to functions in util.c */
941#endif
942
0f85fab0 943#ifdef CASTNEGFLOAT
79072805 944#define U_S(what) ((U16)(what))
0f85fab0 945#define U_I(what) ((unsigned int)(what))
79072805 946#define U_L(what) ((U32)(what))
0f85fab0 947#else
a6e633de
PP
948# ifdef __cplusplus
949 extern "C" {
950# endif
a0d0e21e 951U32 cast_ulong _((double));
a6e633de
PP
952# ifdef __cplusplus
953 }
954# endif
232e078e
AD
955#define U_S(what) ((U16)cast_ulong((double)(what)))
956#define U_I(what) ((unsigned int)cast_ulong((double)(what)))
957#define U_L(what) (cast_ulong((double)(what)))
ee0007ab
LW
958#endif
959
ed6116ce
LW
960#ifdef CASTI32
961#define I_32(what) ((I32)(what))
a0d0e21e 962#define I_V(what) ((IV)(what))
5d94fbed 963#define U_V(what) ((UV)(what))
ed6116ce 964#else
a6e633de
PP
965# ifdef __cplusplus
966 extern "C" {
967# endif
a0d0e21e 968I32 cast_i32 _((double));
a0d0e21e 969IV cast_iv _((double));
5d94fbed 970UV cast_uv _((double));
a6e633de
PP
971# ifdef __cplusplus
972 }
973# endif
974#define I_32(what) (cast_i32((double)(what)))
975#define I_V(what) (cast_iv((double)(what)))
5d94fbed 976#define U_V(what) (cast_uv((double)(what)))
ed6116ce
LW
977#endif
978
79072805
LW
979struct Outrec {
980 I32 o_lines;
d9d8d8de 981 char *o_str;
79072805 982 U32 o_len;
8d063cd8
LW
983};
984
352d5a3a
LW
985#ifndef MAXSYSFD
986# define MAXSYSFD 2
987#endif
ee0007ab 988
f82b3d41
PP
989#ifndef TMPPATH
990# define TMPPATH "/tmp/perl-eXXXXXX"
a0d0e21e 991#endif
79072805
LW
992
993#ifndef __cplusplus
a0d0e21e
LW
994Uid_t getuid _((void));
995Uid_t geteuid _((void));
996Gid_t getgid _((void));
997Gid_t getegid _((void));
79072805 998#endif
8d063cd8
LW
999
1000#ifdef DEBUGGING
0c30d9ec 1001#ifndef Perl_debug_log
760ac839 1002#define Perl_debug_log PerlIO_stderr()
0c30d9ec 1003#endif
d96024cf 1004#define YYDEBUG 1
79072805
LW
1005#define DEB(a) a
1006#define DEBUG(a) if (debug) a
1007#define DEBUG_p(a) if (debug & 1) a
1008#define DEBUG_s(a) if (debug & 2) a
1009#define DEBUG_l(a) if (debug & 4) a
1010#define DEBUG_t(a) if (debug & 8) a
1011#define DEBUG_o(a) if (debug & 16) a
1012#define DEBUG_c(a) if (debug & 32) a
1013#define DEBUG_P(a) if (debug & 64) a
0c30d9ec 1014#define DEBUG_m(a) if (curinterp && debug & 128) a
79072805
LW
1015#define DEBUG_f(a) if (debug & 256) a
1016#define DEBUG_r(a) if (debug & 512) a
1017#define DEBUG_x(a) if (debug & 1024) a
1018#define DEBUG_u(a) if (debug & 2048) a
1019#define DEBUG_L(a) if (debug & 4096) a
1020#define DEBUG_H(a) if (debug & 8192) a
1021#define DEBUG_X(a) if (debug & 16384) a
8990e307 1022#define DEBUG_D(a) if (debug & 32768) a
79072805
LW
1023#else
1024#define DEB(a)
1025#define DEBUG(a)
1026#define DEBUG_p(a)
1027#define DEBUG_s(a)
1028#define DEBUG_l(a)
1029#define DEBUG_t(a)
1030#define DEBUG_o(a)
1031#define DEBUG_c(a)
1032#define DEBUG_P(a)
1033#define DEBUG_m(a)
1034#define DEBUG_f(a)
1035#define DEBUG_r(a)
1036#define DEBUG_x(a)
1037#define DEBUG_u(a)
1038#define DEBUG_L(a)
1039#define DEBUG_H(a)
1040#define DEBUG_X(a)
8990e307 1041#define DEBUG_D(a)
8d063cd8 1042#endif
fe14fcc3 1043#define YYMAXDEPTH 300
8d063cd8 1044
a6e633de 1045#ifndef assert /* <assert.h> might have been included somehow */
79072805
LW
1046#define assert(what) DEB( { \
1047 if (!(what)) { \
463ee0b2 1048 croak("Assertion failed: file \"%s\", line %d", \
79072805
LW
1049 __FILE__, __LINE__); \
1050 exit(1); \
1051 }})
a6e633de 1052#endif
8d063cd8 1053
450a55e4 1054struct ufuncs {
a0d0e21e
LW
1055 I32 (*uf_val)_((IV, SV*));
1056 I32 (*uf_set)_((IV, SV*));
1057 IV uf_index;
450a55e4
LW
1058};
1059
fe14fcc3 1060/* Fix these up for __STDC__ */
a0d0e21e
LW
1061#ifndef __cplusplus
1062char *mktemp _((char*));
1063double atof _((const char*));
1064#endif
79072805 1065
352d5a3a 1066#ifndef STANDARD_C
fe14fcc3 1067/* All of these are in stdlib.h or time.h for ANSI C */
85e6fe83 1068Time_t time();
8d063cd8 1069struct tm *gmtime(), *localtime();
93a17b20 1070char *strchr(), *strrchr();
378cc40b 1071char *strcpy(), *strcat();
352d5a3a 1072#endif /* ! STANDARD_C */
8d063cd8 1073
79072805
LW
1074
1075#ifdef I_MATH
1076# include <math.h>
1077#else
1078# ifdef __cplusplus
1079 extern "C" {
1080# endif
a0d0e21e 1081 double exp _((double));
a0d0e21e
LW
1082 double log _((double));
1083 double sqrt _((double));
1084 double modf _((double,double*));
1085 double sin _((double));
1086 double cos _((double));
1087 double atan2 _((double,double));
1088 double pow _((double,double));
79072805
LW
1089# ifdef __cplusplus
1090 };
1091# endif
1092#endif
1093
a0d0e21e 1094#ifndef __cplusplus
3fc1aec6
PP
1095#ifdef __NeXT__ /* or whatever catches all NeXTs */
1096char *crypt (); /* Maybe more hosts will need the unprototyped version */
1097#else
a0d0e21e 1098char *crypt _((const char*, const char*));
3fc1aec6 1099#endif
a0d0e21e
LW
1100char *getenv _((const char*));
1101Off_t lseek _((int,Off_t,int));
1102char *getlogin _((void));
1103#endif
79072805 1104
16d20bd9 1105#ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
378cc40b 1106#define UNLINK unlnk
a0d0e21e 1107I32 unlnk _((char*));
8d063cd8
LW
1108#else
1109#define UNLINK unlink
1110#endif
a687059c 1111
fe14fcc3 1112#ifndef HAS_SETREUID
85e6fe83
LW
1113# ifdef HAS_SETRESUID
1114# define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
1115# define HAS_SETREUID
1116# endif
a687059c 1117#endif
fe14fcc3 1118#ifndef HAS_SETREGID
85e6fe83
LW
1119# ifdef HAS_SETRESGID
1120# define setregid(r,e) setresgid(r,e,(Gid_t)-1)
1121# define HAS_SETREGID
1122# endif
a687059c 1123#endif
ee0007ab
LW
1124
1125#define SCAN_DEF 0
1126#define SCAN_TR 1
1127#define SCAN_REPL 2
79072805 1128
760ac839
LW
1129#ifdef MYMALLOC
1130# ifndef DEBUGGING_MSTATS
1131# define DEBUGGING_MSTATS
1132# endif
1133#endif
1134
79072805 1135#ifdef DEBUGGING
4633a7c4 1136# ifndef register
a0d0e21e
LW
1137# define register
1138# endif
1139# define PAD_SV(po) pad_sv(po)
79072805 1140#else
a0d0e21e 1141# define PAD_SV(po) curpad[po]
79072805
LW
1142#endif
1143
1144/****************/
1145/* Truly global */
1146/****************/
1147
1148/* global state */
a0d0e21e 1149EXT PerlInterpreter * curinterp; /* currently running interpreter */
0c30d9ec
PP
1150/* VMS doesn't use environ array and NeXT has problems with crt0.o globals */
1151#if !defined(VMS) && !(defined(NeXT) && defined(__DYNAMIC__))
79072805 1152extern char ** environ; /* environment variables supplied via exec */
0c30d9ec
PP
1153#else
1154# if defined(NeXT) && defined(__DYNAMIC__)
1155
1156# include <mach-o/dyld.h>
1157EXT char *** environ_pointer;
1158# define environ (*environ_pointer)
1159# endif
1160#endif /* environ processing */
1161
79072805
LW
1162EXT int uid; /* current real user id */
1163EXT int euid; /* current effective user id */
1164EXT int gid; /* current real group id */
1165EXT int egid; /* current effective group id */
1166EXT bool nomemok; /* let malloc context handle nomem */
1167EXT U32 an; /* malloc sequence number */
463ee0b2 1168EXT U32 cop_seqmax; /* statement sequence number */
c07a80fd 1169EXT U16 op_seqmax; /* op sequence number */
8990e307 1170EXT U32 evalseq; /* eval sequence number */
463ee0b2 1171EXT U32 sub_generation; /* inc to force methods to be looked up again */
79072805
LW
1172EXT char ** origenviron;
1173EXT U32 origalen;
a0d0e21e 1174EXT U32 * profiledata;
84ea024a 1175EXT int maxo INIT(MAXO);/* Number of ops */
728e2803 1176EXT char * osname; /* operating system */
79072805 1177
a0d0e21e
LW
1178EXT XPV* xiv_arenaroot; /* list of allocated xiv areas */
1179EXT IV ** xiv_root; /* free xiv list--shared by interpreters */
8990e307
LW
1180EXT double * xnv_root; /* free xnv list--shared by interpreters */
1181EXT XRV * xrv_root; /* free xrv list--shared by interpreters */
1182EXT XPV * xpv_root; /* free xpv list--shared by interpreters */
4633a7c4 1183EXT HE * he_root; /* free he list--shared by interpreters */
c07a80fd
PP
1184EXT char * nice_chunk; /* a nice chunk of memory to reuse */
1185EXT U32 nice_chunk_size;/* how nice the chunk of memory is */
8990e307 1186
79072805
LW
1187/* Stack for currently executing thread--context switch must handle this. */
1188EXT SV ** stack_base; /* stack->array_ary */
1189EXT SV ** stack_sp; /* stack pointer now */
1190EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
1191
1192/* likewise for these */
1193
1194EXT OP * op; /* current op--oughta be in a global register */
1195
1196EXT I32 * scopestack; /* blocks we've entered */
1197EXT I32 scopestack_ix;
1198EXT I32 scopestack_max;
1199
1200EXT ANY* savestack; /* to save non-local values on */
1201EXT I32 savestack_ix;
1202EXT I32 savestack_max;
1203
1204EXT OP ** retstack; /* returns we've pushed */
1205EXT I32 retstack_ix;
1206EXT I32 retstack_max;
1207
1208EXT I32 * markstack; /* stackmarks we're remembering */
1209EXT I32 * markstack_ptr; /* stackmarks we're remembering */
1210EXT I32 * markstack_max; /* stackmarks we're remembering */
1211
1212EXT SV ** curpad;
1213
1214/* temp space */
1215EXT SV * Sv;
3fc1aec6 1216EXT HE He;
79072805 1217EXT XPV * Xpv;
f82b3d41 1218EXT char buf[2048]; /* should be longer than PATH_MAX */
79072805
LW
1219EXT char tokenbuf[256];
1220EXT struct stat statbuf;
ecfc5424 1221#ifdef HAS_TIMES
79072805
LW
1222EXT struct tms timesbuf;
1223#endif
463ee0b2 1224EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
79072805
LW
1225
1226/* for tmp use in stupid debuggers */
1227EXT int * di;
1228EXT short * ds;
1229EXT char * dc;
1230
1231/* handy constants */
1232EXT char * Yes INIT("1");
1233EXT char * No INIT("");
1234EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
79072805
LW
1235EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
1236EXT char * vert INIT("|");
1237
8990e307 1238EXT char warn_uninit[]
a0d0e21e 1239 INIT("Use of uninitialized value");
463ee0b2
LW
1240EXT char warn_nosemi[]
1241 INIT("Semicolon seems to be missing");
1242EXT char warn_reserved[]
1243 INIT("Unquoted string \"%s\" may clash with future reserved word");
1244EXT char warn_nl[]
93a17b20 1245 INIT("Unsuccessful %s on filename containing newline");
a0d0e21e
LW
1246EXT char no_wrongref[]
1247 INIT("Can't use %s ref as %s ref");
1248EXT char no_symref[]
748a9306 1249 INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
93a17b20 1250EXT char no_usym[]
8990e307 1251 INIT("Can't use an undefined value as %s reference");
93a17b20
LW
1252EXT char no_aelem[]
1253 INIT("Modification of non-creatable array value attempted, subscript %d");
1254EXT char no_helem[]
1255 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
1256EXT char no_modify[]
1257 INIT("Modification of a read-only value attempted");
1258EXT char no_mem[]
1259 INIT("Out of memory!\n");
1260EXT char no_security[]
463ee0b2 1261 INIT("Insecure dependency in %s%s");
93a17b20
LW
1262EXT char no_sock_func[]
1263 INIT("Unsupported socket function \"%s\" called");
1264EXT char no_dir_func[]
1265 INIT("Unsupported directory function \"%s\" called");
1266EXT char no_func[]
1267 INIT("The %s function is unimplemented");
748a9306
LW
1268EXT char no_myglob[]
1269 INIT("\"my\" variable %s can't be in a package");
93a17b20 1270
79072805
LW
1271EXT SV sv_undef;
1272EXT SV sv_no;
1273EXT SV sv_yes;
1274#ifdef CSH
1275 EXT char * cshname INIT(CSH);
1276 EXT I32 cshlen;
1277#endif
1278
1279#ifdef DOINIT
8e07c86e
AD
1280EXT char *sig_name[] = { SIG_NAME };
1281EXT int sig_num[] = { SIG_NUM };
0c30d9ec
PP
1282EXT SV * psig_ptr[sizeof(sig_num)/sizeof(*sig_num)];
1283EXT SV * psig_name[sizeof(sig_num)/sizeof(*sig_num)];
79072805
LW
1284#else
1285EXT char *sig_name[];
8e07c86e 1286EXT int sig_num[];
0c30d9ec
PP
1287EXT SV * psig_ptr[];
1288EXT SV * psig_name[];
79072805
LW
1289#endif
1290
1291#ifdef DOINIT
79072805
LW
1292EXT unsigned char fold[] = { /* fast case folding table */
1293 0, 1, 2, 3, 4, 5, 6, 7,
1294 8, 9, 10, 11, 12, 13, 14, 15,
1295 16, 17, 18, 19, 20, 21, 22, 23,
1296 24, 25, 26, 27, 28, 29, 30, 31,
1297 32, 33, 34, 35, 36, 37, 38, 39,
1298 40, 41, 42, 43, 44, 45, 46, 47,
1299 48, 49, 50, 51, 52, 53, 54, 55,
1300 56, 57, 58, 59, 60, 61, 62, 63,
1301 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1302 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1303 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1304 'x', 'y', 'z', 91, 92, 93, 94, 95,
1305 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1306 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1307 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1308 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1309 128, 129, 130, 131, 132, 133, 134, 135,
1310 136, 137, 138, 139, 140, 141, 142, 143,
1311 144, 145, 146, 147, 148, 149, 150, 151,
1312 152, 153, 154, 155, 156, 157, 158, 159,
1313 160, 161, 162, 163, 164, 165, 166, 167,
1314 168, 169, 170, 171, 172, 173, 174, 175,
1315 176, 177, 178, 179, 180, 181, 182, 183,
1316 184, 185, 186, 187, 188, 189, 190, 191,
1317 192, 193, 194, 195, 196, 197, 198, 199,
1318 200, 201, 202, 203, 204, 205, 206, 207,
1319 208, 209, 210, 211, 212, 213, 214, 215,
1320 216, 217, 218, 219, 220, 221, 222, 223,
1321 224, 225, 226, 227, 228, 229, 230, 231,
1322 232, 233, 234, 235, 236, 237, 238, 239,
1323 240, 241, 242, 243, 244, 245, 246, 247,
1324 248, 249, 250, 251, 252, 253, 254, 255
1325};
1326#else
1327EXT unsigned char fold[];
1328#endif
1329
1330#ifdef DOINIT
1331EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
1332 1, 2, 84, 151, 154, 155, 156, 157,
1333 165, 246, 250, 3, 158, 7, 18, 29,
1334 40, 51, 62, 73, 85, 96, 107, 118,
1335 129, 140, 147, 148, 149, 150, 152, 153,
1336 255, 182, 224, 205, 174, 176, 180, 217,
1337 233, 232, 236, 187, 235, 228, 234, 226,
1338 222, 219, 211, 195, 188, 193, 185, 184,
1339 191, 183, 201, 229, 181, 220, 194, 162,
1340 163, 208, 186, 202, 200, 218, 198, 179,
1341 178, 214, 166, 170, 207, 199, 209, 206,
1342 204, 160, 212, 216, 215, 192, 175, 173,
1343 243, 172, 161, 190, 203, 189, 164, 230,
1344 167, 248, 227, 244, 242, 255, 241, 231,
1345 240, 253, 169, 210, 245, 237, 249, 247,
1346 239, 168, 252, 251, 254, 238, 223, 221,
1347 213, 225, 177, 197, 171, 196, 159, 4,
1348 5, 6, 8, 9, 10, 11, 12, 13,
1349 14, 15, 16, 17, 19, 20, 21, 22,
1350 23, 24, 25, 26, 27, 28, 30, 31,
1351 32, 33, 34, 35, 36, 37, 38, 39,
1352 41, 42, 43, 44, 45, 46, 47, 48,
1353 49, 50, 52, 53, 54, 55, 56, 57,
1354 58, 59, 60, 61, 63, 64, 65, 66,
1355 67, 68, 69, 70, 71, 72, 74, 75,
1356 76, 77, 78, 79, 80, 81, 82, 83,
1357 86, 87, 88, 89, 90, 91, 92, 93,
1358 94, 95, 97, 98, 99, 100, 101, 102,
1359 103, 104, 105, 106, 108, 109, 110, 111,
1360 112, 113, 114, 115, 116, 117, 119, 120,
1361 121, 122, 123, 124, 125, 126, 127, 128,
1362 130, 131, 132, 133, 134, 135, 136, 137,
1363 138, 139, 141, 142, 143, 144, 145, 146
1364};
1365#else
1366EXT unsigned char freq[];
1367#endif
1368
8990e307
LW
1369#ifdef DEBUGGING
1370#ifdef DOINIT
1371EXT char* block_type[] = {
1372 "NULL",
1373 "SUB",
1374 "EVAL",
1375 "LOOP",
1376 "SUBST",
1377 "BLOCK",
1378};
1379#else
1380EXT char* block_type[];
1381#endif
1382#endif
1383
79072805
LW
1384/*****************************************************************************/
1385/* This lexer/parser stuff is currently global since yacc is hard to reenter */
1386/*****************************************************************************/
8990e307 1387/* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
79072805 1388
a0d0e21e
LW
1389#include "perly.h"
1390
79072805
LW
1391typedef enum {
1392 XOPERATOR,
1393 XTERM,
79072805 1394 XREF,
8990e307 1395 XSTATE,
a0d0e21e
LW
1396 XBLOCK,
1397 XTERMBLOCK
79072805
LW
1398} expectation;
1399
a0d0e21e
LW
1400EXT U32 lex_state; /* next token is determined */
1401EXT U32 lex_defer; /* state after determined token */
1402EXT expectation lex_expect; /* expect after determined token */
1403EXT I32 lex_brackets; /* bracket count */
1404EXT I32 lex_formbrack; /* bracket count at outer format level */
1405EXT I32 lex_fakebrack; /* outer bracket is mere delimiter */
1406EXT I32 lex_casemods; /* casemod count */
1407EXT I32 lex_dojoin; /* doing an array interpolation */
1408EXT I32 lex_starts; /* how many interps done on level */
1409EXT SV * lex_stuff; /* runtime pattern from m// or s/// */
1410EXT SV * lex_repl; /* runtime replacement from s/// */
1411EXT OP * lex_op; /* extra info to pass back on op */
1412EXT OP * lex_inpat; /* in pattern $) and $| are special */
1413EXT I32 lex_inwhat; /* what kind of quoting are we in */
1414EXT char * lex_brackstack; /* what kind of brackets to pop */
1415EXT char * lex_casestack; /* what kind of case mods in effect */
1416
1417/* What we know when we're in LEX_KNOWNEXT state. */
1418EXT YYSTYPE nextval[5]; /* value of next token, if any */
1419EXT I32 nexttype[5]; /* type of next token */
1420EXT I32 nexttoke;
1421
760ac839 1422EXT PerlIO * VOL rsfp INIT(Nullfp);
79072805
LW
1423EXT SV * linestr;
1424EXT char * bufptr;
1425EXT char * oldbufptr;
1426EXT char * oldoldbufptr;
1427EXT char * bufend;
8990e307 1428EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */
16d20bd9 1429EXT AV * rsfp_filters;
79072805
LW
1430
1431EXT I32 multi_start; /* 1st line of multi-line string */
1432EXT I32 multi_end; /* last line of multi-line string */
1433EXT I32 multi_open; /* delimiter of said string */
1434EXT I32 multi_close; /* delimiter of said string */
1435
1436EXT GV * scrgv;
1437EXT I32 error_count; /* how many errors so far, max 10 */
1438EXT I32 subline; /* line this subroutine began on */
1439EXT SV * subname; /* name of current subroutine */
1440
748a9306 1441EXT CV * compcv; /* currently compiling subroutine */
93a17b20 1442EXT AV * comppad; /* storage for lexically scoped temporaries */
8990e307
LW
1443EXT AV * comppad_name; /* variable names for "my" variables */
1444EXT I32 comppad_name_fill;/* last "introduced" variable offset */
0c30d9ec 1445EXT I32 comppad_name_floor;/* start of vars in innermost block */
8990e307
LW
1446EXT I32 min_intro_pending;/* start of vars to introduce */
1447EXT I32 max_intro_pending;/* end of vars to introduce */
79072805 1448EXT I32 padix; /* max used index in current "register" pad */
a0d0e21e 1449EXT I32 padix_floor; /* how low may inner block reset padix */
748a9306 1450EXT I32 pad_reset_pending; /* reset pad on next attempted alloc */
79072805
LW
1451EXT COP compiling;
1452
79072805
LW
1453EXT I32 thisexpr; /* name id for nothing_in_common() */
1454EXT char * last_uni; /* position of last named-unary operator */
1455EXT char * last_lop; /* position of last list operator */
8990e307 1456EXT OPCODE last_lop_op; /* last list operator */
93a17b20 1457EXT bool in_my; /* we're compiling a "my" declaration */
79072805
LW
1458#ifdef FCRYPT
1459EXT I32 cryptseen; /* has fast crypt() been initialized? */
1460#endif
1461
85e6fe83
LW
1462EXT U32 hints; /* various compilation flags */
1463
1464 /* Note: the lowest 8 bits are reserved for
1465 stuffing into op->op_private */
1466#define HINT_INTEGER 0x00000001
1467#define HINT_STRICT_REFS 0x00000002
1468
1469#define HINT_BLOCK_SCOPE 0x00000100
1470#define HINT_STRICT_SUBS 0x00000200
1471#define HINT_STRICT_VARS 0x00000400
0c30d9ec 1472#define HINT_STRICT_UNTIE 0x00000800
85e6fe83 1473
79072805
LW
1474/**************************************************************************/
1475/* This regexp stuff is global since it always happens within 1 expr eval */
1476/**************************************************************************/
1477
1478EXT char * regprecomp; /* uncompiled string. */
1479EXT char * regparse; /* Input-scan pointer. */
1480EXT char * regxend; /* End of input for compile */
1481EXT I32 regnpar; /* () count. */
1482EXT char * regcode; /* Code-emit pointer; &regdummy = don't. */
1483EXT I32 regsize; /* Code size. */
a0d0e21e 1484EXT I32 regnaughty; /* How bad is this pattern? */
79072805
LW
1485EXT I32 regsawback; /* Did we see \1, ...? */
1486
1487EXT char * reginput; /* String-input pointer. */
79072805
LW
1488EXT char * regbol; /* Beginning of input, for ^ check. */
1489EXT char * regeol; /* End of input, for $ check. */
1490EXT char ** regstartp; /* Pointer to startp array. */
1491EXT char ** regendp; /* Ditto for endp. */
a0d0e21e 1492EXT U32 * reglastparen; /* Similarly for lastparen. */
79072805 1493EXT char * regtill; /* How far we are required to go. */
a0d0e21e
LW
1494EXT U16 regflags; /* are we folding, multilining? */
1495EXT char regprev; /* char before regbol, \n if none */
79072805 1496
760ac839
LW
1497EXT bool do_undump; /* -u or dump seen? */
1498EXT VOL U32 debug;
1499
79072805
LW
1500/***********************************************/
1501/* Global only to current interpreter instance */
1502/***********************************************/
1503
8990e307 1504#ifdef MULTIPLICITY
79072805
LW
1505#define IEXT
1506#define IINIT(x)
1507struct interpreter {
1508#else
1509#define IEXT EXT
1510#define IINIT(x) INIT(x)
1511#endif
1512
1513/* pseudo environmental stuff */
1514IEXT int Iorigargc;
1515IEXT char ** Iorigargv;
1516IEXT GV * Ienvgv;
1517IEXT GV * Isiggv;
1518IEXT GV * Iincgv;
1519IEXT char * Iorigfilename;
748a9306
LW
1520IEXT SV * Idiehook;
1521IEXT SV * Iwarnhook;
1522IEXT SV * Iparsehook;
79072805 1523
c07a80fd
PP
1524/* Various states of an input record separator SV (rs, nrs) */
1525#define RsSNARF(sv) (! SvOK(sv))
1526#define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv))
1527#define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv))
1528
79072805
LW
1529/* switches */
1530IEXT char * Icddir;
1531IEXT bool Iminus_c;
a5f75d66 1532IEXT char Ipatchlevel[10];
728e2803 1533IEXT char ** Ilocalpatches;
c07a80fd 1534IEXT SV * Inrs;
2304df62 1535IEXT char * Isplitstr IINIT(" ");
79072805
LW
1536IEXT bool Ipreprocess;
1537IEXT bool Iminus_n;
1538IEXT bool Iminus_p;
1539IEXT bool Iminus_l;
1540IEXT bool Iminus_a;
2304df62 1541IEXT bool Iminus_F;
79072805
LW
1542IEXT bool Idoswitches;
1543IEXT bool Idowarn;
1544IEXT bool Idoextract;
79072805
LW
1545IEXT bool Isawampersand; /* must save all match strings */
1546IEXT bool Isawstudy; /* do fbm_instr on all strings */
1547IEXT bool Isawi; /* study must assume case insensitive */
1548IEXT bool Isawvec;
1549IEXT bool Iunsafe;
79072805
LW
1550IEXT char * Iinplace;
1551IEXT char * Ie_tmpname;
760ac839 1552IEXT PerlIO * Ie_fp;
79072805 1553IEXT U32 Iperldb;
748a9306
LW
1554 /* This value may be raised by extensions for testing purposes */
1555IEXT int Iperl_destruct_level; /* 0=none, 1=full, 2=full with checks */
79072805
LW
1556
1557/* magical thingies */
85e6fe83 1558IEXT Time_t Ibasetime; /* $^T */
79072805
LW
1559IEXT SV * Iformfeed; /* $^L */
1560IEXT char * Ichopset IINIT(" \n-"); /* $: */
c07a80fd 1561IEXT SV * Irs; /* $/ */
79072805 1562IEXT char * Iofs; /* $, */
8990e307 1563IEXT STRLEN Iofslen;
79072805 1564IEXT char * Iors; /* $\ */
8990e307 1565IEXT STRLEN Iorslen;
79072805
LW
1566IEXT char * Iofmt; /* $# */
1567IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1568IEXT int Imultiline; /* $*--do strings hold >1 line? */
748a9306 1569IEXT U32 Istatusvalue; /* $? */
79072805
LW
1570
1571IEXT struct stat Istatcache; /* _ */
1572IEXT GV * Istatgv;
1573IEXT SV * Istatname IINIT(Nullsv);
1574
1575/* shortcuts to various I/O objects */
1576IEXT GV * Istdingv;
1577IEXT GV * Ilast_in_gv;
1578IEXT GV * Idefgv;
1579IEXT GV * Iargvgv;
1580IEXT GV * Idefoutgv;
79072805
LW
1581IEXT GV * Iargvoutgv;
1582
1583/* shortcuts to regexp stuff */
1584IEXT GV * Ileftgv;
1585IEXT GV * Iampergv;
1586IEXT GV * Irightgv;
1587IEXT PMOP * Icurpm; /* what to do \ interps from */
79072805
LW
1588IEXT I32 * Iscreamfirst;
1589IEXT I32 * Iscreamnext;
1590IEXT I32 Imaxscream IINIT(-1);
1591IEXT SV * Ilastscream;
1592
4633a7c4
LW
1593/* shortcuts to misc objects */
1594IEXT GV * Ierrgv;
1595
79072805
LW
1596/* shortcuts to debugging objects */
1597IEXT GV * IDBgv;
1598IEXT GV * IDBline;
1599IEXT GV * IDBsub;
1600IEXT SV * IDBsingle;
1601IEXT SV * IDBtrace;
1602IEXT SV * IDBsignal;
1603IEXT AV * Ilineary; /* lines of script for debugger */
1604IEXT AV * Idbargs; /* args to call listed by caller function */
1605
1606/* symbol tables */
1607IEXT HV * Idefstash; /* main symbol table */
1608IEXT HV * Icurstash; /* symbol table for current package */
1609IEXT HV * Idebstash; /* symbol table for perldb package */
1610IEXT SV * Icurstname; /* name of current package */
93a17b20
LW
1611IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1612IEXT AV * Iendav; /* names of END subroutines */
0c30d9ec 1613IEXT HV * Istrtab; /* shared string table */
79072805
LW
1614
1615/* memory management */
79072805
LW
1616IEXT SV ** Itmps_stack;
1617IEXT I32 Itmps_ix IINIT(-1);
1618IEXT I32 Itmps_floor IINIT(-1);
8990e307
LW
1619IEXT I32 Itmps_max;
1620IEXT I32 Isv_count; /* how many SV* are currently allocated */
a0d0e21e 1621IEXT I32 Isv_objcount; /* how many objects are currently allocated */
8990e307
LW
1622IEXT SV* Isv_root; /* storage for SVs belonging to interp */
1623IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */
79072805
LW
1624
1625/* funky return mechanisms */
1626IEXT I32 Ilastspbase;
1627IEXT I32 Ilastsize;
1628IEXT int Iforkprocess; /* so do_open |- can return proc# */
1629
1630/* subprocess state */
1631IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1632IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1633
1634/* internal state */
463ee0b2
LW
1635IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1636IEXT OP * Irestartop; /* Are we propagating an error from croak? */
79072805 1637IEXT int Idelaymagic; /* ($<,$>) = ... */
2304df62 1638IEXT bool Idirty; /* In the middle of tearing things down? */
748a9306 1639IEXT U8 Ilocalizing; /* are we processing a local() list? */
79072805 1640IEXT bool Itainted; /* using variables controlled by $< */
463ee0b2 1641IEXT bool Itainting; /* doing taint checks */
e50aee73 1642IEXT char * Iop_mask IINIT(NULL); /* masked operations for safe evals */
79072805
LW
1643
1644/* trace state */
1645IEXT I32 Idlevel;
1646IEXT I32 Idlmax IINIT(128);
1647IEXT char * Idebname;
1648IEXT char * Idebdelim;
1649
1650/* current interpreter roots */
748a9306 1651IEXT CV * Imain_cv;
463ee0b2
LW
1652IEXT OP * Imain_root;
1653IEXT OP * Imain_start;
1654IEXT OP * Ieval_root;
1655IEXT OP * Ieval_start;
79072805
LW
1656
1657/* runtime control stuff */
1658IEXT COP * VOL Icurcop IINIT(&compiling);
0c30d9ec 1659IEXT COP * Icurcopdb IINIT(NULL);
79072805
LW
1660IEXT line_t Icopline IINIT(NOLINE);
1661IEXT CONTEXT * Icxstack;
1662IEXT I32 Icxstack_ix IINIT(-1);
1663IEXT I32 Icxstack_max IINIT(128);
a5f75d66 1664IEXT Sigjmp_buf Itop_env;
a0d0e21e 1665IEXT I32 Irunlevel;
79072805
LW
1666
1667/* stack stuff */
0c30d9ec 1668IEXT AV * Icurstack; /* THE STACK */
79072805
LW
1669IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1670IEXT SV ** Imystack_base; /* stack->array_ary */
1671IEXT SV ** Imystack_sp; /* stack pointer now */
1672IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1673
1674/* format accumulators */
463ee0b2
LW
1675IEXT SV * Iformtarget;
1676IEXT SV * Ibodytarget;
1677IEXT SV * Itoptarget;
79072805
LW
1678
1679/* statics moved here for shared library purposes */
93a17b20 1680IEXT SV Istrchop; /* return value from chop */
79072805
LW
1681IEXT int Ifilemode; /* so nextargv() can preserve mode */
1682IEXT int Ilastfd; /* what to preserve mode on */
1683IEXT char * Ioldname; /* what to preserve mode on */
1684IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1685IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1686IEXT OP * Isortcop; /* user defined sort routine */
1687IEXT HV * Isortstash; /* which is in some package or other */
1688IEXT GV * Ifirstgv; /* $a */
1689IEXT GV * Isecondgv; /* $b */
1690IEXT AV * Isortstack; /* temp stack during pp_sort() */
1691IEXT AV * Isignalstack; /* temp stack during sighandler() */
1692IEXT SV * Imystrk; /* temp key string for do_each() */
1693IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
79072805
LW
1694IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1695IEXT I32 Igensym; /* next symbol for getsym() to define */
1696IEXT bool Ipreambled;
3c81428c 1697IEXT AV * Ipreambleav;
79072805
LW
1698IEXT int Ilaststatval IINIT(-1);
1699IEXT I32 Ilaststype IINIT(OP_STAT);
1700
1701#undef IEXT
1702#undef IINIT
1703
8990e307 1704#ifdef MULTIPLICITY
79072805
LW
1705};
1706#else
1707struct interpreter {
1708 char broiled;
1709};
1710#endif
1711
1712#include "pp.h"
1713
1714#ifdef __cplusplus
1715extern "C" {
1716#endif
1717
1718#include "proto.h"
1719
a0d0e21e
LW
1720#ifdef EMBED
1721#define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1722#define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1723#else
1724#define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1725#define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1726#endif
1727
79072805
LW
1728#ifdef __cplusplus
1729};
1730#endif
1731
93a17b20 1732/* The following must follow proto.h */
79072805
LW
1733
1734#ifdef DOINIT
4633a7c4 1735EXT MGVTBL vtbl_sv = {magic_get,
463ee0b2
LW
1736 magic_set,
1737 magic_len,
1738 0, 0};
4633a7c4
LW
1739EXT MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1740EXT MGVTBL vtbl_envelem = {0, magic_setenv,
85e6fe83
LW
1741 0, magic_clearenv,
1742 0};
4633a7c4 1743EXT MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
0c30d9ec
PP
1744EXT MGVTBL vtbl_sigelem = {magic_getsig,
1745 magic_setsig,
1746 0, magic_clearsig,
1747 0};
4633a7c4 1748EXT MGVTBL vtbl_pack = {0, 0, 0, magic_wipepack,
a0d0e21e 1749 0};
4633a7c4 1750EXT MGVTBL vtbl_packelem = {magic_getpack,
463ee0b2
LW
1751 magic_setpack,
1752 0, magic_clearpack,
1753 0};
4633a7c4 1754EXT MGVTBL vtbl_dbline = {0, magic_setdbline,
463ee0b2 1755 0, 0, 0};
4633a7c4 1756EXT MGVTBL vtbl_isa = {0, magic_setisa,
463ee0b2 1757 0, 0, 0};
4633a7c4 1758EXT MGVTBL vtbl_isaelem = {0, magic_setisa,
463ee0b2 1759 0, 0, 0};
4633a7c4 1760EXT MGVTBL vtbl_arylen = {magic_getarylen,
463ee0b2
LW
1761 magic_setarylen,
1762 0, 0, 0};
4633a7c4 1763EXT MGVTBL vtbl_glob = {magic_getglob,
463ee0b2
LW
1764 magic_setglob,
1765 0, 0, 0};
4633a7c4 1766EXT MGVTBL vtbl_mglob = {0, magic_setmglob,
463ee0b2 1767 0, 0, 0};
4633a7c4 1768EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
463ee0b2 1769 0, 0, 0};
4633a7c4 1770EXT MGVTBL vtbl_substr = {0, magic_setsubstr,
463ee0b2 1771 0, 0, 0};
4633a7c4 1772EXT MGVTBL vtbl_vec = {0, magic_setvec,
463ee0b2 1773 0, 0, 0};
4633a7c4 1774EXT MGVTBL vtbl_pos = {magic_getpos,
a0d0e21e
LW
1775 magic_setpos,
1776 0, 0, 0};
4633a7c4 1777EXT MGVTBL vtbl_bm = {0, magic_setbm,
463ee0b2 1778 0, 0, 0};
4633a7c4 1779EXT MGVTBL vtbl_uvar = {magic_getuvar,
463ee0b2
LW
1780 magic_setuvar,
1781 0, 0, 0};
a0d0e21e
LW
1782
1783#ifdef OVERLOAD
4633a7c4 1784EXT MGVTBL vtbl_amagic = {0, magic_setamagic,
748a9306 1785 0, 0, magic_setamagic};
4633a7c4 1786EXT MGVTBL vtbl_amagicelem = {0, magic_setamagic,
748a9306 1787 0, 0, magic_setamagic};
a0d0e21e
LW
1788#endif /* OVERLOAD */
1789
79072805
LW
1790#else
1791EXT MGVTBL vtbl_sv;
1792EXT MGVTBL vtbl_env;
1793EXT MGVTBL vtbl_envelem;
1794EXT MGVTBL vtbl_sig;
1795EXT MGVTBL vtbl_sigelem;
463ee0b2
LW
1796EXT MGVTBL vtbl_pack;
1797EXT MGVTBL vtbl_packelem;
79072805 1798EXT MGVTBL vtbl_dbline;
463ee0b2
LW
1799EXT MGVTBL vtbl_isa;
1800EXT MGVTBL vtbl_isaelem;
79072805
LW
1801EXT MGVTBL vtbl_arylen;
1802EXT MGVTBL vtbl_glob;
93a17b20 1803EXT MGVTBL vtbl_mglob;
463ee0b2 1804EXT MGVTBL vtbl_taint;
79072805
LW
1805EXT MGVTBL vtbl_substr;
1806EXT MGVTBL vtbl_vec;
a0d0e21e 1807EXT MGVTBL vtbl_pos;
79072805
LW
1808EXT MGVTBL vtbl_bm;
1809EXT MGVTBL vtbl_uvar;
a0d0e21e
LW
1810
1811#ifdef OVERLOAD
1812EXT MGVTBL vtbl_amagic;
1813EXT MGVTBL vtbl_amagicelem;
1814#endif /* OVERLOAD */
1815
79072805 1816#endif
85e6fe83 1817
a0d0e21e
LW
1818#ifdef OVERLOAD
1819EXT long amagic_generation;
1820
748a9306 1821#define NofAMmeth 29
a0d0e21e
LW
1822#ifdef DOINIT
1823EXT char * AMG_names[NofAMmeth][2] = {
1824 {"fallback","abs"},
1825 {"bool", "nomethod"},
1826 {"\"\"", "0+"},
1827 {"+","+="},
1828 {"-","-="},
1829 {"*", "*="},
1830 {"/", "/="},
1831 {"%", "%="},
1832 {"**", "**="},
1833 {"<<", "<<="},
1834 {">>", ">>="},
748a9306
LW
1835 {"&", "&="},
1836 {"|", "|="},
1837 {"^", "^="},
a0d0e21e
LW
1838 {"<", "<="},
1839 {">", ">="},
1840 {"==", "!="},
1841 {"<=>", "cmp"},
1842 {"lt", "le"},
1843 {"gt", "ge"},
1844 {"eq", "ne"},
a0d0e21e
LW
1845 {"!", "~"},
1846 {"++", "--"},
1847 {"atan2", "cos"},
1848 {"sin", "exp"},
1849 {"log", "sqrt"},
1850 {"x","x="},
748a9306
LW
1851 {".",".="},
1852 {"=","neg"}
a0d0e21e
LW
1853};
1854#else
1855EXT char * AMG_names[NofAMmeth][2];
1856#endif /* def INITAMAGIC */
1857
1858struct am_table {
1859 long was_ok_sub;
1860 long was_ok_am;
1861 CV* table[NofAMmeth*2];
1862 long fallback;
1863};
1864typedef struct am_table AMT;
1865
1866#define AMGfallNEVER 1
1867#define AMGfallNO 2
1868#define AMGfallYES 3
1869
1870enum {
1871 fallback_amg, abs_amg,
1872 bool__amg, nomethod_amg,
1873 string_amg, numer_amg,
1874 add_amg, add_ass_amg,
1875 subtr_amg, subtr_ass_amg,
1876 mult_amg, mult_ass_amg,
1877 div_amg, div_ass_amg,
1878 mod_amg, mod_ass_amg,
1879 pow_amg, pow_ass_amg,
1880 lshift_amg, lshift_ass_amg,
1881 rshift_amg, rshift_ass_amg,
748a9306
LW
1882 band_amg, band_ass_amg,
1883 bor_amg, bor_ass_amg,
1884 bxor_amg, bxor_ass_amg,
a0d0e21e
LW
1885 lt_amg, le_amg,
1886 gt_amg, ge_amg,
1887 eq_amg, ne_amg,
1888 ncmp_amg, scmp_amg,
1889 slt_amg, sle_amg,
1890 sgt_amg, sge_amg,
1891 seq_amg, sne_amg,
a0d0e21e
LW
1892 not_amg, compl_amg,
1893 inc_amg, dec_amg,
1894 atan2_amg, cos_amg,
1895 sin_amg, exp_amg,
1896 log_amg, sqrt_amg,
1897 repeat_amg, repeat_ass_amg,
748a9306
LW
1898 concat_amg, concat_ass_amg,
1899 copy_amg, neg_amg
a0d0e21e
LW
1900};
1901#endif /* OVERLOAD */
1902
760ac839
LW
1903#if !defined(PERLIO_IS_STDIO) && defined(HAS_ATTRIBUTE)
1904/*
1905 * Now we have __attribute__ out of the way
1906 * Remap printf
1907 */
1908#define printf PerlIO_stdoutf
1909#endif
1910
85e6fe83 1911#endif /* Include guard */
a6e633de 1912