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