3 * Copyright (c) 1987-1994, Larry Wall
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.
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.
23 #endif /* PERL_FOR_X2P */
26 * STMT_START { statements; } STMT_END;
27 * can be used as a single statement, as in
28 * if (x) STMT_START { ... } STMT_END; else ...
30 * Trying to select a version that gives no warnings...
32 #if !(defined(STMT_START) && defined(STMT_END))
33 # if defined(__GNUC__) && !defined(__STRICT_ANSI__)
34 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
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
42 # define STMT_START do
43 # define STMT_END while (0)
54 # define BYTEORDER 0x1234
57 /* Overall memory policy? */
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...
70 /* define this once if either system, instead of cluttering up the src */
71 #if defined(MSDOS) || defined(atarist)
75 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
79 #if defined(HASVOLATILE) || defined(STANDARD_C)
81 # define VOL // to temporarily suppress warnings
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()
96 # define BSD_GETPGRP(pid) getpgrp((pid))
99 # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
103 # define BSD_GETPGRP(pid) getpgrp2((pid))
109 # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
116 #ifndef _TYPES_ /* If types.h defines this it's easy. */
117 # ifndef major /* Does everyone's types.h define this? */
118 # include <sys/types.h>
132 # include <varargs.h>
138 #ifdef USE_NEXT_CTYPE
140 #if NX_CURRENT_COMPILER_RELEASE >= 400
141 #include <objc/NXCType.h>
142 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
143 #include <appkit/NXCType.h>
144 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
146 #else /* !USE_NEXT_CTYPE */
148 #endif /* USE_NEXT_CTYPE */
154 #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
161 # ifdef PARAM_NEEDS_TYPES
162 # include <sys/types.h>
164 # include <sys/param.h>
168 /* Use all the "standard" definitions? */
169 #if defined(STANDARD_C) && defined(I_STDLIB)
171 #endif /* STANDARD_C */
173 /* Maybe this comes after <stdlib.h> so we don't try to change
174 the standard library prototypes?. We'll use our own in
175 proto.h instead. I guess. The patch had no explanation.
179 # define malloc Perl_malloc
180 # define realloc Perl_realloc
181 # define free Perl_free
182 # define calloc Perl_calloc
184 # define safemalloc malloc
185 # define saferealloc realloc
186 # define safefree free
187 # define safecalloc calloc
190 #define MEM_SIZE Size_t
192 #if defined(I_STRING) || defined(__cplusplus)
195 # include <strings.h>
198 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
200 #define strrchr rindex
203 #if defined(mips) && defined(ultrix) && !defined(__STDC__)
212 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
214 extern char * memcpy _((char*, char*, int));
220 # define memcpy(d,s,l) bcopy(s,d,l)
222 # define memcpy(d,s,l) my_bcopy(s,d,l)
225 #endif /* HAS_MEMCPY */
228 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
230 extern char *memset _((char*, int, int));
233 # define memzero(d,l) memset(d,0,l)
237 # define memzero(d,l) bzero(d,l)
239 # define memzero(d,l) my_bzero(d,l)
242 #endif /* HAS_MEMSET */
245 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
247 extern int memcmp _((char*, char*, int));
252 # define memcmp my_memcmp
254 #endif /* HAS_MEMCMP */
256 /* XXX we prefer bcmp slightly for comparisons that don't care about ordering */
259 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
261 #endif /* HAS_BCMP */
263 #if !defined(HAS_MEMMOVE) && !defined(memmove)
264 # if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
265 # define memmove(d,s,l) bcopy(s,d,l)
267 # if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
268 # define memmove(d,s,l) memcpy(d,s,l)
270 # define memmove(d,s,l) my_bcopy(s,d,l)
276 # include <netinet/in.h>
280 #include <sys/stat.h>
283 /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
284 like UTekV) are broken, sometimes giving false positives. Undefine
285 them here and let the code below set them to proper values.
287 The ghs macro stands for GreenHills Software C-1.8.5 which
288 is the C compiler for sysV88 and the various derivatives.
289 This header file bug is corrected in gcc-2.5.8 and later versions.
290 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
292 #if defined(uts) || (defined(m88k) && defined(ghs))
306 # ifdef I_SYS_TIME_KERNEL
309 # include <sys/time.h>
310 # ifdef I_SYS_TIME_KERNEL
316 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
317 # include <sys/times.h>
321 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
327 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
329 #endif /* !HAS_MKFIFO */
334 # include <net/errno.h>
338 # define FIXSTATUS(sts) (U_L((sts) & 0xffff))
339 # define SHIFTSTATUS(sts) ((sts) >> 8)
340 # define SETERRNO(errcode,vmserrcode) errno = (errcode)
342 # define FIXSTATUS(sts) (U_L(sts))
343 # define SHIFTSTATUS(sts) (sts)
344 # define SETERRNO(errcode,vmserrcode) STMT_START {set_errno(errcode); set_vaxc_errno(vmserrcode);} STMT_END
349 extern int errno; /* ANSI allows errno to be an lvalue expr */
355 char *strerror _((int,...));
357 char *strerror _((int));
360 # define Strerror strerror
363 # ifdef HAS_SYS_ERRLIST
365 extern char *sys_errlist[];
367 # define Strerror(e) \
368 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
375 # include <sys/ioctl.h>
379 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
380 # ifdef HAS_SOCKETPAIR
381 # undef HAS_SOCKETPAIR
396 /* Configure already sets Direntry_t */
397 #if defined(I_DIRENT)
399 # if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
400 # include <sys/dir.h>
404 # include <sys/ndir.h>
408 # include <ndir.h> /* may be wrong in the future */
410 # include <sys/dir.h>
417 /* work around botch in SunOS 4.0.1 and 4.0.2 */
419 # define fputs(sv,fp) fprintf(fp,"%s",sv)
424 * The following gobbledygook brought to you on behalf of __STDC__.
425 * (I could just use #ifndef __STDC__, but this is more bulletproof
426 * in the face of half-implementations.)
431 # define S_IFMT _S_IFMT
433 # define S_IFMT 0170000
438 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
442 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
447 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
449 # define S_ISBLK(m) (0)
454 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
459 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
461 # define S_ISFIFO(m) (0)
467 # define S_ISLNK(m) _S_ISLNK(m)
470 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
473 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
475 # define S_ISLNK(m) (0)
483 # define S_ISSOCK(m) _S_ISSOCK(m)
486 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
489 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
491 # define S_ISSOCK(m) (0)
499 # define S_IRUSR S_IREAD
500 # define S_IWUSR S_IWRITE
501 # define S_IXUSR S_IEXEC
503 # define S_IRUSR 0400
504 # define S_IWUSR 0200
505 # define S_IXUSR 0100
507 # define S_IRGRP (S_IRUSR>>3)
508 # define S_IWGRP (S_IWUSR>>3)
509 # define S_IXGRP (S_IXUSR>>3)
510 # define S_IROTH (S_IRUSR>>6)
511 # define S_IWOTH (S_IWUSR>>6)
512 # define S_IXOTH (S_IXUSR>>6)
516 # define S_ISUID 04000
520 # define S_ISGID 02000
527 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
528 # define SLOPPYDIVIDE
531 #if defined(cray) || defined(convex) || BYTEORDER > 0xffff
544 # define Quad_t long long
550 typedef unsigned Quad_t UV;
553 typedef unsigned long UV;
556 /* Previously these definitions used hardcoded figures.
557 * It is hoped these formula are more portable, although
558 * no data one way or another is presently known to me.
559 * The "PERL_" names are used because these calculated constants
560 * do not meet the ANSI requirements for LONG_MAX, etc., which
561 * need to be constants acceptable to #if - kja
562 * define PERL_LONG_MAX 2147483647L
563 * define PERL_LONG_MIN (-LONG_MAX - 1)
564 * define PERL ULONG_MAX 4294967295L
567 #ifdef I_LIMITS /* Needed for cast_xxx() functions below. */
576 #define PERL_LONG_MAX LONG_MAX
578 # ifdef MAXLONG /* Often used in <values.h> */
579 # define PERL_LONG_MAX MAXLONG
581 # define PERL_LONG_MAX ((long) ((~(unsigned long)0) >> 1))
586 #define PERL_LONG_MIN LONG_MIN
589 # define PERL_LONG_MIN MINLONG
591 # define PERL_LONG_MIN (-LONG_MAX - ((3 & -1) == 3))
596 #define PERL_ULONG_MAX ULONG_MAX
599 # define PERL_ULONG_MAX MAXULONG
601 # define PERL_ULONG_MAX (~(unsigned long)0)
606 #define PERL_ULONG_MIN ULONG_MIN
608 # define ULONG_MIN 0L
611 typedef MEM_SIZE STRLEN;
613 typedef struct op OP;
614 typedef struct cop COP;
615 typedef struct unop UNOP;
616 typedef struct binop BINOP;
617 typedef struct listop LISTOP;
618 typedef struct logop LOGOP;
619 typedef struct condop CONDOP;
620 typedef struct pmop PMOP;
621 typedef struct svop SVOP;
622 typedef struct gvop GVOP;
623 typedef struct pvop PVOP;
624 typedef struct loop LOOP;
626 typedef struct Outrec Outrec;
627 typedef struct interpreter PerlInterpreter;
628 typedef struct ff FF;
629 typedef struct sv SV;
630 typedef struct av AV;
631 typedef struct hv HV;
632 typedef struct cv CV;
633 typedef struct regexp REGEXP;
634 typedef struct gp GP;
635 typedef struct gv GV;
636 typedef struct io IO;
637 typedef struct context CONTEXT;
638 typedef struct block BLOCK;
640 typedef struct magic MAGIC;
641 typedef struct xrv XRV;
642 typedef struct xpv XPV;
643 typedef struct xpviv XPVIV;
644 typedef struct xpvnv XPVNV;
645 typedef struct xpvmg XPVMG;
646 typedef struct xpvlv XPVLV;
647 typedef struct xpvav XPVAV;
648 typedef struct xpvhv XPVHV;
649 typedef struct xpvgv XPVGV;
650 typedef struct xpvcv XPVCV;
651 typedef struct xpvbm XPVBM;
652 typedef struct xpvfm XPVFM;
653 typedef struct xpvio XPVIO;
654 typedef struct mgvtbl MGVTBL;
655 typedef union any ANY;
659 typedef I32 (*filter_t) _((int, SV *, int));
660 #define FILTER_READ(idx, sv, len) filter_read(idx, sv, len)
661 #define FILTER_DATA(idx) (AvARRAY(rsfp_filters)[idx])
662 #define FILTER_ISREADER(idx) (idx >= AvFILL(rsfp_filters))
675 # include "./plan9/plan9ish.h"
677 # include "unixish.h"
682 #ifndef SH_PATH /* May be a variable. */
683 # define SH_PATH BIN_SH
685 # define BIN_SH "/bin/sh"
690 #define pause() sleep((32767<<16)+32767)
695 /* on BSDish systes we're safe */
696 # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
698 /* otherwise guess at what's safe */
699 # define IOCPARM_LEN(x) 256
708 void (*any_dptr) _((void*));
725 /* work around some libPW problems */
730 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
734 #if defined(htonl) && !defined(HAS_HTONL)
737 #if defined(htons) && !defined(HAS_HTONS)
740 #if defined(ntohl) && !defined(HAS_NTOHL)
743 #if defined(ntohs) && !defined(HAS_NTOHS)
747 #if (BYTEORDER & 0xffff) != 0x4321
753 #define htons my_swap
754 #define htonl my_htonl
755 #define ntohs my_swap
756 #define ntohl my_ntohl
759 #if (BYTEORDER & 0xffff) == 0x4321
768 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
771 #if BYTEORDER != 0x1234
776 # if BYTEORDER == 0x4321
777 # define vtohl(x) ((((x)&0xFF)<<24) \
779 +(((x)&0x0000FF00)<<8) \
780 +(((x)&0x00FF0000)>>8) )
781 # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
782 # define htovl(x) vtohl(x)
783 # define htovs(x) vtohs(x)
785 /* otherwise default to functions in util.c */
789 #define U_S(what) ((U16)(what))
790 #define U_I(what) ((unsigned int)(what))
791 #define U_L(what) ((U32)(what))
793 U32 cast_ulong _((double));
794 #define U_S(what) ((U16)cast_ulong((double)(what)))
795 #define U_I(what) ((unsigned int)cast_ulong((double)(what)))
796 #define U_L(what) (cast_ulong((double)(what)))
800 #define I_32(what) ((I32)(what))
801 #define I_V(what) ((IV)(what))
802 #define U_V(what) ((UV)(what))
804 I32 cast_i32 _((double));
805 #define I_32(what) (cast_i32((double)(what)))
806 IV cast_iv _((double));
807 #define I_V(what) (cast_iv((double)(what)))
808 UV cast_uv _((double));
809 #define U_V(what) (cast_uv((double)(what)))
823 # define TMPPATH "/tmp/perl-eXXXXXX"
827 Uid_t getuid _((void));
828 Uid_t geteuid _((void));
829 Gid_t getgid _((void));
830 Gid_t getegid _((void));
834 #ifndef Perl_debug_log
835 #define Perl_debug_log PerlIO_stderr()
839 #define DEBUG(a) if (debug) a
840 #define DEBUG_p(a) if (debug & 1) a
841 #define DEBUG_s(a) if (debug & 2) a
842 #define DEBUG_l(a) if (debug & 4) a
843 #define DEBUG_t(a) if (debug & 8) a
844 #define DEBUG_o(a) if (debug & 16) a
845 #define DEBUG_c(a) if (debug & 32) a
846 #define DEBUG_P(a) if (debug & 64) a
847 #define DEBUG_m(a) if (curinterp && debug & 128) a
848 #define DEBUG_f(a) if (debug & 256) a
849 #define DEBUG_r(a) if (debug & 512) a
850 #define DEBUG_x(a) if (debug & 1024) a
851 #define DEBUG_u(a) if (debug & 2048) a
852 #define DEBUG_L(a) if (debug & 4096) a
853 #define DEBUG_H(a) if (debug & 8192) a
854 #define DEBUG_X(a) if (debug & 16384) a
855 #define DEBUG_D(a) if (debug & 32768) a
876 #define YYMAXDEPTH 300
878 #define assert(what) DEB( { \
880 croak("Assertion failed: file \"%s\", line %d", \
881 __FILE__, __LINE__); \
886 I32 (*uf_val)_((IV, SV*));
887 I32 (*uf_set)_((IV, SV*));
891 /* Fix these up for __STDC__ */
893 char *mktemp _((char*));
894 double atof _((const char*));
898 /* All of these are in stdlib.h or time.h for ANSI C */
900 struct tm *gmtime(), *localtime();
901 char *strchr(), *strrchr();
902 char *strcpy(), *strcat();
903 #endif /* ! STANDARD_C */
912 double exp _((double));
913 double log _((double));
914 double sqrt _((double));
915 double modf _((double,double*));
916 double sin _((double));
917 double cos _((double));
918 double atan2 _((double,double));
919 double pow _((double,double));
926 char *crypt _((const char*, const char*));
927 char *getenv _((const char*));
928 Off_t lseek _((int,Off_t,int));
929 char *getlogin _((void));
932 #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
934 I32 unlnk _((char*));
936 #define UNLINK unlink
940 # ifdef HAS_SETRESUID
941 # define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
942 # define HAS_SETREUID
946 # ifdef HAS_SETRESGID
947 # define setregid(r,e) setresgid(r,e,(Gid_t)-1)
948 # define HAS_SETREGID
957 # ifndef DEBUGGING_MSTATS
958 # define DEBUGGING_MSTATS
966 # define PAD_SV(po) pad_sv(po)
968 # define PAD_SV(po) curpad[po]
976 EXT PerlInterpreter * curinterp; /* currently running interpreter */
977 /* VMS doesn't use environ array and NeXT has problems with crt0.o globals */
978 #if !defined(VMS) && !(defined(NeXT) && defined(__DYNAMIC__))
979 extern char ** environ; /* environment variables supplied via exec */
981 # if defined(NeXT) && defined(__DYNAMIC__)
983 # include <mach-o/dyld.h>
984 EXT char *** environ_pointer;
985 # define environ (*environ_pointer)
987 #endif /* environ processing */
989 EXT int uid; /* current real user id */
990 EXT int euid; /* current effective user id */
991 EXT int gid; /* current real group id */
992 EXT int egid; /* current effective group id */
993 EXT bool nomemok; /* let malloc context handle nomem */
994 EXT U32 an; /* malloc sequence number */
995 EXT U32 cop_seqmax; /* statement sequence number */
996 EXT U16 op_seqmax; /* op sequence number */
997 EXT U32 evalseq; /* eval sequence number */
998 EXT U32 sub_generation; /* inc to force methods to be looked up again */
999 EXT char ** origenviron;
1001 EXT U32 * profiledata;
1002 EXT int maxo INIT(MAXO);/* Number of ops */
1003 EXT char * osname; /* operating system */
1005 EXT XPV* xiv_arenaroot; /* list of allocated xiv areas */
1006 EXT IV ** xiv_root; /* free xiv list--shared by interpreters */
1007 EXT double * xnv_root; /* free xnv list--shared by interpreters */
1008 EXT XRV * xrv_root; /* free xrv list--shared by interpreters */
1009 EXT XPV * xpv_root; /* free xpv list--shared by interpreters */
1010 EXT HE * he_root; /* free he list--shared by interpreters */
1011 EXT char * nice_chunk; /* a nice chunk of memory to reuse */
1012 EXT U32 nice_chunk_size;/* how nice the chunk of memory is */
1014 /* Stack for currently executing thread--context switch must handle this. */
1015 EXT SV ** stack_base; /* stack->array_ary */
1016 EXT SV ** stack_sp; /* stack pointer now */
1017 EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
1019 /* likewise for these */
1021 EXT OP * op; /* current op--oughta be in a global register */
1023 EXT I32 * scopestack; /* blocks we've entered */
1024 EXT I32 scopestack_ix;
1025 EXT I32 scopestack_max;
1027 EXT ANY* savestack; /* to save non-local values on */
1028 EXT I32 savestack_ix;
1029 EXT I32 savestack_max;
1031 EXT OP ** retstack; /* returns we've pushed */
1032 EXT I32 retstack_ix;
1033 EXT I32 retstack_max;
1035 EXT I32 * markstack; /* stackmarks we're remembering */
1036 EXT I32 * markstack_ptr; /* stackmarks we're remembering */
1037 EXT I32 * markstack_max; /* stackmarks we're remembering */
1044 EXT char buf[2048]; /* should be longer than PATH_MAX */
1045 EXT char tokenbuf[256];
1046 EXT struct stat statbuf;
1048 EXT struct tms timesbuf;
1050 EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
1052 /* for tmp use in stupid debuggers */
1057 /* handy constants */
1058 EXT char * Yes INIT("1");
1059 EXT char * No INIT("");
1060 EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
1061 EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
1062 EXT char * vert INIT("|");
1064 EXT char warn_uninit[]
1065 INIT("Use of uninitialized value");
1066 EXT char warn_nosemi[]
1067 INIT("Semicolon seems to be missing");
1068 EXT char warn_reserved[]
1069 INIT("Unquoted string \"%s\" may clash with future reserved word");
1071 INIT("Unsuccessful %s on filename containing newline");
1072 EXT char no_wrongref[]
1073 INIT("Can't use %s ref as %s ref");
1074 EXT char no_symref[]
1075 INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
1077 INIT("Can't use an undefined value as %s reference");
1079 INIT("Modification of non-creatable array value attempted, subscript %d");
1081 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
1082 EXT char no_modify[]
1083 INIT("Modification of a read-only value attempted");
1085 INIT("Out of memory!\n");
1086 EXT char no_security[]
1087 INIT("Insecure dependency in %s%s");
1088 EXT char no_sock_func[]
1089 INIT("Unsupported socket function \"%s\" called");
1090 EXT char no_dir_func[]
1091 INIT("Unsupported directory function \"%s\" called");
1093 INIT("The %s function is unimplemented");
1094 EXT char no_myglob[]
1095 INIT("\"my\" variable %s can't be in a package");
1101 EXT char * cshname INIT(CSH);
1106 EXT char *sig_name[] = { SIG_NAME };
1107 EXT int sig_num[] = { SIG_NUM };
1108 EXT SV * psig_ptr[sizeof(sig_num)/sizeof(*sig_num)];
1109 EXT SV * psig_name[sizeof(sig_num)/sizeof(*sig_num)];
1111 EXT char *sig_name[];
1113 EXT SV * psig_ptr[];
1114 EXT SV * psig_name[];
1118 EXT unsigned char fold[] = { /* fast case folding table */
1119 0, 1, 2, 3, 4, 5, 6, 7,
1120 8, 9, 10, 11, 12, 13, 14, 15,
1121 16, 17, 18, 19, 20, 21, 22, 23,
1122 24, 25, 26, 27, 28, 29, 30, 31,
1123 32, 33, 34, 35, 36, 37, 38, 39,
1124 40, 41, 42, 43, 44, 45, 46, 47,
1125 48, 49, 50, 51, 52, 53, 54, 55,
1126 56, 57, 58, 59, 60, 61, 62, 63,
1127 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1128 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1129 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1130 'x', 'y', 'z', 91, 92, 93, 94, 95,
1131 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1132 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1133 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1134 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1135 128, 129, 130, 131, 132, 133, 134, 135,
1136 136, 137, 138, 139, 140, 141, 142, 143,
1137 144, 145, 146, 147, 148, 149, 150, 151,
1138 152, 153, 154, 155, 156, 157, 158, 159,
1139 160, 161, 162, 163, 164, 165, 166, 167,
1140 168, 169, 170, 171, 172, 173, 174, 175,
1141 176, 177, 178, 179, 180, 181, 182, 183,
1142 184, 185, 186, 187, 188, 189, 190, 191,
1143 192, 193, 194, 195, 196, 197, 198, 199,
1144 200, 201, 202, 203, 204, 205, 206, 207,
1145 208, 209, 210, 211, 212, 213, 214, 215,
1146 216, 217, 218, 219, 220, 221, 222, 223,
1147 224, 225, 226, 227, 228, 229, 230, 231,
1148 232, 233, 234, 235, 236, 237, 238, 239,
1149 240, 241, 242, 243, 244, 245, 246, 247,
1150 248, 249, 250, 251, 252, 253, 254, 255
1153 EXT unsigned char fold[];
1157 EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
1158 1, 2, 84, 151, 154, 155, 156, 157,
1159 165, 246, 250, 3, 158, 7, 18, 29,
1160 40, 51, 62, 73, 85, 96, 107, 118,
1161 129, 140, 147, 148, 149, 150, 152, 153,
1162 255, 182, 224, 205, 174, 176, 180, 217,
1163 233, 232, 236, 187, 235, 228, 234, 226,
1164 222, 219, 211, 195, 188, 193, 185, 184,
1165 191, 183, 201, 229, 181, 220, 194, 162,
1166 163, 208, 186, 202, 200, 218, 198, 179,
1167 178, 214, 166, 170, 207, 199, 209, 206,
1168 204, 160, 212, 216, 215, 192, 175, 173,
1169 243, 172, 161, 190, 203, 189, 164, 230,
1170 167, 248, 227, 244, 242, 255, 241, 231,
1171 240, 253, 169, 210, 245, 237, 249, 247,
1172 239, 168, 252, 251, 254, 238, 223, 221,
1173 213, 225, 177, 197, 171, 196, 159, 4,
1174 5, 6, 8, 9, 10, 11, 12, 13,
1175 14, 15, 16, 17, 19, 20, 21, 22,
1176 23, 24, 25, 26, 27, 28, 30, 31,
1177 32, 33, 34, 35, 36, 37, 38, 39,
1178 41, 42, 43, 44, 45, 46, 47, 48,
1179 49, 50, 52, 53, 54, 55, 56, 57,
1180 58, 59, 60, 61, 63, 64, 65, 66,
1181 67, 68, 69, 70, 71, 72, 74, 75,
1182 76, 77, 78, 79, 80, 81, 82, 83,
1183 86, 87, 88, 89, 90, 91, 92, 93,
1184 94, 95, 97, 98, 99, 100, 101, 102,
1185 103, 104, 105, 106, 108, 109, 110, 111,
1186 112, 113, 114, 115, 116, 117, 119, 120,
1187 121, 122, 123, 124, 125, 126, 127, 128,
1188 130, 131, 132, 133, 134, 135, 136, 137,
1189 138, 139, 141, 142, 143, 144, 145, 146
1192 EXT unsigned char freq[];
1197 EXT char* block_type[] = {
1206 EXT char* block_type[];
1210 /*****************************************************************************/
1211 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1212 /*****************************************************************************/
1213 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
1226 EXT U32 lex_state; /* next token is determined */
1227 EXT U32 lex_defer; /* state after determined token */
1228 EXT expectation lex_expect; /* expect after determined token */
1229 EXT I32 lex_brackets; /* bracket count */
1230 EXT I32 lex_formbrack; /* bracket count at outer format level */
1231 EXT I32 lex_fakebrack; /* outer bracket is mere delimiter */
1232 EXT I32 lex_casemods; /* casemod count */
1233 EXT I32 lex_dojoin; /* doing an array interpolation */
1234 EXT I32 lex_starts; /* how many interps done on level */
1235 EXT SV * lex_stuff; /* runtime pattern from m// or s/// */
1236 EXT SV * lex_repl; /* runtime replacement from s/// */
1237 EXT OP * lex_op; /* extra info to pass back on op */
1238 EXT OP * lex_inpat; /* in pattern $) and $| are special */
1239 EXT I32 lex_inwhat; /* what kind of quoting are we in */
1240 EXT char * lex_brackstack; /* what kind of brackets to pop */
1241 EXT char * lex_casestack; /* what kind of case mods in effect */
1243 /* What we know when we're in LEX_KNOWNEXT state. */
1244 EXT YYSTYPE nextval[5]; /* value of next token, if any */
1245 EXT I32 nexttype[5]; /* type of next token */
1248 EXT PerlIO * VOL rsfp INIT(Nullfp);
1251 EXT char * oldbufptr;
1252 EXT char * oldoldbufptr;
1254 EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */
1255 EXT AV * rsfp_filters;
1257 EXT I32 multi_start; /* 1st line of multi-line string */
1258 EXT I32 multi_end; /* last line of multi-line string */
1259 EXT I32 multi_open; /* delimiter of said string */
1260 EXT I32 multi_close; /* delimiter of said string */
1263 EXT I32 error_count; /* how many errors so far, max 10 */
1264 EXT I32 subline; /* line this subroutine began on */
1265 EXT SV * subname; /* name of current subroutine */
1267 EXT CV * compcv; /* currently compiling subroutine */
1268 EXT AV * comppad; /* storage for lexically scoped temporaries */
1269 EXT AV * comppad_name; /* variable names for "my" variables */
1270 EXT I32 comppad_name_fill;/* last "introduced" variable offset */
1271 EXT I32 comppad_name_floor;/* start of vars in innermost block */
1272 EXT I32 min_intro_pending;/* start of vars to introduce */
1273 EXT I32 max_intro_pending;/* end of vars to introduce */
1274 EXT I32 padix; /* max used index in current "register" pad */
1275 EXT I32 padix_floor; /* how low may inner block reset padix */
1276 EXT I32 pad_reset_pending; /* reset pad on next attempted alloc */
1279 EXT I32 thisexpr; /* name id for nothing_in_common() */
1280 EXT char * last_uni; /* position of last named-unary operator */
1281 EXT char * last_lop; /* position of last list operator */
1282 EXT OPCODE last_lop_op; /* last list operator */
1283 EXT bool in_my; /* we're compiling a "my" declaration */
1285 EXT I32 cryptseen; /* has fast crypt() been initialized? */
1288 EXT U32 hints; /* various compilation flags */
1290 /* Note: the lowest 8 bits are reserved for
1291 stuffing into op->op_private */
1292 #define HINT_INTEGER 0x00000001
1293 #define HINT_STRICT_REFS 0x00000002
1295 #define HINT_BLOCK_SCOPE 0x00000100
1296 #define HINT_STRICT_SUBS 0x00000200
1297 #define HINT_STRICT_VARS 0x00000400
1298 #define HINT_STRICT_UNTIE 0x00000800
1300 /**************************************************************************/
1301 /* This regexp stuff is global since it always happens within 1 expr eval */
1302 /**************************************************************************/
1304 EXT char * regprecomp; /* uncompiled string. */
1305 EXT char * regparse; /* Input-scan pointer. */
1306 EXT char * regxend; /* End of input for compile */
1307 EXT I32 regnpar; /* () count. */
1308 EXT char * regcode; /* Code-emit pointer; ®dummy = don't. */
1309 EXT I32 regsize; /* Code size. */
1310 EXT I32 regnaughty; /* How bad is this pattern? */
1311 EXT I32 regsawback; /* Did we see \1, ...? */
1313 EXT char * reginput; /* String-input pointer. */
1314 EXT char * regbol; /* Beginning of input, for ^ check. */
1315 EXT char * regeol; /* End of input, for $ check. */
1316 EXT char ** regstartp; /* Pointer to startp array. */
1317 EXT char ** regendp; /* Ditto for endp. */
1318 EXT U32 * reglastparen; /* Similarly for lastparen. */
1319 EXT char * regtill; /* How far we are required to go. */
1320 EXT U16 regflags; /* are we folding, multilining? */
1321 EXT char regprev; /* char before regbol, \n if none */
1323 EXT bool do_undump; /* -u or dump seen? */
1326 /***********************************************/
1327 /* Global only to current interpreter instance */
1328 /***********************************************/
1333 struct interpreter {
1336 #define IINIT(x) INIT(x)
1339 /* pseudo environmental stuff */
1341 IEXT char ** Iorigargv;
1345 IEXT char * Iorigfilename;
1347 IEXT SV * Iwarnhook;
1348 IEXT SV * Iparsehook;
1350 /* Various states of an input record separator SV (rs, nrs) */
1351 #define RsSNARF(sv) (! SvOK(sv))
1352 #define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv))
1353 #define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv))
1358 IEXT char Ipatchlevel[10];
1359 IEXT char ** Ilocalpatches;
1361 IEXT char * Isplitstr IINIT(" ");
1362 IEXT bool Ipreprocess;
1368 IEXT bool Idoswitches;
1370 IEXT bool Idoextract;
1371 IEXT bool Isawampersand; /* must save all match strings */
1372 IEXT bool Isawstudy; /* do fbm_instr on all strings */
1373 IEXT bool Isawi; /* study must assume case insensitive */
1376 IEXT char * Iinplace;
1377 IEXT char * Ie_tmpname;
1378 IEXT PerlIO * Ie_fp;
1380 /* This value may be raised by extensions for testing purposes */
1381 IEXT int Iperl_destruct_level; /* 0=none, 1=full, 2=full with checks */
1383 /* magical thingies */
1384 IEXT Time_t Ibasetime; /* $^T */
1385 IEXT SV * Iformfeed; /* $^L */
1386 IEXT char * Ichopset IINIT(" \n-"); /* $: */
1387 IEXT SV * Irs; /* $/ */
1388 IEXT char * Iofs; /* $, */
1389 IEXT STRLEN Iofslen;
1390 IEXT char * Iors; /* $\ */
1391 IEXT STRLEN Iorslen;
1392 IEXT char * Iofmt; /* $# */
1393 IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1394 IEXT int Imultiline; /* $*--do strings hold >1 line? */
1395 IEXT U32 Istatusvalue; /* $? */
1397 IEXT struct stat Istatcache; /* _ */
1399 IEXT SV * Istatname IINIT(Nullsv);
1401 /* shortcuts to various I/O objects */
1403 IEXT GV * Ilast_in_gv;
1406 IEXT GV * Idefoutgv;
1407 IEXT GV * Iargvoutgv;
1409 /* shortcuts to regexp stuff */
1413 IEXT PMOP * Icurpm; /* what to do \ interps from */
1414 IEXT I32 * Iscreamfirst;
1415 IEXT I32 * Iscreamnext;
1416 IEXT I32 Imaxscream IINIT(-1);
1417 IEXT SV * Ilastscream;
1419 /* shortcuts to misc objects */
1422 /* shortcuts to debugging objects */
1426 IEXT SV * IDBsingle;
1428 IEXT SV * IDBsignal;
1429 IEXT AV * Ilineary; /* lines of script for debugger */
1430 IEXT AV * Idbargs; /* args to call listed by caller function */
1433 IEXT HV * Idefstash; /* main symbol table */
1434 IEXT HV * Icurstash; /* symbol table for current package */
1435 IEXT HV * Idebstash; /* symbol table for perldb package */
1436 IEXT SV * Icurstname; /* name of current package */
1437 IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1438 IEXT AV * Iendav; /* names of END subroutines */
1439 IEXT HV * Istrtab; /* shared string table */
1441 /* memory management */
1442 IEXT SV ** Itmps_stack;
1443 IEXT I32 Itmps_ix IINIT(-1);
1444 IEXT I32 Itmps_floor IINIT(-1);
1446 IEXT I32 Isv_count; /* how many SV* are currently allocated */
1447 IEXT I32 Isv_objcount; /* how many objects are currently allocated */
1448 IEXT SV* Isv_root; /* storage for SVs belonging to interp */
1449 IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */
1451 /* funky return mechanisms */
1452 IEXT I32 Ilastspbase;
1454 IEXT int Iforkprocess; /* so do_open |- can return proc# */
1456 /* subprocess state */
1457 IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1458 IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1460 /* internal state */
1461 IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1462 IEXT OP * Irestartop; /* Are we propagating an error from croak? */
1463 IEXT int Idelaymagic; /* ($<,$>) = ... */
1464 IEXT bool Idirty; /* In the middle of tearing things down? */
1465 IEXT U8 Ilocalizing; /* are we processing a local() list? */
1466 IEXT bool Itainted; /* using variables controlled by $< */
1467 IEXT bool Itainting; /* doing taint checks */
1468 IEXT char * Iop_mask IINIT(NULL); /* masked operations for safe evals */
1472 IEXT I32 Idlmax IINIT(128);
1473 IEXT char * Idebname;
1474 IEXT char * Idebdelim;
1476 /* current interpreter roots */
1478 IEXT OP * Imain_root;
1479 IEXT OP * Imain_start;
1480 IEXT OP * Ieval_root;
1481 IEXT OP * Ieval_start;
1483 /* runtime control stuff */
1484 IEXT COP * VOL Icurcop IINIT(&compiling);
1485 IEXT COP * Icurcopdb IINIT(NULL);
1486 IEXT line_t Icopline IINIT(NOLINE);
1487 IEXT CONTEXT * Icxstack;
1488 IEXT I32 Icxstack_ix IINIT(-1);
1489 IEXT I32 Icxstack_max IINIT(128);
1490 IEXT Sigjmp_buf Itop_env;
1494 IEXT AV * Icurstack; /* THE STACK */
1495 IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1496 IEXT SV ** Imystack_base; /* stack->array_ary */
1497 IEXT SV ** Imystack_sp; /* stack pointer now */
1498 IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1500 /* format accumulators */
1501 IEXT SV * Iformtarget;
1502 IEXT SV * Ibodytarget;
1503 IEXT SV * Itoptarget;
1505 /* statics moved here for shared library purposes */
1506 IEXT SV Istrchop; /* return value from chop */
1507 IEXT int Ifilemode; /* so nextargv() can preserve mode */
1508 IEXT int Ilastfd; /* what to preserve mode on */
1509 IEXT char * Ioldname; /* what to preserve mode on */
1510 IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1511 IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1512 IEXT OP * Isortcop; /* user defined sort routine */
1513 IEXT HV * Isortstash; /* which is in some package or other */
1514 IEXT GV * Ifirstgv; /* $a */
1515 IEXT GV * Isecondgv; /* $b */
1516 IEXT AV * Isortstack; /* temp stack during pp_sort() */
1517 IEXT AV * Isignalstack; /* temp stack during sighandler() */
1518 IEXT SV * Imystrk; /* temp key string for do_each() */
1519 IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
1520 IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1521 IEXT I32 Igensym; /* next symbol for getsym() to define */
1522 IEXT bool Ipreambled;
1523 IEXT AV * Ipreambleav;
1524 IEXT int Ilaststatval IINIT(-1);
1525 IEXT I32 Ilaststype IINIT(OP_STAT);
1533 struct interpreter {
1547 #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1548 #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1550 #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1551 #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1558 /* The following must follow proto.h */
1561 EXT MGVTBL vtbl_sv = {magic_get,
1565 EXT MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1566 EXT MGVTBL vtbl_envelem = {0, magic_setenv,
1569 EXT MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1570 EXT MGVTBL vtbl_sigelem = {magic_getsig,
1574 EXT MGVTBL vtbl_pack = {0, 0, 0, magic_wipepack,
1576 EXT MGVTBL vtbl_packelem = {magic_getpack,
1580 EXT MGVTBL vtbl_dbline = {0, magic_setdbline,
1582 EXT MGVTBL vtbl_isa = {0, magic_setisa,
1584 EXT MGVTBL vtbl_isaelem = {0, magic_setisa,
1586 EXT MGVTBL vtbl_arylen = {magic_getarylen,
1589 EXT MGVTBL vtbl_glob = {magic_getglob,
1592 EXT MGVTBL vtbl_mglob = {0, magic_setmglob,
1594 EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1596 EXT MGVTBL vtbl_substr = {0, magic_setsubstr,
1598 EXT MGVTBL vtbl_vec = {0, magic_setvec,
1600 EXT MGVTBL vtbl_pos = {magic_getpos,
1603 EXT MGVTBL vtbl_bm = {0, magic_setbm,
1605 EXT MGVTBL vtbl_uvar = {magic_getuvar,
1610 EXT MGVTBL vtbl_amagic = {0, magic_setamagic,
1611 0, 0, magic_setamagic};
1612 EXT MGVTBL vtbl_amagicelem = {0, magic_setamagic,
1613 0, 0, magic_setamagic};
1614 #endif /* OVERLOAD */
1618 EXT MGVTBL vtbl_env;
1619 EXT MGVTBL vtbl_envelem;
1620 EXT MGVTBL vtbl_sig;
1621 EXT MGVTBL vtbl_sigelem;
1622 EXT MGVTBL vtbl_pack;
1623 EXT MGVTBL vtbl_packelem;
1624 EXT MGVTBL vtbl_dbline;
1625 EXT MGVTBL vtbl_isa;
1626 EXT MGVTBL vtbl_isaelem;
1627 EXT MGVTBL vtbl_arylen;
1628 EXT MGVTBL vtbl_glob;
1629 EXT MGVTBL vtbl_mglob;
1630 EXT MGVTBL vtbl_taint;
1631 EXT MGVTBL vtbl_substr;
1632 EXT MGVTBL vtbl_vec;
1633 EXT MGVTBL vtbl_pos;
1635 EXT MGVTBL vtbl_uvar;
1638 EXT MGVTBL vtbl_amagic;
1639 EXT MGVTBL vtbl_amagicelem;
1640 #endif /* OVERLOAD */
1645 EXT long amagic_generation;
1647 #define NofAMmeth 29
1649 EXT char * AMG_names[NofAMmeth][2] = {
1651 {"bool", "nomethod"},
1681 EXT char * AMG_names[NofAMmeth][2];
1682 #endif /* def INITAMAGIC */
1687 CV* table[NofAMmeth*2];
1690 typedef struct am_table AMT;
1692 #define AMGfallNEVER 1
1694 #define AMGfallYES 3
1697 fallback_amg, abs_amg,
1698 bool__amg, nomethod_amg,
1699 string_amg, numer_amg,
1700 add_amg, add_ass_amg,
1701 subtr_amg, subtr_ass_amg,
1702 mult_amg, mult_ass_amg,
1703 div_amg, div_ass_amg,
1704 mod_amg, mod_ass_amg,
1705 pow_amg, pow_ass_amg,
1706 lshift_amg, lshift_ass_amg,
1707 rshift_amg, rshift_ass_amg,
1708 band_amg, band_ass_amg,
1709 bor_amg, bor_ass_amg,
1710 bxor_amg, bxor_ass_amg,
1723 repeat_amg, repeat_ass_amg,
1724 concat_amg, concat_ass_amg,
1727 #endif /* OVERLOAD */
1729 #if !defined(PERLIO_IS_STDIO) && defined(HAS_ATTRIBUTE)
1731 * Now we have __attribute__ out of the way
1734 #define printf PerlIO_stdoutf
1737 #endif /* Include guard */