perl5.000 patch.0j: fix minor portability and build problems remaining even after...
[p5sagit/p5-mst-13.2.git] / perl.h
CommitLineData
a0d0e21e 1/* perl.h
a687059c 2 *
a0d0e21e 3 * Copyright (c) 1987-1994, Larry Wall
a687059c 4 *
352d5a3a 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 9#ifndef H_PERL
10#define H_PERL 1
a0d0e21e 11#define OVERLOAD
8d063cd8 12
79072805 13#include "embed.h"
14
85e6fe83 15#define VOIDUSED 1
ac58e20f 16#include "config.h"
79072805 17
18#ifndef BYTEORDER
19# define BYTEORDER 0x1234
20#endif
21
22/* Overall memory policy? */
23#ifndef CONSERVATIVE
24# define LIBERAL 1
25#endif
26
27/*
28 * The following contortions are brought to you on behalf of all the
29 * standards, semi-standards, de facto standards, not-so-de-facto standards
30 * of the world, as well as all the other botches anyone ever thought of.
31 * The basic theory is that if we work hard enough here, the rest of the
32 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
33 */
ac58e20f 34
45d8adaa 35#ifdef MYMALLOC
36# ifdef HIDEMYMALLOC
37# define malloc Mymalloc
38# define realloc Myremalloc
39# define free Myfree
40# endif
41# define safemalloc malloc
42# define saferealloc realloc
43# define safefree free
44#endif
45
46/* work around some libPW problems */
45d8adaa 47#ifdef DOINIT
a0d0e21e 48EXT char Error[1];
45d8adaa 49#endif
50
ee0007ab 51/* define this once if either system, instead of cluttering up the src */
52#if defined(MSDOS) || defined(atarist)
53#define DOSISH 1
54#endif
55
a0d0e21e 56#if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
352d5a3a 57# define STANDARD_C 1
58#endif
59
60#if defined(HASVOLATILE) || defined(STANDARD_C)
79072805 61# ifdef __cplusplus
62# define VOL // to temporarily suppress warnings
63# else
64# define VOL volatile
65# endif
663a0e37 66#else
79072805 67# define VOL
663a0e37 68#endif
69
463ee0b2 70#define TAINT_IF(c) (tainted |= (c))
71#define TAINT_NOT (tainted = 0)
72#define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
73#define TAINT_ENV() if (tainting) taint_env()
a687059c 74
fe14fcc3 75#ifndef HAS_VFORK
03a14243 76# define vfork fork
77#endif
78
fe14fcc3 79#ifdef HAS_GETPGRP2
80# ifndef HAS_GETPGRP
81# define HAS_GETPGRP
663a0e37 82# endif
663a0e37 83#endif
84
fe14fcc3 85#ifdef HAS_SETPGRP2
86# ifndef HAS_SETPGRP
87# define HAS_SETPGRP
663a0e37 88# endif
663a0e37 89#endif
90
fe14fcc3 91#include <stdio.h>
a0d0e21e 92#ifdef USE_NEXT_CTYPE
93#include <appkit/NXCType.h>
94#else
fe14fcc3 95#include <ctype.h>
a0d0e21e 96#endif
97
98#ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
99#undef METHOD
100#endif
101
fe14fcc3 102#include <setjmp.h>
79072805 103
a0d0e21e 104#ifdef I_SYS_PARAM
79072805 105# ifdef PARAM_NEEDS_TYPES
106# include <sys/types.h>
107# endif
108# include <sys/param.h>
352d5a3a 109#endif
79072805 110
111
112/* Use all the "standard" definitions? */
a0d0e21e 113#if defined(STANDARD_C) && defined(I_STDLIB)
79072805 114# include <stdlib.h>
352d5a3a 115#endif /* STANDARD_C */
03a14243 116
a0d0e21e 117#define MEM_SIZE Size_t
118
119#if defined(I_STRING) || defined(__cplusplus)
120# include <string.h>
121#else
122# include <strings.h>
123#endif
124
125#if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
126#define strchr index
127#define strrchr rindex
128#endif
129
130#if defined(mips) && defined(ultrix) && !defined(__STDC__)
79072805 131# undef HAS_MEMCMP
663a0e37 132#endif
fe14fcc3 133
134#ifdef HAS_MEMCPY
85e6fe83 135# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
fe14fcc3 136# ifndef memcpy
a0d0e21e 137 extern char * memcpy _((char*, char*, int));
ee0007ab 138# endif
139# endif
140#else
141# ifndef memcpy
142# ifdef HAS_BCOPY
143# define memcpy(d,s,l) bcopy(s,d,l)
144# else
145# define memcpy(d,s,l) my_bcopy(s,d,l)
146# endif
147# endif
148#endif /* HAS_MEMCPY */
fe14fcc3 149
ee0007ab 150#ifdef HAS_MEMSET
85e6fe83 151# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 152# ifndef memset
a0d0e21e 153 extern char *memset _((char*, int, int));
ee0007ab 154# endif
155# endif
156# define memzero(d,l) memset(d,0,l)
157#else
158# ifndef memzero
159# ifdef HAS_BZERO
160# define memzero(d,l) bzero(d,l)
161# else
162# define memzero(d,l) my_bzero(d,l)
163# endif
352d5a3a 164# endif
ee0007ab 165#endif /* HAS_MEMSET */
166
167#ifdef HAS_MEMCMP
85e6fe83 168# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 169# ifndef memcmp
a0d0e21e 170 extern int memcmp _((char*, char*, int));
ee0007ab 171# endif
172# endif
173#else
174# ifndef memcmp
ecfc5424 175# define memcmp my_memcmp
352d5a3a 176# endif
ee0007ab 177#endif /* HAS_MEMCMP */
8d063cd8 178
ee0007ab 179/* we prefer bcmp slightly for comparisons that don't care about ordering */
180#ifndef HAS_BCMP
352d5a3a 181# ifndef bcmp
182# define bcmp(s1,s2,l) memcmp(s1,s2,l)
183# endif
ee0007ab 184#endif /* HAS_BCMP */
185
85e6fe83 186#if !defined(HAS_MEMMOVE) && !defined(memmove)
2304df62 187# if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
79072805 188# define memmove(d,s,l) bcopy(s,d,l)
189# else
2304df62 190# if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
79072805 191# define memmove(d,s,l) memcpy(d,s,l)
192# else
193# define memmove(d,s,l) my_bcopy(s,d,l)
194# endif
195# endif
d9d8d8de 196#endif
378cc40b 197
198#ifndef _TYPES_ /* If types.h defines this it's easy. */
79072805 199# ifndef major /* Does everyone's types.h define this? */
200# include <sys/types.h>
201# endif
378cc40b 202#endif
203
ae986130 204#ifdef I_NETINET_IN
79072805 205# include <netinet/in.h>
ae986130 206#endif
207
1aef975c 208#ifdef I_SYS_STAT
8d063cd8 209#include <sys/stat.h>
1aef975c 210#endif
79072805 211
a0d0e21e 212/* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
213 like UTekV) are broken, sometimes giving false positives. Undefine
214 them here and let the code below set them to proper values.
215
216 The ghs macro stands for GreenHills Software C-1.8.5 which
217 is the C compiler for sysV88 and the various derivatives.
218 This header file bug is corrected in gcc-2.5.8 and later versions.
219 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
220
221#if defined(uts) || (defined(m88k) && defined(ghs))
79072805 222# undef S_ISDIR
223# undef S_ISCHR
224# undef S_ISBLK
225# undef S_ISREG
226# undef S_ISFIFO
227# undef S_ISLNK
ee0007ab 228#endif
135863df 229
663a0e37 230#ifdef I_TIME
231# include <time.h>
ffed7fef 232#endif
663a0e37 233
fe14fcc3 234#ifdef I_SYS_TIME
85e6fe83 235# ifdef I_SYS_TIME_KERNEL
663a0e37 236# define KERNEL
237# endif
238# include <sys/time.h>
85e6fe83 239# ifdef I_SYS_TIME_KERNEL
663a0e37 240# undef KERNEL
241# endif
a687059c 242#endif
135863df 243
d9d8d8de 244#ifndef MSDOS
a0d0e21e 245# if defined(HAS_TIMES) && defined(I_SYS_TIMES)
85e6fe83 246# include <sys/times.h>
247# endif
d9d8d8de 248#endif
8d063cd8 249
fe14fcc3 250#if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
79072805 251# undef HAS_STRERROR
663a0e37 252#endif
253
a0d0e21e 254#ifndef HAS_MKFIFO
255# ifndef mkfifo
256# define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
257# endif
258#endif /* !HAS_MKFIFO */
259
663a0e37 260#include <errno.h>
ed6116ce 261#ifdef HAS_SOCKET
85e6fe83 262# ifdef I_NET_ERRNO
ed6116ce 263# include <net/errno.h>
264# endif
265#endif
266
d9d8d8de 267#ifndef MSDOS
79072805 268# ifndef errno
269 extern int errno; /* ANSI allows errno to be an lvalue expr */
270# endif
d9d8d8de 271#endif
663a0e37 272
2304df62 273#ifdef HAS_STRERROR
a0d0e21e 274# ifdef VMS
275 char *strerror _((int,...));
276# else
277 char *strerror _((int));
278# endif
2304df62 279# ifndef Strerror
280# define Strerror strerror
281# endif
282#else
283# ifdef HAS_SYS_ERRLIST
79072805 284 extern int sys_nerr;
285 extern char *sys_errlist[];
2304df62 286# ifndef Strerror
287# define Strerror(e) \
79072805 288 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
2304df62 289# endif
79072805 290# endif
35c8bce7 291#endif
663a0e37 292
2304df62 293#ifdef I_SYS_IOCTL
79072805 294# ifndef _IOCTL_
295# include <sys/ioctl.h>
296# endif
a687059c 297#endif
298
ee0007ab 299#if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
79072805 300# ifdef HAS_SOCKETPAIR
301# undef HAS_SOCKETPAIR
302# endif
2304df62 303# ifdef I_NDBM
304# undef I_NDBM
79072805 305# endif
a687059c 306#endif
307
a687059c 308#if INTSIZE == 2
79072805 309# define htoni htons
310# define ntohi ntohs
a687059c 311#else
79072805 312# define htoni htonl
313# define ntohi ntohl
a687059c 314#endif
315
a0d0e21e 316/* Configure already sets Direntry_t */
35c8bce7 317#if defined(I_DIRENT)
663a0e37 318# include <dirent.h>
a0d0e21e 319# if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
320# include <sys/dir.h>
321# endif
ae986130 322#else
fe14fcc3 323# ifdef I_SYS_NDIR
79a0689e 324# include <sys/ndir.h>
663a0e37 325# else
fe14fcc3 326# ifdef I_SYS_DIR
79a0689e 327# ifdef hp9000s500
328# include <ndir.h> /* may be wrong in the future */
329# else
330# include <sys/dir.h>
331# endif
663a0e37 332# endif
333# endif
a0d0e21e 334#endif
a687059c 335
352d5a3a 336#ifdef FPUTS_BOTCH
337/* work around botch in SunOS 4.0.1 and 4.0.2 */
338# ifndef fputs
79072805 339# define fputs(sv,fp) fprintf(fp,"%s",sv)
352d5a3a 340# endif
341#endif
342
c623bd54 343/*
344 * The following gobbledygook brought to you on behalf of __STDC__.
345 * (I could just use #ifndef __STDC__, but this is more bulletproof
346 * in the face of half-implementations.)
347 */
348
349#ifndef S_IFMT
350# ifdef _S_IFMT
351# define S_IFMT _S_IFMT
352# else
353# define S_IFMT 0170000
354# endif
355#endif
356
357#ifndef S_ISDIR
358# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
359#endif
360
361#ifndef S_ISCHR
362# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
363#endif
364
365#ifndef S_ISBLK
fe14fcc3 366# ifdef S_IFBLK
367# define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
368# else
369# define S_ISBLK(m) (0)
370# endif
c623bd54 371#endif
372
373#ifndef S_ISREG
374# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
375#endif
376
377#ifndef S_ISFIFO
fe14fcc3 378# ifdef S_IFIFO
379# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
380# else
381# define S_ISFIFO(m) (0)
382# endif
c623bd54 383#endif
384
385#ifndef S_ISLNK
386# ifdef _S_ISLNK
387# define S_ISLNK(m) _S_ISLNK(m)
388# else
389# ifdef _S_IFLNK
390# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
391# else
392# ifdef S_IFLNK
393# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
394# else
395# define S_ISLNK(m) (0)
396# endif
397# endif
398# endif
399#endif
400
401#ifndef S_ISSOCK
402# ifdef _S_ISSOCK
403# define S_ISSOCK(m) _S_ISSOCK(m)
404# else
405# ifdef _S_IFSOCK
406# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
407# else
408# ifdef S_IFSOCK
409# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
410# else
411# define S_ISSOCK(m) (0)
412# endif
413# endif
414# endif
415#endif
416
417#ifndef S_IRUSR
418# ifdef S_IREAD
419# define S_IRUSR S_IREAD
420# define S_IWUSR S_IWRITE
421# define S_IXUSR S_IEXEC
422# else
423# define S_IRUSR 0400
424# define S_IWUSR 0200
425# define S_IXUSR 0100
426# endif
427# define S_IRGRP (S_IRUSR>>3)
428# define S_IWGRP (S_IWUSR>>3)
429# define S_IXGRP (S_IXUSR>>3)
430# define S_IROTH (S_IRUSR>>6)
431# define S_IWOTH (S_IWUSR>>6)
432# define S_IXOTH (S_IXUSR>>6)
433#endif
434
435#ifndef S_ISUID
436# define S_ISUID 04000
437#endif
438
439#ifndef S_ISGID
440# define S_ISGID 02000
441#endif
442
79072805 443#ifdef ff_next
444# undef ff_next
352d5a3a 445#endif
446
a0d0e21e 447#if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
45d8adaa 448# define SLOPPYDIVIDE
449#endif
450
988174c1 451#if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
ecfc5424 452# define HAS_QUAD
45d8adaa 453#endif
454
ecfc5424 455#ifdef HAS_QUAD
45d8adaa 456# ifdef cray
ecfc5424 457# define Quad_t int
45d8adaa 458# else
988174c1 459# if defined(convex) || defined (uts)
ecfc5424 460# define Quad_t long long
45d8adaa 461# else
ecfc5424 462# define Quad_t long
45d8adaa 463# endif
464# endif
465#endif
466
79072805 467#ifdef DOSISH
468# include "dosish.h"
469#else
a0d0e21e 470# if defined(VMS)
471# include "vmsish.h"
472# else
79072805 473# include "unixish.h"
a0d0e21e 474# endif
79072805 475#endif
476
477#ifndef HAS_PAUSE
478#define pause() sleep((32767<<16)+32767)
479#endif
480
481#ifndef IOCPARM_LEN
482# ifdef IOCPARM_MASK
483 /* on BSDish systes we're safe */
484# define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
485# else
486 /* otherwise guess at what's safe */
487# define IOCPARM_LEN(x) 256
488# endif
489#endif
490
ee0007ab 491typedef MEM_SIZE STRLEN;
450a55e4 492
79072805 493typedef struct op OP;
494typedef struct cop COP;
495typedef struct unop UNOP;
496typedef struct binop BINOP;
497typedef struct listop LISTOP;
498typedef struct logop LOGOP;
499typedef struct condop CONDOP;
500typedef struct pmop PMOP;
501typedef struct svop SVOP;
502typedef struct gvop GVOP;
503typedef struct pvop PVOP;
504typedef struct cvop CVOP;
505typedef struct loop LOOP;
506
507typedef struct Outrec Outrec;
93a17b20 508typedef struct interpreter PerlInterpreter;
79072805 509typedef struct ff FF;
79072805 510typedef struct sv SV;
511typedef struct av AV;
512typedef struct hv HV;
513typedef struct cv CV;
378cc40b 514typedef struct regexp REGEXP;
79072805 515typedef struct gp GP;
516typedef struct sv GV;
8990e307 517typedef struct io IO;
79072805 518typedef struct context CONTEXT;
519typedef struct block BLOCK;
520
521typedef struct magic MAGIC;
ed6116ce 522typedef struct xrv XRV;
79072805 523typedef struct xpv XPV;
524typedef struct xpviv XPVIV;
525typedef struct xpvnv XPVNV;
526typedef struct xpvmg XPVMG;
527typedef struct xpvlv XPVLV;
528typedef struct xpvav XPVAV;
529typedef struct xpvhv XPVHV;
530typedef struct xpvgv XPVGV;
531typedef struct xpvcv XPVCV;
532typedef struct xpvbm XPVBM;
533typedef struct xpvfm XPVFM;
8990e307 534typedef struct xpvio XPVIO;
79072805 535typedef struct mgvtbl MGVTBL;
536typedef union any ANY;
8d063cd8 537
a0d0e21e 538typedef FILE * (*cryptswitch_t) _((FILE *rfp));
539
378cc40b 540#include "handy.h"
a0d0e21e 541
ecfc5424 542#ifdef HAS_QUAD
543typedef Quad_t IV;
a0d0e21e 544#else
545typedef long IV;
546#endif
547
79072805 548union any {
549 void* any_ptr;
550 I32 any_i32;
a0d0e21e 551 IV any_iv;
85e6fe83 552 long any_long;
a0d0e21e 553 void (*any_dptr) _((void*));
79072805 554};
555
378cc40b 556#include "regexp.h"
79072805 557#include "sv.h"
378cc40b 558#include "util.h"
8d063cd8 559#include "form.h"
79072805 560#include "gv.h"
561#include "cv.h"
562#include "opcode.h"
563#include "op.h"
564#include "cop.h"
565#include "av.h"
566#include "hv.h"
567#include "mg.h"
568#include "scope.h"
8d063cd8 569
450a55e4 570#if defined(iAPX286) || defined(M_I286) || defined(I80286)
a687059c 571# define I286
572#endif
573
fe14fcc3 574#if defined(htonl) && !defined(HAS_HTONL)
575#define HAS_HTONL
ae986130 576#endif
fe14fcc3 577#if defined(htons) && !defined(HAS_HTONS)
578#define HAS_HTONS
ae986130 579#endif
fe14fcc3 580#if defined(ntohl) && !defined(HAS_NTOHL)
581#define HAS_NTOHL
ae986130 582#endif
fe14fcc3 583#if defined(ntohs) && !defined(HAS_NTOHS)
584#define HAS_NTOHS
ae986130 585#endif
fe14fcc3 586#ifndef HAS_HTONL
d9d8d8de 587#if (BYTEORDER & 0xffff) != 0x4321
fe14fcc3 588#define HAS_HTONS
589#define HAS_HTONL
590#define HAS_NTOHS
591#define HAS_NTOHL
a687059c 592#define MYSWAP
593#define htons my_swap
594#define htonl my_htonl
595#define ntohs my_swap
596#define ntohl my_ntohl
597#endif
598#else
d9d8d8de 599#if (BYTEORDER & 0xffff) == 0x4321
fe14fcc3 600#undef HAS_HTONS
601#undef HAS_HTONL
602#undef HAS_NTOHS
603#undef HAS_NTOHL
a687059c 604#endif
605#endif
606
988174c1 607/*
608 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
609 * -DWS
610 */
611#if BYTEORDER != 0x1234
612# define HAS_VTOHL
613# define HAS_VTOHS
614# define HAS_HTOVL
615# define HAS_HTOVS
616# if BYTEORDER == 0x4321
617# define vtohl(x) ((((x)&0xFF)<<24) \
618 +(((x)>>24)&0xFF) \
619 +(((x)&0x0000FF00)<<8) \
620 +(((x)&0x00FF0000)>>8) )
621# define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
622# define htovl(x) vtohl(x)
623# define htovs(x) vtohs(x)
624# endif
625 /* otherwise default to functions in util.c */
626#endif
627
0f85fab0 628#ifdef CASTNEGFLOAT
79072805 629#define U_S(what) ((U16)(what))
0f85fab0 630#define U_I(what) ((unsigned int)(what))
79072805 631#define U_L(what) ((U32)(what))
0f85fab0 632#else
a0d0e21e 633U32 cast_ulong _((double));
79072805 634#define U_S(what) ((U16)cast_ulong(what))
635#define U_I(what) ((unsigned int)cast_ulong(what))
636#define U_L(what) (cast_ulong(what))
ee0007ab 637#endif
638
ed6116ce 639#ifdef CASTI32
640#define I_32(what) ((I32)(what))
a0d0e21e 641#define I_V(what) ((IV)(what))
ed6116ce 642#else
a0d0e21e 643I32 cast_i32 _((double));
ed6116ce 644#define I_32(what) (cast_i32(what))
a0d0e21e 645IV cast_iv _((double));
646#define I_V(what) (cast_iv(what))
ed6116ce 647#endif
648
79072805 649struct Outrec {
650 I32 o_lines;
d9d8d8de 651 char *o_str;
79072805 652 U32 o_len;
8d063cd8 653};
654
352d5a3a 655#ifndef MAXSYSFD
656# define MAXSYSFD 2
657#endif
ee0007ab 658
a0d0e21e 659#ifdef DOSISH
57ebbfd0 660#define TMPPATH "plXXXXXX"
a0d0e21e 661#else
662#ifdef VMS
663#define TMPPATH "/sys$scratch/perl-eXXXXXX"
664#else
665#define TMPPATH "/tmp/perl-eXXXXXX"
666#endif
667#endif
79072805 668
669#ifndef __cplusplus
a0d0e21e 670Uid_t getuid _((void));
671Uid_t geteuid _((void));
672Gid_t getgid _((void));
673Gid_t getegid _((void));
79072805 674#endif
8d063cd8 675
676#ifdef DEBUGGING
d96024cf 677#define YYDEBUG 1
79072805 678#define DEB(a) a
679#define DEBUG(a) if (debug) a
680#define DEBUG_p(a) if (debug & 1) a
681#define DEBUG_s(a) if (debug & 2) a
682#define DEBUG_l(a) if (debug & 4) a
683#define DEBUG_t(a) if (debug & 8) a
684#define DEBUG_o(a) if (debug & 16) a
685#define DEBUG_c(a) if (debug & 32) a
686#define DEBUG_P(a) if (debug & 64) a
687#define DEBUG_m(a) if (debug & 128) a
688#define DEBUG_f(a) if (debug & 256) a
689#define DEBUG_r(a) if (debug & 512) a
690#define DEBUG_x(a) if (debug & 1024) a
691#define DEBUG_u(a) if (debug & 2048) a
692#define DEBUG_L(a) if (debug & 4096) a
693#define DEBUG_H(a) if (debug & 8192) a
694#define DEBUG_X(a) if (debug & 16384) a
8990e307 695#define DEBUG_D(a) if (debug & 32768) a
79072805 696#else
697#define DEB(a)
698#define DEBUG(a)
699#define DEBUG_p(a)
700#define DEBUG_s(a)
701#define DEBUG_l(a)
702#define DEBUG_t(a)
703#define DEBUG_o(a)
704#define DEBUG_c(a)
705#define DEBUG_P(a)
706#define DEBUG_m(a)
707#define DEBUG_f(a)
708#define DEBUG_r(a)
709#define DEBUG_x(a)
710#define DEBUG_u(a)
711#define DEBUG_L(a)
712#define DEBUG_H(a)
713#define DEBUG_X(a)
8990e307 714#define DEBUG_D(a)
8d063cd8 715#endif
fe14fcc3 716#define YYMAXDEPTH 300
8d063cd8 717
79072805 718#define assert(what) DEB( { \
719 if (!(what)) { \
463ee0b2 720 croak("Assertion failed: file \"%s\", line %d", \
79072805 721 __FILE__, __LINE__); \
722 exit(1); \
723 }})
8d063cd8 724
450a55e4 725struct ufuncs {
a0d0e21e 726 I32 (*uf_val)_((IV, SV*));
727 I32 (*uf_set)_((IV, SV*));
728 IV uf_index;
450a55e4 729};
730
fe14fcc3 731/* Fix these up for __STDC__ */
a0d0e21e 732#ifndef __cplusplus
733char *mktemp _((char*));
734double atof _((const char*));
735#endif
79072805 736
352d5a3a 737#ifndef STANDARD_C
fe14fcc3 738/* All of these are in stdlib.h or time.h for ANSI C */
85e6fe83 739Time_t time();
8d063cd8 740struct tm *gmtime(), *localtime();
93a17b20 741char *strchr(), *strrchr();
378cc40b 742char *strcpy(), *strcat();
352d5a3a 743#endif /* ! STANDARD_C */
8d063cd8 744
79072805 745
746#ifdef I_MATH
747# include <math.h>
748#else
749# ifdef __cplusplus
750 extern "C" {
751# endif
a0d0e21e 752 double exp _((double));
753 double fmod _((double,double));
754 double log _((double));
755 double sqrt _((double));
756 double modf _((double,double*));
757 double sin _((double));
758 double cos _((double));
759 double atan2 _((double,double));
760 double pow _((double,double));
79072805 761# ifdef __cplusplus
762 };
763# endif
764#endif
765
75f92628 766#ifndef HAS_FMOD
767# ifdef HAS_DREM
768# define fmod(x,y) drem((x),(y))
769# else
770# define USE_MY_FMOD
771# define fmod(x,y) my_fmod(x,y)
772# endif
a0d0e21e 773#endif
79072805 774
a0d0e21e 775#ifndef __cplusplus
776char *crypt _((const char*, const char*));
777char *getenv _((const char*));
778Off_t lseek _((int,Off_t,int));
779char *getlogin _((void));
780#endif
79072805 781
8d063cd8 782#ifdef EUNICE
378cc40b 783#define UNLINK unlnk
a0d0e21e 784I32 unlnk _((char*));
8d063cd8 785#else
786#define UNLINK unlink
787#endif
a687059c 788
fe14fcc3 789#ifndef HAS_SETREUID
85e6fe83 790# ifdef HAS_SETRESUID
791# define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
792# define HAS_SETREUID
793# endif
a687059c 794#endif
fe14fcc3 795#ifndef HAS_SETREGID
85e6fe83 796# ifdef HAS_SETRESGID
797# define setregid(r,e) setresgid(r,e,(Gid_t)-1)
798# define HAS_SETREGID
799# endif
a687059c 800#endif
ee0007ab 801
802#define SCAN_DEF 0
803#define SCAN_TR 1
804#define SCAN_REPL 2
79072805 805
806#ifdef DEBUGGING
a0d0e21e 807# ifndef register
808# define register
809# endif
810# define PAD_SV(po) pad_sv(po)
79072805 811#else
a0d0e21e 812# define PAD_SV(po) curpad[po]
79072805 813#endif
814
815/****************/
816/* Truly global */
817/****************/
818
819/* global state */
a0d0e21e 820EXT PerlInterpreter * curinterp; /* currently running interpreter */
821#ifndef VMS /* VMS doesn't use environ array */
79072805 822extern char ** environ; /* environment variables supplied via exec */
a0d0e21e 823#endif
79072805 824EXT int uid; /* current real user id */
825EXT int euid; /* current effective user id */
826EXT int gid; /* current real group id */
827EXT int egid; /* current effective group id */
828EXT bool nomemok; /* let malloc context handle nomem */
829EXT U32 an; /* malloc sequence number */
463ee0b2 830EXT U32 cop_seqmax; /* statement sequence number */
831EXT U32 op_seqmax; /* op sequence number */
8990e307 832EXT U32 evalseq; /* eval sequence number */
463ee0b2 833EXT U32 sub_generation; /* inc to force methods to be looked up again */
79072805 834EXT char ** origenviron;
835EXT U32 origalen;
a0d0e21e 836EXT U32 * profiledata;
79072805 837
a0d0e21e 838EXT XPV* xiv_arenaroot; /* list of allocated xiv areas */
839EXT IV ** xiv_root; /* free xiv list--shared by interpreters */
8990e307 840EXT double * xnv_root; /* free xnv list--shared by interpreters */
841EXT XRV * xrv_root; /* free xrv list--shared by interpreters */
842EXT XPV * xpv_root; /* free xpv list--shared by interpreters */
843
79072805 844/* Stack for currently executing thread--context switch must handle this. */
845EXT SV ** stack_base; /* stack->array_ary */
846EXT SV ** stack_sp; /* stack pointer now */
847EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
848
849/* likewise for these */
850
851EXT OP * op; /* current op--oughta be in a global register */
852
853EXT I32 * scopestack; /* blocks we've entered */
854EXT I32 scopestack_ix;
855EXT I32 scopestack_max;
856
857EXT ANY* savestack; /* to save non-local values on */
858EXT I32 savestack_ix;
859EXT I32 savestack_max;
860
861EXT OP ** retstack; /* returns we've pushed */
862EXT I32 retstack_ix;
863EXT I32 retstack_max;
864
865EXT I32 * markstack; /* stackmarks we're remembering */
866EXT I32 * markstack_ptr; /* stackmarks we're remembering */
867EXT I32 * markstack_max; /* stackmarks we're remembering */
868
869EXT SV ** curpad;
870
871/* temp space */
872EXT SV * Sv;
873EXT XPV * Xpv;
874EXT char buf[1024];
875EXT char tokenbuf[256];
876EXT struct stat statbuf;
ecfc5424 877#ifdef HAS_TIMES
79072805 878EXT struct tms timesbuf;
879#endif
463ee0b2 880EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
79072805 881
882/* for tmp use in stupid debuggers */
883EXT int * di;
884EXT short * ds;
885EXT char * dc;
886
887/* handy constants */
888EXT char * Yes INIT("1");
889EXT char * No INIT("");
890EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
79072805 891EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
892EXT char * vert INIT("|");
893
8990e307 894EXT char warn_uninit[]
a0d0e21e 895 INIT("Use of uninitialized value");
463ee0b2 896EXT char warn_nosemi[]
897 INIT("Semicolon seems to be missing");
898EXT char warn_reserved[]
899 INIT("Unquoted string \"%s\" may clash with future reserved word");
900EXT char warn_nl[]
93a17b20 901 INIT("Unsuccessful %s on filename containing newline");
a0d0e21e 902EXT char no_wrongref[]
903 INIT("Can't use %s ref as %s ref");
904EXT char no_symref[]
905 INIT("Can't use a string as %s ref while \"strict refs\" in use");
93a17b20 906EXT char no_usym[]
8990e307 907 INIT("Can't use an undefined value as %s reference");
93a17b20 908EXT char no_aelem[]
909 INIT("Modification of non-creatable array value attempted, subscript %d");
910EXT char no_helem[]
911 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
912EXT char no_modify[]
913 INIT("Modification of a read-only value attempted");
914EXT char no_mem[]
915 INIT("Out of memory!\n");
916EXT char no_security[]
463ee0b2 917 INIT("Insecure dependency in %s%s");
93a17b20 918EXT char no_sock_func[]
919 INIT("Unsupported socket function \"%s\" called");
920EXT char no_dir_func[]
921 INIT("Unsupported directory function \"%s\" called");
922EXT char no_func[]
923 INIT("The %s function is unimplemented");
924
79072805 925EXT SV sv_undef;
926EXT SV sv_no;
927EXT SV sv_yes;
928#ifdef CSH
929 EXT char * cshname INIT(CSH);
930 EXT I32 cshlen;
931#endif
932
933#ifdef DOINIT
934EXT char *sig_name[] = {
935 SIG_NAME,0
936};
937#else
938EXT char *sig_name[];
939#endif
940
941#ifdef DOINIT
79072805 942EXT unsigned char fold[] = { /* fast case folding table */
943 0, 1, 2, 3, 4, 5, 6, 7,
944 8, 9, 10, 11, 12, 13, 14, 15,
945 16, 17, 18, 19, 20, 21, 22, 23,
946 24, 25, 26, 27, 28, 29, 30, 31,
947 32, 33, 34, 35, 36, 37, 38, 39,
948 40, 41, 42, 43, 44, 45, 46, 47,
949 48, 49, 50, 51, 52, 53, 54, 55,
950 56, 57, 58, 59, 60, 61, 62, 63,
951 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
952 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
953 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
954 'x', 'y', 'z', 91, 92, 93, 94, 95,
955 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
956 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
957 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
958 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
959 128, 129, 130, 131, 132, 133, 134, 135,
960 136, 137, 138, 139, 140, 141, 142, 143,
961 144, 145, 146, 147, 148, 149, 150, 151,
962 152, 153, 154, 155, 156, 157, 158, 159,
963 160, 161, 162, 163, 164, 165, 166, 167,
964 168, 169, 170, 171, 172, 173, 174, 175,
965 176, 177, 178, 179, 180, 181, 182, 183,
966 184, 185, 186, 187, 188, 189, 190, 191,
967 192, 193, 194, 195, 196, 197, 198, 199,
968 200, 201, 202, 203, 204, 205, 206, 207,
969 208, 209, 210, 211, 212, 213, 214, 215,
970 216, 217, 218, 219, 220, 221, 222, 223,
971 224, 225, 226, 227, 228, 229, 230, 231,
972 232, 233, 234, 235, 236, 237, 238, 239,
973 240, 241, 242, 243, 244, 245, 246, 247,
974 248, 249, 250, 251, 252, 253, 254, 255
975};
976#else
977EXT unsigned char fold[];
978#endif
979
980#ifdef DOINIT
981EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
982 1, 2, 84, 151, 154, 155, 156, 157,
983 165, 246, 250, 3, 158, 7, 18, 29,
984 40, 51, 62, 73, 85, 96, 107, 118,
985 129, 140, 147, 148, 149, 150, 152, 153,
986 255, 182, 224, 205, 174, 176, 180, 217,
987 233, 232, 236, 187, 235, 228, 234, 226,
988 222, 219, 211, 195, 188, 193, 185, 184,
989 191, 183, 201, 229, 181, 220, 194, 162,
990 163, 208, 186, 202, 200, 218, 198, 179,
991 178, 214, 166, 170, 207, 199, 209, 206,
992 204, 160, 212, 216, 215, 192, 175, 173,
993 243, 172, 161, 190, 203, 189, 164, 230,
994 167, 248, 227, 244, 242, 255, 241, 231,
995 240, 253, 169, 210, 245, 237, 249, 247,
996 239, 168, 252, 251, 254, 238, 223, 221,
997 213, 225, 177, 197, 171, 196, 159, 4,
998 5, 6, 8, 9, 10, 11, 12, 13,
999 14, 15, 16, 17, 19, 20, 21, 22,
1000 23, 24, 25, 26, 27, 28, 30, 31,
1001 32, 33, 34, 35, 36, 37, 38, 39,
1002 41, 42, 43, 44, 45, 46, 47, 48,
1003 49, 50, 52, 53, 54, 55, 56, 57,
1004 58, 59, 60, 61, 63, 64, 65, 66,
1005 67, 68, 69, 70, 71, 72, 74, 75,
1006 76, 77, 78, 79, 80, 81, 82, 83,
1007 86, 87, 88, 89, 90, 91, 92, 93,
1008 94, 95, 97, 98, 99, 100, 101, 102,
1009 103, 104, 105, 106, 108, 109, 110, 111,
1010 112, 113, 114, 115, 116, 117, 119, 120,
1011 121, 122, 123, 124, 125, 126, 127, 128,
1012 130, 131, 132, 133, 134, 135, 136, 137,
1013 138, 139, 141, 142, 143, 144, 145, 146
1014};
1015#else
1016EXT unsigned char freq[];
1017#endif
1018
8990e307 1019#ifdef DEBUGGING
1020#ifdef DOINIT
1021EXT char* block_type[] = {
1022 "NULL",
1023 "SUB",
1024 "EVAL",
1025 "LOOP",
1026 "SUBST",
1027 "BLOCK",
1028};
1029#else
1030EXT char* block_type[];
1031#endif
1032#endif
1033
79072805 1034/*****************************************************************************/
1035/* This lexer/parser stuff is currently global since yacc is hard to reenter */
1036/*****************************************************************************/
8990e307 1037/* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
79072805 1038
a0d0e21e 1039#include "perly.h"
1040
79072805 1041typedef enum {
1042 XOPERATOR,
1043 XTERM,
79072805 1044 XREF,
8990e307 1045 XSTATE,
a0d0e21e 1046 XBLOCK,
1047 XTERMBLOCK
79072805 1048} expectation;
1049
a0d0e21e 1050EXT U32 lex_state; /* next token is determined */
1051EXT U32 lex_defer; /* state after determined token */
1052EXT expectation lex_expect; /* expect after determined token */
1053EXT I32 lex_brackets; /* bracket count */
1054EXT I32 lex_formbrack; /* bracket count at outer format level */
1055EXT I32 lex_fakebrack; /* outer bracket is mere delimiter */
1056EXT I32 lex_casemods; /* casemod count */
1057EXT I32 lex_dojoin; /* doing an array interpolation */
1058EXT I32 lex_starts; /* how many interps done on level */
1059EXT SV * lex_stuff; /* runtime pattern from m// or s/// */
1060EXT SV * lex_repl; /* runtime replacement from s/// */
1061EXT OP * lex_op; /* extra info to pass back on op */
1062EXT OP * lex_inpat; /* in pattern $) and $| are special */
1063EXT I32 lex_inwhat; /* what kind of quoting are we in */
1064EXT char * lex_brackstack; /* what kind of brackets to pop */
1065EXT char * lex_casestack; /* what kind of case mods in effect */
1066
1067/* What we know when we're in LEX_KNOWNEXT state. */
1068EXT YYSTYPE nextval[5]; /* value of next token, if any */
1069EXT I32 nexttype[5]; /* type of next token */
1070EXT I32 nexttoke;
1071
79072805 1072EXT FILE * VOL rsfp INIT(Nullfp);
1073EXT SV * linestr;
1074EXT char * bufptr;
1075EXT char * oldbufptr;
1076EXT char * oldoldbufptr;
1077EXT char * bufend;
8990e307 1078EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */
a0d0e21e 1079EXT char * autoboot_preamble INIT(Nullch);
79072805 1080
1081EXT I32 multi_start; /* 1st line of multi-line string */
1082EXT I32 multi_end; /* last line of multi-line string */
1083EXT I32 multi_open; /* delimiter of said string */
1084EXT I32 multi_close; /* delimiter of said string */
1085
1086EXT GV * scrgv;
1087EXT I32 error_count; /* how many errors so far, max 10 */
1088EXT I32 subline; /* line this subroutine began on */
1089EXT SV * subname; /* name of current subroutine */
1090
93a17b20 1091EXT AV * comppad; /* storage for lexically scoped temporaries */
8990e307 1092EXT AV * comppad_name; /* variable names for "my" variables */
1093EXT I32 comppad_name_fill;/* last "introduced" variable offset */
1094EXT I32 min_intro_pending;/* start of vars to introduce */
1095EXT I32 max_intro_pending;/* end of vars to introduce */
79072805 1096EXT I32 padix; /* max used index in current "register" pad */
a0d0e21e 1097EXT I32 padix_floor; /* how low may inner block reset padix */
1098EXT bool pad_reset_pending; /* reset pad on next attempted alloc */
79072805 1099EXT COP compiling;
1100
79072805 1101EXT I32 thisexpr; /* name id for nothing_in_common() */
1102EXT char * last_uni; /* position of last named-unary operator */
1103EXT char * last_lop; /* position of last list operator */
8990e307 1104EXT OPCODE last_lop_op; /* last list operator */
93a17b20 1105EXT bool in_my; /* we're compiling a "my" declaration */
79072805 1106#ifdef FCRYPT
1107EXT I32 cryptseen; /* has fast crypt() been initialized? */
1108#endif
1109
85e6fe83 1110EXT U32 hints; /* various compilation flags */
1111
1112 /* Note: the lowest 8 bits are reserved for
1113 stuffing into op->op_private */
1114#define HINT_INTEGER 0x00000001
1115#define HINT_STRICT_REFS 0x00000002
1116
1117#define HINT_BLOCK_SCOPE 0x00000100
1118#define HINT_STRICT_SUBS 0x00000200
1119#define HINT_STRICT_VARS 0x00000400
1120
79072805 1121/**************************************************************************/
1122/* This regexp stuff is global since it always happens within 1 expr eval */
1123/**************************************************************************/
1124
1125EXT char * regprecomp; /* uncompiled string. */
1126EXT char * regparse; /* Input-scan pointer. */
1127EXT char * regxend; /* End of input for compile */
1128EXT I32 regnpar; /* () count. */
1129EXT char * regcode; /* Code-emit pointer; &regdummy = don't. */
1130EXT I32 regsize; /* Code size. */
a0d0e21e 1131EXT I32 regnaughty; /* How bad is this pattern? */
79072805 1132EXT I32 regsawback; /* Did we see \1, ...? */
1133
1134EXT char * reginput; /* String-input pointer. */
79072805 1135EXT char * regbol; /* Beginning of input, for ^ check. */
1136EXT char * regeol; /* End of input, for $ check. */
1137EXT char ** regstartp; /* Pointer to startp array. */
1138EXT char ** regendp; /* Ditto for endp. */
a0d0e21e 1139EXT U32 * reglastparen; /* Similarly for lastparen. */
79072805 1140EXT char * regtill; /* How far we are required to go. */
a0d0e21e 1141EXT U16 regflags; /* are we folding, multilining? */
1142EXT char regprev; /* char before regbol, \n if none */
79072805 1143
1144/***********************************************/
1145/* Global only to current interpreter instance */
1146/***********************************************/
1147
8990e307 1148#ifdef MULTIPLICITY
79072805 1149#define IEXT
1150#define IINIT(x)
1151struct interpreter {
1152#else
1153#define IEXT EXT
1154#define IINIT(x) INIT(x)
1155#endif
1156
1157/* pseudo environmental stuff */
1158IEXT int Iorigargc;
1159IEXT char ** Iorigargv;
1160IEXT GV * Ienvgv;
1161IEXT GV * Isiggv;
1162IEXT GV * Iincgv;
1163IEXT char * Iorigfilename;
1164
1165/* switches */
1166IEXT char * Icddir;
1167IEXT bool Iminus_c;
1168IEXT char Ipatchlevel[6];
1169IEXT char * Inrs IINIT("\n");
1170IEXT U32 Inrschar IINIT('\n'); /* final char of rs, or 0777 if none */
1171IEXT I32 Inrslen IINIT(1);
2304df62 1172IEXT char * Isplitstr IINIT(" ");
79072805 1173IEXT bool Ipreprocess;
1174IEXT bool Iminus_n;
1175IEXT bool Iminus_p;
1176IEXT bool Iminus_l;
1177IEXT bool Iminus_a;
2304df62 1178IEXT bool Iminus_F;
79072805 1179IEXT bool Idoswitches;
1180IEXT bool Idowarn;
1181IEXT bool Idoextract;
79072805 1182IEXT bool Isawampersand; /* must save all match strings */
1183IEXT bool Isawstudy; /* do fbm_instr on all strings */
1184IEXT bool Isawi; /* study must assume case insensitive */
1185IEXT bool Isawvec;
1186IEXT bool Iunsafe;
1187IEXT bool Ido_undump; /* -u or dump seen? */
1188IEXT char * Iinplace;
1189IEXT char * Ie_tmpname;
1190IEXT FILE * Ie_fp;
1191IEXT VOL U32 Idebug;
1192IEXT U32 Iperldb;
1193
1194/* magical thingies */
85e6fe83 1195IEXT Time_t Ibasetime; /* $^T */
79072805 1196IEXT SV * Iformfeed; /* $^L */
1197IEXT char * Ichopset IINIT(" \n-"); /* $: */
1198IEXT char * Irs IINIT("\n"); /* $/ */
1199IEXT U32 Irschar IINIT('\n'); /* final char of rs, or 0777 if none */
8990e307 1200IEXT STRLEN Irslen IINIT(1);
79072805 1201IEXT bool Irspara;
1202IEXT char * Iofs; /* $, */
8990e307 1203IEXT STRLEN Iofslen;
79072805 1204IEXT char * Iors; /* $\ */
8990e307 1205IEXT STRLEN Iorslen;
79072805 1206IEXT char * Iofmt; /* $# */
1207IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1208IEXT int Imultiline; /* $*--do strings hold >1 line? */
1209IEXT U16 Istatusvalue; /* $? */
1210
1211IEXT struct stat Istatcache; /* _ */
1212IEXT GV * Istatgv;
1213IEXT SV * Istatname IINIT(Nullsv);
1214
1215/* shortcuts to various I/O objects */
1216IEXT GV * Istdingv;
1217IEXT GV * Ilast_in_gv;
1218IEXT GV * Idefgv;
1219IEXT GV * Iargvgv;
1220IEXT GV * Idefoutgv;
79072805 1221IEXT GV * Iargvoutgv;
1222
1223/* shortcuts to regexp stuff */
1224IEXT GV * Ileftgv;
1225IEXT GV * Iampergv;
1226IEXT GV * Irightgv;
1227IEXT PMOP * Icurpm; /* what to do \ interps from */
79072805 1228IEXT I32 * Iscreamfirst;
1229IEXT I32 * Iscreamnext;
1230IEXT I32 Imaxscream IINIT(-1);
1231IEXT SV * Ilastscream;
1232
1233/* shortcuts to debugging objects */
1234IEXT GV * IDBgv;
1235IEXT GV * IDBline;
1236IEXT GV * IDBsub;
1237IEXT SV * IDBsingle;
1238IEXT SV * IDBtrace;
1239IEXT SV * IDBsignal;
1240IEXT AV * Ilineary; /* lines of script for debugger */
1241IEXT AV * Idbargs; /* args to call listed by caller function */
1242
1243/* symbol tables */
1244IEXT HV * Idefstash; /* main symbol table */
1245IEXT HV * Icurstash; /* symbol table for current package */
1246IEXT HV * Idebstash; /* symbol table for perldb package */
1247IEXT SV * Icurstname; /* name of current package */
93a17b20 1248IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1249IEXT AV * Iendav; /* names of END subroutines */
1250IEXT AV * Ipad; /* storage for lexically scoped temporaries */
1251IEXT AV * Ipadname; /* variable names for "my" variables */
79072805 1252
1253/* memory management */
79072805 1254IEXT SV ** Itmps_stack;
1255IEXT I32 Itmps_ix IINIT(-1);
1256IEXT I32 Itmps_floor IINIT(-1);
8990e307 1257IEXT I32 Itmps_max;
1258IEXT I32 Isv_count; /* how many SV* are currently allocated */
a0d0e21e 1259IEXT I32 Isv_objcount; /* how many objects are currently allocated */
8990e307 1260IEXT SV* Isv_root; /* storage for SVs belonging to interp */
1261IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */
79072805 1262
1263/* funky return mechanisms */
1264IEXT I32 Ilastspbase;
1265IEXT I32 Ilastsize;
1266IEXT int Iforkprocess; /* so do_open |- can return proc# */
1267
1268/* subprocess state */
1269IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1270IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1271
1272/* internal state */
463ee0b2 1273IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1274IEXT OP * Irestartop; /* Are we propagating an error from croak? */
79072805 1275IEXT int Idelaymagic; /* ($<,$>) = ... */
2304df62 1276IEXT bool Idirty; /* In the middle of tearing things down? */
79072805 1277IEXT bool Ilocalizing; /* are we processing a local() list? */
79072805 1278IEXT bool Itainted; /* using variables controlled by $< */
463ee0b2 1279IEXT bool Itainting; /* doing taint checks */
79072805 1280
1281/* trace state */
1282IEXT I32 Idlevel;
1283IEXT I32 Idlmax IINIT(128);
1284IEXT char * Idebname;
1285IEXT char * Idebdelim;
1286
1287/* current interpreter roots */
463ee0b2 1288IEXT OP * Imain_root;
1289IEXT OP * Imain_start;
1290IEXT OP * Ieval_root;
1291IEXT OP * Ieval_start;
79072805 1292
1293/* runtime control stuff */
1294IEXT COP * VOL Icurcop IINIT(&compiling);
1295IEXT line_t Icopline IINIT(NOLINE);
1296IEXT CONTEXT * Icxstack;
1297IEXT I32 Icxstack_ix IINIT(-1);
1298IEXT I32 Icxstack_max IINIT(128);
1299IEXT jmp_buf Itop_env;
a0d0e21e 1300IEXT I32 Irunlevel;
79072805 1301
1302/* stack stuff */
1303IEXT AV * Istack; /* THE STACK */
1304IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1305IEXT SV ** Imystack_base; /* stack->array_ary */
1306IEXT SV ** Imystack_sp; /* stack pointer now */
1307IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1308
1309/* format accumulators */
463ee0b2 1310IEXT SV * Iformtarget;
1311IEXT SV * Ibodytarget;
1312IEXT SV * Itoptarget;
79072805 1313
1314/* statics moved here for shared library purposes */
93a17b20 1315IEXT SV Istrchop; /* return value from chop */
79072805 1316IEXT int Ifilemode; /* so nextargv() can preserve mode */
1317IEXT int Ilastfd; /* what to preserve mode on */
1318IEXT char * Ioldname; /* what to preserve mode on */
1319IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1320IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1321IEXT OP * Isortcop; /* user defined sort routine */
1322IEXT HV * Isortstash; /* which is in some package or other */
1323IEXT GV * Ifirstgv; /* $a */
1324IEXT GV * Isecondgv; /* $b */
1325IEXT AV * Isortstack; /* temp stack during pp_sort() */
1326IEXT AV * Isignalstack; /* temp stack during sighandler() */
1327IEXT SV * Imystrk; /* temp key string for do_each() */
1328IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
79072805 1329IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1330IEXT I32 Igensym; /* next symbol for getsym() to define */
1331IEXT bool Ipreambled;
1332IEXT int Ilaststatval IINIT(-1);
1333IEXT I32 Ilaststype IINIT(OP_STAT);
1334
1335#undef IEXT
1336#undef IINIT
1337
8990e307 1338#ifdef MULTIPLICITY
79072805 1339};
1340#else
1341struct interpreter {
1342 char broiled;
1343};
1344#endif
1345
1346#include "pp.h"
1347
1348#ifdef __cplusplus
1349extern "C" {
1350#endif
1351
a0d0e21e 1352#ifdef __cplusplus
1353# ifndef I_STDARG
1354# define I_STDARG 1
1355# endif
1356#endif
1357
1358#ifdef I_STDARG
2304df62 1359# include <stdarg.h>
1360#else
1361# ifdef I_VARARGS
1362# include <varargs.h>
1363# endif
1364#endif
1365
79072805 1366#include "proto.h"
1367
a0d0e21e 1368#ifdef EMBED
1369#define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1370#define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1371#else
1372#define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1373#define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1374#endif
1375
79072805 1376#ifdef __cplusplus
1377};
1378#endif
1379
93a17b20 1380/* The following must follow proto.h */
79072805 1381
1382#ifdef DOINIT
463ee0b2 1383MGVTBL vtbl_sv = {magic_get,
1384 magic_set,
1385 magic_len,
1386 0, 0};
1387MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1388MGVTBL vtbl_envelem = {0, magic_setenv,
85e6fe83 1389 0, magic_clearenv,
1390 0};
463ee0b2 1391MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1392MGVTBL vtbl_sigelem = {0, magic_setsig,
1393 0, 0, 0};
a0d0e21e 1394MGVTBL vtbl_pack = {0, 0, 0, magic_wipepack,
1395 0};
463ee0b2 1396MGVTBL vtbl_packelem = {magic_getpack,
1397 magic_setpack,
1398 0, magic_clearpack,
1399 0};
1400MGVTBL vtbl_dbline = {0, magic_setdbline,
1401 0, 0, 0};
1402MGVTBL vtbl_isa = {0, magic_setisa,
1403 0, 0, 0};
1404MGVTBL vtbl_isaelem = {0, magic_setisa,
1405 0, 0, 0};
1406MGVTBL vtbl_arylen = {magic_getarylen,
1407 magic_setarylen,
1408 0, 0, 0};
1409MGVTBL vtbl_glob = {magic_getglob,
1410 magic_setglob,
1411 0, 0, 0};
1412MGVTBL vtbl_mglob = {0, magic_setmglob,
1413 0, 0, 0};
1414MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1415 0, 0, 0};
1416MGVTBL vtbl_substr = {0, magic_setsubstr,
1417 0, 0, 0};
1418MGVTBL vtbl_vec = {0, magic_setvec,
1419 0, 0, 0};
a0d0e21e 1420MGVTBL vtbl_pos = {magic_getpos,
1421 magic_setpos,
1422 0, 0, 0};
463ee0b2 1423MGVTBL vtbl_bm = {0, magic_setbm,
1424 0, 0, 0};
1425MGVTBL vtbl_uvar = {magic_getuvar,
1426 magic_setuvar,
1427 0, 0, 0};
a0d0e21e 1428
1429#ifdef OVERLOAD
1430MGVTBL vtbl_amagic = {0, magic_setamagic,
1431 0, 0, 0};
1432MGVTBL vtbl_amagicelem = {0, magic_setamagic,
1433 0, 0, 0};
1434#endif /* OVERLOAD */
1435
79072805 1436#else
1437EXT MGVTBL vtbl_sv;
1438EXT MGVTBL vtbl_env;
1439EXT MGVTBL vtbl_envelem;
1440EXT MGVTBL vtbl_sig;
1441EXT MGVTBL vtbl_sigelem;
463ee0b2 1442EXT MGVTBL vtbl_pack;
1443EXT MGVTBL vtbl_packelem;
79072805 1444EXT MGVTBL vtbl_dbline;
463ee0b2 1445EXT MGVTBL vtbl_isa;
1446EXT MGVTBL vtbl_isaelem;
79072805 1447EXT MGVTBL vtbl_arylen;
1448EXT MGVTBL vtbl_glob;
93a17b20 1449EXT MGVTBL vtbl_mglob;
463ee0b2 1450EXT MGVTBL vtbl_taint;
79072805 1451EXT MGVTBL vtbl_substr;
1452EXT MGVTBL vtbl_vec;
a0d0e21e 1453EXT MGVTBL vtbl_pos;
79072805 1454EXT MGVTBL vtbl_bm;
1455EXT MGVTBL vtbl_uvar;
a0d0e21e 1456
1457#ifdef OVERLOAD
1458EXT MGVTBL vtbl_amagic;
1459EXT MGVTBL vtbl_amagicelem;
1460#endif /* OVERLOAD */
1461
79072805 1462#endif
85e6fe83 1463
a0d0e21e 1464#ifdef OVERLOAD
1465EXT long amagic_generation;
1466
1467#define NofAMmeth 27
1468#ifdef DOINIT
1469EXT char * AMG_names[NofAMmeth][2] = {
1470 {"fallback","abs"},
1471 {"bool", "nomethod"},
1472 {"\"\"", "0+"},
1473 {"+","+="},
1474 {"-","-="},
1475 {"*", "*="},
1476 {"/", "/="},
1477 {"%", "%="},
1478 {"**", "**="},
1479 {"<<", "<<="},
1480 {">>", ">>="},
1481 {"<", "<="},
1482 {">", ">="},
1483 {"==", "!="},
1484 {"<=>", "cmp"},
1485 {"lt", "le"},
1486 {"gt", "ge"},
1487 {"eq", "ne"},
1488 {"&", "^"},
1489 {"|", "neg"},
1490 {"!", "~"},
1491 {"++", "--"},
1492 {"atan2", "cos"},
1493 {"sin", "exp"},
1494 {"log", "sqrt"},
1495 {"x","x="},
1496 {".",".="}
1497};
1498#else
1499EXT char * AMG_names[NofAMmeth][2];
1500#endif /* def INITAMAGIC */
1501
1502struct am_table {
1503 long was_ok_sub;
1504 long was_ok_am;
1505 CV* table[NofAMmeth*2];
1506 long fallback;
1507};
1508typedef struct am_table AMT;
1509
1510#define AMGfallNEVER 1
1511#define AMGfallNO 2
1512#define AMGfallYES 3
1513
1514enum {
1515 fallback_amg, abs_amg,
1516 bool__amg, nomethod_amg,
1517 string_amg, numer_amg,
1518 add_amg, add_ass_amg,
1519 subtr_amg, subtr_ass_amg,
1520 mult_amg, mult_ass_amg,
1521 div_amg, div_ass_amg,
1522 mod_amg, mod_ass_amg,
1523 pow_amg, pow_ass_amg,
1524 lshift_amg, lshift_ass_amg,
1525 rshift_amg, rshift_ass_amg,
1526 lt_amg, le_amg,
1527 gt_amg, ge_amg,
1528 eq_amg, ne_amg,
1529 ncmp_amg, scmp_amg,
1530 slt_amg, sle_amg,
1531 sgt_amg, sge_amg,
1532 seq_amg, sne_amg,
1533 band_amg, bxor_amg,
1534 bor_amg, neg_amg,
1535 not_amg, compl_amg,
1536 inc_amg, dec_amg,
1537 atan2_amg, cos_amg,
1538 sin_amg, exp_amg,
1539 log_amg, sqrt_amg,
1540 repeat_amg, repeat_ass_amg,
1541 concat_amg, concat_ass_amg
1542};
1543#endif /* OVERLOAD */
1544
85e6fe83 1545#endif /* Include guard */