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