d37851c5b54cc81f27fcddacda653972473581d4
[p5sagit/p5-mst-13.2.git] / perl.h
1 /*    perl.h
2  *
3  *    Copyright (c) 1987-2001, 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
12 #ifdef PERL_FOR_X2P
13 /*
14  * This file is being used for x2p stuff.
15  * Above symbol is defined via -D in 'x2p/Makefile.SH'
16  * Decouple x2p stuff from some of perls more extreme eccentricities.
17  */
18 #undef MULTIPLICITY
19 #undef USE_STDIO
20 #define USE_STDIO
21 #endif /* PERL_FOR_X2P */
22
23 #define VOIDUSED 1
24 #ifdef PERL_MICRO
25 #   include "uconfig.h"
26 #else
27 #   include "config.h"
28 #endif
29
30 #if defined(USE_ITHREADS) && defined(USE_5005THREADS)
31 #  include "error: USE_ITHREADS and USE_5005THREADS are incompatible"
32 #endif
33
34 /* XXX This next guard can disappear if the sources are revised
35    to use USE_5005THREADS throughout. -- A.D  1/6/2000
36 */
37 #if defined(USE_ITHREADS) && defined(USE_5005THREADS)
38 #  include "error: USE_ITHREADS and USE_5005THREADS are incompatible"
39 #endif
40
41 /* See L<perlguts/"The Perl API"> for detailed notes on
42  * PERL_IMPLICIT_CONTEXT and PERL_IMPLICIT_SYS */
43
44 #ifdef USE_ITHREADS
45 #  if !defined(MULTIPLICITY)
46 #    define MULTIPLICITY
47 #  endif
48 #endif
49
50 #ifdef USE_5005THREADS
51 #  ifndef PERL_IMPLICIT_CONTEXT
52 #    define PERL_IMPLICIT_CONTEXT
53 #  endif
54 #endif
55
56 #if defined(MULTIPLICITY)
57 #  ifndef PERL_IMPLICIT_CONTEXT
58 #    define PERL_IMPLICIT_CONTEXT
59 #  endif
60 #endif
61
62 #ifdef PERL_IMPLICIT_CONTEXT
63 #  ifdef USE_5005THREADS
64 struct perl_thread;
65 #    define pTHX        register struct perl_thread *thr PERL_UNUSED_DECL
66 #    define aTHX        thr
67 #    define dTHR        dNOOP /* only backward compatibility */
68 #    define dTHXa(a)    pTHX = (struct perl_thread*)a
69 #  else
70 #    ifndef MULTIPLICITY
71 #      define MULTIPLICITY
72 #    endif
73 #    define pTHX        register PerlInterpreter *my_perl PERL_UNUSED_DECL
74 #    define aTHX        my_perl
75 #    define dTHXa(a)    pTHX = (PerlInterpreter*)a
76 #  endif
77 #  define dTHX          pTHX = PERL_GET_THX
78 #  define pTHX_         pTHX,
79 #  define aTHX_         aTHX,
80 #  define pTHX_1        2       
81 #  define pTHX_2        3
82 #  define pTHX_3        4
83 #  define pTHX_4        5
84 #endif
85
86 #define STATIC static
87 #define CPERLscope(x) x
88 #define CPERLarg void
89 #define CPERLarg_
90 #define _CPERLarg
91 #define PERL_OBJECT_THIS
92 #define _PERL_OBJECT_THIS
93 #define PERL_OBJECT_THIS_
94 #define CALL_FPTR(fptr) (*fptr)
95
96 #define CALLRUNOPS  CALL_FPTR(PL_runops)
97 #define CALLREGCOMP CALL_FPTR(PL_regcompp)
98 #define CALLREGEXEC CALL_FPTR(PL_regexecp)
99 #define CALLREG_INTUIT_START CALL_FPTR(PL_regint_start)
100 #define CALLREG_INTUIT_STRING CALL_FPTR(PL_regint_string)
101 #define CALLREGFREE CALL_FPTR(PL_regfree)
102
103 #ifdef PERL_FLEXIBLE_EXCEPTIONS
104 #  define CALLPROTECT CALL_FPTR(PL_protect)
105 #endif
106
107 #ifdef HASATTRIBUTE
108 #  define PERL_UNUSED_DECL __attribute__((unused))
109 #else
110 #  define PERL_UNUSED_DECL
111 #endif
112
113 /* gcc -Wall:
114  * for silencing unused variables that are actually used most of the time,
115  * but we cannot quite get rid of, such `ax' in PPCODE+noargs xsubs
116  */
117 #define PERL_UNUSED_VAR(var) if (0) var = var
118
119 #define NOOP (void)0
120 #define dNOOP extern int Perl___notused PERL_UNUSED_DECL
121
122 #ifndef pTHX
123 #  define pTHX          void
124 #  define pTHX_
125 #  define aTHX
126 #  define aTHX_
127 #  define dTHXa(a)      dNOOP
128 #  define dTHX          dNOOP
129 #  define pTHX_1        1       
130 #  define pTHX_2        2
131 #  define pTHX_3        3
132 #  define pTHX_4        4
133 #endif
134
135 /* these are only defined for compatibility; should not be used internally */
136 #if !defined(pTHXo) && !defined(PERL_CORE)
137 #  define pTHXo         pTHX
138 #  define pTHXo_        pTHX_
139 #  define aTHXo         aTHX
140 #  define aTHXo_        aTHX_
141 #  define dTHXo         dTHX
142 #  define dTHXoa(x)     dTHXa(x)
143 #endif
144
145 #ifndef pTHXx
146 #  define pTHXx         register PerlInterpreter *my_perl
147 #  define pTHXx_        pTHXx,
148 #  define aTHXx         my_perl
149 #  define aTHXx_        aTHXx,
150 #  define dTHXx         dTHX
151 #endif
152
153 /* Under PERL_IMPLICIT_SYS (used in Windows for fork emulation)
154  * PerlIO_foo() expands to PL_StdIO->pFOO(PL_StdIO, ...).
155  * dTHXs is therefore needed for all functions using PerlIO_foo(). */
156 #ifdef PERL_IMPLICIT_SYS
157 #  define dTHXs         dTHX
158 #else
159 #  define dTHXs         dNOOP
160 #endif
161
162 #undef START_EXTERN_C
163 #undef END_EXTERN_C
164 #undef EXTERN_C
165 #ifdef __cplusplus
166 #  define START_EXTERN_C extern "C" {
167 #  define END_EXTERN_C }
168 #  define EXTERN_C extern "C"
169 #else
170 #  define START_EXTERN_C
171 #  define END_EXTERN_C
172 #  define EXTERN_C extern
173 #endif
174
175 #ifdef OP_IN_REGISTER
176 #  ifdef __GNUC__
177 #    define stringify_immed(s) #s
178 #    define stringify(s) stringify_immed(s)
179 register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
180 #  endif
181 #endif
182
183 /*
184  * STMT_START { statements; } STMT_END;
185  * can be used as a single statement, as in
186  * if (x) STMT_START { ... } STMT_END; else ...
187  *
188  * Trying to select a version that gives no warnings...
189  */
190 #if !(defined(STMT_START) && defined(STMT_END))
191 # if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(__cplusplus)
192 #   define STMT_START   (void)( /* gcc supports ``({ STATEMENTS; })'' */
193 #   define STMT_END     )
194 # else
195    /* Now which other defined()s do we need here ??? */
196 #  if (VOIDFLAGS) && (defined(sun) || defined(__sun__))
197 #   define STMT_START   if (1)
198 #   define STMT_END     else (void)0
199 #  else
200 #   define STMT_START   do
201 #   define STMT_END     while (0)
202 #  endif
203 # endif
204 #endif
205
206 #define WITH_THX(s) STMT_START { dTHX; s; } STMT_END
207 #define WITH_THR(s) WITH_THX(s)
208
209 /*
210  * SOFT_CAST can be used for args to prototyped functions to retain some
211  * type checking; it only casts if the compiler does not know prototypes.
212  */
213 #if defined(CAN_PROTOTYPE) && defined(DEBUGGING_COMPILE)
214 #define SOFT_CAST(type) 
215 #else
216 #define SOFT_CAST(type) (type)
217 #endif
218
219 #ifndef BYTEORDER  /* Should never happen -- byteorder is in config.h */
220 #   define BYTEORDER 0x1234
221 #endif
222
223 /* Overall memory policy? */
224 #ifndef CONSERVATIVE
225 #   define LIBERAL 1
226 #endif
227
228 #if 'A' == 65 && 'I' == 73 && 'J' == 74 && 'Z' == 90
229 #define ASCIIish
230 #else
231 #undef  ASCIIish
232 #endif
233
234 /*
235  * The following contortions are brought to you on behalf of all the
236  * standards, semi-standards, de facto standards, not-so-de-facto standards
237  * of the world, as well as all the other botches anyone ever thought of.
238  * The basic theory is that if we work hard enough here, the rest of the
239  * code can be a lot prettier.  Well, so much for theory.  Sorry, Henry...
240  */
241
242 /* define this once if either system, instead of cluttering up the src */
243 #if defined(MSDOS) || defined(atarist) || defined(WIN32) || defined(NETWARE)
244 #define DOSISH 1
245 #endif
246
247 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus) || defined( EPOC) || defined(NETWARE)
248 # define STANDARD_C 1
249 #endif
250
251 #if defined(__cplusplus) || defined(WIN32) || defined(__sgi) || defined(OS2) || defined(__DGUX) || defined( EPOC) || defined(__QNX__) || defined(NETWARE)
252 # define DONT_DECLARE_STD 1
253 #endif
254
255 #if defined(HASVOLATILE) || defined(STANDARD_C)
256 #   ifdef __cplusplus
257 #       define VOL              // to temporarily suppress warnings
258 #   else
259 #       define VOL volatile
260 #   endif
261 #else
262 #   define VOL
263 #endif
264
265 #define TAINT           (PL_tainted = TRUE)
266 #define TAINT_NOT       (PL_tainted = FALSE)
267 #define TAINT_IF(c)     if (c) { PL_tainted = TRUE; }
268 #define TAINT_ENV()     if (PL_tainting) { taint_env(); }
269 #define TAINT_PROPER(s) if (PL_tainting) { taint_proper(Nullch, s); }
270
271 /* XXX All process group stuff is handled in pp_sys.c.  Should these
272    defines move there?  If so, I could simplify this a lot. --AD  9/96.
273 */
274 /* Process group stuff changed from traditional BSD to POSIX.
275    perlfunc.pod documents the traditional BSD-style syntax, so we'll
276    try to preserve that, if possible.
277 */
278 #ifdef HAS_SETPGID
279 #  define BSD_SETPGRP(pid, pgrp)        setpgid((pid), (pgrp))
280 #else
281 #  if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
282 #    define BSD_SETPGRP(pid, pgrp)      setpgrp((pid), (pgrp))
283 #  else
284 #    ifdef HAS_SETPGRP2  /* DG/UX */
285 #      define BSD_SETPGRP(pid, pgrp)    setpgrp2((pid), (pgrp))
286 #    endif
287 #  endif
288 #endif
289 #if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
290 #  define HAS_SETPGRP  /* Well, effectively it does . . . */
291 #endif
292
293 /* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
294     our life easier :-) so we'll try it.
295 */
296 #ifdef HAS_GETPGID
297 #  define BSD_GETPGRP(pid)              getpgid((pid))
298 #else
299 #  if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
300 #    define BSD_GETPGRP(pid)            getpgrp((pid))
301 #  else
302 #    ifdef HAS_GETPGRP2  /* DG/UX */
303 #      define BSD_GETPGRP(pid)          getpgrp2((pid))
304 #    endif
305 #  endif
306 #endif
307 #if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
308 #  define HAS_GETPGRP  /* Well, effectively it does . . . */
309 #endif
310
311 /* These are not exact synonyms, since setpgrp() and getpgrp() may
312    have different behaviors, but perl.h used to define USE_BSDPGRP
313    (prior to 5.003_05) so some extension might depend on it.
314 */
315 #if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
316 #  ifndef USE_BSDPGRP
317 #    define USE_BSDPGRP
318 #  endif
319 #endif
320
321 /* Use the reentrant APIs like localtime_r and getpwent_r */
322 /* Win32 has naturally threadsafe libraries, no need to use any _r variants. */
323 #if defined(USE_ITHREADS) && !defined(USE_REENTRANT_API) && !defined(WIN32)
324 #   define USE_REENTRANT_API
325 #endif
326
327 /* HP-UX 10.X CMA (Common Multithreaded Architecure) insists that
328    pthread.h must be included before all other header files.
329 */
330 #if (defined(USE_5005THREADS) || defined(USE_ITHREADS)) \
331     && defined(PTHREAD_H_FIRST) && defined(I_PTHREAD)
332 #  include <pthread.h>
333 #endif
334
335 #ifndef _TYPES_         /* If types.h defines this it's easy. */
336 #   ifndef major                /* Does everyone's types.h define this? */
337 #       include <sys/types.h>
338 #   endif
339 #endif
340
341 #ifdef __cplusplus
342 #  ifndef I_STDARG
343 #    define I_STDARG 1
344 #  endif
345 #endif
346
347 #ifdef I_STDARG
348 #  include <stdarg.h>
349 #else
350 #  ifdef I_VARARGS
351 #    include <varargs.h>
352 #  endif
353 #endif
354
355 #ifdef USE_NEXT_CTYPE
356
357 #if NX_CURRENT_COMPILER_RELEASE >= 500
358 #  include <bsd/ctypes.h>
359 #else
360 #  if NX_CURRENT_COMPILER_RELEASE >= 400
361 #    include <objc/NXCType.h>
362 #  else /*  NX_CURRENT_COMPILER_RELEASE < 400 */
363 #    include <appkit/NXCType.h>
364 #  endif /*  NX_CURRENT_COMPILER_RELEASE >= 400 */
365 #endif /*  NX_CURRENT_COMPILER_RELEASE >= 500 */
366
367 #else /* !USE_NEXT_CTYPE */
368 #include <ctype.h>
369 #endif /* USE_NEXT_CTYPE */
370
371 #ifdef METHOD   /* Defined by OSF/1 v3.0 by ctype.h */
372 #undef METHOD
373 #endif
374
375 #ifdef PERL_MICRO
376 #   define NO_LOCALE
377 #endif
378
379 #ifdef I_LOCALE
380 #   include <locale.h>
381 #endif
382
383 #if !defined(NO_LOCALE) && defined(HAS_SETLOCALE)
384 #   define USE_LOCALE
385 #   if !defined(NO_LOCALE_COLLATE) && defined(LC_COLLATE) \
386        && defined(HAS_STRXFRM)
387 #       define USE_LOCALE_COLLATE
388 #   endif
389 #   if !defined(NO_LOCALE_CTYPE) && defined(LC_CTYPE)
390 #       define USE_LOCALE_CTYPE
391 #   endif
392 #   if !defined(NO_LOCALE_NUMERIC) && defined(LC_NUMERIC)
393 #       define USE_LOCALE_NUMERIC
394 #   endif
395 #endif /* !NO_LOCALE && HAS_SETLOCALE */
396
397 #include <setjmp.h>
398
399 #ifdef I_SYS_PARAM
400 #   ifdef PARAM_NEEDS_TYPES
401 #       include <sys/types.h>
402 #   endif
403 #   include <sys/param.h>
404 #endif
405
406 /* Use all the "standard" definitions? */
407 #if defined(STANDARD_C) && defined(I_STDLIB)
408 #   include <stdlib.h>
409 #endif
410
411 /* If this causes problems, set i_unistd=undef in the hint file.  */
412 #ifdef I_UNISTD
413 #   include <unistd.h>
414 #endif
415
416 #if defined(HAS_SYSCALL) && !defined(HAS_SYSCALL_PROTO)
417 int syscall(int, ...);
418 #endif
419
420 #if defined(HAS_USLEEP) && !defined(HAS_USLEEP_PROTO)
421 int usleep(unsigned int);
422 #endif
423
424 #ifdef PERL_MICRO /* Last chance to export Perl_my_swap */
425 #  define MYSWAP
426 #endif
427
428 #if !defined(PERL_FOR_X2P) && !defined(WIN32)
429 #  include "embed.h"
430 #endif
431
432 #define MEM_SIZE Size_t
433
434 #if defined(STANDARD_C) && defined(I_STDDEF)
435 #   include <stddef.h>
436 #   define STRUCT_OFFSET(s,m)  offsetof(s,m)
437 #else
438 #   define STRUCT_OFFSET(s,m)  (Size_t)(&(((s *)0)->m))
439 #endif
440
441 #if defined(I_STRING) || defined(__cplusplus)
442 #   include <string.h>
443 #else
444 #   include <strings.h>
445 #endif
446
447 /* This comes after <stdlib.h> so we don't try to change the standard
448  * library prototypes; we'll use our own in proto.h instead. */
449
450 #ifdef MYMALLOC
451 #  ifdef PERL_POLLUTE_MALLOC
452 #   ifndef PERL_EXTMALLOC_DEF
453 #    define Perl_malloc         malloc
454 #    define Perl_calloc         calloc
455 #    define Perl_realloc        realloc
456 #    define Perl_mfree          free
457 #   endif
458 #  else
459 #    define EMBEDMYMALLOC       /* for compatibility */
460 #  endif
461 Malloc_t Perl_malloc (MEM_SIZE nbytes);
462 Malloc_t Perl_calloc (MEM_SIZE elements, MEM_SIZE size);
463 Malloc_t Perl_realloc (Malloc_t where, MEM_SIZE nbytes);
464 /* 'mfree' rather than 'free', since there is already a 'perl_free'
465  * that causes clashes with case-insensitive linkers */
466 Free_t   Perl_mfree (Malloc_t where);
467
468 typedef struct perl_mstats perl_mstats_t;
469
470 #  define safemalloc  Perl_malloc
471 #  define safecalloc  Perl_calloc
472 #  define saferealloc Perl_realloc
473 #  define safefree    Perl_mfree
474 #else  /* MYMALLOC */
475 #  define safemalloc  safesysmalloc
476 #  define safecalloc  safesyscalloc
477 #  define saferealloc safesysrealloc
478 #  define safefree    safesysfree
479 #endif /* MYMALLOC */
480
481 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
482 #define strchr index
483 #define strrchr rindex
484 #endif
485
486 #ifdef I_MEMORY
487 #  include <memory.h>
488 #endif
489
490 #ifdef HAS_MEMCPY
491 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
492 #    ifndef memcpy
493         extern char * memcpy (char*, char*, int);
494 #    endif
495 #  endif
496 #else
497 #   ifndef memcpy
498 #       ifdef HAS_BCOPY
499 #           define memcpy(d,s,l) bcopy(s,d,l)
500 #       else
501 #           define memcpy(d,s,l) my_bcopy(s,d,l)
502 #       endif
503 #   endif
504 #endif /* HAS_MEMCPY */
505
506 #ifdef HAS_MEMSET
507 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
508 #    ifndef memset
509         extern char *memset (char*, int, int);
510 #    endif
511 #  endif
512 #else
513 #  undef  memset
514 #  define memset(d,c,l) my_memset(d,c,l)
515 #endif /* HAS_MEMSET */
516
517 #if !defined(HAS_MEMMOVE) && !defined(memmove)
518 #   if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
519 #       define memmove(d,s,l) bcopy(s,d,l)
520 #   else
521 #       if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
522 #           define memmove(d,s,l) memcpy(d,s,l)
523 #       else
524 #           define memmove(d,s,l) my_bcopy(s,d,l)
525 #       endif
526 #   endif
527 #endif
528
529 #if defined(mips) && defined(ultrix) && !defined(__STDC__)
530 #   undef HAS_MEMCMP
531 #endif
532
533 #if defined(HAS_MEMCMP) && defined(HAS_SANE_MEMCMP)
534 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
535 #    ifndef memcmp
536         extern int memcmp (char*, char*, int);
537 #    endif
538 #  endif
539 #  ifdef BUGGY_MSC
540   #  pragma function(memcmp)
541 #  endif
542 #else
543 #   ifndef memcmp
544 #       define memcmp   my_memcmp
545 #   endif
546 #endif /* HAS_MEMCMP && HAS_SANE_MEMCMP */
547
548 #ifndef memzero
549 #   ifdef HAS_MEMSET
550 #       define memzero(d,l) memset(d,0,l)
551 #   else
552 #       ifdef HAS_BZERO
553 #           define memzero(d,l) bzero(d,l)
554 #       else
555 #           define memzero(d,l) my_bzero(d,l)
556 #       endif
557 #   endif
558 #endif
559
560 #ifndef memchr
561 #   ifndef HAS_MEMCHR
562 #       define memchr(s,c,n) ninstr((char*)(s), ((char*)(s)) + n, &(c), &(c) + 1)
563 #   endif
564 #endif
565
566 #ifndef HAS_BCMP
567 #   ifndef bcmp
568 #       define bcmp(s1,s2,l) memcmp(s1,s2,l)
569 #   endif
570 #endif /* !HAS_BCMP */
571
572 #ifdef I_NETINET_IN
573 #   include <netinet/in.h>
574 #endif
575
576 #ifdef I_ARPA_INET
577 #   include <arpa/inet.h>
578 #endif
579
580 #if defined(SF_APPEND) && defined(USE_SFIO) && defined(I_SFIO)
581 /* <sfio.h> defines SF_APPEND and <sys/stat.h> might define SF_APPEND
582  * (the neo-BSD seem to do this).  */
583 #   undef SF_APPEND
584 #endif
585
586 #ifdef I_SYS_STAT
587 #   include <sys/stat.h>
588 #endif
589
590 /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
591    like UTekV) are broken, sometimes giving false positives.  Undefine
592    them here and let the code below set them to proper values.
593
594    The ghs macro stands for GreenHills Software C-1.8.5 which
595    is the C compiler for sysV88 and the various derivatives.
596    This header file bug is corrected in gcc-2.5.8 and later versions.
597    --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94.  */
598
599 #if defined(uts) || (defined(m88k) && defined(ghs))
600 #   undef S_ISDIR
601 #   undef S_ISCHR
602 #   undef S_ISBLK
603 #   undef S_ISREG
604 #   undef S_ISFIFO
605 #   undef S_ISLNK
606 #endif
607
608 #ifdef I_TIME
609 #   include <time.h>
610 #endif
611
612 #ifdef I_SYS_TIME
613 #   ifdef I_SYS_TIME_KERNEL
614 #       define KERNEL
615 #   endif
616 #   include <sys/time.h>
617 #   ifdef I_SYS_TIME_KERNEL
618 #       undef KERNEL
619 #   endif
620 #endif
621
622 #if defined(HAS_TIMES) && defined(I_SYS_TIMES)
623 #    include <sys/times.h>
624 #endif
625
626 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
627 #   undef HAS_STRERROR
628 #endif
629
630 #include <errno.h>
631
632 #if defined(WIN32) && defined(PERL_IMPLICIT_SYS)
633 #  define WIN32SCK_IS_STDSCK            /* don't pull in custom wsock layer */
634 #endif
635
636 /* In Tru64 use the 4.4BSD struct msghdr, not the 4.3 one */
637 #if defined(__osf__) && defined(__alpha) && !defined(_SOCKADDR_LEN)
638 #  define _SOCKADDR_LEN
639 #endif
640
641 #if defined(HAS_SOCKET) && !defined(VMS) && !defined(WIN32) /* VMS/WIN32 handle sockets via vmsish.h/win32.h */
642 # include <sys/socket.h>
643 # if defined(USE_SOCKS) && defined(I_SOCKS)
644 #   if !defined(INCLUDE_PROTOTYPES)
645 #       define INCLUDE_PROTOTYPES /* for <socks.h> */
646 #       define PERL_SOCKS_NEED_PROTOTYPES
647 #   endif
648 #   ifdef USE_5005THREADS
649 #       define PERL_USE_THREADS /* store our value */
650 #       undef USE_5005THREADS
651 #   endif
652 #   include <socks.h>
653 #   ifdef USE_5005THREADS
654 #       undef USE_5005THREADS /* socks.h does this on its own */
655 #   endif
656 #   ifdef PERL_USE_THREADS
657 #       define USE_5005THREADS /* restore our value */
658 #       undef PERL_USE_THREADS
659 #   endif
660 #   ifdef PERL_SOCKS_NEED_PROTOTYPES /* keep cpp space clean */
661 #       undef INCLUDE_PROTOTYPES
662 #       undef PERL_SOCKS_NEED_PROTOTYPES
663 #   endif
664 # endif
665 # ifdef I_NETDB
666 #  ifdef NETWARE
667 #   include<stdio.h>
668 #  endif
669 #  include <netdb.h>
670 # endif
671 # ifndef ENOTSOCK
672 #  ifdef I_NET_ERRNO
673 #   include <net/errno.h>
674 #  endif
675 # endif
676 #endif
677
678 /* sockatmark() is so new (2001) that many places might have it hidden
679  * behind some -D_BLAH_BLAH_SOURCE guard. */
680 #if defined(HAS_SOCKATMARK) && !defined(HAS_SOCKATMARK_PROTO)
681 int sockatmark(int);
682 #endif
683
684 #ifdef SETERRNO
685 # undef SETERRNO  /* SOCKS might have defined this */
686 #endif
687
688 #ifdef VMS
689 #   define SETERRNO(errcode,vmserrcode) \
690         STMT_START {                    \
691             set_errno(errcode);         \
692             set_vaxc_errno(vmserrcode); \
693         } STMT_END
694 #else
695 #   define SETERRNO(errcode,vmserrcode) (errno = (errcode))
696 #endif
697
698 /* These definitions are sneaky.
699  * Their only purpose is to avoid warnings on strict ANSI (non-VMS)
700  * compilers which can get huffy about dollars in identifiers,
701  * which is common practise in VMS.  The definitions in the
702  * non-VMS branch are not used (since the VMS error code is
703  * unsurprisingly not of much use in non-VMS) -- but their only
704  * point is to be something non-dollared.  Neither are all instances
705  * of dollared variables hidden this way, only at the spots where
706  * non-VMS platforms see them. */
707 #ifdef VMS
708 #define VMS_LIB_INVARGV LIB$_INVARG
709 #define VMS_RMS_DIR     RMS$_DIR
710 #define VMS_RMS_FAC     RMS$_FAC
711 #define VMS_RMS_IFI     RMS$_IFI
712 #define VMS_RMS_ISI     RMS$_ISI
713 #define VMS_SS_ACCVIO   SS$_ACCVIO
714 #define VMS_SS_IVCHAN   SS$_IVCHAN
715 #define VMS_SS_NORMAL   SS$_NORMAL
716 #else
717 #define VMS_LIB_INVARG  EINVAL
718 #define VMS_RMS_DIR     EBADF
719 #define VMS_RMS_FAC     0
720 #define VMS_RMS_IFI     EBADF
721 #define VMS_RMS_ISI     EBADF
722 #define VMS_SS_ACCVIO   EFAULT
723 #define VMS_SS_IVCHAN   EBADF
724 #define VMS_SS_NORMAL   0
725 #endif
726
727 #ifdef USE_5005THREADS
728 #  define ERRSV (thr->errsv)
729 #  define DEFSV THREADSV(0)
730 #  define SAVE_DEFSV save_threadsv(0)
731 #else
732 #  define ERRSV GvSV(PL_errgv)
733 #  define DEFSV GvSV(PL_defgv)
734 #  define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
735 #endif /* USE_5005THREADS */
736
737 #define ERRHV GvHV(PL_errgv)    /* XXX unused, here for compatibility */
738
739 #ifndef errno
740         extern int errno;     /* ANSI allows errno to be an lvalue expr.
741                                * For example in multithreaded environments
742                                * something like this might happen:
743                                * extern int *_errno(void);
744                                * #define errno (*_errno()) */
745 #endif
746
747 #ifdef HAS_STRERROR
748 #       ifdef VMS
749         char *strerror (int,...);
750 #       else
751 #ifndef DONT_DECLARE_STD
752         char *strerror (int);
753 #endif
754 #       endif
755 #       ifndef Strerror
756 #           define Strerror strerror
757 #       endif
758 #else
759 #    ifdef HAS_SYS_ERRLIST
760         extern int sys_nerr;
761         extern char *sys_errlist[];
762 #       ifndef Strerror
763 #           define Strerror(e) \
764                 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
765 #       endif
766 #   endif
767 #endif
768
769 #ifdef I_SYS_IOCTL
770 #   ifndef _IOCTL_
771 #       include <sys/ioctl.h>
772 #   endif
773 #endif
774
775 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
776 #   ifdef HAS_SOCKETPAIR
777 #       undef HAS_SOCKETPAIR
778 #   endif
779 #   ifdef I_NDBM
780 #       undef I_NDBM
781 #   endif
782 #endif
783
784 #if INTSIZE == 2
785 #   define htoni htons
786 #   define ntohi ntohs
787 #else
788 #   define htoni htonl
789 #   define ntohi ntohl
790 #endif
791
792 /* Configure already sets Direntry_t */
793 #if defined(I_DIRENT)
794 #   include <dirent.h>
795     /* NeXT needs dirent + sys/dir.h */
796 #   if  defined(I_SYS_DIR) && (defined(NeXT) || defined(__NeXT__))
797 #       include <sys/dir.h>
798 #   endif
799 #else
800 #   ifdef I_SYS_NDIR
801 #       include <sys/ndir.h>
802 #   else
803 #       ifdef I_SYS_DIR
804 #           ifdef hp9000s500
805 #               include <ndir.h>        /* may be wrong in the future */
806 #           else
807 #               include <sys/dir.h>
808 #           endif
809 #       endif
810 #   endif
811 #endif
812
813 #ifdef PERL_MICRO
814 #   ifndef DIR
815 #      define DIR void
816 #   endif
817 #endif
818
819 #ifdef FPUTS_BOTCH
820 /* work around botch in SunOS 4.0.1 and 4.0.2 */
821 #   ifndef fputs
822 #       define fputs(sv,fp) fprintf(fp,"%s",sv)
823 #   endif
824 #endif
825
826 /*
827  * The following gobbledygook brought to you on behalf of __STDC__.
828  * (I could just use #ifndef __STDC__, but this is more bulletproof
829  * in the face of half-implementations.)
830  */
831
832 #ifdef I_SYSMODE
833 #include <sys/mode.h>
834 #endif
835
836 #ifndef S_IFMT
837 #   ifdef _S_IFMT
838 #       define S_IFMT _S_IFMT
839 #   else
840 #       define S_IFMT 0170000
841 #   endif
842 #endif
843
844 #ifndef S_ISDIR
845 #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
846 #endif
847
848 #ifndef S_ISCHR
849 #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
850 #endif
851
852 #ifndef S_ISBLK
853 #   ifdef S_IFBLK
854 #       define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
855 #   else
856 #       define S_ISBLK(m) (0)
857 #   endif
858 #endif
859
860 #ifndef S_ISREG
861 #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
862 #endif
863
864 #ifndef S_ISFIFO
865 #   ifdef S_IFIFO
866 #       define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
867 #   else
868 #       define S_ISFIFO(m) (0)
869 #   endif
870 #endif
871
872 #ifndef S_ISLNK
873 #   ifdef _S_ISLNK
874 #       define S_ISLNK(m) _S_ISLNK(m)
875 #   else
876 #       ifdef _S_IFLNK
877 #           define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
878 #       else
879 #           ifdef S_IFLNK
880 #               define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
881 #           else
882 #               define S_ISLNK(m) (0)
883 #           endif
884 #       endif
885 #   endif
886 #endif
887
888 #ifndef S_ISSOCK
889 #   ifdef _S_ISSOCK
890 #       define S_ISSOCK(m) _S_ISSOCK(m)
891 #   else
892 #       ifdef _S_IFSOCK
893 #           define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
894 #       else
895 #           ifdef S_IFSOCK
896 #               define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
897 #           else
898 #               define S_ISSOCK(m) (0)
899 #           endif
900 #       endif
901 #   endif
902 #endif
903
904 #ifndef S_IRUSR
905 #   ifdef S_IREAD
906 #       define S_IRUSR S_IREAD
907 #       define S_IWUSR S_IWRITE
908 #       define S_IXUSR S_IEXEC
909 #   else
910 #       define S_IRUSR 0400
911 #       define S_IWUSR 0200
912 #       define S_IXUSR 0100
913 #   endif
914 #endif
915
916 #ifndef S_IRGRP
917 #   ifdef S_IRUSR
918 #       define S_IRGRP (S_IRUSR>>3)
919 #       define S_IWGRP (S_IWUSR>>3)
920 #       define S_IXGRP (S_IXUSR>>3)
921 #   else
922 #       define S_IRGRP 0040
923 #       define S_IWGRP 0020
924 #       define S_IXGRP 0010
925 #   endif
926 #endif
927
928 #ifndef S_IROTH
929 #   ifdef S_IRUSR
930 #       define S_IROTH (S_IRUSR>>6)
931 #       define S_IWOTH (S_IWUSR>>6)
932 #       define S_IXOTH (S_IXUSR>>6)
933 #   else
934 #       define S_IROTH 0040
935 #       define S_IWOTH 0020
936 #       define S_IXOTH 0010
937 #   endif
938 #endif
939
940 #ifndef S_ISUID
941 #   define S_ISUID 04000
942 #endif
943
944 #ifndef S_ISGID
945 #   define S_ISGID 02000
946 #endif
947
948 #ifndef S_IRWXU
949 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
950 #endif
951
952 #ifndef S_IRWXG
953 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
954 #endif
955
956 #ifndef S_IRWXO
957 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
958 #endif
959
960 #ifndef S_IREAD
961 #   define S_IREAD S_IRUSR
962 #endif
963
964 #ifndef S_IWRITE
965 #   define S_IWRITE S_IWUSR
966 #endif
967
968 #ifndef S_IEXEC
969 #   define S_IEXEC S_IXUSR
970 #endif
971
972 #ifdef ff_next
973 #   undef ff_next
974 #endif
975
976 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
977 #   define SLOPPYDIVIDE
978 #endif
979
980 #ifdef UV
981 #undef UV
982 #endif
983
984 #ifdef  SPRINTF_E_BUG
985 #  define sprintf UTS_sprintf_wrap
986 #endif
987
988 /* Configure gets this right but the UTS compiler gets it wrong.
989    -- Hal Morris <hom00@utsglobal.com> */
990 #ifdef UTS
991 #  undef  UVTYPE
992 #  define UVTYPE unsigned
993 #endif
994
995 /*
996     The IV type is supposed to be long enough to hold any integral
997     value or a pointer.
998     --Andy Dougherty    August 1996
999 */
1000
1001 typedef IVTYPE IV;
1002 typedef UVTYPE UV;
1003
1004 #if defined(USE_64_BIT_INT) && defined(HAS_QUAD)
1005 #  if QUADKIND == QUAD_IS_INT64_T && defined(INT64_MAX)
1006 #    define IV_MAX INT64_MAX
1007 #    define IV_MIN INT64_MIN
1008 #    define UV_MAX UINT64_MAX
1009 #    ifndef UINT64_MIN
1010 #      define UINT64_MIN 0
1011 #    endif
1012 #    define UV_MIN UINT64_MIN
1013 #  else
1014 #    define IV_MAX PERL_QUAD_MAX
1015 #    define IV_MIN PERL_QUAD_MIN
1016 #    define UV_MAX PERL_UQUAD_MAX
1017 #    define UV_MIN PERL_UQUAD_MIN
1018 #  endif
1019 #  define IV_IS_QUAD
1020 #  define UV_IS_QUAD
1021 #else
1022 #  if defined(INT32_MAX) && IVSIZE == 4
1023 #    define IV_MAX INT32_MAX
1024 #    define IV_MIN INT32_MIN
1025 #    ifndef UINT32_MAX_BROKEN /* e.g. HP-UX with gcc messes this up */
1026 #        define UV_MAX UINT32_MAX
1027 #    else
1028 #        define UV_MAX 4294967295U
1029 #    endif
1030 #    ifndef UINT32_MIN
1031 #      define UINT32_MIN 0
1032 #    endif
1033 #    define UV_MIN UINT32_MIN
1034 #  else
1035 #    define IV_MAX PERL_LONG_MAX
1036 #    define IV_MIN PERL_LONG_MIN
1037 #    define UV_MAX PERL_ULONG_MAX
1038 #    define UV_MIN PERL_ULONG_MIN
1039 #  endif
1040 #  if IVSIZE == 8
1041 #    define IV_IS_QUAD
1042 #    define UV_IS_QUAD
1043 #    ifndef HAS_QUAD
1044 #      define HAS_QUAD
1045 #    endif
1046 #  else
1047 #    undef IV_IS_QUAD
1048 #    undef UV_IS_QUAD
1049 #    undef HAS_QUAD
1050 #  endif
1051 #endif
1052
1053 #if defined(uts) || defined(UTS)
1054 #       undef UV_MAX
1055 #       define UV_MAX (4294967295u)
1056 #endif
1057
1058 #define IV_DIG (BIT_DIGITS(IVSIZE * 8))
1059 #define UV_DIG (BIT_DIGITS(UVSIZE * 8))
1060
1061 #ifndef NO_PERL_PRESERVE_IVUV
1062 #define PERL_PRESERVE_IVUV      /* We like our integers to stay integers. */
1063 #endif
1064
1065 /*
1066  *  The macros INT2PTR and NUM2PTR are (despite their names)
1067  *  bi-directional: they will convert int/float to or from pointers.
1068  *  However the conversion to int/float are named explicitly:
1069  *  PTR2IV, PTR2UV, PTR2NV.
1070  *
1071  *  For int conversions we do not need two casts if pointers are
1072  *  the same size as IV and UV.   Otherwise we need an explicit
1073  *  cast (PTRV) to avoid compiler warnings.
1074  */
1075 #if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
1076 #  define PTRV                  UV
1077 #  define INT2PTR(any,d)        (any)(d)
1078 #else
1079 #  if PTRSIZE == LONGSIZE
1080 #    define PTRV                unsigned long
1081 #  else
1082 #    define PTRV                unsigned
1083 #  endif
1084 #  define INT2PTR(any,d)        (any)(PTRV)(d)
1085 #endif
1086 #define NUM2PTR(any,d)  (any)(PTRV)(d)
1087 #define PTR2IV(p)       INT2PTR(IV,p)
1088 #define PTR2UV(p)       INT2PTR(UV,p)
1089 #define PTR2NV(p)       NUM2PTR(NV,p)
1090 #if PTRSIZE == LONGSIZE
1091 #  define PTR2ul(p)     (unsigned long)(p)
1092 #else
1093 #  define PTR2ul(p)     INT2PTR(unsigned long,p)        
1094 #endif
1095
1096 #ifdef USE_LONG_DOUBLE
1097 #  if defined(HAS_LONG_DOUBLE) && LONG_DOUBLESIZE == DOUBLESIZE
1098 #      define LONG_DOUBLE_EQUALS_DOUBLE
1099 #  endif
1100 #  if !(defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE))
1101 #     undef USE_LONG_DOUBLE /* Ouch! */
1102 #  endif
1103 #endif
1104
1105 #ifdef OVR_DBL_DIG
1106 /* Use an overridden DBL_DIG */
1107 # ifdef DBL_DIG
1108 #  undef DBL_DIG
1109 # endif
1110 # define DBL_DIG OVR_DBL_DIG
1111 #else
1112 /* The following is all to get DBL_DIG, in order to pick a nice
1113    default value for printing floating point numbers in Gconvert.
1114    (see config.h)
1115 */
1116 #ifdef I_LIMITS
1117 #include <limits.h>
1118 #endif
1119 #ifdef I_FLOAT
1120 #include <float.h>
1121 #endif
1122 #ifndef HAS_DBL_DIG
1123 #define DBL_DIG 15   /* A guess that works lots of places */
1124 #endif
1125 #endif
1126 #ifdef I_FLOAT
1127 #include <float.h>
1128 #endif
1129 #ifndef HAS_DBL_DIG
1130 #define DBL_DIG 15   /* A guess that works lots of places */
1131 #endif
1132
1133 #ifdef OVR_LDBL_DIG
1134 /* Use an overridden LDBL_DIG */
1135 # ifdef LDBL_DIG
1136 #  undef LDBL_DIG
1137 # endif
1138 # define LDBL_DIG OVR_LDBL_DIG
1139 #else
1140 /* The following is all to get LDBL_DIG, in order to pick a nice
1141    default value for printing floating point numbers in Gconvert.
1142    (see config.h)
1143 */
1144 # ifdef I_LIMITS
1145 #   include <limits.h>
1146 # endif
1147 # ifdef I_FLOAT
1148 #  include <float.h>
1149 # endif
1150 # ifndef HAS_LDBL_DIG
1151 #  if LONG_DOUBLESIZE == 10
1152 #   define LDBL_DIG 18 /* assume IEEE */
1153 #  else
1154 #   if LONG_DOUBLESIZE == 12
1155 #    define LDBL_DIG 18 /* gcc? */
1156 #   else
1157 #    if LONG_DOUBLESIZE == 16
1158 #     define LDBL_DIG 33 /* assume IEEE */
1159 #    else
1160 #     if LONG_DOUBLESIZE == DOUBLESIZE
1161 #      define LDBL_DIG DBL_DIG /* bummer */
1162 #     endif
1163 #    endif
1164 #   endif
1165 #  endif
1166 # endif
1167 #endif
1168
1169 typedef NVTYPE NV;
1170
1171 #ifdef I_IEEEFP
1172 #   include <ieeefp.h>
1173 #endif
1174
1175 #ifdef USE_LONG_DOUBLE
1176 #   ifdef I_SUNMATH
1177 #       include <sunmath.h>
1178 #   endif
1179 #   define NV_DIG LDBL_DIG
1180 #   ifdef LDBL_MANT_DIG
1181 #       define NV_MANT_DIG LDBL_MANT_DIG
1182 #   endif
1183 #   ifdef LDBL_MIN
1184 #       define NV_MIN LDBL_MIN
1185 #   endif
1186 #   ifdef LDBL_MAX
1187 #       define NV_MAX LDBL_MAX
1188 #   endif
1189 #   ifdef LDBL_MIN_10_EXP
1190 #       define NV_MIN_10_EXP LDBL_MIN_10_EXP
1191 #   endif
1192 #   ifdef LDBL_MAX_10_EXP
1193 #       define NV_MAX_10_EXP LDBL_MAX_10_EXP
1194 #   endif
1195 #   ifdef LDBL_EPSILON
1196 #       define NV_EPSILON LDBL_EPSILON
1197 #   endif
1198 #   ifdef LDBL_MAX
1199 #       define NV_MAX LDBL_MAX
1200 #       define NV_MIN LDBL_MIN
1201 #   else
1202 #       ifdef HUGE_VALL
1203 #           define NV_MAX HUGE_VALL
1204 #       else
1205 #           ifdef HUGE_VAL
1206 #               define NV_MAX ((NV)HUGE_VAL)
1207 #           endif
1208 #       endif
1209 #   endif
1210 #   ifdef HAS_SQRTL
1211 #       define Perl_cos cosl
1212 #       define Perl_sin sinl
1213 #       define Perl_sqrt sqrtl
1214 #       define Perl_exp expl
1215 #       define Perl_log logl
1216 #       define Perl_atan2 atan2l
1217 #       define Perl_pow powl
1218 #       define Perl_floor floorl
1219 #       define Perl_fmod fmodl
1220 #   endif
1221 /* e.g. libsunmath doesn't have modfl and frexpl as of mid-March 2000 */
1222 #   ifdef HAS_MODFL
1223 #       define Perl_modf(x,y) modfl(x,y)
1224 #   else
1225 #       define Perl_modf(x,y) ((long double)modf((double)(x),(double*)(y)))
1226 #   endif
1227 #   ifdef HAS_FREXPL
1228 #       define Perl_frexp(x,y) frexpl(x,y)
1229 #   else
1230 #       define Perl_frexp(x,y) ((long double)frexp((double)(x),y))
1231 #   endif
1232 #   ifndef Perl_isinf
1233 #       ifdef HAS_ISNANL
1234 #           define Perl_isnan(x) isnanl(x)
1235 #       endif
1236 #   endif
1237 #   ifndef Perl_isinf
1238 #       ifdef HAS_FINITEL
1239 #           define Perl_isinf(x) !(finitel(x)||Perl_isnan(x))
1240 #       endif
1241 #   endif
1242 #else
1243 #   define NV_DIG DBL_DIG
1244 #   ifdef DBL_MANT_DIG
1245 #       define NV_MANT_DIG DBL_MANT_DIG
1246 #   endif
1247 #   ifdef DBL_MIN
1248 #       define NV_MIN DBL_MIN
1249 #   endif
1250 #   ifdef DBL_MAX
1251 #       define NV_MAX DBL_MAX
1252 #   endif
1253 #   ifdef DBL_MIN_10_EXP
1254 #       define NV_MIN_10_EXP DBL_MIN_10_EXP
1255 #   endif
1256 #   ifdef DBL_MAX_10_EXP
1257 #       define NV_MAX_10_EXP DBL_MAX_10_EXP
1258 #   endif
1259 #   ifdef DBL_EPSILON
1260 #       define NV_EPSILON DBL_EPSILON
1261 #   endif
1262 #   ifdef DBL_MAX
1263 #       define NV_MAX DBL_MAX
1264 #       define NV_MIN DBL_MIN
1265 #   else
1266 #       ifdef HUGE_VAL
1267 #           define NV_MAX HUGE_VAL
1268 #       endif
1269 #   endif
1270 #   define Perl_cos cos
1271 #   define Perl_sin sin
1272 #   define Perl_sqrt sqrt
1273 #   define Perl_exp exp
1274 #   define Perl_log log
1275 #   define Perl_atan2 atan2
1276 #   define Perl_pow pow
1277 #   define Perl_floor floor
1278 #   define Perl_fmod fmod
1279 #   define Perl_modf(x,y) modf(x,y)
1280 #   define Perl_frexp(x,y) frexp(x,y)
1281 #endif
1282
1283 /* rumor has it that Win32 has _fpclass() */
1284
1285 #if !defined(Perl_fp_class) && (defined(HAS_FPCLASS)||defined(HAS_FPCLASSL))
1286 #    ifdef I_IEEFP
1287 #        include <ieeefp.h>
1288 #    endif
1289 #    ifdef I_FP
1290 #        include <fp.h>
1291 #    endif
1292 #    if defined(USE_LONG_DOUBLE) && defined(HAS_FPCLASSL)
1293 #        define Perl_fp_class()         fpclassl(x)
1294 #    else
1295 #        define Perl_fp_class()         fpclass(x)
1296 #    endif
1297 #    define Perl_fp_class_snan(x)       (Perl_fp_class(x)==FP_CLASS_SNAN)
1298 #    define Perl_fp_class_qnan(x)       (Perl_fp_class(x)==FP_CLASS_QNAN)
1299 #    define Perl_fp_class_nan(x)        (Perl_fp_class(x)==FP_CLASS_SNAN||Perl_fp_class(x)==FP_CLASS_QNAN)
1300 #    define Perl_fp_class_ninf(x)       (Perl_fp_class(x)==FP_CLASS_NINF)
1301 #    define Perl_fp_class_pinf(x)       (Perl_fp_class(x)==FP_CLASS_PINF)
1302 #    define Perl_fp_class_inf(x)        (Perl_fp_class(x)==FP_CLASS_NINF||Perl_fp_class(x)==FP_CLASS_PINF)
1303 #    define Perl_fp_class_nnorm(x)      (Perl_fp_class(x)==FP_CLASS_NNORM)
1304 #    define Perl_fp_class_pnorm(x)      (Perl_fp_class(x)==FP_CLASS_PNORM)
1305 #    define Perl_fp_class_norm(x)       (Perl_fp_class(x)==FP_CLASS_NNORM||Perl_fp_class(x)==FP_CLASS_PNORM)
1306 #    define Perl_fp_class_ndenorm(x)    (Perl_fp_class(x)==FP_CLASS_NDENORM)
1307 #    define Perl_fp_class_pdenorm(x)    (Perl_fp_class(x)==FP_CLASS_PDENORM)
1308 #    define Perl_fp_class_denorm(x)     (Perl_fp_class(x)==FP_CLASS_NDENORM||Perl_fp_class(x)==FP_CLASS_PDENORM)
1309 #    define Perl_fp_class_nzero(x)      (Perl_fp_class(x)==FP_CLASS_NZERO)
1310 #    define Perl_fp_class_pzero(x)      (Perl_fp_class(x)==FP_CLASS_PZERO)
1311 #    define Perl_fp_class_zero(x)       (Perl_fp_class(x)==FP_CLASS_NZERO||Perl_fp_class(x)==FP_CLASS_PZERO)
1312 #endif
1313
1314 #if !defined(Perl_fp_class) && defined(HAS_FP_CLASS)
1315 #    include <math.h>
1316 #    if !defined(FP_SNAN) && defined(I_FP_CLASS)
1317 #        include <fp_class.h>
1318 #    endif
1319 #    define Perl_fp_class(x)            fp_class(x)
1320 #    define Perl_fp_class_snan(x)       (fp_class(x)==FP_SNAN)
1321 #    define Perl_fp_class_qnan(x)       (fp_class(x)==FP_QNAN)
1322 #    define Perl_fp_class_nan(x)        (fp_class(x)==FP_SNAN||fp_class(x)==FP_QNAN)
1323 #    define Perl_fp_class_ninf(x)       (fp_class(x)==FP_NEG_INF)
1324 #    define Perl_fp_class_pinf(x)       (fp_class(x)==FP_POS_INF)
1325 #    define Perl_fp_class_inf(x)        (fp_class(x)==FP_NEG_INF||fp_class(x)==FP_POS_INF)
1326 #    define Perl_fp_class_nnorm(x)      (fp_class(x)==FP_NEG_NORM)
1327 #    define Perl_fp_class_pnorm(x)      (fp_class(x)==FP_POS_NORM)
1328 #    define Perl_fp_class_norm(x)       (fp_class(x)==FP_NEG_NORM||fp_class(x)==FP_POS_NORM)
1329 #    define Perl_fp_class_ndenorm(x)    (fp_class(x)==FP_NEG_DENORM)
1330 #    define Perl_fp_class_pdenorm(x)    (fp_class(x)==FP_POS_DENORM)
1331 #    define Perl_fp_class_denorm(x)     (fp_class(x)==FP_NEG_DENORM||fp_class(x)==FP_POS_DENORM)
1332 #    define Perl_fp_class_nzero(x)      (fp_class(x)==FP_NEG_ZERO)
1333 #    define Perl_fp_class_pzero(x)      (fp_class(x)==FP_POS_ZERO)
1334 #    define Perl_fp_class_zero(x)       (fp_class(x)==FP_NEG_ZERO||fp_class(x)==FP_POS_ZERO)
1335 #endif
1336
1337 #if !defined(Perl_fp_class) && defined(HAS_FPCLASSIFY)
1338 #    include <math.h>
1339 #    define Perl_fp_class(x)            fpclassify(x)
1340 #    define Perl_fp_class_nan(x)        (fp_classify(x)==FP_SNAN|FP|_fp_classify(x)==QNAN)
1341 #    define Perl_fp_class_inf(x)        (fp_classify(x)==FP_INFINITE)
1342 #    define Perl_fp_class_norm(x)       (fp_classify(x)==FP_NORMAL)
1343 #    define Perl_fp_class_denorm(x)     (fp_classify(x)==FP_SUBNORMAL)
1344 #    define Perl_fp_class_zero(x)       (fp_classify(x)==FP_ZERO)
1345 #endif
1346
1347 #if !defined(Perl_fp_class) && defined(HAS_CLASS)
1348 #    include <math.h>
1349 #    ifndef _cplusplus
1350 #        define Perl_fp_class(x)        class(x)
1351 #    else
1352 #        define Perl_fp_class(x)        _class(x)
1353 #    endif
1354 #    define Perl_fp_class_snan(x)       (Perl_fp_class(x)==FP_NANS)
1355 #    define Perl_fp_class_qnan(x)       (Perl_fp_class(x)==FP_NANQ)
1356 #    define Perl_fp_class_nan(x)        (Perl_fp_class(x)==FP_SNAN||Perl_fp_class(x)==FP_QNAN)
1357 #    define Perl_fp_class_ninf(x)       (Perl_fp_class(x)==FP_MINUS_INF)
1358 #    define Perl_fp_class_pinf(x)       (Perl_fp_class(x)==FP_PLUS_INF)
1359 #    define Perl_fp_class_inf(x)        (Perl_fp_class(x)==FP_MINUS_INF||Perl_fp_class(x)==FP_PLUS_INF)
1360 #    define Perl_fp_class_nnorm(x)      (Perl_fp_class(x)==FP_MINUS_NORM)
1361 #    define Perl_fp_class_pnorm(x)      (Perl_fp_class(x)==FP_PLUS_NORM)
1362 #    define Perl_fp_class_norm(x)       (Perl_fp_class(x)==FP_MINUS_NORM||Perl_fp_class(x)==FP_PLUS_NORM)
1363 #    define Perl_fp_class_ndenorm(x)    (Perl_fp_class(x)==FP_MINUS_DENORM)
1364 #    define Perl_fp_class_pdenorm(x)    (Perl_fp_class(x)==FP_PLUS_DENORM)
1365 #    define Perl_fp_class_denorm(x)     (Perl_fp_class(x)==FP_MINUS_DENORM||Perl_fp_class(x)==FP_PLUS_DENORM)
1366 #    define Perl_fp_class_nzero(x)      (Perl_fp_class(x)==FP_MINUS_ZERO)
1367 #    define Perl_fp_class_pzero(x)      (Perl_fp_class(x)==FP_PLUS_ZERO)
1368 #    define Perl_fp_class_zero(x)       (Perl_fp_class(x)==FP_MINUS_ZERO||Perl_fp_class(x)==FP_PLUS_ZERO)
1369 #endif
1370
1371 /* rumor has it that Win32 has _isnan() */
1372
1373 #ifndef Perl_isnan
1374 #   ifdef HAS_ISNAN
1375 #       define Perl_isnan(x) isnan((NV)x)
1376 #   else
1377 #       ifdef Perl_fp_class_nan
1378 #           define Perl_isnan(x) Perl_fp_class_nan(x)
1379 #       else
1380 #           ifdef HAS_UNORDERED
1381 #               define Perl_isnan(x) unordered((x), 0.0)
1382 #           else
1383 #               define Perl_isnan(x) ((x)!=(x))
1384 #           endif
1385 #       endif
1386 #   endif
1387 #endif
1388
1389 #ifndef Perl_isinf
1390 #   ifdef HAS_ISINF
1391 #       define Perl_isinf(x) isinf((NV)x)
1392 #   else
1393 #       ifdef Perl_fp_class_inf
1394 #           define Perl_isinf(x) Perl_fp_class_inf(x)
1395 #       else
1396 #           define Perl_isinf(x) ((x)==NV_INF)
1397 #       endif
1398 #   endif
1399 #endif
1400
1401 #ifndef Perl_isfinite
1402 #   ifdef HAS_FINITE
1403 #       define Perl_isfinite(x) finite((NV)x)
1404 #   else
1405 #       ifdef HAS_ISFINITE
1406 #           define Perl_isfinite(x) isfinite(x)
1407 #       else
1408 #           ifdef Perl_fp_class_finite
1409 #               define Perl_isfinite(x) Perl_fp_class_finite(x)
1410 #           else
1411 #               define Perl_isfinite(x) !(Perl_is_inf(x)||Perl_is_nan(x))
1412 #           endif
1413 #       endif
1414 #   endif
1415 #endif
1416
1417 #define Perl_atof(s) Perl_my_atof(s)
1418 #define Perl_atof2(s, np) Perl_my_atof2(s, np)
1419
1420 /* Previously these definitions used hardcoded figures.
1421  * It is hoped these formula are more portable, although
1422  * no data one way or another is presently known to me.
1423  * The "PERL_" names are used because these calculated constants
1424  * do not meet the ANSI requirements for LONG_MAX, etc., which
1425  * need to be constants acceptable to #if - kja
1426  *    define PERL_LONG_MAX        2147483647L
1427  *    define PERL_LONG_MIN        (-LONG_MAX - 1)
1428  *    define PERL ULONG_MAX       4294967295L
1429  */
1430
1431 #ifdef I_LIMITS  /* Needed for cast_xxx() functions below. */
1432 #  include <limits.h>
1433 #else
1434 #ifdef I_VALUES
1435 #  include <values.h>
1436 #endif
1437 #endif
1438
1439 /*
1440  * Try to figure out max and min values for the integral types.  THE CORRECT
1441  * SOLUTION TO THIS MESS: ADAPT enquire.c FROM GCC INTO CONFIGURE.  The
1442  * following hacks are used if neither limits.h or values.h provide them:
1443  * U<TYPE>_MAX: for types >= int: ~(unsigned TYPE)0
1444  *              for types <  int:  (unsigned TYPE)~(unsigned)0
1445  *      The argument to ~ must be unsigned so that later signed->unsigned
1446  *      conversion can't modify the value's bit pattern (e.g. -0 -> +0),
1447  *      and it must not be smaller than int because ~ does integral promotion.
1448  * <type>_MAX: (<type>) (U<type>_MAX >> 1)
1449  * <type>_MIN: -<type>_MAX - <is_twos_complement_architecture: (3 & -1) == 3>.
1450  *      The latter is a hack which happens to work on some machines but
1451  *      does *not* catch any random system, or things like integer types
1452  *      with NaN if that is possible.
1453  *
1454  * All of the types are explicitly cast to prevent accidental loss of
1455  * numeric range, and in the hope that they will be less likely to confuse
1456  * over-eager optimizers.
1457  *
1458  */
1459
1460 #define PERL_UCHAR_MIN ((unsigned char)0)
1461
1462 #ifdef UCHAR_MAX
1463 #  define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
1464 #else
1465 #  ifdef MAXUCHAR
1466 #    define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
1467 #  else
1468 #    define PERL_UCHAR_MAX       ((unsigned char)~(unsigned)0)
1469 #  endif
1470 #endif
1471
1472 /*
1473  * CHAR_MIN and CHAR_MAX are not included here, as the (char) type may be
1474  * ambiguous. It may be equivalent to (signed char) or (unsigned char)
1475  * depending on local options. Until Configure detects this (or at least
1476  * detects whether the "signed" keyword is available) the CHAR ranges
1477  * will not be included. UCHAR functions normally.
1478  *                                                           - kja
1479  */
1480
1481 #define PERL_USHORT_MIN ((unsigned short)0)
1482
1483 #ifdef USHORT_MAX
1484 #  define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
1485 #else
1486 #  ifdef MAXUSHORT
1487 #    define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
1488 #  else
1489 #    ifdef USHRT_MAX
1490 #      define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
1491 #    else
1492 #      define PERL_USHORT_MAX       ((unsigned short)~(unsigned)0)
1493 #    endif
1494 #  endif
1495 #endif
1496
1497 #ifdef SHORT_MAX
1498 #  define PERL_SHORT_MAX ((short)SHORT_MAX)
1499 #else
1500 #  ifdef MAXSHORT    /* Often used in <values.h> */
1501 #    define PERL_SHORT_MAX ((short)MAXSHORT)
1502 #  else
1503 #    ifdef SHRT_MAX
1504 #      define PERL_SHORT_MAX ((short)SHRT_MAX)
1505 #    else
1506 #      define PERL_SHORT_MAX      ((short) (PERL_USHORT_MAX >> 1))
1507 #    endif
1508 #  endif
1509 #endif
1510
1511 #ifdef SHORT_MIN
1512 #  define PERL_SHORT_MIN ((short)SHORT_MIN)
1513 #else
1514 #  ifdef MINSHORT
1515 #    define PERL_SHORT_MIN ((short)MINSHORT)
1516 #  else
1517 #    ifdef SHRT_MIN
1518 #      define PERL_SHORT_MIN ((short)SHRT_MIN)
1519 #    else
1520 #      define PERL_SHORT_MIN        (-PERL_SHORT_MAX - ((3 & -1) == 3))
1521 #    endif
1522 #  endif
1523 #endif
1524
1525 #ifdef UINT_MAX
1526 #  define PERL_UINT_MAX ((unsigned int)UINT_MAX)
1527 #else
1528 #  ifdef MAXUINT
1529 #    define PERL_UINT_MAX ((unsigned int)MAXUINT)
1530 #  else
1531 #    define PERL_UINT_MAX       (~(unsigned int)0)
1532 #  endif
1533 #endif
1534
1535 #define PERL_UINT_MIN ((unsigned int)0)
1536
1537 #ifdef INT_MAX
1538 #  define PERL_INT_MAX ((int)INT_MAX)
1539 #else
1540 #  ifdef MAXINT    /* Often used in <values.h> */
1541 #    define PERL_INT_MAX ((int)MAXINT)
1542 #  else
1543 #    define PERL_INT_MAX        ((int)(PERL_UINT_MAX >> 1))
1544 #  endif
1545 #endif
1546
1547 #ifdef INT_MIN
1548 #  define PERL_INT_MIN ((int)INT_MIN)
1549 #else
1550 #  ifdef MININT
1551 #    define PERL_INT_MIN ((int)MININT)
1552 #  else
1553 #    define PERL_INT_MIN        (-PERL_INT_MAX - ((3 & -1) == 3))
1554 #  endif
1555 #endif
1556
1557 #ifdef ULONG_MAX
1558 #  define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
1559 #else
1560 #  ifdef MAXULONG
1561 #    define PERL_ULONG_MAX ((unsigned long)MAXULONG)
1562 #  else
1563 #    define PERL_ULONG_MAX       (~(unsigned long)0)
1564 #  endif
1565 #endif
1566
1567 #define PERL_ULONG_MIN ((unsigned long)0L)
1568
1569 #ifdef LONG_MAX
1570 #  define PERL_LONG_MAX ((long)LONG_MAX)
1571 #else
1572 #  ifdef MAXLONG    /* Often used in <values.h> */
1573 #    define PERL_LONG_MAX ((long)MAXLONG)
1574 #  else
1575 #    define PERL_LONG_MAX        ((long) (PERL_ULONG_MAX >> 1))
1576 #  endif
1577 #endif
1578
1579 #ifdef LONG_MIN
1580 #  define PERL_LONG_MIN ((long)LONG_MIN)
1581 #else
1582 #  ifdef MINLONG
1583 #    define PERL_LONG_MIN ((long)MINLONG)
1584 #  else
1585 #    define PERL_LONG_MIN        (-PERL_LONG_MAX - ((3 & -1) == 3))
1586 #  endif
1587 #endif
1588
1589 #ifdef UV_IS_QUAD
1590
1591 #    define PERL_UQUAD_MAX      (~(UV)0)
1592 #    define PERL_UQUAD_MIN      ((UV)0)
1593 #    define PERL_QUAD_MAX       ((IV) (PERL_UQUAD_MAX >> 1))
1594 #    define PERL_QUAD_MIN       (-PERL_QUAD_MAX - ((3 & -1) == 3))
1595
1596 #endif
1597
1598 struct perl_mstats {
1599     UV *nfree;
1600     UV *ntotal;
1601     IV topbucket, topbucket_ev, topbucket_odd, totfree, total, total_chain;
1602     IV total_sbrk, sbrks, sbrk_good, sbrk_slack, start_slack, sbrked_remains;
1603     IV minbucket;
1604     /* Level 1 info */
1605     UV *bucket_mem_size;
1606     UV *bucket_available_size;
1607     UV nbuckets;
1608 };
1609 struct RExC_state_t;
1610
1611 typedef MEM_SIZE STRLEN;
1612
1613 typedef struct op OP;
1614 typedef struct cop COP;
1615 typedef struct unop UNOP;
1616 typedef struct binop BINOP;
1617 typedef struct listop LISTOP;
1618 typedef struct logop LOGOP;
1619 typedef struct pmop PMOP;
1620 typedef struct svop SVOP;
1621 typedef struct padop PADOP;
1622 typedef struct pvop PVOP;
1623 typedef struct loop LOOP;
1624
1625 typedef struct interpreter PerlInterpreter;
1626
1627 /* Amdahl's <ksync.h> has struct sv */
1628 /* SGI's <sys/sema.h> has struct sv */
1629 #if defined(UTS) || defined(__sgi)
1630 #   define STRUCT_SV perl_sv
1631 #else
1632 #   define STRUCT_SV sv
1633 #endif
1634 typedef struct STRUCT_SV SV;
1635 typedef struct av AV;
1636 typedef struct hv HV;
1637 typedef struct cv CV;
1638 typedef struct regexp REGEXP;
1639 typedef struct gp GP;
1640 typedef struct gv GV;
1641 typedef struct io IO;
1642 typedef struct context PERL_CONTEXT;
1643 typedef struct block BLOCK;
1644
1645 typedef struct magic MAGIC;
1646 typedef struct xrv XRV;
1647 typedef struct xpv XPV;
1648 typedef struct xpviv XPVIV;
1649 typedef struct xpvuv XPVUV;
1650 typedef struct xpvnv XPVNV;
1651 typedef struct xpvmg XPVMG;
1652 typedef struct xpvlv XPVLV;
1653 typedef struct xpvav XPVAV;
1654 typedef struct xpvhv XPVHV;
1655 typedef struct xpvgv XPVGV;
1656 typedef struct xpvcv XPVCV;
1657 typedef struct xpvbm XPVBM;
1658 typedef struct xpvfm XPVFM;
1659 typedef struct xpvio XPVIO;
1660 typedef struct mgvtbl MGVTBL;
1661 typedef union any ANY;
1662 typedef struct ptr_tbl_ent PTR_TBL_ENT_t;
1663 typedef struct ptr_tbl PTR_TBL_t;
1664 typedef struct clone_params CLONE_PARAMS;
1665
1666
1667 #include "handy.h"
1668
1669 #if defined(USE_LARGE_FILES) && !defined(NO_64_BIT_RAWIO)
1670 #   if LSEEKSIZE == 8 && !defined(USE_64_BIT_RAWIO)
1671 #       define USE_64_BIT_RAWIO /* implicit */
1672 #   endif
1673 #endif
1674
1675 /* Notice the use of HAS_FSEEKO: now we are obligated to always use
1676  * fseeko/ftello if possible.  Don't go #defining ftell to ftello yourself,
1677  * however, because operating systems like to do that themself. */
1678 #ifndef FSEEKSIZE
1679 #   ifdef HAS_FSEEKO
1680 #       define FSEEKSIZE LSEEKSIZE
1681 #   else
1682 #       define FSEEKSIZE LONGSIZE
1683 #   endif
1684 #endif
1685
1686 #if defined(USE_LARGE_FILES) && !defined(NO_64_BIT_STDIO)
1687 #   if FSEEKSIZE == 8 && !defined(USE_64_BIT_STDIO)
1688 #       define USE_64_BIT_STDIO /* implicit */
1689 #   endif
1690 #endif
1691
1692 #ifdef USE_64_BIT_RAWIO
1693 #   ifdef HAS_OFF64_T
1694 #       undef Off_t
1695 #       define Off_t off64_t
1696 #       undef LSEEKSIZE
1697 #       define LSEEKSIZE 8
1698 #   endif
1699 /* Most 64-bit environments have defines like _LARGEFILE_SOURCE that
1700  * will trigger defines like the ones below.  Some 64-bit environments,
1701  * however, do not.  Therefore we have to explicitly mix and match. */
1702 #   if defined(USE_OPEN64)
1703 #       define open open64
1704 #   endif
1705 #   if defined(USE_LSEEK64)
1706 #       define lseek lseek64
1707 #   else
1708 #       if defined(USE_LLSEEK)
1709 #           define lseek llseek
1710 #       endif
1711 #   endif
1712 #   if defined(USE_STAT64)
1713 #       define stat stat64
1714 #   endif
1715 #   if defined(USE_FSTAT64)
1716 #       define fstat fstat64
1717 #   endif
1718 #   if defined(USE_LSTAT64)
1719 #       define lstat lstat64
1720 #   endif
1721 #   if defined(USE_FLOCK64)
1722 #       define flock flock64
1723 #   endif
1724 #   if defined(USE_LOCKF64)
1725 #       define lockf lockf64
1726 #   endif
1727 #   if defined(USE_FCNTL64)
1728 #       define fcntl fcntl64
1729 #   endif
1730 #   if defined(USE_TRUNCATE64)
1731 #       define truncate truncate64
1732 #   endif
1733 #   if defined(USE_FTRUNCATE64)
1734 #       define ftruncate ftruncate64
1735 #   endif
1736 #endif
1737
1738 #ifdef USE_64_BIT_STDIO
1739 #   ifdef HAS_FPOS64_T
1740 #       undef Fpos_t
1741 #       define Fpos_t fpos64_t
1742 #   endif
1743 /* Most 64-bit environments have defines like _LARGEFILE_SOURCE that
1744  * will trigger defines like the ones below.  Some 64-bit environments,
1745  * however, do not. */
1746 #   if defined(USE_FOPEN64)
1747 #       define fopen fopen64
1748 #   endif
1749 #   if defined(USE_FSEEK64)
1750 #       define fseek fseek64 /* don't do fseeko here, see perlio.c */
1751 #   endif
1752 #   if defined(USE_FTELL64)
1753 #       define ftell ftell64 /* don't do ftello here, see perlio.c */
1754 #   endif
1755 #   if defined(USE_FSETPOS64)
1756 #       define fsetpos fsetpos64
1757 #   endif
1758 #   if defined(USE_FGETPOS64)
1759 #       define fgetpos fgetpos64
1760 #   endif
1761 #   if defined(USE_TMPFILE64)
1762 #       define tmpfile tmpfile64
1763 #   endif
1764 #   if defined(USE_FREOPEN64)
1765 #       define freopen freopen64
1766 #   endif
1767 #endif
1768
1769 #if defined(OS2)
1770 #  include "iperlsys.h"
1771 #endif
1772
1773 #if defined(__OPEN_VM)
1774 # include "vmesa/vmesaish.h"
1775 #endif
1776
1777 #ifdef DOSISH
1778 # if defined(OS2)
1779 #   include "os2ish.h"
1780 # else
1781 #   include "dosish.h"
1782 # endif
1783 #else
1784 # if defined(VMS)
1785 #   include "vmsish.h"
1786 # else
1787 #   if defined(PLAN9)
1788 #     include "./plan9/plan9ish.h"
1789 #   else
1790 #     if defined(MPE)
1791 #       include "mpeix/mpeixish.h"
1792 #     else
1793 #       if defined(__VOS__)
1794 #         include "vosish.h"
1795 #       else
1796 #         if defined(EPOC)
1797 #           include "epocish.h"
1798 #         else
1799 #           if defined(MACOS_TRADITIONAL)
1800 #             include "macos/macish.h"
1801 #             ifndef NO_ENVIRON_ARRAY
1802 #               define NO_ENVIRON_ARRAY
1803 #             endif
1804 #           else
1805 #             include "unixish.h"
1806 #           endif
1807 #         endif
1808 #       endif
1809 #     endif
1810 #   endif
1811 # endif
1812 #endif
1813
1814 #ifndef NO_ENVIRON_ARRAY
1815 #  define USE_ENVIRON_ARRAY
1816 #endif
1817
1818 #ifdef JPL
1819     /* E.g. JPL needs to operate on a copy of the real environment.
1820      * JDK 1.2 and 1.3 seem to get upset if the original environment
1821      * is diddled with. */
1822 #   define NEED_ENVIRON_DUP_FOR_MODIFY
1823 #endif
1824
1825 /*
1826  * initialise to avoid floating-point exceptions from overflow, etc
1827  */
1828 #ifndef PERL_FPU_INIT
1829 #  ifdef HAS_FPSETMASK
1830 #    if HAS_FLOATINGPOINT_H
1831 #      include <floatingpoint.h>
1832 #    endif
1833 #    define PERL_FPU_INIT fpsetmask(0);
1834 #  else
1835 #    if defined(SIGFPE) && defined(SIG_IGN)
1836 #      define PERL_FPU_INIT signal(SIGFPE, SIG_IGN);
1837 #    else
1838 #      define PERL_FPU_INIT
1839 #    endif
1840 #  endif
1841 #endif
1842
1843 #ifndef PERL_SYS_INIT3
1844 #  define PERL_SYS_INIT3(argvp,argcp,envp) PERL_SYS_INIT(argvp,argcp)
1845 #endif
1846
1847 #ifndef PERL_WRITE_MSG_TO_CONSOLE
1848 #  define PERL_WRITE_MSG_TO_CONSOLE(io, msg, len) PerlIO_write(io, msg, len)
1849 #endif
1850
1851 #ifndef MAXPATHLEN
1852 #  ifdef PATH_MAX
1853 #    ifdef _POSIX_PATH_MAX
1854 #       if PATH_MAX > _POSIX_PATH_MAX
1855 /* MAXPATHLEN is supposed to include the final null character,
1856  * as opposed to PATH_MAX and _POSIX_PATH_MAX. */
1857 #         define MAXPATHLEN (PATH_MAX+1)
1858 #       else
1859 #         define MAXPATHLEN (_POSIX_PATH_MAX+1)
1860 #       endif
1861 #    else
1862 #      define MAXPATHLEN (PATH_MAX+1)
1863 #    endif
1864 #  else
1865 #    ifdef _POSIX_PATH_MAX
1866 #       define MAXPATHLEN (_POSIX_PATH_MAX+1)
1867 #    else
1868 #       define MAXPATHLEN 1024  /* Err on the large side. */
1869 #    endif
1870 #  endif
1871 #endif
1872
1873 /*
1874  * USE_5005THREADS needs to be after unixish.h as <pthread.h> includes
1875  * <sys/signal.h> which defines NSIG - which will stop inclusion of <signal.h>
1876  * this results in many functions being undeclared which bothers C++
1877  * May make sense to have threads after "*ish.h" anyway
1878  */
1879
1880 #if defined(USE_5005THREADS) || defined(USE_ITHREADS)
1881 #  if defined(USE_5005THREADS)
1882    /* pending resolution of licensing issues, we avoid the erstwhile
1883     * atomic.h everywhere */
1884 #  define EMULATE_ATOMIC_REFCOUNTS
1885 #  endif
1886 #  ifdef NETWARE
1887 #   include <nw5thread.h>
1888 #  else
1889 #  ifdef FAKE_THREADS
1890 #    include "fakethr.h"
1891 #  else
1892 #    ifdef WIN32
1893 #      include <win32thread.h>
1894 #    else
1895 #      ifdef OS2
1896 #        include "os2thread.h"
1897 #      else
1898 #        ifdef I_MACH_CTHREADS
1899 #          include <mach/cthreads.h>
1900 #          if (defined(NeXT) || defined(__NeXT__)) && defined(PERL_POLLUTE_MALLOC)
1901 #            define MUTEX_INIT_CALLS_MALLOC
1902 #          endif
1903 typedef cthread_t       perl_os_thread;
1904 typedef mutex_t         perl_mutex;
1905 typedef condition_t     perl_cond;
1906 typedef void *          perl_key;
1907 #        else /* Posix threads */
1908 #          ifdef I_PTHREAD
1909 #            include <pthread.h>
1910 #          endif
1911 typedef pthread_t       perl_os_thread;
1912 typedef pthread_mutex_t perl_mutex;
1913 typedef pthread_cond_t  perl_cond;
1914 typedef pthread_key_t   perl_key;
1915 #        endif /* I_MACH_CTHREADS */
1916 #      endif /* OS2 */
1917 #    endif /* WIN32 */
1918 #  endif /* FAKE_THREADS */
1919 #endif  /* NETWARE */
1920 #endif /* USE_5005THREADS || USE_ITHREADS */
1921
1922 #ifdef WIN32
1923 #  include "win32.h"
1924 #endif
1925
1926 #ifdef NETWARE
1927 #  include "netware.h"
1928 #endif
1929
1930 #ifdef VMS
1931 #   define STATUS_NATIVE        PL_statusvalue_vms
1932 #   define STATUS_NATIVE_EXPORT \
1933         (((I32)PL_statusvalue_vms == -1 ? 44 : PL_statusvalue_vms) | (VMSISH_HUSHED ? 0x10000000 : 0))
1934 #   define STATUS_NATIVE_SET(n)                                         \
1935         STMT_START {                                                    \
1936             PL_statusvalue_vms = (n);                                   \
1937             if ((I32)PL_statusvalue_vms == -1)                          \
1938                 PL_statusvalue = -1;                                    \
1939             else if (PL_statusvalue_vms & STS$M_SUCCESS)                \
1940                 PL_statusvalue = 0;                                     \
1941             else if ((PL_statusvalue_vms & STS$M_SEVERITY) == 0)        \
1942                 PL_statusvalue = 1 << 8;                                \
1943             else                                                        \
1944                 PL_statusvalue = (PL_statusvalue_vms & STS$M_SEVERITY) << 8;    \
1945         } STMT_END
1946 #   define STATUS_POSIX PL_statusvalue
1947 #   ifdef VMSISH_STATUS
1948 #       define STATUS_CURRENT   (VMSISH_STATUS ? STATUS_NATIVE : STATUS_POSIX)
1949 #   else
1950 #       define STATUS_CURRENT   STATUS_POSIX
1951 #   endif
1952 #   define STATUS_POSIX_SET(n)                          \
1953         STMT_START {                                    \
1954             PL_statusvalue = (n);                               \
1955             if (PL_statusvalue != -1) {                 \
1956                 PL_statusvalue &= 0xFFFF;                       \
1957                 PL_statusvalue_vms = PL_statusvalue ? 44 : 1;   \
1958             }                                           \
1959             else PL_statusvalue_vms = -1;                       \
1960         } STMT_END
1961 #   define STATUS_ALL_SUCCESS   (PL_statusvalue = 0, PL_statusvalue_vms = 1)
1962 #   define STATUS_ALL_FAILURE   (PL_statusvalue = 1, PL_statusvalue_vms = 44)
1963 #else
1964 #   define STATUS_NATIVE        STATUS_POSIX
1965 #   define STATUS_NATIVE_EXPORT STATUS_POSIX
1966 #   define STATUS_NATIVE_SET    STATUS_POSIX_SET
1967 #   define STATUS_POSIX         PL_statusvalue
1968 #   define STATUS_POSIX_SET(n)          \
1969         STMT_START {                    \
1970             PL_statusvalue = (n);               \
1971             if (PL_statusvalue != -1)   \
1972                 PL_statusvalue &= 0xFFFF;       \
1973         } STMT_END
1974 #   define STATUS_CURRENT STATUS_POSIX
1975 #   define STATUS_ALL_SUCCESS   (PL_statusvalue = 0)
1976 #   define STATUS_ALL_FAILURE   (PL_statusvalue = 1)
1977 #endif
1978
1979 /* flags in PL_exit_flags for nature of exit() */
1980 #define PERL_EXIT_EXPECTED      0x01
1981 #define PERL_EXIT_DESTRUCT_END  0x02  /* Run END in perl_destruct */
1982
1983 #ifndef MEMBER_TO_FPTR
1984 #  define MEMBER_TO_FPTR(name)          name
1985 #endif
1986
1987 /* format to use for version numbers in file/directory names */
1988 /* XXX move to Configure? */
1989 #ifndef PERL_FS_VER_FMT
1990 #  define PERL_FS_VER_FMT       "%d.%d.%d"
1991 #endif
1992
1993 /* This defines a way to flush all output buffers.  This may be a
1994  * performance issue, so we allow people to disable it.  Also, if
1995  * we are using stdio, there are broken implementations of fflush(NULL)
1996  * out there, Solaris being the most prominent.
1997  */
1998 #ifndef PERL_FLUSHALL_FOR_CHILD
1999 # if defined(USE_PERLIO) || defined(FFLUSH_NULL) || defined(USE_SFIO)
2000 #  define PERL_FLUSHALL_FOR_CHILD       PerlIO_flush((PerlIO*)NULL)
2001 # else
2002 #  ifdef FFLUSH_ALL
2003 #   define PERL_FLUSHALL_FOR_CHILD      my_fflush_all()
2004 #  else
2005 #   define PERL_FLUSHALL_FOR_CHILD      NOOP
2006 #  endif
2007 # endif
2008 #endif
2009
2010 #ifndef PERL_WAIT_FOR_CHILDREN
2011 #  define PERL_WAIT_FOR_CHILDREN        NOOP
2012 #endif
2013
2014 /* the traditional thread-unsafe notion of "current interpreter". */
2015 #ifndef PERL_SET_INTERP
2016 #  define PERL_SET_INTERP(i)            (PL_curinterp = (PerlInterpreter*)(i))
2017 #endif
2018
2019 #ifndef PERL_GET_INTERP
2020 #  define PERL_GET_INTERP               (PL_curinterp)
2021 #endif
2022
2023 #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_GET_THX)
2024 #  ifdef USE_5005THREADS
2025 #    define PERL_GET_THX                ((struct perl_thread *)PERL_GET_CONTEXT)
2026 #  else
2027 #  ifdef MULTIPLICITY
2028 #    define PERL_GET_THX                ((PerlInterpreter *)PERL_GET_CONTEXT)
2029 #  endif
2030 #  endif
2031 #  define PERL_SET_THX(t)               PERL_SET_CONTEXT(t)
2032 #endif
2033
2034 #ifndef SVf
2035 #  ifdef CHECK_FORMAT
2036 #    define SVf "p"
2037 #  else
2038 #    define SVf "_"
2039 #  endif
2040 #endif
2041
2042 #ifndef UVf
2043 #  ifdef CHECK_FORMAT
2044 #    define UVf UVuf
2045 #  else
2046 #    define UVf "Vu"
2047 #  endif
2048 #endif
2049
2050 #ifndef VDf
2051 #  ifdef CHECK_FORMAT
2052 #    define VDf "p"
2053 #  else
2054 #    define VDf "vd"
2055 #  endif
2056 #endif
2057
2058 #ifndef Nullformat
2059 #  ifdef CHECK_FORMAT
2060 #    define Nullformat "%s",""
2061 #  else
2062 #    define Nullformat Nullch
2063 #  endif
2064 #endif
2065
2066 /* Some unistd.h's give a prototype for pause() even though
2067    HAS_PAUSE ends up undefined.  This causes the #define
2068    below to be rejected by the compiler.  Sigh.
2069 */
2070 #ifdef HAS_PAUSE
2071 #define Pause   pause
2072 #else
2073 #define Pause() sleep((32767<<16)+32767)
2074 #endif
2075
2076 #ifndef IOCPARM_LEN
2077 #   ifdef IOCPARM_MASK
2078         /* on BSDish systes we're safe */
2079 #       define IOCPARM_LEN(x)  (((x) >> 16) & IOCPARM_MASK)
2080 #   else
2081         /* otherwise guess at what's safe */
2082 #       define IOCPARM_LEN(x)   256
2083 #   endif
2084 #endif
2085
2086 #if defined(__CYGWIN__)
2087 /* USEMYBINMODE
2088  *   This symbol, if defined, indicates that the program should
2089  *   use the routine my_binmode(FILE *fp, char iotype, int mode) to insure
2090  *   that a file is in "binary" mode -- that is, that no translation
2091  *   of bytes occurs on read or write operations.
2092  */
2093 #  define USEMYBINMODE / **/
2094 #  define my_binmode(fp, iotype, mode) \
2095             (PerlLIO_setmode(PerlIO_fileno(fp), mode) != -1 ? TRUE : FALSE)
2096 #endif
2097
2098 #ifdef UNION_ANY_DEFINITION
2099 UNION_ANY_DEFINITION;
2100 #else
2101 union any {
2102     void*       any_ptr;
2103     I32         any_i32;
2104     IV          any_iv;
2105     long        any_long;
2106     void        (*any_dptr) (void*);
2107     void        (*any_dxptr) (pTHX_ void*);
2108 };
2109 #endif
2110
2111 #ifdef USE_5005THREADS
2112 #define ARGSproto struct perl_thread *thr
2113 #else
2114 #define ARGSproto
2115 #endif /* USE_5005THREADS */
2116
2117 typedef I32 (*filter_t) (pTHX_ int, SV *, int);
2118
2119 #define FILTER_READ(idx, sv, len)  filter_read(idx, sv, len)
2120 #define FILTER_DATA(idx)           (AvARRAY(PL_rsfp_filters)[idx])
2121 #define FILTER_ISREADER(idx)       (idx >= AvFILLp(PL_rsfp_filters))
2122
2123 #if !defined(OS2)
2124 #  include "iperlsys.h"
2125 #endif
2126 #include "regexp.h"
2127 #include "sv.h"
2128 #include "util.h"
2129 #include "form.h"
2130 #include "gv.h"
2131 #include "cv.h"
2132 #include "opnames.h"
2133 #include "op.h"
2134 #include "cop.h"
2135 #include "av.h"
2136 #include "hv.h"
2137 #include "mg.h"
2138 #include "scope.h"
2139 #include "warnings.h"
2140 #include "utf8.h"
2141 #include "sharedsv.h"
2142
2143 /* Current curly descriptor */
2144 typedef struct curcur CURCUR;
2145 struct curcur {
2146     int         parenfloor;     /* how far back to strip paren data */
2147     int         cur;            /* how many instances of scan we've matched */
2148     int         min;            /* the minimal number of scans to match */
2149     int         max;            /* the maximal number of scans to match */
2150     int         minmod;         /* whether to work our way up or down */
2151     regnode *   scan;           /* the thing to match */
2152     regnode *   next;           /* what has to match after it */
2153     char *      lastloc;        /* where we started matching this scan */
2154     CURCUR *    oldcc;          /* current curly before we started this one */
2155 };
2156
2157 typedef struct _sublex_info SUBLEXINFO;
2158 struct _sublex_info {
2159     I32 super_state;    /* lexer state to save */
2160     I32 sub_inwhat;     /* "lex_inwhat" to use */
2161     OP *sub_op;         /* "lex_op" to use */
2162     char *super_bufptr; /* PL_bufptr that was */
2163     char *super_bufend; /* PL_bufend that was */
2164 };
2165
2166 typedef struct magic_state MGS; /* struct magic_state defined in mg.c */
2167
2168 struct scan_data_t;             /* Used in S_* functions in regcomp.c */
2169 struct regnode_charclass_class; /* Used in S_* functions in regcomp.c */
2170
2171 typedef I32 CHECKPOINT;
2172
2173 struct ptr_tbl_ent {
2174     struct ptr_tbl_ent*         next;
2175     void*                       oldval;
2176     void*                       newval;
2177 };
2178
2179 struct ptr_tbl {
2180     struct ptr_tbl_ent**        tbl_ary;
2181     UV                          tbl_max;
2182     UV                          tbl_items;
2183 };
2184
2185 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
2186 #   define I286
2187 #endif
2188
2189 #if defined(htonl) && !defined(HAS_HTONL)
2190 #define HAS_HTONL
2191 #endif
2192 #if defined(htons) && !defined(HAS_HTONS)
2193 #define HAS_HTONS
2194 #endif
2195 #if defined(ntohl) && !defined(HAS_NTOHL)
2196 #define HAS_NTOHL
2197 #endif
2198 #if defined(ntohs) && !defined(HAS_NTOHS)
2199 #define HAS_NTOHS
2200 #endif
2201 #ifndef HAS_HTONL
2202 #if (BYTEORDER & 0xffff) != 0x4321
2203 #define HAS_HTONS
2204 #define HAS_HTONL
2205 #define HAS_NTOHS
2206 #define HAS_NTOHL
2207 #define MYSWAP
2208 #define htons my_swap
2209 #define htonl my_htonl
2210 #define ntohs my_swap
2211 #define ntohl my_ntohl
2212 #endif
2213 #else
2214 #if (BYTEORDER & 0xffff) == 0x4321
2215 #undef HAS_HTONS
2216 #undef HAS_HTONL
2217 #undef HAS_NTOHS
2218 #undef HAS_NTOHL
2219 #endif
2220 #endif
2221
2222 /*
2223  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
2224  * -DWS
2225  */
2226 #if BYTEORDER != 0x1234
2227 # define HAS_VTOHL
2228 # define HAS_VTOHS
2229 # define HAS_HTOVL
2230 # define HAS_HTOVS
2231 # if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
2232 #  define vtohl(x)      ((((x)&0xFF)<<24)       \
2233                         +(((x)>>24)&0xFF)       \
2234                         +(((x)&0x0000FF00)<<8)  \
2235                         +(((x)&0x00FF0000)>>8)  )
2236 #  define vtohs(x)      ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
2237 #  define htovl(x)      vtohl(x)
2238 #  define htovs(x)      vtohs(x)
2239 # endif
2240         /* otherwise default to functions in util.c */
2241 #endif
2242
2243 /* *MAX Plus 1. A floating point value.
2244    Hopefully expressed in a way that dodgy floating point can't mess up.
2245    >> 2 rather than 1, so that value is safely less than I32_MAX after 1
2246    is added to it
2247    May find that some broken compiler will want the value cast to I32.
2248    [after the shift, as signed >> may not be as secure as unsigned >>]
2249 */
2250 #define I32_MAX_P1 (2.0 * (1 + (((U32)I32_MAX) >> 1)))
2251 #define U32_MAX_P1 (4.0 * (1 + ((U32_MAX) >> 2)))
2252 /* For compilers that can't correctly cast NVs over 0x7FFFFFFF (or
2253    0x7FFFFFFFFFFFFFFF) to an unsigned integer. In the future, sizeof(UV)
2254    may be greater than sizeof(IV), so don't assume that half max UV is max IV.
2255 */
2256 #define U32_MAX_P1_HALF (2.0 * (1 + ((U32_MAX) >> 2)))
2257
2258 #define UV_MAX_P1 (4.0 * (1 + ((UV_MAX) >> 2)))
2259 #define IV_MAX_P1 (2.0 * (1 + (((UV)IV_MAX) >> 1)))
2260 #define UV_MAX_P1_HALF (2.0 * (1 + ((UV_MAX) >> 2)))
2261
2262 /* This may look like unnecessary jumping through hoops, but converting
2263    out of range floating point values to integers *is* undefined behaviour,
2264    and it is starting to bite.
2265 */
2266 #ifndef CAST_INLINE
2267 #define I_32(what) (cast_i32((NV)(what)))
2268 #define U_32(what) (cast_ulong((NV)(what)))
2269 #define I_V(what) (cast_iv((NV)(what)))
2270 #define U_V(what) (cast_uv((NV)(what)))
2271 #else
2272 #define I_32(n) ((n) < I32_MAX_P1 ? ((n) < I32_MIN ? I32_MIN : (I32) (n)) \
2273                   : ((n) < U32_MAX_P1 ? (I32)(U32) (n) \
2274                      : ((n) > 0 ? (I32) U32_MAX : 0 /* NaN */)))
2275 #define U_32(n) ((n) < 0.0 ? ((n) < I32_MIN ? (UV) I32_MIN : (U32)(I32) (n)) \
2276                   : ((n) < U32_MAX_P1 ? (U32) (n) \
2277                      : ((n) > 0 ? U32_MAX : 0 /* NaN */)))
2278 #define I_V(n) ((n) < IV_MAX_P1 ? ((n) < IV_MIN ? IV_MIN : (IV) (n)) \
2279                   : ((n) < UV_MAX_P1 ? (IV)(UV) (n) \
2280                      : ((n) > 0 ? (IV)UV_MAX : 0 /* NaN */)))
2281 #define U_V(n) ((n) < 0.0 ? ((n) < IV_MIN ? (UV) IV_MIN : (UV)(IV) (n)) \
2282                   : ((n) < UV_MAX_P1 ? (UV) (n) \
2283                      : ((n) > 0 ? UV_MAX : 0 /* NaN */)))
2284 #endif
2285
2286 #define U_S(what) ((U16)U_32(what))
2287 #define U_I(what) ((unsigned int)U_32(what))
2288 #define U_L(what) U_32(what)
2289
2290 /* These do not care about the fractional part, only about the range. */
2291 #define NV_WITHIN_IV(nv) (I_V(nv) >= IV_MIN && I_V(nv) <= IV_MAX)
2292 #define NV_WITHIN_UV(nv) ((nv)>=0.0 && U_V(nv) >= UV_MIN && U_V(nv) <= UV_MAX)
2293
2294 /* Used with UV/IV arguments: */
2295                                         /* XXXX: need to speed it up */
2296 #define CLUMP_2UV(iv)   ((iv) < 0 ? 0 : (UV)(iv))
2297 #define CLUMP_2IV(uv)   ((uv) > (UV)IV_MAX ? IV_MAX : (IV)(uv))
2298
2299 #ifndef MAXSYSFD
2300 #   define MAXSYSFD 2
2301 #endif
2302
2303 #ifndef __cplusplus
2304 #ifndef UNDER_CE
2305 Uid_t getuid (void);
2306 Uid_t geteuid (void);
2307 Gid_t getgid (void);
2308 Gid_t getegid (void);
2309 #endif
2310 #endif
2311
2312 #ifndef Perl_debug_log
2313 #  define Perl_debug_log        PerlIO_stderr()
2314 #endif
2315
2316 #ifndef Perl_error_log
2317 #  define Perl_error_log        (PL_stderrgv                    \
2318                                  && GvIOp(PL_stderrgv)          \
2319                                  && IoOFP(GvIOp(PL_stderrgv))   \
2320                                  ? IoOFP(GvIOp(PL_stderrgv))    \
2321                                  : PerlIO_stderr())
2322 #endif
2323
2324
2325 #define DEBUG_p_FLAG            0x00000001 /*      1 */
2326 #define DEBUG_s_FLAG            0x00000002 /*      2 */
2327 #define DEBUG_l_FLAG            0x00000004 /*      4 */
2328 #define DEBUG_t_FLAG            0x00000008 /*      8 */
2329 #define DEBUG_o_FLAG            0x00000010 /*     16 */
2330 #define DEBUG_c_FLAG            0x00000020 /*     32 */
2331 #define DEBUG_P_FLAG            0x00000040 /*     64 */
2332 #define DEBUG_m_FLAG            0x00000080 /*    128 */
2333 #define DEBUG_f_FLAG            0x00000100 /*    256 */
2334 #define DEBUG_r_FLAG            0x00000200 /*    512 */
2335 #define DEBUG_x_FLAG            0x00000400 /*   1024 */
2336 #define DEBUG_u_FLAG            0x00000800 /*   2048 */
2337 #define DEBUG_L_FLAG            0x00001000 /*   4096 */
2338 #define DEBUG_H_FLAG            0x00002000 /*   8192 */
2339 #define DEBUG_X_FLAG            0x00004000 /*  16384 */
2340 #define DEBUG_D_FLAG            0x00008000 /*  32768 */
2341 #define DEBUG_S_FLAG            0x00010000 /*  65536 */
2342 #define DEBUG_T_FLAG            0x00020000 /* 131072 */
2343 #define DEBUG_R_FLAG            0x00040000 /* 262144 */
2344 #define DEBUG_MASK              0x0007FFFF /* mask of all the standard flags */
2345
2346 #define DEBUG_DB_RECURSE_FLAG   0x40000000
2347 #define DEBUG_TOP_FLAG          0x80000000 /* XXX what's this for ??? */
2348
2349
2350 #ifdef DEBUGGING
2351
2352 #  undef  YYDEBUG
2353 #  define YYDEBUG 1
2354
2355 #  define DEBUG_p_TEST (PL_debug & DEBUG_p_FLAG)
2356 #  define DEBUG_s_TEST (PL_debug & DEBUG_s_FLAG)
2357 #  define DEBUG_l_TEST (PL_debug & DEBUG_l_FLAG)
2358 #  define DEBUG_t_TEST (PL_debug & DEBUG_t_FLAG)
2359 #  define DEBUG_o_TEST (PL_debug & DEBUG_o_FLAG)
2360 #  define DEBUG_c_TEST (PL_debug & DEBUG_c_FLAG)
2361 #  define DEBUG_P_TEST (PL_debug & DEBUG_P_FLAG)
2362 #  define DEBUG_m_TEST (PL_debug & DEBUG_m_FLAG)
2363 #  define DEBUG_f_TEST (PL_debug & DEBUG_f_FLAG)
2364 #  define DEBUG_r_TEST (PL_debug & DEBUG_r_FLAG)
2365 #  define DEBUG_x_TEST (PL_debug & DEBUG_x_FLAG)
2366 #  define DEBUG_u_TEST (PL_debug & DEBUG_u_FLAG)
2367 #  define DEBUG_L_TEST (PL_debug & DEBUG_L_FLAG)
2368 #  define DEBUG_H_TEST (PL_debug & DEBUG_H_FLAG)
2369 #  define DEBUG_X_TEST (PL_debug & DEBUG_X_FLAG)
2370 #  define DEBUG_D_TEST (PL_debug & DEBUG_D_FLAG)
2371 #  define DEBUG_S_TEST (PL_debug & DEBUG_S_FLAG)
2372 #  define DEBUG_T_TEST (PL_debug & DEBUG_T_FLAG)
2373 #  define DEBUG_R_TEST (PL_debug & DEBUG_R_FLAG)
2374
2375 #  define DEB(a)     a
2376 #  define DEBUG(a)   if (PL_debug)   a
2377 #  define DEBUG_p(a) if (DEBUG_p_TEST) a
2378 #  define DEBUG_s(a) if (DEBUG_s_TEST) a
2379 #  define DEBUG_l(a) if (DEBUG_l_TEST) a
2380 #  define DEBUG_t(a) if (DEBUG_t_TEST) a
2381 #  define DEBUG_o(a) if (DEBUG_o_TEST) a
2382 #  define DEBUG_c(a) if (DEBUG_c_TEST) a
2383 #  define DEBUG_P(a) if (DEBUG_P_TEST) a
2384
2385      /* Temporarily turn off memory debugging in case the a
2386       * does memory allocation, either directly or indirectly. */
2387 #  define DEBUG_m(a)  \
2388     STMT_START {                                                        \
2389         if (PERL_GET_INTERP) { dTHX; if (DEBUG_m_TEST) {PL_debug&=~DEBUG_m_FLAG; a; PL_debug|=DEBUG_m_FLAG;} } \
2390     } STMT_END
2391
2392 #  define DEBUG__(t, a) \
2393         STMT_START { \
2394                 if (t) STMT_START {a;} STMT_END; \
2395         } STMT_END
2396
2397 #  define DEBUG_f(a) DEBUG__(DEBUG_f_TEST, a)
2398 #  define DEBUG_r(a) DEBUG__(DEBUG_r_TEST, a)
2399 #  define DEBUG_x(a) DEBUG__(DEBUG_x_TEST, a)
2400 #  define DEBUG_u(a) DEBUG__(DEBUG_u_TEST, a)
2401 #  define DEBUG_L(a) DEBUG__(DEBUG_L_TEST, a)
2402 #  define DEBUG_H(a) DEBUG__(DEBUG_H_TEST, a)
2403 #  define DEBUG_X(a) DEBUG__(DEBUG_X_TEST, a)
2404 #  define DEBUG_D(a) DEBUG__(DEBUG_D_TEST, a)
2405
2406 #  ifdef USE_5005THREADS
2407 #    define DEBUG_S(a) DEBUG__(DEBUG_S_TEST, a)
2408 #  else
2409 #    define DEBUG_S(a)
2410 #  endif
2411
2412 #  define DEBUG_T(a) DEBUG__(DEBUG_T_TEST, a)
2413 #  define DEBUG_R(a) DEBUG__(DEBUG_R_TEST, a)
2414
2415 #else /* DEBUGGING */
2416
2417 #  define DEBUG_p_TEST (0)
2418 #  define DEBUG_s_TEST (0)
2419 #  define DEBUG_l_TEST (0)
2420 #  define DEBUG_t_TEST (0)
2421 #  define DEBUG_o_TEST (0)
2422 #  define DEBUG_c_TEST (0)
2423 #  define DEBUG_P_TEST (0)
2424 #  define DEBUG_m_TEST (0)
2425 #  define DEBUG_f_TEST (0)
2426 #  define DEBUG_r_TEST (0)
2427 #  define DEBUG_x_TEST (0)
2428 #  define DEBUG_u_TEST (0)
2429 #  define DEBUG_L_TEST (0)
2430 #  define DEBUG_H_TEST (0)
2431 #  define DEBUG_X_TEST (0)
2432 #  define DEBUG_D_TEST (0)
2433 #  define DEBUG_S_TEST (0)
2434 #  define DEBUG_T_TEST (0)
2435 #  define DEBUG_R_TEST (0)
2436
2437 #  define DEB(a)
2438 #  define DEBUG(a)
2439 #  define DEBUG_p(a)
2440 #  define DEBUG_s(a)
2441 #  define DEBUG_l(a)
2442 #  define DEBUG_t(a)
2443 #  define DEBUG_o(a)
2444 #  define DEBUG_c(a)
2445 #  define DEBUG_P(a)
2446 #  define DEBUG_m(a)
2447 #  define DEBUG_f(a)
2448 #  define DEBUG_r(a)
2449 #  define DEBUG_x(a)
2450 #  define DEBUG_u(a)
2451 #  define DEBUG_L(a)
2452 #  define DEBUG_H(a)
2453 #  define DEBUG_X(a)
2454 #  define DEBUG_D(a)
2455 #  define DEBUG_S(a)
2456 #  define DEBUG_T(a)
2457 #  define DEBUG_R(a)
2458 #endif /* DEBUGGING */
2459
2460
2461 /* These constants should be used in preference to to raw characters
2462  * when using magic. Note that some perl guts still assume
2463  * certain character properties of these constants, namely that
2464  * isUPPER() and toLOWER() may do useful mappings.
2465  *
2466  * Update the magic_names table in dump.c when adding/amending these
2467  */
2468
2469 #define PERL_MAGIC_sv             '\0' /* Special scalar variable */
2470 #define PERL_MAGIC_overload       'A' /* %OVERLOAD hash */
2471 #define PERL_MAGIC_overload_elem  'a' /* %OVERLOAD hash element */
2472 #define PERL_MAGIC_overload_table 'c' /* Holds overload table (AMT) on stash */
2473 #define PERL_MAGIC_bm             'B' /* Boyer-Moore (fast string search) */
2474 #define PERL_MAGIC_regdata        'D' /* Regex match position data
2475                                         (@+ and @- vars) */
2476 #define PERL_MAGIC_regdatum       'd' /* Regex match position data element */
2477 #define PERL_MAGIC_env            'E' /* %ENV hash */
2478 #define PERL_MAGIC_envelem        'e' /* %ENV hash element */
2479 #define PERL_MAGIC_fm             'f' /* Formline ('compiled' format) */
2480 #define PERL_MAGIC_regex_global   'g' /* m//g target / study()ed string */
2481 #define PERL_MAGIC_isa            'I' /* @ISA array */
2482 #define PERL_MAGIC_isaelem        'i' /* @ISA array element */
2483 #define PERL_MAGIC_nkeys          'k' /* scalar(keys()) lvalue */
2484 #define PERL_MAGIC_dbfile         'L' /* Debugger %_<filename */
2485 #define PERL_MAGIC_dbline         'l' /* Debugger %_<filename element */
2486 #define PERL_MAGIC_mutex          'm' /* ??? */
2487 #define PERL_MAGIC_collxfrm       'o' /* Locale transformation */
2488 #define PERL_MAGIC_tied           'P' /* Tied array or hash */
2489 #define PERL_MAGIC_tiedelem       'p' /* Tied array or hash element */
2490 #define PERL_MAGIC_tiedscalar     'q' /* Tied scalar or handle */
2491 #define PERL_MAGIC_qr             'r' /* precompiled qr// regex */
2492 #define PERL_MAGIC_sig            'S' /* %SIG hash */
2493 #define PERL_MAGIC_sigelem        's' /* %SIG hash element */
2494 #define PERL_MAGIC_taint          't' /* Taintedness */
2495 #define PERL_MAGIC_uvar           'U' /* Available for use by extensions */
2496 #define PERL_MAGIC_vec            'v' /* vec() lvalue */
2497 #define PERL_MAGIC_substr         'x' /* substr() lvalue */
2498 #define PERL_MAGIC_defelem        'y' /* Shadow "foreach" iterator variable /
2499                                         smart parameter vivification */
2500 #define PERL_MAGIC_glob           '*' /* GV (typeglob) */
2501 #define PERL_MAGIC_arylen         '#' /* Array length ($#ary) */
2502 #define PERL_MAGIC_pos            '.' /* pos() lvalue */
2503 #define PERL_MAGIC_backref        '<' /* ??? */
2504 #define PERL_MAGIC_ext            '~' /* Available for use by extensions */
2505
2506
2507 #define YYMAXDEPTH 300
2508
2509 #ifndef assert  /* <assert.h> might have been included somehow */
2510 #define assert(what)    DEB( {                                          \
2511         if (!(what)) {                                                  \
2512             Perl_croak(aTHX_ "Assertion failed: file \"%s\", line %d",  \
2513                 __FILE__, __LINE__);                                    \
2514             PerlProc_exit(1);                                           \
2515         }})
2516 #endif
2517
2518 struct ufuncs {
2519     I32 (*uf_val)(pTHX_ IV, SV*);
2520     I32 (*uf_set)(pTHX_ IV, SV*);
2521     IV uf_index;
2522 };
2523
2524 /* In pre-5.7-Perls the PERL_MAGIC_uvar magic didn't get the thread context.
2525  * XS code wanting to be backward compatible can do something
2526  * like the following:
2527
2528 #ifndef PERL_MG_UFUNC
2529 #define PERL_MG_UFUNC(name,ix,sv) I32 name(IV ix, SV *sv)
2530 #endif
2531
2532 static PERL_MG_UFUNC(foo_get, index, val)
2533 {
2534     sv_setsv(val, ...);
2535     return TRUE;
2536 }
2537
2538 -- Doug MacEachern
2539
2540 */
2541
2542 #ifndef PERL_MG_UFUNC
2543 #define PERL_MG_UFUNC(name,ix,sv) I32 name(pTHX_ IV ix, SV *sv)
2544 #endif
2545
2546 /* Fix these up for __STDC__ */
2547 #ifndef DONT_DECLARE_STD
2548 char *mktemp (char*);
2549 #ifndef atof
2550 double atof (const char*);
2551 #endif
2552 #endif
2553
2554 #ifndef STANDARD_C
2555 /* All of these are in stdlib.h or time.h for ANSI C */
2556 Time_t time();
2557 struct tm *gmtime(), *localtime();
2558 #if defined(OEMVS) || defined(__OPEN_VM)
2559 char *(strchr)(), *(strrchr)();
2560 char *(strcpy)(), *(strcat)();
2561 #else
2562 char *strchr(), *strrchr();
2563 char *strcpy(), *strcat();
2564 #endif
2565 #endif /* ! STANDARD_C */
2566
2567
2568 #ifdef I_MATH
2569 #    include <math.h>
2570 #else
2571 START_EXTERN_C
2572             double exp (double);
2573             double log (double);
2574             double log10 (double);
2575             double sqrt (double);
2576             double frexp (double,int*);
2577             double ldexp (double,int);
2578             double modf (double,double*);
2579             double sin (double);
2580             double cos (double);
2581             double atan2 (double,double);
2582             double pow (double,double);
2583 END_EXTERN_C
2584 #endif
2585
2586 #if !defined(NV_INF) && defined(USE_LONG_DOUBLE) && defined(LDBL_INFINITY)
2587 #  define NV_INF LDBL_INFINITY
2588 #endif
2589 #if !defined(NV_INF) && defined(DBL_INFINITY)
2590 #  define NV_INF (NV)DBL_INFINITY
2591 #endif
2592 #if !defined(NV_INF) && defined(INFINITY)
2593 #  define NV_INF (NV)INFINITY
2594 #endif
2595 #if !defined(NV_INF) && defined(INF)
2596 #  define NV_INF (NV)INF
2597 #endif
2598 #if !defined(NV_INF) && defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
2599 #  define NV_INF (NV)HUGE_VALL
2600 #endif
2601 #if !defined(NV_INF) && defined(HUGE_VAL)
2602 #  define NV_INF (NV)HUGE_VAL
2603 #endif
2604
2605 #if !defined(NV_NAN) && defined(USE_LONG_DOUBLE)
2606 #   if !defined(NV_NAN) && defined(LDBL_NAN)
2607 #       define NV_NAN LDBL_NAN
2608 #   endif
2609 #   if !defined(NV_NAN) && defined(LDBL_QNAN)
2610 #       define NV_NAN LDBL_QNAN
2611 #   endif
2612 #   if !defined(NV_NAN) && defined(LDBL_SNAN)
2613 #       define NV_NAN LDBL_SNAN
2614 #   endif
2615 #endif
2616 #if !defined(NV_NAN) && defined(DBL_NAN)
2617 #  define NV_NAN (NV)DBL_NAN
2618 #endif
2619 #if !defined(NV_NAN) && defined(DBL_QNAN)
2620 #  define NV_NAN (NV)DBL_QNAN
2621 #endif
2622 #if !defined(NV_NAN) && defined(DBL_SNAN)
2623 #  define NV_NAN (NV)DBL_SNAN
2624 #endif
2625 #if !defined(NV_NAN) && defined(QNAN)
2626 #  define NV_NAN (NV)QNAN
2627 #endif
2628 #if !defined(NV_NAN) && defined(SNAN)
2629 #  define NV_NAN (NV)SNAN
2630 #endif
2631 #if !defined(NV_NAN) && defined(NAN)
2632 #  define NV_NAN (NV)NAN
2633 #endif
2634
2635 #ifndef __cplusplus
2636 #  if defined(NeXT) || defined(__NeXT__) /* or whatever catches all NeXTs */
2637 char *crypt ();       /* Maybe more hosts will need the unprototyped version */
2638 #  else
2639 #    if !defined(WIN32) && !defined(VMS)
2640 char *crypt (const char*, const char*);
2641 #    endif /* !WIN32 */
2642 #  endif /* !NeXT && !__NeXT__ */
2643 #  ifndef DONT_DECLARE_STD
2644 #    ifndef getenv
2645 char *getenv (const char*);
2646 #    endif /* !getenv */
2647 #    if !defined(HAS_LSEEK_PROTO) && !defined(EPOC) && !defined(__hpux)
2648 #      ifdef _FILE_OFFSET_BITS
2649 #        if _FILE_OFFSET_BITS == 64
2650 Off_t lseek (int,Off_t,int);
2651 #        endif
2652 #      endif
2653 #    endif
2654 #  endif /* !DONT_DECLARE_STD */
2655 char *getlogin (void);
2656 #endif /* !__cplusplus */
2657
2658 #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
2659 #define UNLINK unlnk
2660 I32 unlnk (char*);
2661 #else
2662 #define UNLINK PerlLIO_unlink
2663 #endif
2664
2665 /* some versions of glibc are missing the setresuid() proto */
2666 #if defined(HAS_SETRESUID) && !defined(HAS_SETRESUID_PROTO)
2667 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
2668 #endif
2669 /* some versions of glibc are missing the setresgid() proto */
2670 #if defined(HAS_SETRESGID) && !defined(HAS_SETRESGID_PROTO)
2671 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
2672 #endif
2673
2674 #ifndef HAS_SETREUID
2675 #  ifdef HAS_SETRESUID
2676 #    define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
2677 #    define HAS_SETREUID
2678 #  endif
2679 #endif
2680 #ifndef HAS_SETREGID
2681 #  ifdef HAS_SETRESGID
2682 #    define setregid(r,e) setresgid(r,e,(Gid_t)-1)
2683 #    define HAS_SETREGID
2684 #  endif
2685 #endif
2686
2687 /* Sighandler_t defined in iperlsys.h */
2688
2689 #ifdef HAS_SIGACTION
2690 typedef struct sigaction Sigsave_t;
2691 #else
2692 typedef Sighandler_t Sigsave_t;
2693 #endif
2694
2695 #define SCAN_DEF 0
2696 #define SCAN_TR 1
2697 #define SCAN_REPL 2
2698
2699 #ifdef DEBUGGING
2700 # ifndef register
2701 #  define register
2702 # endif
2703 # define PAD_SV(po) pad_sv(po)
2704 # define RUNOPS_DEFAULT Perl_runops_debug
2705 #else
2706 # define PAD_SV(po) PL_curpad[po]
2707 # define RUNOPS_DEFAULT Perl_runops_standard
2708 #endif
2709
2710 #ifdef MYMALLOC
2711 #  ifdef MUTEX_INIT_CALLS_MALLOC
2712 #    define MALLOC_INIT                                 \
2713         STMT_START {                                    \
2714                 PL_malloc_mutex = NULL;                 \
2715                 MUTEX_INIT(&PL_malloc_mutex);           \
2716         } STMT_END
2717 #    define MALLOC_TERM                                 \
2718         STMT_START {                                    \
2719                 perl_mutex tmp = PL_malloc_mutex;       \
2720                 PL_malloc_mutex = NULL;                 \
2721                 MUTEX_DESTROY(&tmp);                    \
2722         } STMT_END
2723 #  else
2724 #    define MALLOC_INIT MUTEX_INIT(&PL_malloc_mutex)
2725 #    define MALLOC_TERM MUTEX_DESTROY(&PL_malloc_mutex)
2726 #  endif
2727 #else
2728 #  define MALLOC_INIT
2729 #  define MALLOC_TERM
2730 #endif
2731
2732
2733 typedef int (CPERLscope(*runops_proc_t)) (pTHX);
2734 typedef OP* (CPERLscope(*PPADDR_t)[]) (pTHX);
2735
2736 /* _ (for $_) must be first in the following list (DEFSV requires it) */
2737 #define THREADSV_NAMES "_123456789&`'+/.,\\\";^-%=|~:\001\005!@"
2738
2739 /* NeXT has problems with crt0.o globals */
2740 #if defined(__DYNAMIC__) && \
2741     (defined(NeXT) || defined(__NeXT__) || defined(__APPLE__))
2742 #  if defined(NeXT) || defined(__NeXT)
2743 #    include <mach-o/dyld.h>
2744 #    define environ (*environ_pointer)
2745 EXT char *** environ_pointer;
2746 #  else
2747 #    if defined(__APPLE__) && defined(PERL_CORE)
2748 #      include <crt_externs.h>  /* for the env array */
2749 #      define environ (*_NSGetEnviron())
2750 #    endif
2751 #  endif
2752 #else
2753    /* VMS and some other platforms don't use the environ array */
2754 #  ifdef USE_ENVIRON_ARRAY
2755 #    if !defined(DONT_DECLARE_STD) || \
2756         (defined(__svr4__) && defined(__GNUC__) && defined(sun)) || \
2757         defined(__sgi) || \
2758         defined(__DGUX)
2759 extern char **  environ;        /* environment variables supplied via exec */
2760 #    endif
2761 #  endif
2762 #endif
2763
2764 START_EXTERN_C
2765
2766 /* handy constants */
2767 EXTCONST char PL_warn_uninit[]
2768   INIT("Use of uninitialized value%s%s");
2769 EXTCONST char PL_warn_nosemi[]
2770   INIT("Semicolon seems to be missing");
2771 EXTCONST char PL_warn_reserved[]
2772   INIT("Unquoted string \"%s\" may clash with future reserved word");
2773 EXTCONST char PL_warn_nl[]
2774   INIT("Unsuccessful %s on filename containing newline");
2775 EXTCONST char PL_no_wrongref[]
2776   INIT("Can't use %s ref as %s ref");
2777 EXTCONST char PL_no_symref[]
2778   INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
2779 EXTCONST char PL_no_usym[]
2780   INIT("Can't use an undefined value as %s reference");
2781 EXTCONST char PL_no_aelem[]
2782   INIT("Modification of non-creatable array value attempted, subscript %d");
2783 EXTCONST char PL_no_helem[]
2784   INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
2785 EXTCONST char PL_no_modify[]
2786   INIT("Modification of a read-only value attempted");
2787 EXTCONST char PL_no_mem[]
2788   INIT("Out of memory!\n");
2789 EXTCONST char PL_no_security[]
2790   INIT("Insecure dependency in %s%s");
2791 EXTCONST char PL_no_sock_func[]
2792   INIT("Unsupported socket function \"%s\" called");
2793 EXTCONST char PL_no_dir_func[]
2794   INIT("Unsupported directory function \"%s\" called");
2795 EXTCONST char PL_no_func[]
2796   INIT("The %s function is unimplemented");
2797 EXTCONST char PL_no_myglob[]
2798   INIT("\"my\" variable %s can't be in a package");
2799
2800 EXTCONST char PL_uuemap[65]
2801   INIT("`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_");
2802
2803
2804 #ifdef DOINIT
2805 EXT char *PL_sig_name[] = { SIG_NAME };
2806 EXT int   PL_sig_num[]  = { SIG_NUM };
2807 #else
2808 EXT char *PL_sig_name[];
2809 EXT int   PL_sig_num[];
2810 #endif
2811
2812 /* fast conversion and case folding tables */
2813
2814 #ifdef DOINIT
2815 #ifdef EBCDIC
2816 EXT unsigned char PL_fold[] = { /* fast EBCDIC case folding table */
2817     0,      1,      2,      3,      4,      5,      6,      7,
2818     8,      9,      10,     11,     12,     13,     14,     15,
2819     16,     17,     18,     19,     20,     21,     22,     23,
2820     24,     25,     26,     27,     28,     29,     30,     31,
2821     32,     33,     34,     35,     36,     37,     38,     39,
2822     40,     41,     42,     43,     44,     45,     46,     47,
2823     48,     49,     50,     51,     52,     53,     54,     55,
2824     56,     57,     58,     59,     60,     61,     62,     63,
2825     64,     65,     66,     67,     68,     69,     70,     71,
2826     72,     73,     74,     75,     76,     77,     78,     79,
2827     80,     81,     82,     83,     84,     85,     86,     87,
2828     88,     89,     90,     91,     92,     93,     94,     95,
2829     96,     97,     98,     99,     100,    101,    102,    103,
2830     104,    105,    106,    107,    108,    109,    110,    111,
2831     112,    113,    114,    115,    116,    117,    118,    119,
2832     120,    121,    122,    123,    124,    125,    126,    127,
2833     128,    'A',    'B',    'C',    'D',    'E',    'F',    'G',
2834     'H',    'I',    138,    139,    140,    141,    142,    143,
2835     144,    'J',    'K',    'L',    'M',    'N',    'O',    'P',
2836     'Q',    'R',    154,    155,    156,    157,    158,    159,
2837     160,    161,    'S',    'T',    'U',    'V',    'W',    'X',
2838     'Y',    'Z',    170,    171,    172,    173,    174,    175,
2839     176,    177,    178,    179,    180,    181,    182,    183,
2840     184,    185,    186,    187,    188,    189,    190,    191,
2841     192,    'a',    'b',    'c',    'd',    'e',    'f',    'g',
2842     'h',    'i',    202,    203,    204,    205,    206,    207,
2843     208,    'j',    'k',    'l',    'm',    'n',    'o',    'p',
2844     'q',    'r',    218,    219,    220,    221,    222,    223,
2845     224,    225,    's',    't',    'u',    'v',    'w',    'x',
2846     'y',    'z',    234,    235,    236,    237,    238,    239,
2847     240,    241,    242,    243,    244,    245,    246,    247,
2848     248,    249,    250,    251,    252,    253,    254,    255
2849 };
2850 #else   /* ascii rather than ebcdic */
2851 EXTCONST  unsigned char PL_fold[] = {
2852         0,      1,      2,      3,      4,      5,      6,      7,
2853         8,      9,      10,     11,     12,     13,     14,     15,
2854         16,     17,     18,     19,     20,     21,     22,     23,
2855         24,     25,     26,     27,     28,     29,     30,     31,
2856         32,     33,     34,     35,     36,     37,     38,     39,
2857         40,     41,     42,     43,     44,     45,     46,     47,
2858         48,     49,     50,     51,     52,     53,     54,     55,
2859         56,     57,     58,     59,     60,     61,     62,     63,
2860         64,     'a',    'b',    'c',    'd',    'e',    'f',    'g',
2861         'h',    'i',    'j',    'k',    'l',    'm',    'n',    'o',
2862         'p',    'q',    'r',    's',    't',    'u',    'v',    'w',
2863         'x',    'y',    'z',    91,     92,     93,     94,     95,
2864         96,     'A',    'B',    'C',    'D',    'E',    'F',    'G',
2865         'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',
2866         'P',    'Q',    'R',    'S',    'T',    'U',    'V',    'W',
2867         'X',    'Y',    'Z',    123,    124,    125,    126,    127,
2868         128,    129,    130,    131,    132,    133,    134,    135,
2869         136,    137,    138,    139,    140,    141,    142,    143,
2870         144,    145,    146,    147,    148,    149,    150,    151,
2871         152,    153,    154,    155,    156,    157,    158,    159,
2872         160,    161,    162,    163,    164,    165,    166,    167,
2873         168,    169,    170,    171,    172,    173,    174,    175,
2874         176,    177,    178,    179,    180,    181,    182,    183,
2875         184,    185,    186,    187,    188,    189,    190,    191,
2876         192,    193,    194,    195,    196,    197,    198,    199,
2877         200,    201,    202,    203,    204,    205,    206,    207,
2878         208,    209,    210,    211,    212,    213,    214,    215,
2879         216,    217,    218,    219,    220,    221,    222,    223,    
2880         224,    225,    226,    227,    228,    229,    230,    231,
2881         232,    233,    234,    235,    236,    237,    238,    239,
2882         240,    241,    242,    243,    244,    245,    246,    247,
2883         248,    249,    250,    251,    252,    253,    254,    255
2884 };
2885 #endif  /* !EBCDIC */
2886 #else
2887 EXTCONST unsigned char PL_fold[];
2888 #endif
2889
2890 #ifdef DOINIT
2891 EXT unsigned char PL_fold_locale[] = {
2892         0,      1,      2,      3,      4,      5,      6,      7,
2893         8,      9,      10,     11,     12,     13,     14,     15,
2894         16,     17,     18,     19,     20,     21,     22,     23,
2895         24,     25,     26,     27,     28,     29,     30,     31,
2896         32,     33,     34,     35,     36,     37,     38,     39,
2897         40,     41,     42,     43,     44,     45,     46,     47,
2898         48,     49,     50,     51,     52,     53,     54,     55,
2899         56,     57,     58,     59,     60,     61,     62,     63,
2900         64,     'a',    'b',    'c',    'd',    'e',    'f',    'g',
2901         'h',    'i',    'j',    'k',    'l',    'm',    'n',    'o',
2902         'p',    'q',    'r',    's',    't',    'u',    'v',    'w',
2903         'x',    'y',    'z',    91,     92,     93,     94,     95,
2904         96,     'A',    'B',    'C',    'D',    'E',    'F',    'G',
2905         'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',
2906         'P',    'Q',    'R',    'S',    'T',    'U',    'V',    'W',
2907         'X',    'Y',    'Z',    123,    124,    125,    126,    127,
2908         128,    129,    130,    131,    132,    133,    134,    135,
2909         136,    137,    138,    139,    140,    141,    142,    143,
2910         144,    145,    146,    147,    148,    149,    150,    151,
2911         152,    153,    154,    155,    156,    157,    158,    159,
2912         160,    161,    162,    163,    164,    165,    166,    167,
2913         168,    169,    170,    171,    172,    173,    174,    175,
2914         176,    177,    178,    179,    180,    181,    182,    183,
2915         184,    185,    186,    187,    188,    189,    190,    191,
2916         192,    193,    194,    195,    196,    197,    198,    199,
2917         200,    201,    202,    203,    204,    205,    206,    207,
2918         208,    209,    210,    211,    212,    213,    214,    215,
2919         216,    217,    218,    219,    220,    221,    222,    223,    
2920         224,    225,    226,    227,    228,    229,    230,    231,
2921         232,    233,    234,    235,    236,    237,    238,    239,
2922         240,    241,    242,    243,    244,    245,    246,    247,
2923         248,    249,    250,    251,    252,    253,    254,    255
2924 };
2925 #else
2926 EXT unsigned char PL_fold_locale[];
2927 #endif
2928
2929 #ifdef DOINIT
2930 #ifdef EBCDIC
2931 EXT unsigned char PL_freq[] = {/* EBCDIC frequencies for mixed English/C */
2932     1,      2,      84,     151,    154,    155,    156,    157,
2933     165,    246,    250,    3,      158,    7,      18,     29,
2934     40,     51,     62,     73,     85,     96,     107,    118,
2935     129,    140,    147,    148,    149,    150,    152,    153,
2936     255,      6,      8,      9,     10,     11,     12,     13,
2937      14,     15,     24,     25,     26,     27,     28,    226,
2938      29,     30,     31,     32,     33,     43,     44,     45,
2939      46,     47,     48,     49,     50,     76,     77,     78,
2940      79,     80,     81,     82,     83,     84,     85,     86,
2941      87,     94,     95,    234,    181,    233,    187,    190,
2942     180,     96,     97,     98,     99,    100,    101,    102,
2943     104,    112,    182,    174,    236,    232,    229,    103,
2944     228,    226,    114,    115,    116,    117,    118,    119,
2945     120,    121,    122,    235,    176,    230,    194,    162,
2946     130,    131,    132,    133,    134,    135,    136,    137,
2947     138,    139,    201,    205,    163,    217,    220,    224,
2948     5,      248,    227,    244,    242,    255,    241,    231,
2949     240,    253,    16,     197,    19,     20,     21,     187,
2950     23,     169,    210,    245,    237,    249,    247,    239,
2951     168,    252,    34,     196,    36,     37,     38,     39,
2952     41,     42,     251,    254,    238,    223,    221,    213,
2953     225,    177,    52,     53,     54,     55,     56,     57,
2954     58,     59,     60,     61,     63,     64,     65,     66,
2955     67,     68,     69,     70,     71,     72,     74,     75,
2956     205,    208,    186,    202,    200,    218,    198,    179,
2957     178,    214,    88,     89,     90,     91,     92,     93,
2958     217,    166,    170,    207,    199,    209,    206,    204,
2959     160,    212,    105,    106,    108,    109,    110,    111,
2960     203,    113,    216,    215,    192,    175,    193,    243,
2961     172,    161,    123,    124,    125,    126,    127,    128,
2962     222,    219,    211,    195,    188,    193,    185,    184,
2963     191,    183,    141,    142,    143,    144,    145,    146
2964 };
2965 #else  /* ascii rather than ebcdic */
2966 EXTCONST unsigned char PL_freq[] = {    /* letter frequencies for mixed English/C */
2967         1,      2,      84,     151,    154,    155,    156,    157,
2968         165,    246,    250,    3,      158,    7,      18,     29,
2969         40,     51,     62,     73,     85,     96,     107,    118,
2970         129,    140,    147,    148,    149,    150,    152,    153,
2971         255,    182,    224,    205,    174,    176,    180,    217,
2972         233,    232,    236,    187,    235,    228,    234,    226,
2973         222,    219,    211,    195,    188,    193,    185,    184,
2974         191,    183,    201,    229,    181,    220,    194,    162,
2975         163,    208,    186,    202,    200,    218,    198,    179,
2976         178,    214,    166,    170,    207,    199,    209,    206,
2977         204,    160,    212,    216,    215,    192,    175,    173,
2978         243,    172,    161,    190,    203,    189,    164,    230,
2979         167,    248,    227,    244,    242,    255,    241,    231,
2980         240,    253,    169,    210,    245,    237,    249,    247,
2981         239,    168,    252,    251,    254,    238,    223,    221,
2982         213,    225,    177,    197,    171,    196,    159,    4,
2983         5,      6,      8,      9,      10,     11,     12,     13,
2984         14,     15,     16,     17,     19,     20,     21,     22,
2985         23,     24,     25,     26,     27,     28,     30,     31,
2986         32,     33,     34,     35,     36,     37,     38,     39,
2987         41,     42,     43,     44,     45,     46,     47,     48,
2988         49,     50,     52,     53,     54,     55,     56,     57,
2989         58,     59,     60,     61,     63,     64,     65,     66,
2990         67,     68,     69,     70,     71,     72,     74,     75,
2991         76,     77,     78,     79,     80,     81,     82,     83,
2992         86,     87,     88,     89,     90,     91,     92,     93,
2993         94,     95,     97,     98,     99,     100,    101,    102,
2994         103,    104,    105,    106,    108,    109,    110,    111,
2995         112,    113,    114,    115,    116,    117,    119,    120,
2996         121,    122,    123,    124,    125,    126,    127,    128,
2997         130,    131,    132,    133,    134,    135,    136,    137,
2998         138,    139,    141,    142,    143,    144,    145,    146
2999 };
3000 #endif
3001 #else
3002 EXTCONST unsigned char PL_freq[];
3003 #endif
3004
3005 #ifdef DEBUGGING
3006 #ifdef DOINIT
3007 EXTCONST char* PL_block_type[] = {
3008         "NULL",
3009         "SUB",
3010         "EVAL",
3011         "LOOP",
3012         "SUBST",
3013         "BLOCK",
3014 };
3015 #else
3016 EXTCONST char* PL_block_type[];
3017 #endif
3018 #endif
3019
3020 END_EXTERN_C
3021
3022 /*****************************************************************************/
3023 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
3024 /*****************************************************************************/
3025 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
3026
3027 #include "perly.h"
3028
3029 #define LEX_NOTPARSING          11      /* borrowed from toke.c */
3030
3031 typedef enum {
3032     XOPERATOR,
3033     XTERM,
3034     XREF,
3035     XSTATE,
3036     XBLOCK,
3037     XATTRBLOCK,
3038     XATTRTERM,
3039     XTERMBLOCK
3040 } expectation;
3041
3042 enum {          /* pass one of these to get_vtbl */
3043     want_vtbl_sv,
3044     want_vtbl_env,
3045     want_vtbl_envelem,
3046     want_vtbl_sig,
3047     want_vtbl_sigelem,
3048     want_vtbl_pack,
3049     want_vtbl_packelem,
3050     want_vtbl_dbline,
3051     want_vtbl_isa,
3052     want_vtbl_isaelem,
3053     want_vtbl_arylen,
3054     want_vtbl_glob,
3055     want_vtbl_mglob,
3056     want_vtbl_nkeys,
3057     want_vtbl_taint,
3058     want_vtbl_substr,
3059     want_vtbl_vec,
3060     want_vtbl_pos,
3061     want_vtbl_bm,
3062     want_vtbl_fm,
3063     want_vtbl_uvar,
3064     want_vtbl_defelem,
3065     want_vtbl_regexp,
3066     want_vtbl_collxfrm,
3067     want_vtbl_amagic,
3068     want_vtbl_amagicelem,
3069 #ifdef USE_5005THREADS
3070     want_vtbl_mutex,
3071 #endif
3072     want_vtbl_regdata,
3073     want_vtbl_regdatum,
3074     want_vtbl_backref
3075 };
3076
3077                                 /* Note: the lowest 8 bits are reserved for
3078                                    stuffing into op->op_private */
3079 #define HINT_PRIVATE_MASK       0x000000ff
3080 #define HINT_INTEGER            0x00000001
3081 #define HINT_STRICT_REFS        0x00000002
3082 #define HINT_LOCALE             0x00000004
3083 #define HINT_BYTES              0x00000008
3084 /* #define HINT_notused10       0x00000010 */
3085                                 /* Note: 20,40,80 used for NATIVE_HINTS */
3086
3087 #define HINT_BLOCK_SCOPE        0x00000100
3088 #define HINT_STRICT_SUBS        0x00000200
3089 #define HINT_STRICT_VARS        0x00000400
3090
3091 #define HINT_NEW_INTEGER        0x00001000
3092 #define HINT_NEW_FLOAT          0x00002000
3093 #define HINT_NEW_BINARY         0x00004000
3094 #define HINT_NEW_STRING         0x00008000
3095 #define HINT_NEW_RE             0x00010000
3096 #define HINT_LOCALIZE_HH        0x00020000 /* %^H needs to be copied */
3097
3098 #define HINT_RE_TAINT           0x00100000
3099 #define HINT_RE_EVAL            0x00200000
3100
3101 #define HINT_FILETEST_ACCESS    0x00400000
3102 #define HINT_UTF8               0x00800000
3103
3104 /* Various states of the input record separator SV (rs) */
3105 #define RsSNARF(sv)   (! SvOK(sv))
3106 #define RsSIMPLE(sv)  (SvOK(sv) && (! SvPOK(sv) || SvCUR(sv)))
3107 #define RsPARA(sv)    (SvPOK(sv) && ! SvCUR(sv))
3108 #define RsRECORD(sv)  (SvROK(sv) && (SvIV(SvRV(sv)) > 0))
3109
3110 /* Enable variables which are pointers to functions */
3111 typedef void (CPERLscope(*peep_t))(pTHX_ OP* o);
3112 typedef regexp*(CPERLscope(*regcomp_t)) (pTHX_ char* exp, char* xend, PMOP* pm);
3113 typedef I32 (CPERLscope(*regexec_t)) (pTHX_ regexp* prog, char* stringarg,
3114                                       char* strend, char* strbeg, I32 minend,
3115                                       SV* screamer, void* data, U32 flags);
3116 typedef char* (CPERLscope(*re_intuit_start_t)) (pTHX_ regexp *prog, SV *sv,
3117                                                 char *strpos, char *strend,
3118                                                 U32 flags,
3119                                                 struct re_scream_pos_data_s *d);
3120 typedef SV*     (CPERLscope(*re_intuit_string_t)) (pTHX_ regexp *prog);
3121 typedef void    (CPERLscope(*regfree_t)) (pTHX_ struct regexp* r);
3122
3123 typedef void (*DESTRUCTORFUNC_NOCONTEXT_t) (void*);
3124 typedef void (*DESTRUCTORFUNC_t) (pTHX_ void*);
3125 typedef void (*SVFUNC_t) (pTHX_ SV*);
3126 typedef I32  (*SVCOMPARE_t) (pTHX_ SV*, SV*);
3127 typedef void (*XSINIT_t) (pTHX);
3128 typedef void (*ATEXIT_t) (pTHX_ void*);
3129 typedef void (*XSUBADDR_t) (pTHX_ CV *);
3130
3131 /* Set up PERLVAR macros for populating structs */
3132 #define PERLVAR(var,type) type var;
3133 #define PERLVARA(var,n,type) type var[n];
3134 #define PERLVARI(var,type,init) type var;
3135 #define PERLVARIC(var,type,init) type var;
3136
3137 /* Interpreter exitlist entry */
3138 typedef struct exitlistentry {
3139     void (*fn) (pTHX_ void*);
3140     void *ptr;
3141 } PerlExitListEntry;
3142
3143 #ifdef PERL_GLOBAL_STRUCT
3144 struct perl_vars {
3145 #  include "perlvars.h"
3146 };
3147
3148 #  ifdef PERL_CORE
3149 EXT struct perl_vars PL_Vars;
3150 EXT struct perl_vars *PL_VarsPtr INIT(&PL_Vars);
3151 #  else /* PERL_CORE */
3152 #    if !defined(__GNUC__) || !defined(WIN32)
3153 EXT
3154 #    endif /* WIN32 */
3155 struct perl_vars *PL_VarsPtr;
3156 #    define PL_Vars (*((PL_VarsPtr) \
3157                        ? PL_VarsPtr : (PL_VarsPtr = Perl_GetVars(aTHX))))
3158 #  endif /* PERL_CORE */
3159 #endif /* PERL_GLOBAL_STRUCT */
3160
3161 #if defined(MULTIPLICITY)
3162 /* If we have multiple interpreters define a struct
3163    holding variables which must be per-interpreter
3164    If we don't have threads anything that would have
3165    be per-thread is per-interpreter.
3166 */
3167
3168 struct interpreter {
3169 #  ifndef USE_5005THREADS
3170 #    include "thrdvar.h"
3171 #  endif
3172 #  include "intrpvar.h"
3173 /*
3174  * The following is a buffer where new variables must
3175  * be defined to maintain binary compatibility with previous versions
3176  */
3177 PERLVARA(object_compatibility,30,       char)
3178 };
3179
3180 #else
3181 struct interpreter {
3182     char broiled;
3183 };
3184 #endif /* MULTIPLICITY */
3185
3186 #ifdef USE_5005THREADS
3187 /* If we have threads define a struct with all the variables
3188  * that have to be per-thread
3189  */
3190
3191
3192 struct perl_thread {
3193 #include "thrdvar.h"
3194 };
3195
3196 typedef struct perl_thread *Thread;
3197
3198 #else
3199 typedef void *Thread;
3200 #endif
3201
3202 /* Done with PERLVAR macros for now ... */
3203 #undef PERLVAR
3204 #undef PERLVARA
3205 #undef PERLVARI
3206 #undef PERLVARIC
3207
3208 #include "thread.h"
3209 #include "pp.h"
3210
3211 #ifndef PERL_CALLCONV
3212 #  define PERL_CALLCONV
3213 #endif
3214
3215 #ifndef NEXT30_NO_ATTRIBUTE
3216 #  ifndef HASATTRIBUTE       /* disable GNU-cc attribute checking? */
3217 #    ifdef  __attribute__      /* Avoid possible redefinition errors */
3218 #      undef  __attribute__
3219 #    endif
3220 #    define __attribute__(attr)
3221 #  endif
3222 #endif
3223
3224 #undef PERL_CKDEF
3225 #undef PERL_PPDEF
3226 #define PERL_CKDEF(s)   OP *s (pTHX_ OP *o);
3227 #define PERL_PPDEF(s)   OP *s (pTHX);
3228
3229 #include "proto.h"
3230
3231 /* this has structure inits, so it cannot be included before here */
3232 #include "opcode.h"
3233
3234 /* The following must follow proto.h as #defines mess up syntax */
3235
3236 #if !defined(PERL_FOR_X2P)
3237 #  include "embedvar.h"
3238 #endif
3239
3240 /* Now include all the 'global' variables
3241  * If we don't have threads or multiple interpreters
3242  * these include variables that would have been their struct-s
3243  */
3244
3245 #define PERLVAR(var,type) EXT type PL_##var;
3246 #define PERLVARA(var,n,type) EXT type PL_##var[n];
3247 #define PERLVARI(var,type,init) EXT type  PL_##var INIT(init);
3248 #define PERLVARIC(var,type,init) EXTCONST type PL_##var INIT(init);
3249
3250 #if !defined(MULTIPLICITY)
3251 START_EXTERN_C
3252 #  include "intrpvar.h"
3253 #  ifndef USE_5005THREADS
3254 #    include "thrdvar.h"
3255 #  endif
3256 END_EXTERN_C
3257 #endif
3258
3259 #if defined(WIN32)
3260 #  include "embed.h"
3261 #endif
3262
3263 #ifndef PERL_GLOBAL_STRUCT
3264 START_EXTERN_C
3265
3266 #  include "perlvars.h"
3267
3268 END_EXTERN_C
3269 #endif
3270
3271 #undef PERLVAR
3272 #undef PERLVARA
3273 #undef PERLVARI
3274 #undef PERLVARIC
3275
3276 START_EXTERN_C
3277
3278 #ifdef DOINIT
3279
3280 EXT MGVTBL PL_vtbl_sv = {MEMBER_TO_FPTR(Perl_magic_get),
3281                                 MEMBER_TO_FPTR(Perl_magic_set),
3282                                         MEMBER_TO_FPTR(Perl_magic_len),
3283                                                 0,      0};
3284 EXT MGVTBL PL_vtbl_env =        {0,     MEMBER_TO_FPTR(Perl_magic_set_all_env),
3285                                 0,      MEMBER_TO_FPTR(Perl_magic_clear_all_env),
3286                                                         0};
3287 EXT MGVTBL PL_vtbl_envelem =    {0,     MEMBER_TO_FPTR(Perl_magic_setenv),
3288                                         0,      MEMBER_TO_FPTR(Perl_magic_clearenv),
3289                                                         0};
3290 EXT MGVTBL PL_vtbl_sig =        {0,     0,               0, 0, 0};
3291 #ifdef PERL_MICRO
3292 EXT MGVTBL PL_vtbl_sigelem =    {0,     0,               0, 0, 0};
3293 #else
3294 EXT MGVTBL PL_vtbl_sigelem =    {MEMBER_TO_FPTR(Perl_magic_getsig),
3295                                         MEMBER_TO_FPTR(Perl_magic_setsig),
3296                                         0,      MEMBER_TO_FPTR(Perl_magic_clearsig),
3297                                                         0};
3298 #endif
3299 EXT MGVTBL PL_vtbl_pack =       {0,     0,      MEMBER_TO_FPTR(Perl_magic_sizepack),    MEMBER_TO_FPTR(Perl_magic_wipepack),
3300                                                         0};
3301 EXT MGVTBL PL_vtbl_packelem =   {MEMBER_TO_FPTR(Perl_magic_getpack),
3302                                 MEMBER_TO_FPTR(Perl_magic_setpack),
3303                                         0,      MEMBER_TO_FPTR(Perl_magic_clearpack),
3304                                                         0};
3305 EXT MGVTBL PL_vtbl_dbline =     {0,     MEMBER_TO_FPTR(Perl_magic_setdbline),
3306                                         0,      0,      0};
3307 EXT MGVTBL PL_vtbl_isa =        {0,     MEMBER_TO_FPTR(Perl_magic_setisa),
3308                                         0,      MEMBER_TO_FPTR(Perl_magic_setisa),
3309                                                         0};
3310 EXT MGVTBL PL_vtbl_isaelem =    {0,     MEMBER_TO_FPTR(Perl_magic_setisa),
3311                                         0,      0,      0};
3312 EXT MGVTBL PL_vtbl_arylen =     {MEMBER_TO_FPTR(Perl_magic_getarylen),
3313                                 MEMBER_TO_FPTR(Perl_magic_setarylen),
3314                                         0,      0,      0};
3315 EXT MGVTBL PL_vtbl_glob =       {MEMBER_TO_FPTR(Perl_magic_getglob),
3316                                 MEMBER_TO_FPTR(Perl_magic_setglob),
3317                                         0,      0,      0};
3318 EXT MGVTBL PL_vtbl_mglob =      {0,     MEMBER_TO_FPTR(Perl_magic_setmglob),
3319                                         0,      0,      0};
3320 EXT MGVTBL PL_vtbl_nkeys =      {MEMBER_TO_FPTR(Perl_magic_getnkeys),
3321                                 MEMBER_TO_FPTR(Perl_magic_setnkeys),
3322                                         0,      0,      0};
3323 EXT MGVTBL PL_vtbl_taint =      {MEMBER_TO_FPTR(Perl_magic_gettaint),MEMBER_TO_FPTR(Perl_magic_settaint),
3324                                         0,      0,      0};
3325 EXT MGVTBL PL_vtbl_substr =     {MEMBER_TO_FPTR(Perl_magic_getsubstr), MEMBER_TO_FPTR(Perl_magic_setsubstr),
3326                                         0,      0,      0};
3327 EXT MGVTBL PL_vtbl_vec =        {MEMBER_TO_FPTR(Perl_magic_getvec),
3328                                 MEMBER_TO_FPTR(Perl_magic_setvec),
3329                                         0,      0,      0};
3330 EXT MGVTBL PL_vtbl_pos =        {MEMBER_TO_FPTR(Perl_magic_getpos),
3331                                 MEMBER_TO_FPTR(Perl_magic_setpos),
3332                                         0,      0,      0};
3333 EXT MGVTBL PL_vtbl_bm = {0,     MEMBER_TO_FPTR(Perl_magic_setbm),
3334                                         0,      0,      0};
3335 EXT MGVTBL PL_vtbl_fm = {0,     MEMBER_TO_FPTR(Perl_magic_setfm),
3336                                         0,      0,      0};
3337 EXT MGVTBL PL_vtbl_uvar =       {MEMBER_TO_FPTR(Perl_magic_getuvar),
3338                                 MEMBER_TO_FPTR(Perl_magic_setuvar),
3339                                         0,      0,      0};
3340 #ifdef USE_5005THREADS
3341 EXT MGVTBL PL_vtbl_mutex =      {0,     0,      0,      0,      MEMBER_TO_FPTR(Perl_magic_mutexfree)};
3342 #endif /* USE_5005THREADS */
3343 EXT MGVTBL PL_vtbl_defelem = {MEMBER_TO_FPTR(Perl_magic_getdefelem),MEMBER_TO_FPTR(Perl_magic_setdefelem),
3344                                         0,      0,      0};
3345
3346 EXT MGVTBL PL_vtbl_regexp = {0,0,0,0, MEMBER_TO_FPTR(Perl_magic_freeregexp)};
3347 EXT MGVTBL PL_vtbl_regdata = {0, 0, MEMBER_TO_FPTR(Perl_magic_regdata_cnt), 0, 0};
3348 EXT MGVTBL PL_vtbl_regdatum = {MEMBER_TO_FPTR(Perl_magic_regdatum_get),
3349                                MEMBER_TO_FPTR(Perl_magic_regdatum_set), 0, 0, 0};
3350
3351 #ifdef USE_LOCALE_COLLATE
3352 EXT MGVTBL PL_vtbl_collxfrm = {0,
3353                                 MEMBER_TO_FPTR(Perl_magic_setcollxfrm),
3354                                         0,      0,      0};
3355 #endif
3356
3357 EXT MGVTBL PL_vtbl_amagic =       {0,     MEMBER_TO_FPTR(Perl_magic_setamagic),
3358                                         0,      0,      MEMBER_TO_FPTR(Perl_magic_setamagic)};
3359 EXT MGVTBL PL_vtbl_amagicelem =   {0,     MEMBER_TO_FPTR(Perl_magic_setamagic),
3360                                         0,      0,      MEMBER_TO_FPTR(Perl_magic_setamagic)};
3361
3362 EXT MGVTBL PL_vtbl_backref =      {0,   0,
3363                                         0,      0,      MEMBER_TO_FPTR(Perl_magic_killbackrefs)};
3364
3365 EXT MGVTBL PL_vtbl_ovrld   =      {0,   0,
3366                                         0,      0,      MEMBER_TO_FPTR(Perl_magic_freeovrld)};
3367
3368 #else /* !DOINIT */
3369
3370 EXT MGVTBL PL_vtbl_sv;
3371 EXT MGVTBL PL_vtbl_env;
3372 EXT MGVTBL PL_vtbl_envelem;
3373 EXT MGVTBL PL_vtbl_sig;
3374 EXT MGVTBL PL_vtbl_sigelem;
3375 EXT MGVTBL PL_vtbl_pack;
3376 EXT MGVTBL PL_vtbl_packelem;
3377 EXT MGVTBL PL_vtbl_dbline;
3378 EXT MGVTBL PL_vtbl_isa;
3379 EXT MGVTBL PL_vtbl_isaelem;
3380 EXT MGVTBL PL_vtbl_arylen;
3381 EXT MGVTBL PL_vtbl_glob;
3382 EXT MGVTBL PL_vtbl_mglob;
3383 EXT MGVTBL PL_vtbl_nkeys;
3384 EXT MGVTBL PL_vtbl_taint;
3385 EXT MGVTBL PL_vtbl_substr;
3386 EXT MGVTBL PL_vtbl_vec;
3387 EXT MGVTBL PL_vtbl_pos;
3388 EXT MGVTBL PL_vtbl_bm;
3389 EXT MGVTBL PL_vtbl_fm;
3390 EXT MGVTBL PL_vtbl_uvar;
3391 EXT MGVTBL PL_vtbl_ovrld;
3392
3393 #ifdef USE_5005THREADS
3394 EXT MGVTBL PL_vtbl_mutex;
3395 #endif /* USE_5005THREADS */
3396
3397 EXT MGVTBL PL_vtbl_defelem;
3398 EXT MGVTBL PL_vtbl_regexp;
3399 EXT MGVTBL PL_vtbl_regdata;
3400 EXT MGVTBL PL_vtbl_regdatum;
3401
3402 #ifdef USE_LOCALE_COLLATE
3403 EXT MGVTBL PL_vtbl_collxfrm;
3404 #endif
3405
3406 EXT MGVTBL PL_vtbl_amagic;
3407 EXT MGVTBL PL_vtbl_amagicelem;
3408
3409 EXT MGVTBL PL_vtbl_backref;
3410
3411 #endif /* !DOINIT */
3412
3413 enum {
3414   fallback_amg,        abs_amg,
3415   bool__amg,   nomethod_amg,
3416   string_amg,  numer_amg,
3417   add_amg,     add_ass_amg,
3418   subtr_amg,   subtr_ass_amg,
3419   mult_amg,    mult_ass_amg,
3420   div_amg,     div_ass_amg,
3421   modulo_amg,  modulo_ass_amg,
3422   pow_amg,     pow_ass_amg,
3423   lshift_amg,  lshift_ass_amg,
3424   rshift_amg,  rshift_ass_amg,
3425   band_amg,    band_ass_amg,
3426   bor_amg,     bor_ass_amg,
3427   bxor_amg,    bxor_ass_amg,
3428   lt_amg,      le_amg,
3429   gt_amg,      ge_amg,
3430   eq_amg,      ne_amg,
3431   ncmp_amg,    scmp_amg,
3432   slt_amg,     sle_amg,
3433   sgt_amg,     sge_amg,
3434   seq_amg,     sne_amg,
3435   not_amg,     compl_amg,
3436   inc_amg,     dec_amg,
3437   atan2_amg,   cos_amg,
3438   sin_amg,     exp_amg,
3439   log_amg,     sqrt_amg,
3440   repeat_amg,   repeat_ass_amg,
3441   concat_amg,  concat_ass_amg,
3442   copy_amg,    neg_amg,
3443   to_sv_amg,   to_av_amg,
3444   to_hv_amg,   to_gv_amg,
3445   to_cv_amg,   iter_amg,
3446   int_amg,      DESTROY_amg,
3447   max_amg_code
3448   /* Do not leave a trailing comma here.  C9X allows it, C89 doesn't. */
3449 };
3450
3451 #define NofAMmeth max_amg_code
3452 #define AMG_id2name(id) ((char*)PL_AMG_names[id]+1)
3453
3454 #ifdef DOINIT
3455 EXTCONST char * PL_AMG_names[NofAMmeth] = {
3456   /* Names kept in the symbol table.  fallback => "()", the rest has
3457      "(" prepended.  The only other place in perl which knows about
3458      this convention is AMG_id2name (used for debugging output and
3459      'nomethod' only), the only other place which has it hardwired is
3460      overload.pm.  */
3461   "()",         "(abs",                 /* "fallback" should be the first. */
3462   "(bool",      "(nomethod",
3463   "(\"\"",      "(0+",
3464   "(+",         "(+=",
3465   "(-",         "(-=",
3466   "(*",         "(*=",
3467   "(/",         "(/=",
3468   "(%",         "(%=",
3469   "(**",        "(**=",
3470   "(<<",        "(<<=",
3471   "(>>",        "(>>=",
3472   "(&",         "(&=",
3473   "(|",         "(|=",
3474   "(^",         "(^=",
3475   "(<",         "(<=",
3476   "(>",         "(>=",
3477   "(==",        "(!=",
3478   "(<=>",       "(cmp",
3479   "(lt",        "(le",
3480   "(gt",        "(ge",
3481   "(eq",        "(ne",
3482   "(!",         "(~",
3483   "(++",        "(--",
3484   "(atan2",     "(cos",
3485   "(sin",       "(exp",
3486   "(log",       "(sqrt",
3487   "(x",         "(x=",
3488   "(.",         "(.=",
3489   "(=",         "(neg",
3490   "(${}",       "(@{}",
3491   "(%{}",       "(*{}",
3492   "(&{}",       "(<>",
3493   "(int",       "DESTROY",
3494 };
3495 #else
3496 EXTCONST char * PL_AMG_names[NofAMmeth];
3497 #endif /* def INITAMAGIC */
3498
3499 END_EXTERN_C
3500
3501 struct am_table {
3502   long was_ok_sub;
3503   long was_ok_am;
3504   U32 flags;
3505   CV* table[NofAMmeth];
3506   long fallback;
3507 };
3508 struct am_table_short {
3509   long was_ok_sub;
3510   long was_ok_am;
3511   U32 flags;
3512 };
3513 typedef struct am_table AMT;
3514 typedef struct am_table_short AMTS;
3515
3516 #define AMGfallNEVER    1
3517 #define AMGfallNO       2
3518 #define AMGfallYES      3
3519
3520 #define AMTf_AMAGIC             1
3521 #define AMTf_OVERLOADED         2
3522 #define AMT_AMAGIC(amt)         ((amt)->flags & AMTf_AMAGIC)
3523 #define AMT_AMAGIC_on(amt)      ((amt)->flags |= AMTf_AMAGIC)
3524 #define AMT_AMAGIC_off(amt)     ((amt)->flags &= ~AMTf_AMAGIC)
3525 #define AMT_OVERLOADED(amt)     ((amt)->flags & AMTf_OVERLOADED)
3526 #define AMT_OVERLOADED_on(amt)  ((amt)->flags |= AMTf_OVERLOADED)
3527 #define AMT_OVERLOADED_off(amt) ((amt)->flags &= ~AMTf_OVERLOADED)
3528
3529 #define StashHANDLER(stash,meth)        gv_handler((stash),CAT2(meth,_amg))
3530
3531 /*
3532  * some compilers like to redefine cos et alia as faster
3533  * (and less accurate?) versions called F_cos et cetera (Quidquid
3534  * latine dictum sit, altum viditur.)  This trick collides with
3535  * the Perl overloading (amg).  The following #defines fool both.
3536  */
3537
3538 #ifdef _FASTMATH
3539 #   ifdef atan2
3540 #       define F_atan2_amg  atan2_amg
3541 #   endif
3542 #   ifdef cos
3543 #       define F_cos_amg    cos_amg
3544 #   endif
3545 #   ifdef exp
3546 #       define F_exp_amg    exp_amg
3547 #   endif
3548 #   ifdef log
3549 #       define F_log_amg    log_amg
3550 #   endif
3551 #   ifdef pow
3552 #       define F_pow_amg    pow_amg
3553 #   endif
3554 #   ifdef sin
3555 #       define F_sin_amg    sin_amg
3556 #   endif
3557 #   ifdef sqrt
3558 #       define F_sqrt_amg   sqrt_amg
3559 #   endif
3560 #endif /* _FASTMATH */
3561
3562 #define PERLDB_ALL              (PERLDBf_SUB    | PERLDBf_LINE  |       \
3563                                  PERLDBf_NOOPT  | PERLDBf_INTER |       \
3564                                  PERLDBf_SUBLINE| PERLDBf_SINGLE|       \
3565                                  PERLDBf_NAMEEVAL| PERLDBf_NAMEANON)
3566                                         /* No _NONAME, _GOTO */
3567 #define PERLDBf_SUB             0x01    /* Debug sub enter/exit */
3568 #define PERLDBf_LINE            0x02    /* Keep line # */
3569 #define PERLDBf_NOOPT           0x04    /* Switch off optimizations */
3570 #define PERLDBf_INTER           0x08    /* Preserve more data for
3571                                            later inspections  */
3572 #define PERLDBf_SUBLINE         0x10    /* Keep subr source lines */
3573 #define PERLDBf_SINGLE          0x20    /* Start with single-step on */
3574 #define PERLDBf_NONAME          0x40    /* For _SUB: no name of the subr */
3575 #define PERLDBf_GOTO            0x80    /* Report goto: call DB::goto */
3576 #define PERLDBf_NAMEEVAL        0x100   /* Informative names for evals */
3577 #define PERLDBf_NAMEANON        0x200   /* Informative names for anon subs */
3578
3579 #define PERLDB_SUB      (PL_perldb && (PL_perldb & PERLDBf_SUB))
3580 #define PERLDB_LINE     (PL_perldb && (PL_perldb & PERLDBf_LINE))
3581 #define PERLDB_NOOPT    (PL_perldb && (PL_perldb & PERLDBf_NOOPT))
3582 #define PERLDB_INTER    (PL_perldb && (PL_perldb & PERLDBf_INTER))
3583 #define PERLDB_SUBLINE  (PL_perldb && (PL_perldb & PERLDBf_SUBLINE))
3584 #define PERLDB_SINGLE   (PL_perldb && (PL_perldb & PERLDBf_SINGLE))
3585 #define PERLDB_SUB_NN   (PL_perldb && (PL_perldb & (PERLDBf_NONAME)))
3586 #define PERLDB_GOTO     (PL_perldb && (PL_perldb & PERLDBf_GOTO))
3587 #define PERLDB_NAMEEVAL (PL_perldb && (PL_perldb & PERLDBf_NAMEEVAL))
3588 #define PERLDB_NAMEANON (PL_perldb && (PL_perldb & PERLDBf_NAMEANON))
3589
3590
3591 #ifdef USE_LOCALE_NUMERIC
3592
3593 #define SET_NUMERIC_STANDARD() \
3594         set_numeric_standard();
3595
3596 #define SET_NUMERIC_LOCAL() \
3597         set_numeric_local();
3598
3599 #define IN_LOCALE_RUNTIME       (PL_curcop->op_private & HINT_LOCALE)
3600 #define IN_LOCALE_COMPILETIME   (PL_hints & HINT_LOCALE)
3601
3602 #define IN_LOCALE \
3603         (PL_curcop == &PL_compiling ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
3604
3605 #define STORE_NUMERIC_LOCAL_SET_STANDARD() \
3606         bool was_local = PL_numeric_local && IN_LOCALE; \
3607         if (was_local) SET_NUMERIC_STANDARD();
3608
3609 #define STORE_NUMERIC_STANDARD_SET_LOCAL() \
3610         bool was_standard = PL_numeric_standard && IN_LOCALE; \
3611         if (was_standard) SET_NUMERIC_LOCAL();
3612
3613 #define RESTORE_NUMERIC_LOCAL() \
3614         if (was_local) SET_NUMERIC_LOCAL();
3615
3616 #define RESTORE_NUMERIC_STANDARD() \
3617         if (was_standard) SET_NUMERIC_STANDARD();
3618
3619 #define Atof                            my_atof
3620
3621 #else /* !USE_LOCALE_NUMERIC */
3622
3623 #define SET_NUMERIC_STANDARD()          /**/
3624 #define SET_NUMERIC_LOCAL()             /**/
3625 #define IS_NUMERIC_RADIX(a, b)          (0)
3626 #define STORE_NUMERIC_LOCAL_SET_STANDARD()      /**/
3627 #define STORE_NUMERIC_STANDARD_SET_LOCAL()      /**/
3628 #define RESTORE_NUMERIC_LOCAL()         /**/
3629 #define RESTORE_NUMERIC_STANDARD()      /**/
3630 #define Atof                            Perl_atof
3631 #define IN_LOCALE_RUNTIME               0
3632
3633 #endif /* !USE_LOCALE_NUMERIC */
3634
3635 #if !defined(Strtol) && defined(USE_64_BIT_INT) && defined(IV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG
3636 #    ifdef __hpux
3637 #        define strtoll __strtoll       /* secret handshake */
3638 #    endif
3639 #   if !defined(Strtol) && defined(HAS_STRTOLL)
3640 #       define Strtol   strtoll
3641 #   endif
3642 #    if !defined(Strtol) && defined(HAS_STRTOQ)
3643 #       define Strtol   strtoq
3644 #    endif
3645 /* is there atoq() anywhere? */
3646 #endif
3647 #if !defined(Strtol) && defined(HAS_STRTOL)
3648 #   define Strtol       strtol
3649 #endif
3650 #ifndef Atol
3651 /* It would be more fashionable to use Strtol() to define atol()
3652  * (as is done for Atoul(), see below) but for backward compatibility
3653  * we just assume atol(). */
3654 #   if defined(USE_64_BIT_INT) && defined(IV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG && defined(HAS_ATOLL)
3655 #       define Atol     atoll
3656 #   else
3657 #       define Atol     atol
3658 #   endif
3659 #endif
3660
3661 #if !defined(Strtoul) && defined(USE_64_BIT_INT) && defined(UV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG
3662 #    ifdef __hpux
3663 #        define strtoull __strtoull     /* secret handshake */
3664 #    endif
3665 #    if !defined(Strtoul) && defined(HAS_STRTOULL)
3666 #       define Strtoul  strtoull
3667 #    endif
3668 #    if !defined(Strtoul) && defined(HAS_STRTOUQ)
3669 #       define Strtoul  strtouq
3670 #    endif
3671 /* is there atouq() anywhere? */
3672 #endif
3673 #if !defined(Strtoul) && defined(HAS_STRTOUL)
3674 #   define Strtoul      strtoul
3675 #endif
3676 #ifndef Atoul
3677 #   define Atoul(s)     Strtoul(s, (char **)NULL, 10)
3678 #endif
3679
3680 #if !defined(PERLIO_IS_STDIO) && defined(HASATTRIBUTE)
3681 /*
3682  * Now we have __attribute__ out of the way
3683  * Remap printf
3684  */
3685 #undef printf
3686 #ifdef __GNUC__
3687 #define printf(fmt,args...) PerlIO_stdoutf(fmt,##args)
3688 #else
3689 #define printf PerlIO_stdoutf
3690 #endif
3691 #endif
3692
3693 /* if these never got defined, they need defaults */
3694 #ifndef PERL_SET_CONTEXT
3695 #  define PERL_SET_CONTEXT(i)           PERL_SET_INTERP(i)
3696 #endif
3697
3698 #ifndef PERL_GET_CONTEXT
3699 #  define PERL_GET_CONTEXT              PERL_GET_INTERP
3700 #endif
3701
3702 #ifndef PERL_GET_THX
3703 #  define PERL_GET_THX                  ((void*)NULL)
3704 #endif
3705
3706 #ifndef PERL_SET_THX
3707 #  define PERL_SET_THX(t)               NOOP
3708 #endif
3709
3710 #ifndef PERL_SCRIPT_MODE
3711 #define PERL_SCRIPT_MODE "r"
3712 #endif
3713
3714 /*
3715  * Some operating systems are stingy with stack allocation,
3716  * so perl may have to guard against stack overflow.
3717  */
3718 #ifndef PERL_STACK_OVERFLOW_CHECK
3719 #define PERL_STACK_OVERFLOW_CHECK()  NOOP
3720 #endif
3721
3722 /*
3723  * Some nonpreemptive operating systems find it convenient to
3724  * check for asynchronous conditions after each op execution.
3725  * Keep this check simple, or it may slow down execution
3726  * massively.
3727  */
3728
3729 #ifndef PERL_MICRO
3730 #   ifndef PERL_OLD_SIGNALS
3731 #               ifndef PERL_ASYNC_CHECK
3732 #                       define PERL_ASYNC_CHECK() if (PL_sig_pending) despatch_signals()
3733 #               endif
3734 #   endif
3735 #endif
3736
3737 #ifndef PERL_ASYNC_CHECK
3738 #   define PERL_ASYNC_CHECK()  NOOP
3739 #endif
3740
3741 /*
3742  * On some operating systems, a memory allocation may succeed,
3743  * but put the process too close to the system's comfort limit.
3744  * In this case, PERL_ALLOC_CHECK frees the pointer and sets
3745  * it to NULL.
3746  */
3747 #ifndef PERL_ALLOC_CHECK
3748 #define PERL_ALLOC_CHECK(p)  NOOP
3749 #endif
3750
3751 /*
3752  * nice_chunk and nice_chunk size need to be set
3753  * and queried under the protection of sv_mutex
3754  */
3755 #define offer_nice_chunk(chunk, chunk_size) STMT_START {  \
3756        void *new_chunk;                                   \
3757        U32 new_chunk_size;                                \
3758        LOCK_SV_MUTEX;                                     \
3759        new_chunk = (void *)(chunk);                       \
3760        new_chunk_size = (chunk_size);                     \
3761        if (new_chunk_size > PL_nice_chunk_size) {         \
3762            if (PL_nice_chunk) Safefree(PL_nice_chunk);    \
3763            PL_nice_chunk = new_chunk;                     \
3764            PL_nice_chunk_size = new_chunk_size;           \
3765        } else {                                           \
3766            Safefree(chunk);                               \
3767        }                                                  \
3768        UNLOCK_SV_MUTEX;                                   \
3769    } STMT_END
3770
3771 #ifdef HAS_SEM
3772 #   include <sys/ipc.h>
3773 #   include <sys/sem.h>
3774 #   ifndef HAS_UNION_SEMUN      /* Provide the union semun. */
3775     union semun {
3776         int             val;
3777         struct semid_ds *buf;
3778         unsigned short  *array;
3779     };
3780 #   endif
3781 #   ifdef USE_SEMCTL_SEMUN
3782 #       ifdef IRIX32_SEMUN_BROKEN_BY_GCC
3783             union gccbug_semun {
3784                 int             val;
3785                 struct semid_ds *buf;
3786                 unsigned short  *array;
3787                 char            __dummy[5];
3788             };
3789 #           define semun gccbug_semun
3790 #       endif
3791 #       define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun)
3792 #   else
3793 #       ifdef USE_SEMCTL_SEMID_DS
3794 #           ifdef EXTRA_F_IN_SEMUN_BUF
3795 #               define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun.buff)
3796 #           else
3797 #               define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun.buf)
3798 #           endif
3799 #       endif
3800 #   endif
3801 #endif
3802
3803 #ifdef I_FCNTL
3804 #  include <fcntl.h>
3805 #endif
3806
3807 #ifdef I_SYS_FILE
3808 #  include <sys/file.h>
3809 #endif
3810
3811 #if defined(HAS_FLOCK) && !defined(HAS_FLOCK_PROTO)
3812 int flock(int fd, int op);
3813 #endif
3814
3815 #ifndef O_RDONLY
3816 /* Assume UNIX defaults */
3817 #    define O_RDONLY    0000
3818 #    define O_WRONLY    0001
3819 #    define O_RDWR      0002
3820 #    define O_CREAT     0100
3821 #endif
3822
3823 #ifndef O_BINARY
3824 #  define O_BINARY 0
3825 #endif
3826
3827 #ifndef O_TEXT
3828 #  define O_TEXT 0
3829 #endif
3830
3831 #ifdef IAMSUID
3832
3833 #ifdef I_SYS_STATVFS
3834 #   if defined(PERL_SCO) && !defined(_SVID3)
3835 #       define _SVID3
3836 #   endif
3837 #   include <sys/statvfs.h>     /* for f?statvfs() */
3838 #endif
3839 #ifdef I_SYS_MOUNT
3840 #   include <sys/mount.h>       /* for *BSD f?statfs() */
3841 #endif
3842 #ifdef I_MNTENT
3843 #   include <mntent.h>          /* for getmntent() */
3844 #endif
3845 #ifdef I_SYS_STATFS
3846 #   include <sys/statfs.h>      /* for some statfs() */
3847 #endif
3848 #ifdef I_SYS_VFS
3849 #  ifdef __sgi
3850 #    define sv IRIX_sv          /* kludge: IRIX has an sv of its own */
3851 #  endif
3852 #    include <sys/vfs.h>        /* for some statfs() */
3853 #  ifdef __sgi
3854 #    undef IRIX_sv
3855 #  endif
3856 #endif
3857 #ifdef I_USTAT
3858 #   include <ustat.h>           /* for ustat() */
3859 #endif
3860
3861 #if !defined(PERL_MOUNT_NOSUID) && defined(MOUNT_NOSUID)
3862 #    define PERL_MOUNT_NOSUID MOUNT_NOSUID
3863 #endif
3864 #if !defined(PERL_MOUNT_NOSUID) && defined(MNT_NOSUID)
3865 #    define PERL_MOUNT_NOSUID MNT_NOSUID
3866 #endif
3867 #if !defined(PERL_MOUNT_NOSUID) && defined(MS_NOSUID)
3868 #   define PERL_MOUNT_NOSUID MS_NOSUID
3869 #endif
3870 #if !defined(PERL_MOUNT_NOSUID) && defined(M_NOSUID)
3871 #   define PERL_MOUNT_NOSUID M_NOSUID
3872 #endif
3873
3874 #endif /* IAMSUID */
3875
3876 #ifdef I_LIBUTIL
3877 #   include <libutil.h>         /* setproctitle() in some FreeBSDs */
3878 #endif
3879
3880 #ifndef EXEC_ARGV_CAST
3881 #define EXEC_ARGV_CAST(x) x
3882 #endif
3883
3884 #define IS_NUMBER_IN_UV               0x01 /* number within UV range (maybe not
3885                                               int).  value returned in pointed-
3886                                               to UV */
3887 #define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 /* pointed to UV undefined */
3888 #define IS_NUMBER_NOT_INT             0x04 /* saw . or E notation */
3889 #define IS_NUMBER_NEG                 0x08 /* leading minus sign */
3890 #define IS_NUMBER_INFINITY            0x10 /* this is big */
3891 #define IS_NUMBER_NAN                 0x20 /* this is not */
3892
3893 #define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send)
3894
3895 /* Input flags: */
3896 #define PERL_SCAN_ALLOW_UNDERSCORES   0x01 /* grok_??? accept _ in numbers */
3897 #define PERL_SCAN_DISALLOW_PREFIX     0x02 /* grok_??? reject 0x in hex etc */
3898 /* Output flags: */
3899 #define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 /* should this merge with above? */
3900
3901 /* to let user control profiling */
3902 #ifdef PERL_GPROF_CONTROL
3903 extern void moncontrol(int);
3904 #define PERL_GPROF_MONCONTROL(x) moncontrol(x)
3905 #else
3906 #define PERL_GPROF_MONCONTROL(x)
3907 #endif
3908
3909 /* and finally... */
3910 #define PERL_PATCHLEVEL_H_IMPLICIT
3911 #include "patchlevel.h"
3912 #undef PERL_PATCHLEVEL_H_IMPLICIT
3913
3914 /* Mention
3915
3916    NV_PRESERVES_UV
3917
3918    HAS_MKSTEMP
3919    HAS_MKSTEMPS
3920    HAS_MKDTEMP
3921
3922    HAS_GETCWD
3923
3924    HAS_MMAP
3925    HAS_MPROTECT
3926    HAS_MSYNC
3927    HAS_MADVISE
3928    HAS_MUNMAP
3929    I_SYSMMAN
3930    Mmap_t
3931
3932    NVef
3933    NVff
3934    NVgf
3935
3936    HAS_USLEEP
3937    HAS_UALARM
3938
3939    HAS_SETITIMER
3940    HAS_GETITIMER
3941
3942    HAS_SENDMSG
3943    HAS_RECVMSG
3944    HAS_READV
3945    HAS_WRITEV
3946    I_SYSUIO
3947    HAS_STRUCT_MSGHDR
3948    HAS_STRUCT_CMSGHDR
3949
3950    HAS_NL_LANGINFO
3951
3952    so that Configure picks them up. */
3953
3954 #ifdef UNDER_CE
3955 #include "wince.h"
3956 #endif
3957
3958 #endif /* Include guard */