This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make C<no FOO> fail if C<unimport FOO> fails
[perl5.git] / perl.h
1 /*    perl.h
2  *
3  *    Copyright (c) 1987-1994, Larry Wall
4  *
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.
7  *
8  */
9 #ifndef H_PERL
10 #define H_PERL 1
11 #define OVERLOAD
12
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
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
48 #include "embed.h"
49
50 #define VOIDUSED 1
51 #include "config.h"
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  */
69
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
75 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
76 # define STANDARD_C 1
77 #endif
78
79 #if defined(HASVOLATILE) || defined(STANDARD_C)
80 #   ifdef __cplusplus
81 #       define VOL              // to temporarily suppress warnings
82 #   else
83 #       define VOL volatile
84 #   endif
85 #else
86 #   define VOL
87 #endif
88
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()
93
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))
103 #else
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
142 #endif
143
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"
165
166 #ifdef USE_NEXT_CTYPE
167
168 #if NX_CURRENT_COMPILER_RELEASE >= 400
169 #include <objc/NXCType.h>
170 #else /*  NX_CURRENT_COMPILER_RELEASE < 400 */
171 #include <appkit/NXCType.h>
172 #endif /*  NX_CURRENT_COMPILER_RELEASE >= 400 */
173
174 #else /* !USE_NEXT_CTYPE */
175 #include <ctype.h>
176 #endif /* USE_NEXT_CTYPE */
177
178 #ifdef I_LOCALE
179 #include <locale.h>
180 #endif
181
182 EXT int lc_collate_active;
183
184 #ifdef METHOD   /* Defined by OSF/1 v3.0 by ctype.h */
185 #undef METHOD
186 #endif
187
188 #include <setjmp.h>
189
190 #ifdef I_SYS_PARAM
191 #   ifdef PARAM_NEEDS_TYPES
192 #       include <sys/types.h>
193 #   endif
194 #   include <sys/param.h>
195 #endif
196
197
198 /* Use all the "standard" definitions? */
199 #if defined(STANDARD_C) && defined(I_STDLIB)
200 #   include <stdlib.h>
201 #endif /* STANDARD_C */
202
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
208 #   ifdef HIDEMYMALLOC
209 #       define malloc Mymalloc
210 #       define realloc Myremalloc
211 #       define free Myfree
212 #       define calloc Mycalloc
213 #   endif
214 #   define safemalloc malloc
215 #   define saferealloc realloc
216 #   define safefree free
217 #   define safecalloc calloc
218 #endif
219
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__)
234 #   undef HAS_MEMCMP
235 #endif
236
237 #ifdef I_MEMORY
238 #  include <memory.h>
239 #endif
240
241 #ifdef HAS_MEMCPY
242 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
243 #    ifndef memcpy
244         extern char * memcpy _((char*, char*, int));
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 */
256
257 #ifdef HAS_MEMSET
258 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
259 #    ifndef memset
260         extern char *memset _((char*, int, int));
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
271 #   endif
272 #endif /* HAS_MEMSET */
273
274 #ifdef HAS_MEMCMP
275 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
276 #    ifndef memcmp
277         extern int memcmp _((char*, char*, int));
278 #    endif
279 #  endif
280 #else
281 #   ifndef memcmp
282 #       define memcmp   my_memcmp
283 #   endif
284 #endif /* HAS_MEMCMP */
285
286 #if !defined(HAS_MEMMOVE) && !defined(memmove)
287 #   if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
288 #       define memmove(d,s,l) bcopy(s,d,l)
289 #   else
290 #       if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
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
296 #endif
297
298 #ifdef I_NETINET_IN
299 #   include <netinet/in.h>
300 #endif
301
302 #ifdef I_SYS_STAT
303 #include <sys/stat.h>
304 #endif
305
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))
316 #   undef S_ISDIR
317 #   undef S_ISCHR
318 #   undef S_ISBLK
319 #   undef S_ISREG
320 #   undef S_ISFIFO
321 #   undef S_ISLNK
322 #endif
323
324 #ifdef I_TIME
325 #   include <time.h>
326 #endif
327
328 #ifdef I_SYS_TIME
329 #   ifdef I_SYS_TIME_KERNEL
330 #       define KERNEL
331 #   endif
332 #   include <sys/time.h>
333 #   ifdef I_SYS_TIME_KERNEL
334 #       undef KERNEL
335 #   endif
336 #endif
337
338 #ifndef MSDOS
339 #  if defined(HAS_TIMES) && defined(I_SYS_TIMES)
340 #    include <sys/times.h>
341 #  endif
342 #endif
343
344 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
345 #   undef HAS_STRERROR
346 #endif
347
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
354 #include <errno.h>
355 #ifdef HAS_SOCKET
356 #   ifdef I_NET_ERRNO
357 #     include <net/errno.h>
358 #   endif
359 #endif
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)
367 #   define SETERRNO(errcode,vmserrcode) STMT_START {set_errno(errcode); set_vaxc_errno(vmserrcode);} STMT_END
368 #endif
369
370 #ifndef MSDOS
371 #   ifndef errno
372         extern int errno;     /* ANSI allows errno to be an lvalue expr */
373 #   endif
374 #endif
375
376 #ifdef HAS_STRERROR
377 #       ifdef VMS
378         char *strerror _((int,...));
379 #       else
380         char *strerror _((int));
381 #       endif
382 #       ifndef Strerror
383 #           define Strerror strerror
384 #       endif
385 #else
386 #    ifdef HAS_SYS_ERRLIST
387         extern int sys_nerr;
388         extern char *sys_errlist[];
389 #       ifndef Strerror
390 #           define Strerror(e) \
391                 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
392 #       endif
393 #   endif
394 #endif
395
396 #ifdef I_SYS_IOCTL
397 #   ifndef _IOCTL_
398 #       include <sys/ioctl.h>
399 #   endif
400 #endif
401
402 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
403 #   ifdef HAS_SOCKETPAIR
404 #       undef HAS_SOCKETPAIR
405 #   endif
406 #   ifdef I_NDBM
407 #       undef I_NDBM
408 #   endif
409 #endif
410
411 #if INTSIZE == 2
412 #   define htoni htons
413 #   define ntohi ntohs
414 #else
415 #   define htoni htonl
416 #   define ntohi ntohl
417 #endif
418
419 /* Configure already sets Direntry_t */
420 #if defined(I_DIRENT)
421 #   include <dirent.h>
422 #   if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
423 #       include <sys/dir.h>
424 #   endif
425 #else
426 #   ifdef I_SYS_NDIR
427 #       include <sys/ndir.h>
428 #   else
429 #       ifdef I_SYS_DIR
430 #           ifdef hp9000s500
431 #               include <ndir.h>        /* may be wrong in the future */
432 #           else
433 #               include <sys/dir.h>
434 #           endif
435 #       endif
436 #   endif
437 #endif
438
439 #ifdef FPUTS_BOTCH
440 /* work around botch in SunOS 4.0.1 and 4.0.2 */
441 #   ifndef fputs
442 #       define fputs(sv,fp) fprintf(fp,"%s",sv)
443 #   endif
444 #endif
445
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
469 #   ifdef S_IFBLK
470 #       define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
471 #   else
472 #       define S_ISBLK(m) (0)
473 #   endif
474 #endif
475
476 #ifndef S_ISREG
477 #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
478 #endif
479
480 #ifndef S_ISFIFO
481 #   ifdef S_IFIFO
482 #       define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
483 #   else
484 #       define S_ISFIFO(m) (0)
485 #   endif
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
546 #ifdef ff_next
547 #   undef ff_next
548 #endif
549
550 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
551 #   define SLOPPYDIVIDE
552 #endif
553
554 #if defined(cray) || defined(convex) || BYTEORDER > 0xffff
555 #   define HAS_QUAD
556 #endif
557
558 #ifdef UV
559 #undef UV
560 #endif
561
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
575 #ifdef HAS_QUAD
576 #   ifdef cray
577 #       define Quad_t int
578 #   else
579 #       if defined(convex)
580 #           define Quad_t long long
581 #       else
582 #           define Quad_t long
583 #       endif
584 #   endif
585     typedef Quad_t IV;
586     typedef unsigned Quad_t UV;
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
591 #else
592     typedef long IV;
593     typedef unsigned long UV;
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
598 #endif
599
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
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  */
639
640 #define PERL_UCHAR_MIN ((unsigned char)0)
641
642 #ifdef UCHAR_MAX
643 #  define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
644 #else
645 #  ifdef MAXUCHAR
646 #    define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
647 #  else
648 #    define PERL_UCHAR_MAX       ((unsigned char)~(unsigned)0)
649 #  endif
650 #endif
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  */
660
661 #define PERL_USHORT_MIN ((unsigned short)0)
662
663 #ifdef USHORT_MAX
664 #  define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
665 #else
666 #  ifdef MAXUSHORT
667 #    define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
668 #  else
669 #    define PERL_USHORT_MAX       ((unsigned short)~(unsigned)0)
670 #  endif
671 #endif
672
673 #ifdef SHORT_MAX
674 #  define PERL_SHORT_MAX ((short)SHORT_MAX)
675 #else
676 #  ifdef MAXSHORT    /* Often used in <values.h> */
677 #    define PERL_SHORT_MAX ((short)MAXSHORT)
678 #  else
679 #    define PERL_SHORT_MAX      ((short) (PERL_USHORT_MAX >> 1))
680 #  endif
681 #endif
682
683 #ifdef SHORT_MIN
684 #  define PERL_SHORT_MIN ((short)SHORT_MIN)
685 #else
686 #  ifdef MINSHORT
687 #    define PERL_SHORT_MIN ((short)MINSHORT)
688 #  else
689 #    define PERL_SHORT_MIN        (-PERL_SHORT_MAX - ((3 & -1) == 3))
690 #  endif
691 #endif
692
693 #ifdef UINT_MAX
694 #  define PERL_UINT_MAX ((unsigned int)UINT_MAX)
695 #else
696 #  ifdef MAXUINT
697 #    define PERL_UINT_MAX ((unsigned int)MAXUINT)
698 #  else
699 #    define PERL_UINT_MAX       (~(unsigned int)0)
700 #  endif
701 #endif
702
703 #define PERL_UINT_MIN ((unsigned int)0)
704
705 #ifdef INT_MAX
706 #  define PERL_INT_MAX ((int)INT_MAX)
707 #else
708 #  ifdef MAXINT    /* Often used in <values.h> */
709 #    define PERL_INT_MAX ((int)MAXINT)
710 #  else
711 #    define PERL_INT_MAX        ((int)(PERL_UINT_MAX >> 1))
712 #  endif
713 #endif
714
715 #ifdef INT_MIN
716 #  define PERL_INT_MIN ((int)INT_MIN)
717 #else
718 #  ifdef MININT
719 #    define PERL_INT_MIN ((int)MININT)
720 #  else
721 #    define PERL_INT_MIN        (-PERL_INT_MAX - ((3 & -1) == 3))
722 #  endif
723 #endif
724
725 #ifdef ULONG_MAX
726 #  define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
727 #else
728 #  ifdef MAXULONG
729 #    define PERL_ULONG_MAX ((unsigned long)MAXULONG)
730 #  else
731 #    define PERL_ULONG_MAX       (~(unsigned long)0)
732 #  endif
733 #endif
734
735 #define PERL_ULONG_MIN ((unsigned long)0L)
736
737 #ifdef LONG_MAX
738 #  define PERL_LONG_MAX ((long)LONG_MAX)
739 #else
740 #  ifdef MAXLONG    /* Often used in <values.h> */
741 #    define PERL_LONG_MAX ((long)MAXLONG)
742 #  else
743 #    define PERL_LONG_MAX        ((long) (PERL_ULONG_MAX >> 1))
744 #  endif
745 #endif
746
747 #ifdef LONG_MIN
748 #  define PERL_LONG_MIN ((long)LONG_MIN)
749 #else
750 #  ifdef MINLONG
751 #    define PERL_LONG_MIN ((long)MINLONG)
752 #  else
753 #    define PERL_LONG_MIN        (-PERL_LONG_MAX - ((3 & -1) == 3))
754 #  endif
755 #endif
756
757 #ifdef HAS_QUAD
758
759 #  ifdef UQUAD_MAX
760 #    define PERL_UQUAD_MAX ((UV)UQUAD_MAX)
761 #  else
762 #    define PERL_UQUAD_MAX      (~(UV)0)
763 #  endif
764
765 #  define PERL_UQUAD_MIN ((UV)0)
766
767 #  ifdef QUAD_MAX
768 #    define PERL_QUAD_MAX ((IV)QUAD_MAX)
769 #  else
770 #    define PERL_QUAD_MAX       ((IV) (PERL_UQUAD_MAX >> 1))
771 #  endif
772
773 #  ifdef QUAD_MIN
774 #    define PERL_QUAD_MIN ((IV)QUAD_MIN)
775 #  else
776 #    define PERL_QUAD_MIN       (-PERL_QUAD_MAX - ((3 & -1) == 3))
777 #  endif
778
779 #endif
780
781 typedef MEM_SIZE STRLEN;
782
783 typedef struct op OP;
784 typedef struct cop COP;
785 typedef struct unop UNOP;
786 typedef struct binop BINOP;
787 typedef struct listop LISTOP;
788 typedef struct logop LOGOP;
789 typedef struct condop CONDOP;
790 typedef struct pmop PMOP;
791 typedef struct svop SVOP;
792 typedef struct gvop GVOP;
793 typedef struct pvop PVOP;
794 typedef struct loop LOOP;
795
796 typedef struct Outrec Outrec;
797 typedef struct interpreter PerlInterpreter;
798 typedef struct ff FF;
799 typedef struct sv SV;
800 typedef struct av AV;
801 typedef struct hv HV;
802 typedef struct cv CV;
803 typedef struct regexp REGEXP;
804 typedef struct gp GP;
805 typedef struct gv GV;
806 typedef struct io IO;
807 typedef struct context CONTEXT;
808 typedef struct block BLOCK;
809
810 typedef struct magic MAGIC;
811 typedef struct xrv XRV;
812 typedef struct xpv XPV;
813 typedef struct xpviv XPVIV;
814 typedef struct xpvnv XPVNV;
815 typedef struct xpvmg XPVMG;
816 typedef struct xpvlv XPVLV;
817 typedef struct xpvav XPVAV;
818 typedef struct xpvhv XPVHV;
819 typedef struct xpvgv XPVGV;
820 typedef struct xpvcv XPVCV;
821 typedef struct xpvbm XPVBM;
822 typedef struct xpvfm XPVFM;
823 typedef struct xpvio XPVIO;
824 typedef struct mgvtbl MGVTBL;
825 typedef union any ANY;
826
827 #include "handy.h"
828
829 typedef 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
834 #ifdef DOSISH
835 # if defined(OS2)
836 #   include "os2ish.h"
837 # else
838 #   include "dosish.h"
839 # endif
840 #else
841 # if defined(VMS)
842 #   include "vmsish.h"
843 # else
844 #   if defined(PLAN9)
845 #     include "./plan9/plan9ish.h"
846 #   else
847 #     include "unixish.h"
848 #   endif
849 # endif
850 #endif
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)
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
870 #endif
871
872 union any {
873     void*       any_ptr;
874     I32         any_i32;
875     IV          any_iv;
876     long        any_long;
877     void        (*any_dptr) _((void*));
878 };
879
880 #include "regexp.h"
881 #include "sv.h"
882 #include "util.h"
883 #include "form.h"
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"
893
894 /* work around some libPW problems */
895 #ifdef DOINIT
896 EXT char Error[1];
897 #endif
898
899 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
900 #   define I286
901 #endif
902
903 #if defined(htonl) && !defined(HAS_HTONL)
904 #define HAS_HTONL
905 #endif
906 #if defined(htons) && !defined(HAS_HTONS)
907 #define HAS_HTONS
908 #endif
909 #if defined(ntohl) && !defined(HAS_NTOHL)
910 #define HAS_NTOHL
911 #endif
912 #if defined(ntohs) && !defined(HAS_NTOHS)
913 #define HAS_NTOHS
914 #endif
915 #ifndef HAS_HTONL
916 #if (BYTEORDER & 0xffff) != 0x4321
917 #define HAS_HTONS
918 #define HAS_HTONL
919 #define HAS_NTOHS
920 #define HAS_NTOHL
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
928 #if (BYTEORDER & 0xffff) == 0x4321
929 #undef HAS_HTONS
930 #undef HAS_HTONL
931 #undef HAS_NTOHS
932 #undef HAS_NTOHL
933 #endif
934 #endif
935
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
957 #ifdef CASTNEGFLOAT
958 #define U_S(what) ((U16)(what))
959 #define U_I(what) ((unsigned int)(what))
960 #define U_L(what) ((U32)(what))
961 #else
962 #  ifdef __cplusplus
963     extern "C" {
964 #  endif
965 U32 cast_ulong _((double));
966 #  ifdef __cplusplus
967     }
968 #  endif
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)))
972 #endif
973
974 #ifdef CASTI32
975 #define I_32(what) ((I32)(what))
976 #define I_V(what) ((IV)(what))
977 #define U_V(what) ((UV)(what))
978 #else
979 #  ifdef __cplusplus
980     extern "C" {
981 #  endif
982 I32 cast_i32 _((double));
983 IV cast_iv _((double));
984 UV cast_uv _((double));
985 #  ifdef __cplusplus
986     }
987 #  endif
988 #define I_32(what) (cast_i32((double)(what)))
989 #define I_V(what) (cast_iv((double)(what)))
990 #define U_V(what) (cast_uv((double)(what)))
991 #endif
992
993 struct Outrec {
994     I32         o_lines;
995     char        *o_str;
996     U32         o_len;
997 };
998
999 #ifndef MAXSYSFD
1000 #   define MAXSYSFD 2
1001 #endif
1002
1003 #ifndef TMPPATH
1004 #  define TMPPATH "/tmp/perl-eXXXXXX"
1005 #endif
1006
1007 #ifndef __cplusplus
1008 Uid_t getuid _((void));
1009 Uid_t geteuid _((void));
1010 Gid_t getgid _((void));
1011 Gid_t getegid _((void));
1012 #endif
1013
1014 #ifdef DEBUGGING
1015 #ifndef Perl_debug_log
1016 #define Perl_debug_log  PerlIO_stderr()
1017 #endif
1018 #define YYDEBUG 1
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
1028 #define DEBUG_m(a) if (curinterp && debug & 128)        a
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
1036 #define DEBUG_D(a) if (debug & 32768)   a
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)
1055 #define DEBUG_D(a)
1056 #endif
1057 #define YYMAXDEPTH 300
1058
1059 #ifndef assert  /* <assert.h> might have been included somehow */
1060 #define assert(what)    DEB( {                                          \
1061         if (!(what)) {                                                  \
1062             croak("Assertion failed: file \"%s\", line %d",             \
1063                 __FILE__, __LINE__);                                    \
1064             exit(1);                                                    \
1065         }})
1066 #endif
1067
1068 struct ufuncs {
1069     I32 (*uf_val)_((IV, SV*));
1070     I32 (*uf_set)_((IV, SV*));
1071     IV uf_index;
1072 };
1073
1074 /* Fix these up for __STDC__ */
1075 #ifndef __cplusplus
1076 char *mktemp _((char*));
1077 double atof _((const char*));
1078 #endif
1079
1080 #ifndef STANDARD_C
1081 /* All of these are in stdlib.h or time.h for ANSI C */
1082 Time_t time();
1083 struct tm *gmtime(), *localtime();
1084 char *strchr(), *strrchr();
1085 char *strcpy(), *strcat();
1086 #endif /* ! STANDARD_C */
1087
1088
1089 #ifdef I_MATH
1090 #    include <math.h>
1091 #else
1092 #   ifdef __cplusplus
1093         extern "C" {
1094 #   endif
1095             double exp _((double));
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));
1103 #   ifdef __cplusplus
1104         };
1105 #   endif
1106 #endif
1107
1108 #ifndef __cplusplus
1109 #ifdef __NeXT__ /* or whatever catches all NeXTs */
1110 char *crypt ();       /* Maybe more hosts will need the unprototyped version */
1111 #else
1112 char *crypt _((const char*, const char*));
1113 #endif
1114 char *getenv _((const char*));
1115 Off_t lseek _((int,Off_t,int));
1116 char *getlogin _((void));
1117 #endif
1118
1119 #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
1120 #define UNLINK unlnk
1121 I32 unlnk _((char*));
1122 #else
1123 #define UNLINK unlink
1124 #endif
1125
1126 #ifndef HAS_SETREUID
1127 #  ifdef HAS_SETRESUID
1128 #    define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
1129 #    define HAS_SETREUID
1130 #  endif
1131 #endif
1132 #ifndef HAS_SETREGID
1133 #  ifdef HAS_SETRESGID
1134 #    define setregid(r,e) setresgid(r,e,(Gid_t)-1)
1135 #    define HAS_SETREGID
1136 #  endif
1137 #endif
1138
1139 #define SCAN_DEF 0
1140 #define SCAN_TR 1
1141 #define SCAN_REPL 2
1142
1143 #ifdef MYMALLOC
1144 # ifndef DEBUGGING_MSTATS
1145 #  define DEBUGGING_MSTATS
1146 # endif
1147 #endif
1148
1149 #ifdef DEBUGGING
1150 # ifndef register
1151 #  define register
1152 # endif
1153 # define PAD_SV(po) pad_sv(po)
1154 #else
1155 # define PAD_SV(po) curpad[po]
1156 #endif
1157
1158 /****************/
1159 /* Truly global */
1160 /****************/
1161
1162 /* global state */
1163 EXT PerlInterpreter *   curinterp;      /* currently running interpreter */
1164 /* VMS doesn't use environ array and NeXT has problems with crt0.o globals */
1165 #if !defined(VMS) && !(defined(NeXT) && defined(__DYNAMIC__))
1166 extern char **  environ;        /* environment variables supplied via exec */
1167 #else
1168 #  if defined(NeXT) && defined(__DYNAMIC__)
1169
1170 #  include <mach-o/dyld.h>
1171 EXT char *** environ_pointer;
1172 #  define environ (*environ_pointer)
1173 #  endif
1174 #endif /* environ processing */
1175
1176 EXT int         uid;            /* current real user id */
1177 EXT int         euid;           /* current effective user id */
1178 EXT int         gid;            /* current real group id */
1179 EXT int         egid;           /* current effective group id */
1180 EXT bool        nomemok;        /* let malloc context handle nomem */
1181 EXT U32         an;             /* malloc sequence number */
1182 EXT U32         cop_seqmax;     /* statement sequence number */
1183 EXT U16         op_seqmax;      /* op sequence number */
1184 EXT U32         evalseq;        /* eval sequence number */
1185 EXT U32         sub_generation; /* inc to force methods to be looked up again */
1186 EXT char **     origenviron;
1187 EXT U32         origalen;
1188 EXT U32 *       profiledata;
1189 EXT int         maxo INIT(MAXO);/* Number of ops */
1190 EXT char *      osname;         /* operating system */
1191
1192 EXT XPV*        xiv_arenaroot;  /* list of allocated xiv areas */
1193 EXT IV **       xiv_root;       /* free xiv list--shared by interpreters */
1194 EXT double *    xnv_root;       /* free xnv list--shared by interpreters */
1195 EXT XRV *       xrv_root;       /* free xrv list--shared by interpreters */
1196 EXT XPV *       xpv_root;       /* free xpv list--shared by interpreters */
1197 EXT HE *        he_root;        /* free he list--shared by interpreters */
1198 EXT char *      nice_chunk;     /* a nice chunk of memory to reuse */
1199 EXT U32         nice_chunk_size;/* how nice the chunk of memory is */
1200
1201 /* Stack for currently executing thread--context switch must handle this.     */
1202 EXT SV **       stack_base;     /* stack->array_ary */
1203 EXT SV **       stack_sp;       /* stack pointer now */
1204 EXT SV **       stack_max;      /* stack->array_ary + stack->array_max */
1205
1206 /* likewise for these */
1207
1208 EXT OP *        op;             /* current op--oughta be in a global register */
1209
1210 EXT I32 *       scopestack;     /* blocks we've entered */
1211 EXT I32         scopestack_ix;
1212 EXT I32         scopestack_max;
1213
1214 EXT ANY*        savestack;      /* to save non-local values on */
1215 EXT I32         savestack_ix;
1216 EXT I32         savestack_max;
1217
1218 EXT OP **       retstack;       /* returns we've pushed */
1219 EXT I32         retstack_ix;
1220 EXT I32         retstack_max;
1221
1222 EXT I32 *       markstack;      /* stackmarks we're remembering */
1223 EXT I32 *       markstack_ptr;  /* stackmarks we're remembering */
1224 EXT I32 *       markstack_max;  /* stackmarks we're remembering */
1225
1226 EXT SV **       curpad;
1227
1228 /* temp space */
1229 EXT SV *        Sv;
1230 EXT HE          He;
1231 EXT XPV *       Xpv;
1232 EXT char        buf[2048];      /* should be longer than PATH_MAX */
1233 EXT char        tokenbuf[256];
1234 EXT struct stat statbuf;
1235 #ifdef HAS_TIMES
1236 EXT struct tms  timesbuf;
1237 #endif
1238 EXT STRLEN na;          /* for use in SvPV when length is Not Applicable */
1239
1240 /* for tmp use in stupid debuggers */
1241 EXT int *       di;
1242 EXT short *     ds;
1243 EXT char *      dc;
1244
1245 /* handy constants */
1246 EXT char *      Yes INIT("1");
1247 EXT char *      No INIT("");
1248 EXT char *      hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
1249 EXT char *      patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
1250 EXT char *      vert INIT("|");
1251
1252 EXT char        warn_uninit[]
1253   INIT("Use of uninitialized value");
1254 EXT char        warn_nosemi[]
1255   INIT("Semicolon seems to be missing");
1256 EXT char        warn_reserved[]
1257   INIT("Unquoted string \"%s\" may clash with future reserved word");
1258 EXT char        warn_nl[]
1259   INIT("Unsuccessful %s on filename containing newline");
1260 EXT char        no_wrongref[]
1261   INIT("Can't use %s ref as %s ref");
1262 EXT char        no_symref[]
1263   INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
1264 EXT char        no_usym[]
1265   INIT("Can't use an undefined value as %s reference");
1266 EXT char        no_aelem[]
1267   INIT("Modification of non-creatable array value attempted, subscript %d");
1268 EXT char        no_helem[]
1269   INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
1270 EXT char        no_modify[]
1271   INIT("Modification of a read-only value attempted");
1272 EXT char        no_mem[]
1273   INIT("Out of memory!\n");
1274 EXT char        no_security[]
1275   INIT("Insecure dependency in %s%s");
1276 EXT char        no_sock_func[]
1277   INIT("Unsupported socket function \"%s\" called");
1278 EXT char        no_dir_func[]
1279   INIT("Unsupported directory function \"%s\" called");
1280 EXT char        no_func[]
1281   INIT("The %s function is unimplemented");
1282 EXT char        no_myglob[]
1283   INIT("\"my\" variable %s can't be in a package");
1284
1285 EXT SV          sv_undef;
1286 EXT SV          sv_no;
1287 EXT SV          sv_yes;
1288 #ifdef CSH
1289     EXT char *  cshname INIT(CSH);
1290     EXT I32     cshlen;
1291 #endif
1292
1293 #ifdef DOINIT
1294 EXT char *sig_name[] = { SIG_NAME };
1295 EXT int   sig_num[]  = { SIG_NUM };
1296 EXT SV  * psig_ptr[sizeof(sig_num)/sizeof(*sig_num)];
1297 EXT SV  * psig_name[sizeof(sig_num)/sizeof(*sig_num)];
1298 #else
1299 EXT char *sig_name[];
1300 EXT int   sig_num[];
1301 EXT SV  * psig_ptr[];
1302 EXT SV  * psig_name[];
1303 #endif
1304
1305 #ifdef DOINIT
1306 EXT 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
1341 EXT unsigned char fold[];
1342 #endif
1343
1344 #ifdef DOINIT
1345 EXT 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
1380 EXT unsigned char freq[];
1381 #endif
1382
1383 #ifdef DEBUGGING
1384 #ifdef DOINIT
1385 EXT char* block_type[] = {
1386         "NULL",
1387         "SUB",
1388         "EVAL",
1389         "LOOP",
1390         "SUBST",
1391         "BLOCK",
1392 };
1393 #else
1394 EXT char* block_type[];
1395 #endif
1396 #endif
1397
1398 /*****************************************************************************/
1399 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1400 /*****************************************************************************/
1401 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
1402
1403 #include "perly.h"
1404
1405 typedef enum {
1406     XOPERATOR,
1407     XTERM,
1408     XREF,
1409     XSTATE,
1410     XBLOCK,
1411     XTERMBLOCK
1412 } expectation;
1413
1414 EXT U32         lex_state;      /* next token is determined */
1415 EXT U32         lex_defer;      /* state after determined token */
1416 EXT expectation lex_expect;     /* expect after determined token */
1417 EXT I32         lex_brackets;   /* bracket count */
1418 EXT I32         lex_formbrack;  /* bracket count at outer format level */
1419 EXT I32         lex_fakebrack;  /* outer bracket is mere delimiter */
1420 EXT I32         lex_casemods;   /* casemod count */
1421 EXT I32         lex_dojoin;     /* doing an array interpolation */
1422 EXT I32         lex_starts;     /* how many interps done on level */
1423 EXT SV *        lex_stuff;      /* runtime pattern from m// or s/// */
1424 EXT SV *        lex_repl;       /* runtime replacement from s/// */
1425 EXT OP *        lex_op;         /* extra info to pass back on op */
1426 EXT OP *        lex_inpat;      /* in pattern $) and $| are special */
1427 EXT I32         lex_inwhat;     /* what kind of quoting are we in */
1428 EXT char *      lex_brackstack; /* what kind of brackets to pop */
1429 EXT char *      lex_casestack;  /* what kind of case mods in effect */
1430
1431 /* What we know when we're in LEX_KNOWNEXT state. */
1432 EXT YYSTYPE     nextval[5];     /* value of next token, if any */
1433 EXT I32         nexttype[5];    /* type of next token */
1434 EXT I32         nexttoke;
1435
1436 EXT PerlIO * VOL        rsfp INIT(Nullfp);
1437 EXT SV *        linestr;
1438 EXT char *      bufptr;
1439 EXT char *      oldbufptr;
1440 EXT char *      oldoldbufptr;
1441 EXT char *      bufend;
1442 EXT expectation expect INIT(XSTATE);    /* how to interpret ambiguous tokens */
1443 EXT AV *        rsfp_filters;
1444
1445 EXT I32         multi_start;    /* 1st line of multi-line string */
1446 EXT I32         multi_end;      /* last line of multi-line string */
1447 EXT I32         multi_open;     /* delimiter of said string */
1448 EXT I32         multi_close;    /* delimiter of said string */
1449
1450 EXT GV *        scrgv;
1451 EXT I32         error_count;    /* how many errors so far, max 10 */
1452 EXT I32         subline;        /* line this subroutine began on */
1453 EXT SV *        subname;        /* name of current subroutine */
1454
1455 EXT CV *        compcv;         /* currently compiling subroutine */
1456 EXT AV *        comppad;        /* storage for lexically scoped temporaries */
1457 EXT AV *        comppad_name;   /* variable names for "my" variables */
1458 EXT I32         comppad_name_fill;/* last "introduced" variable offset */
1459 EXT I32         comppad_name_floor;/* start of vars in innermost block */
1460 EXT I32         min_intro_pending;/* start of vars to introduce */
1461 EXT I32         max_intro_pending;/* end of vars to introduce */
1462 EXT I32         padix;          /* max used index in current "register" pad */
1463 EXT I32         padix_floor;    /* how low may inner block reset padix */
1464 EXT I32         pad_reset_pending; /* reset pad on next attempted alloc */
1465 EXT COP         compiling;
1466
1467 EXT I32         thisexpr;       /* name id for nothing_in_common() */
1468 EXT char *      last_uni;       /* position of last named-unary operator */
1469 EXT char *      last_lop;       /* position of last list operator */
1470 EXT OPCODE      last_lop_op;    /* last list operator */
1471 EXT bool        in_my;          /* we're compiling a "my" declaration */
1472 #ifdef FCRYPT
1473 EXT I32         cryptseen;      /* has fast crypt() been initialized? */
1474 #endif
1475
1476 EXT 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
1486 #define HINT_STRICT_UNTIE       0x00000800
1487
1488 /**************************************************************************/
1489 /* This regexp stuff is global since it always happens within 1 expr eval */
1490 /**************************************************************************/
1491
1492 EXT char *      regprecomp;     /* uncompiled string. */
1493 EXT char *      regparse;       /* Input-scan pointer. */
1494 EXT char *      regxend;        /* End of input for compile */
1495 EXT I32         regnpar;        /* () count. */
1496 EXT char *      regcode;        /* Code-emit pointer; &regdummy = don't. */
1497 EXT I32         regsize;        /* Code size. */
1498 EXT I32         regnaughty;     /* How bad is this pattern? */
1499 EXT I32         regsawback;     /* Did we see \1, ...? */
1500
1501 EXT char *      reginput;       /* String-input pointer. */
1502 EXT char *      regbol;         /* Beginning of input, for ^ check. */
1503 EXT char *      regeol;         /* End of input, for $ check. */
1504 EXT char **     regstartp;      /* Pointer to startp array. */
1505 EXT char **     regendp;        /* Ditto for endp. */
1506 EXT U32 *       reglastparen;   /* Similarly for lastparen. */
1507 EXT char *      regtill;        /* How far we are required to go. */
1508 EXT U16         regflags;       /* are we folding, multilining? */
1509 EXT char        regprev;        /* char before regbol, \n if none */
1510
1511 EXT bool        do_undump;      /* -u or dump seen? */
1512 EXT VOL U32     debug;
1513
1514 /***********************************************/
1515 /* Global only to current interpreter instance */
1516 /***********************************************/
1517
1518 #ifdef MULTIPLICITY
1519 #define IEXT
1520 #define IINIT(x)
1521 struct interpreter {
1522 #else
1523 #define IEXT EXT
1524 #define IINIT(x) INIT(x)
1525 #endif
1526
1527 /* pseudo environmental stuff */
1528 IEXT int        Iorigargc;
1529 IEXT char **    Iorigargv;
1530 IEXT GV *       Ienvgv;
1531 IEXT GV *       Isiggv;
1532 IEXT GV *       Iincgv;
1533 IEXT char *     Iorigfilename;
1534 IEXT SV *       Idiehook;
1535 IEXT SV *       Iwarnhook;
1536 IEXT SV *       Iparsehook;
1537
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
1543 /* switches */
1544 IEXT char *     Icddir;
1545 IEXT bool       Iminus_c;
1546 IEXT char       Ipatchlevel[10];
1547 IEXT char **    Ilocalpatches;
1548 IEXT SV *       Inrs;
1549 IEXT char *     Isplitstr IINIT(" ");
1550 IEXT bool       Ipreprocess;
1551 IEXT bool       Iminus_n;
1552 IEXT bool       Iminus_p;
1553 IEXT bool       Iminus_l;
1554 IEXT bool       Iminus_a;
1555 IEXT bool       Iminus_F;
1556 IEXT bool       Idoswitches;
1557 IEXT bool       Idowarn;
1558 IEXT bool       Idoextract;
1559 IEXT bool       Isawampersand;  /* must save all match strings */
1560 IEXT bool       Isawstudy;      /* do fbm_instr on all strings */
1561 IEXT bool       Isawi;          /* study must assume case insensitive */
1562 IEXT bool       Isawvec;
1563 IEXT bool       Iunsafe;
1564 IEXT char *     Iinplace;
1565 IEXT char *     Ie_tmpname;
1566 IEXT PerlIO *   Ie_fp;
1567 IEXT U32        Iperldb;
1568         /* This value may be raised by extensions for testing purposes */
1569 IEXT int        Iperl_destruct_level;   /* 0=none, 1=full, 2=full with checks */
1570
1571 /* magical thingies */
1572 IEXT Time_t     Ibasetime;              /* $^T */
1573 IEXT SV *       Iformfeed;              /* $^L */
1574 IEXT char *     Ichopset IINIT(" \n-"); /* $: */
1575 IEXT SV *       Irs;                    /* $/ */
1576 IEXT char *     Iofs;                   /* $, */
1577 IEXT STRLEN     Iofslen;
1578 IEXT char *     Iors;                   /* $\ */
1579 IEXT STRLEN     Iorslen;
1580 IEXT char *     Iofmt;                  /* $# */
1581 IEXT I32        Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1582 IEXT int        Imultiline;       /* $*--do strings hold >1 line? */
1583 IEXT U32        Istatusvalue;   /* $? */
1584
1585 IEXT struct stat Istatcache;            /* _ */
1586 IEXT GV *       Istatgv;
1587 IEXT SV *       Istatname IINIT(Nullsv);
1588
1589 /* shortcuts to various I/O objects */
1590 IEXT GV *       Istdingv;
1591 IEXT GV *       Ilast_in_gv;
1592 IEXT GV *       Idefgv;
1593 IEXT GV *       Iargvgv;
1594 IEXT GV *       Idefoutgv;
1595 IEXT GV *       Iargvoutgv;
1596
1597 /* shortcuts to regexp stuff */
1598 IEXT GV *       Ileftgv;
1599 IEXT GV *       Iampergv;
1600 IEXT GV *       Irightgv;
1601 IEXT PMOP *     Icurpm;         /* what to do \ interps from */
1602 IEXT I32 *      Iscreamfirst;
1603 IEXT I32 *      Iscreamnext;
1604 IEXT I32        Imaxscream IINIT(-1);
1605 IEXT SV *       Ilastscream;
1606
1607 /* shortcuts to misc objects */
1608 IEXT GV *       Ierrgv;
1609
1610 /* shortcuts to debugging objects */
1611 IEXT GV *       IDBgv;
1612 IEXT GV *       IDBline;
1613 IEXT GV *       IDBsub;
1614 IEXT SV *       IDBsingle;
1615 IEXT SV *       IDBtrace;
1616 IEXT SV *       IDBsignal;
1617 IEXT AV *       Ilineary;       /* lines of script for debugger */
1618 IEXT AV *       Idbargs;        /* args to call listed by caller function */
1619
1620 /* symbol tables */
1621 IEXT HV *       Idefstash;      /* main symbol table */
1622 IEXT HV *       Icurstash;      /* symbol table for current package */
1623 IEXT HV *       Idebstash;      /* symbol table for perldb package */
1624 IEXT SV *       Icurstname;     /* name of current package */
1625 IEXT AV *       Ibeginav;       /* names of BEGIN subroutines */
1626 IEXT AV *       Iendav;         /* names of END subroutines */
1627 IEXT HV *       Istrtab;        /* shared string table */
1628
1629 /* memory management */
1630 IEXT SV **      Itmps_stack;
1631 IEXT I32        Itmps_ix IINIT(-1);
1632 IEXT I32        Itmps_floor IINIT(-1);
1633 IEXT I32        Itmps_max;
1634 IEXT I32        Isv_count;      /* how many SV* are currently allocated */
1635 IEXT I32        Isv_objcount;   /* how many objects are currently allocated */
1636 IEXT SV*        Isv_root;       /* storage for SVs belonging to interp */
1637 IEXT SV*        Isv_arenaroot;  /* list of areas for garbage collection */
1638
1639 /* funky return mechanisms */
1640 IEXT I32        Ilastspbase;
1641 IEXT I32        Ilastsize;
1642 IEXT int        Iforkprocess;   /* so do_open |- can return proc# */
1643
1644 /* subprocess state */
1645 IEXT AV *       Ifdpid;         /* keep fd-to-pid mappings for my_popen */
1646 IEXT HV *       Ipidstatus;     /* keep pid-to-status mappings for waitpid */
1647
1648 /* internal state */
1649 IEXT VOL int    Iin_eval;       /* trap "fatal" errors? */
1650 IEXT OP *       Irestartop;     /* Are we propagating an error from croak? */
1651 IEXT int        Idelaymagic;    /* ($<,$>) = ... */
1652 IEXT bool       Idirty;         /* In the middle of tearing things down? */
1653 IEXT U8         Ilocalizing;    /* are we processing a local() list? */
1654 IEXT bool       Itainted;       /* using variables controlled by $< */
1655 IEXT bool       Itainting;      /* doing taint checks */
1656 IEXT char *     Iop_mask IINIT(NULL);   /* masked operations for safe evals */
1657
1658 /* trace state */
1659 IEXT I32        Idlevel;
1660 IEXT I32        Idlmax IINIT(128);
1661 IEXT char *     Idebname;
1662 IEXT char *     Idebdelim;
1663
1664 /* current interpreter roots */
1665 IEXT CV *       Imain_cv;
1666 IEXT OP *       Imain_root;
1667 IEXT OP *       Imain_start;
1668 IEXT OP *       Ieval_root;
1669 IEXT OP *       Ieval_start;
1670
1671 /* runtime control stuff */
1672 IEXT COP * VOL  Icurcop IINIT(&compiling);
1673 IEXT COP *      Icurcopdb IINIT(NULL);
1674 IEXT line_t     Icopline IINIT(NOLINE);
1675 IEXT CONTEXT *  Icxstack;
1676 IEXT I32        Icxstack_ix IINIT(-1);
1677 IEXT I32        Icxstack_max IINIT(128);
1678 IEXT Sigjmp_buf Itop_env;
1679 IEXT I32        Irunlevel;
1680
1681 /* stack stuff */
1682 IEXT AV *       Icurstack;              /* THE STACK */
1683 IEXT AV *       Imainstack;     /* the stack when nothing funny is happening */
1684 IEXT SV **      Imystack_base;  /* stack->array_ary */
1685 IEXT SV **      Imystack_sp;    /* stack pointer now */
1686 IEXT SV **      Imystack_max;   /* stack->array_ary + stack->array_max */
1687
1688 /* format accumulators */
1689 IEXT SV *       Iformtarget;
1690 IEXT SV *       Ibodytarget;
1691 IEXT SV *       Itoptarget;
1692
1693 /* statics moved here for shared library purposes */
1694 IEXT SV         Istrchop;       /* return value from chop */
1695 IEXT int        Ifilemode;      /* so nextargv() can preserve mode */
1696 IEXT int        Ilastfd;        /* what to preserve mode on */
1697 IEXT char *     Ioldname;       /* what to preserve mode on */
1698 IEXT char **    IArgv;          /* stuff to free from do_aexec, vfork safe */
1699 IEXT char *     ICmd;           /* stuff to free from do_aexec, vfork safe */
1700 IEXT OP *       Isortcop;       /* user defined sort routine */
1701 IEXT HV *       Isortstash;     /* which is in some package or other */
1702 IEXT GV *       Ifirstgv;       /* $a */
1703 IEXT GV *       Isecondgv;      /* $b */
1704 IEXT AV *       Isortstack;     /* temp stack during pp_sort() */
1705 IEXT AV *       Isignalstack;   /* temp stack during sighandler() */
1706 IEXT SV *       Imystrk;        /* temp key string for do_each() */
1707 IEXT I32        Idumplvl;       /* indentation level on syntax tree dump */
1708 IEXT PMOP *     Ioldlastpm;     /* for saving regexp context during debugger */
1709 IEXT I32        Igensym;        /* next symbol for getsym() to define */
1710 IEXT bool       Ipreambled;
1711 IEXT AV *       Ipreambleav;
1712 IEXT int        Ilaststatval IINIT(-1);
1713 IEXT I32        Ilaststype IINIT(OP_STAT);
1714
1715 #undef IEXT
1716 #undef IINIT
1717
1718 #ifdef MULTIPLICITY
1719 };
1720 #else
1721 struct interpreter {
1722     char broiled;
1723 };
1724 #endif
1725
1726 #include "pp.h"
1727
1728 #ifdef __cplusplus
1729 extern "C" {
1730 #endif
1731
1732 #include "proto.h"
1733
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
1742 #ifdef __cplusplus
1743 };
1744 #endif
1745
1746 /* The following must follow proto.h */
1747
1748 #ifdef DOINIT
1749 EXT MGVTBL vtbl_sv =    {magic_get,
1750                                 magic_set,
1751                                         magic_len,
1752                                                 0,      0};
1753 EXT MGVTBL vtbl_env =   {0,     0,      0,      0,      0};
1754 EXT MGVTBL vtbl_envelem =       {0,     magic_setenv,
1755                                         0,      magic_clearenv,
1756                                                         0};
1757 EXT MGVTBL vtbl_sig =   {0,     0,               0, 0, 0};
1758 EXT MGVTBL vtbl_sigelem =       {magic_getsig,
1759                                         magic_setsig,
1760                                         0,      magic_clearsig,
1761                                                         0};
1762 EXT MGVTBL vtbl_pack =  {0,     0,      0,      magic_wipepack,
1763                                                         0};
1764 EXT MGVTBL vtbl_packelem =      {magic_getpack,
1765                                 magic_setpack,
1766                                         0,      magic_clearpack,
1767                                                         0};
1768 EXT MGVTBL vtbl_dbline =        {0,     magic_setdbline,
1769                                         0,      0,      0};
1770 EXT MGVTBL vtbl_isa =   {0,     magic_setisa,
1771                                         0,      0,      0};
1772 EXT MGVTBL vtbl_isaelem =       {0,     magic_setisa,
1773                                         0,      0,      0};
1774 EXT MGVTBL vtbl_arylen =        {magic_getarylen,
1775                                 magic_setarylen,
1776                                         0,      0,      0};
1777 EXT MGVTBL vtbl_glob =  {magic_getglob,
1778                                 magic_setglob,
1779                                         0,      0,      0};
1780 EXT MGVTBL vtbl_mglob = {0,     magic_setmglob,
1781                                         0,      0,      0};
1782 EXT MGVTBL vtbl_nkeys = {0,     magic_setnkeys,
1783                                         0,      0,      0};
1784 EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1785                                         0,      0,      0};
1786 EXT MGVTBL vtbl_substr =        {0,     magic_setsubstr,
1787                                         0,      0,      0};
1788 EXT MGVTBL vtbl_vec =   {0,     magic_setvec,
1789                                         0,      0,      0};
1790 EXT MGVTBL vtbl_pos =   {magic_getpos,
1791                                 magic_setpos,
1792                                         0,      0,      0};
1793 EXT MGVTBL vtbl_bm =    {0,     magic_setbm,
1794                                         0,      0,      0};
1795 EXT MGVTBL vtbl_uvar =  {magic_getuvar,
1796                                 magic_setuvar,
1797                                         0,      0,      0};
1798
1799 #ifdef OVERLOAD
1800 EXT MGVTBL vtbl_amagic =       {0,     magic_setamagic,
1801                                         0,      0,      magic_setamagic};
1802 EXT MGVTBL vtbl_amagicelem =   {0,     magic_setamagic,
1803                                         0,      0,      magic_setamagic};
1804 #endif /* OVERLOAD */
1805
1806 #else
1807 EXT MGVTBL vtbl_sv;
1808 EXT MGVTBL vtbl_env;
1809 EXT MGVTBL vtbl_envelem;
1810 EXT MGVTBL vtbl_sig;
1811 EXT MGVTBL vtbl_sigelem;
1812 EXT MGVTBL vtbl_pack;
1813 EXT MGVTBL vtbl_packelem;
1814 EXT MGVTBL vtbl_dbline;
1815 EXT MGVTBL vtbl_isa;
1816 EXT MGVTBL vtbl_isaelem;
1817 EXT MGVTBL vtbl_arylen;
1818 EXT MGVTBL vtbl_glob;
1819 EXT MGVTBL vtbl_mglob;
1820 EXT MGVTBL vtbl_nkeys;
1821 EXT MGVTBL vtbl_taint;
1822 EXT MGVTBL vtbl_substr;
1823 EXT MGVTBL vtbl_vec;
1824 EXT MGVTBL vtbl_pos;
1825 EXT MGVTBL vtbl_bm;
1826 EXT MGVTBL vtbl_uvar;
1827
1828 #ifdef OVERLOAD
1829 EXT MGVTBL vtbl_amagic;
1830 EXT MGVTBL vtbl_amagicelem;
1831 #endif /* OVERLOAD */
1832
1833 #endif
1834
1835 #ifdef OVERLOAD
1836 EXT long amagic_generation;
1837
1838 #define NofAMmeth 29
1839 #ifdef DOINIT
1840 EXT char * AMG_names[NofAMmeth][2] = {
1841   {"fallback","abs"},
1842   {"bool", "nomethod"},
1843   {"\"\"", "0+"},
1844   {"+","+="},
1845   {"-","-="},
1846   {"*", "*="},
1847   {"/", "/="},
1848   {"%", "%="},
1849   {"**", "**="},
1850   {"<<", "<<="},
1851   {">>", ">>="},
1852   {"&", "&="},
1853   {"|", "|="},
1854   {"^", "^="},
1855   {"<", "<="},
1856   {">", ">="},
1857   {"==", "!="},
1858   {"<=>", "cmp"},
1859   {"lt", "le"},
1860   {"gt", "ge"},
1861   {"eq", "ne"},
1862   {"!", "~"},
1863   {"++", "--"},
1864   {"atan2", "cos"},
1865   {"sin", "exp"},
1866   {"log", "sqrt"},
1867   {"x","x="},
1868   {".",".="},
1869   {"=","neg"}
1870 };
1871 #else
1872 EXT char * AMG_names[NofAMmeth][2];
1873 #endif /* def INITAMAGIC */
1874
1875 struct  am_table        {
1876   long was_ok_sub;
1877   long was_ok_am;
1878   CV* table[NofAMmeth*2];
1879   long fallback;
1880 };
1881 typedef struct am_table AMT;
1882
1883 #define AMGfallNEVER    1
1884 #define AMGfallNO       2
1885 #define AMGfallYES      3
1886
1887 enum {
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,
1899   band_amg,     band_ass_amg,
1900   bor_amg,      bor_ass_amg,
1901   bxor_amg,     bxor_ass_amg,
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,
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,
1915   concat_amg,   concat_ass_amg,
1916   copy_amg,     neg_amg
1917 };
1918 #endif /* OVERLOAD */
1919
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
1928 #endif /* Include guard */
1929