3 * Copyright (c) 1987-1997, Larry Wall
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.
15 * This file is being used for x2p stuff.
16 * Above symbol is defined via -D in 'x2p/Makefile.SH'
17 * Decouple x2p stuff from some of perls more extreme eccentricities.
25 #endif /* PERL_FOR_X2P */
31 #define CPERLscope(x) CPerlObj::x
32 #define CPERLproto CPerlObj *
33 #define CPERLproto_ CPERLproto,
34 #define CPERLarg CPerlObj *pPerl
35 #define CPERLarg_ CPERLarg,
38 #define CALLRUNOPS (this->*runops)
40 #else /* !PERL_OBJECT */
43 #define CPERLscope(x) x
50 #define CALLRUNOPS runops
52 #endif /* PERL_OBJECT */
63 # define START_EXTERN_C extern "C" {
64 # define END_EXTERN_C }
65 # define EXTERN_C extern "C"
67 # define START_EXTERN_C
74 # define stringify_immed(s) #s
75 # define stringify(s) stringify_immed(s)
76 register struct op *op asm(stringify(OP_IN_REGISTER));
81 * STMT_START { statements; } STMT_END;
82 * can be used as a single statement, as in
83 * if (x) STMT_START { ... } STMT_END; else ...
85 * Trying to select a version that gives no warnings...
87 #if !(defined(STMT_START) && defined(STMT_END))
88 # if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(__cplusplus)
89 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
92 /* Now which other defined()s do we need here ??? */
93 # if (VOIDFLAGS) && (defined(sun) || defined(__sun__))
94 # define STMT_START if (1)
95 # define STMT_END else (void)0
97 # define STMT_START do
98 # define STMT_END while (0)
105 #define WITH_THR(s) STMT_START { dTHR; s; } STMT_END
108 * SOFT_CAST can be used for args to prototyped functions to retain some
109 * type checking; it only casts if the compiler does not know prototypes.
111 #if defined(CAN_PROTOTYPE) && defined(DEBUGGING_COMPILE)
112 #define SOFT_CAST(type)
114 #define SOFT_CAST(type) (type)
118 # define BYTEORDER 0x1234
121 /* Overall memory policy? */
127 * The following contortions are brought to you on behalf of all the
128 * standards, semi-standards, de facto standards, not-so-de-facto standards
129 * of the world, as well as all the other botches anyone ever thought of.
130 * The basic theory is that if we work hard enough here, the rest of the
131 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
134 /* define this once if either system, instead of cluttering up the src */
135 #if defined(MSDOS) || defined(atarist) || defined(WIN32)
139 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
140 # define STANDARD_C 1
143 #if defined(__cplusplus) || defined(WIN32) || defined(__sgi) || defined(OS2) \
145 # define DONT_DECLARE_STD 1
148 #if defined(NeXT) && !defined(_POSIX_SOURCE)
149 # define MISSING_PID_T
152 #if defined(HASVOLATILE) || defined(STANDARD_C)
154 # define VOL // to temporarily suppress warnings
156 # define VOL volatile
162 #define TAINT (tainted = TRUE)
163 #define TAINT_NOT (tainted = FALSE)
164 #define TAINT_IF(c) if (c) { tainted = TRUE; }
165 #define TAINT_ENV() if (tainting) { taint_env(); }
166 #define TAINT_PROPER(s) if (tainting) { taint_proper(no_security, s); }
172 /* XXX All process group stuff is handled in pp_sys.c. Should these
173 defines move there? If so, I could simplify this a lot. --AD 9/96.
175 /* Process group stuff changed from traditional BSD to POSIX.
176 perlfunc.pod documents the traditional BSD-style syntax, so we'll
177 try to preserve that, if possible.
180 # define BSD_SETPGRP(pid, pgrp) setpgid((pid), (pgrp))
182 # if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
183 # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
185 # ifdef HAS_SETPGRP2 /* DG/UX */
186 # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
190 #if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
191 # define HAS_SETPGRP /* Well, effectively it does . . . */
194 /* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
195 our life easier :-) so we'll try it.
198 # define BSD_GETPGRP(pid) getpgid((pid))
200 # if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
201 # define BSD_GETPGRP(pid) getpgrp((pid))
203 # ifdef HAS_GETPGRP2 /* DG/UX */
204 # define BSD_GETPGRP(pid) getpgrp2((pid))
208 #if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
209 # define HAS_GETPGRP /* Well, effectively it does . . . */
212 /* These are not exact synonyms, since setpgrp() and getpgrp() may
213 have different behaviors, but perl.h used to define USE_BSDPGRP
214 (prior to 5.003_05) so some extension might depend on it.
216 #if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
222 #ifndef _TYPES_ /* If types.h defines this it's easy. */
223 # ifndef major /* Does everyone's types.h define this? */
224 # include <sys/types.h>
238 # include <varargs.h>
245 #include "perlsock.h"
246 #include "perlproc.h"
250 #ifdef USE_NEXT_CTYPE
252 #if NX_CURRENT_COMPILER_RELEASE >= 400
253 #include <objc/NXCType.h>
254 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
255 #include <appkit/NXCType.h>
256 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
258 #else /* !USE_NEXT_CTYPE */
260 #endif /* USE_NEXT_CTYPE */
262 #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
270 #if !defined(NO_LOCALE) && defined(HAS_SETLOCALE)
272 # if !defined(NO_LOCALE_COLLATE) && defined(LC_COLLATE) \
273 && defined(HAS_STRXFRM)
274 # define USE_LOCALE_COLLATE
276 # if !defined(NO_LOCALE_CTYPE) && defined(LC_CTYPE)
277 # define USE_LOCALE_CTYPE
279 # if !defined(NO_LOCALE_NUMERIC) && defined(LC_NUMERIC)
280 # define USE_LOCALE_NUMERIC
282 #endif /* !NO_LOCALE && HAS_SETLOCALE */
287 # ifdef PARAM_NEEDS_TYPES
288 # include <sys/types.h>
290 # include <sys/param.h>
294 /* Use all the "standard" definitions? */
295 #if defined(STANDARD_C) && defined(I_STDLIB)
299 #define MEM_SIZE Size_t
301 /* This comes after <stdlib.h> so we don't try to change the standard
302 * library prototypes; we'll use our own in proto.h instead. */
307 # define malloc Mymalloc
308 # define calloc Mycalloc
309 # define realloc Myremalloc
311 Malloc_t Mymalloc _((MEM_SIZE nbytes));
312 Malloc_t Mycalloc _((MEM_SIZE elements, MEM_SIZE size));
313 Malloc_t Myrealloc _((Malloc_t where, MEM_SIZE nbytes));
314 Free_t Myfree _((Malloc_t where));
316 # ifdef EMBEDMYMALLOC
317 # define malloc Perl_malloc
318 # define calloc Perl_calloc
319 # define realloc Perl_realloc
320 # define free Perl_free
321 Malloc_t Perl_malloc _((MEM_SIZE nbytes));
322 Malloc_t Perl_calloc _((MEM_SIZE elements, MEM_SIZE size));
323 Malloc_t Perl_realloc _((Malloc_t where, MEM_SIZE nbytes));
324 Free_t Perl_free _((Malloc_t where));
331 # define safemalloc malloc
332 # define safecalloc calloc
333 # define saferealloc realloc
334 # define safefree free
336 #endif /* MYMALLOC */
338 #if defined(STANDARD_C) && defined(I_STDDEF)
340 # define STRUCT_OFFSET(s,m) offsetof(s,m)
342 # define STRUCT_OFFSET(s,m) (Size_t)(&(((s *)0)->m))
345 #if defined(I_STRING) || defined(__cplusplus)
348 # include <strings.h>
351 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
353 #define strrchr rindex
361 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
363 extern char * memcpy _((char*, char*, int));
369 # define memcpy(d,s,l) bcopy(s,d,l)
371 # define memcpy(d,s,l) my_bcopy(s,d,l)
374 #endif /* HAS_MEMCPY */
377 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
379 extern char *memset _((char*, int, int));
383 # define memset(d,c,l) my_memset(d,c,l)
384 #endif /* HAS_MEMSET */
386 #if !defined(HAS_MEMMOVE) && !defined(memmove)
387 # if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
388 # define memmove(d,s,l) bcopy(s,d,l)
390 # if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
391 # define memmove(d,s,l) memcpy(d,s,l)
393 # define memmove(d,s,l) my_bcopy(s,d,l)
398 #if defined(mips) && defined(ultrix) && !defined(__STDC__)
402 #if defined(HAS_MEMCMP) && defined(HAS_SANE_MEMCMP)
403 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
405 extern int memcmp _((char*, char*, int));
409 # pragma function(memcmp)
413 # define memcmp my_memcmp
415 #endif /* HAS_MEMCMP && HAS_SANE_MEMCMP */
419 # define memzero(d,l) memset(d,0,l)
422 # define memzero(d,l) bzero(d,l)
424 # define memzero(d,l) my_bzero(d,l)
431 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
433 #endif /* !HAS_BCMP */
436 # include <netinet/in.h>
439 #if defined(SF_APPEND) && defined(USE_SFIO) && defined(I_SFIO)
440 /* <sfio.h> defines SF_APPEND and <sys/stat.h> might define SF_APPEND
441 * (the neo-BSD seem to do this). */
446 # include <sys/stat.h>
449 /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
450 like UTekV) are broken, sometimes giving false positives. Undefine
451 them here and let the code below set them to proper values.
453 The ghs macro stands for GreenHills Software C-1.8.5 which
454 is the C compiler for sysV88 and the various derivatives.
455 This header file bug is corrected in gcc-2.5.8 and later versions.
456 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
458 #if defined(uts) || (defined(m88k) && defined(ghs))
472 # ifdef I_SYS_TIME_KERNEL
475 # include <sys/time.h>
476 # ifdef I_SYS_TIME_KERNEL
481 #if defined(HAS_TIMES) && defined(I_SYS_TIMES)
482 # include <sys/times.h>
485 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
491 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
493 #endif /* !HAS_MKFIFO */
498 # include <net/errno.h>
503 # define SETERRNO(errcode,vmserrcode) \
505 set_errno(errcode); \
506 set_vaxc_errno(vmserrcode); \
509 # define SETERRNO(errcode,vmserrcode) errno = (errcode)
513 # define ERRSV (thr->errsv)
514 # define ERRHV (thr->errhv)
515 # define DEFSV THREADSV(0)
516 # define SAVE_DEFSV save_threadsv(0)
518 # define ERRSV GvSV(errgv)
519 # define ERRHV GvHV(errgv)
520 # define DEFSV GvSV(defgv)
521 # define SAVE_DEFSV SAVESPTR(GvSV(defgv))
522 #endif /* USE_THREADS */
525 extern int errno; /* ANSI allows errno to be an lvalue expr */
530 char *strerror _((int,...));
532 #ifndef DONT_DECLARE_STD
533 char *strerror _((int));
537 # define Strerror strerror
540 # ifdef HAS_SYS_ERRLIST
542 extern char *sys_errlist[];
544 # define Strerror(e) \
545 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
552 # include <sys/ioctl.h>
556 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
557 # ifdef HAS_SOCKETPAIR
558 # undef HAS_SOCKETPAIR
573 /* Configure already sets Direntry_t */
574 #if defined(I_DIRENT)
576 # if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
577 # include <sys/dir.h>
581 # include <sys/ndir.h>
585 # include <ndir.h> /* may be wrong in the future */
587 # include <sys/dir.h>
594 /* work around botch in SunOS 4.0.1 and 4.0.2 */
596 # define fputs(sv,fp) fprintf(fp,"%s",sv)
601 * The following gobbledygook brought to you on behalf of __STDC__.
602 * (I could just use #ifndef __STDC__, but this is more bulletproof
603 * in the face of half-implementations.)
608 # define S_IFMT _S_IFMT
610 # define S_IFMT 0170000
615 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
619 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
624 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
626 # define S_ISBLK(m) (0)
631 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
636 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
638 # define S_ISFIFO(m) (0)
644 # define S_ISLNK(m) _S_ISLNK(m)
647 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
650 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
652 # define S_ISLNK(m) (0)
660 # define S_ISSOCK(m) _S_ISSOCK(m)
663 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
666 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
668 # define S_ISSOCK(m) (0)
676 # define S_IRUSR S_IREAD
677 # define S_IWUSR S_IWRITE
678 # define S_IXUSR S_IEXEC
680 # define S_IRUSR 0400
681 # define S_IWUSR 0200
682 # define S_IXUSR 0100
684 # define S_IRGRP (S_IRUSR>>3)
685 # define S_IWGRP (S_IWUSR>>3)
686 # define S_IXGRP (S_IXUSR>>3)
687 # define S_IROTH (S_IRUSR>>6)
688 # define S_IWOTH (S_IWUSR>>6)
689 # define S_IXOTH (S_IXUSR>>6)
693 # define S_ISUID 04000
697 # define S_ISGID 02000
704 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
705 # define SLOPPYDIVIDE
712 /* XXX QUAD stuff is not currently supported on most systems.
713 Specifically, perl internals don't support long long. Among
714 the many problems is that some compilers support long long,
715 but the underlying library functions (such as sprintf) don't.
716 Some things do work (such as quad pack/unpack on convex);
717 also some systems use long long for the fpos_t typedef. That
720 The IV type is supposed to be long enough to hold any integral
722 --Andy Dougherty August 1996
729 # define Quad_t long long
731 # if BYTEORDER > 0xFFFF
740 typedef unsigned Quad_t UV;
741 # define IV_MAX PERL_QUAD_MAX
742 # define IV_MIN PERL_QUAD_MIN
743 # define UV_MAX PERL_UQUAD_MAX
744 # define UV_MIN PERL_UQUAD_MIN
747 typedef unsigned long UV;
748 # define IV_MAX PERL_LONG_MAX
749 # define IV_MIN PERL_LONG_MIN
750 # define UV_MAX PERL_ULONG_MAX
751 # define UV_MIN PERL_ULONG_MIN
754 /* Previously these definitions used hardcoded figures.
755 * It is hoped these formula are more portable, although
756 * no data one way or another is presently known to me.
757 * The "PERL_" names are used because these calculated constants
758 * do not meet the ANSI requirements for LONG_MAX, etc., which
759 * need to be constants acceptable to #if - kja
760 * define PERL_LONG_MAX 2147483647L
761 * define PERL_LONG_MIN (-LONG_MAX - 1)
762 * define PERL ULONG_MAX 4294967295L
765 #ifdef I_LIMITS /* Needed for cast_xxx() functions below. */
774 * Try to figure out max and min values for the integral types. THE CORRECT
775 * SOLUTION TO THIS MESS: ADAPT enquire.c FROM GCC INTO CONFIGURE. The
776 * following hacks are used if neither limits.h or values.h provide them:
777 * U<TYPE>_MAX: for types >= int: ~(unsigned TYPE)0
778 * for types < int: (unsigned TYPE)~(unsigned)0
779 * The argument to ~ must be unsigned so that later signed->unsigned
780 * conversion can't modify the value's bit pattern (e.g. -0 -> +0),
781 * and it must not be smaller than int because ~ does integral promotion.
782 * <type>_MAX: (<type>) (U<type>_MAX >> 1)
783 * <type>_MIN: -<type>_MAX - <is_twos_complement_architecture: (3 & -1) == 3>.
784 * The latter is a hack which happens to work on some machines but
785 * does *not* catch any random system, or things like integer types
786 * with NaN if that is possible.
788 * All of the types are explicitly cast to prevent accidental loss of
789 * numeric range, and in the hope that they will be less likely to confuse
790 * over-eager optimizers.
794 #define PERL_UCHAR_MIN ((unsigned char)0)
797 # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
800 # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
802 # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
807 * CHAR_MIN and CHAR_MAX are not included here, as the (char) type may be
808 * ambiguous. It may be equivalent to (signed char) or (unsigned char)
809 * depending on local options. Until Configure detects this (or at least
810 * detects whether the "signed" keyword is available) the CHAR ranges
811 * will not be included. UCHAR functions normally.
815 #define PERL_USHORT_MIN ((unsigned short)0)
818 # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
821 # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
823 # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
828 # define PERL_SHORT_MAX ((short)SHORT_MAX)
830 # ifdef MAXSHORT /* Often used in <values.h> */
831 # define PERL_SHORT_MAX ((short)MAXSHORT)
833 # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
838 # define PERL_SHORT_MIN ((short)SHORT_MIN)
841 # define PERL_SHORT_MIN ((short)MINSHORT)
843 # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
848 # define PERL_UINT_MAX ((unsigned int)UINT_MAX)
851 # define PERL_UINT_MAX ((unsigned int)MAXUINT)
853 # define PERL_UINT_MAX (~(unsigned int)0)
857 #define PERL_UINT_MIN ((unsigned int)0)
860 # define PERL_INT_MAX ((int)INT_MAX)
862 # ifdef MAXINT /* Often used in <values.h> */
863 # define PERL_INT_MAX ((int)MAXINT)
865 # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
870 # define PERL_INT_MIN ((int)INT_MIN)
873 # define PERL_INT_MIN ((int)MININT)
875 # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
880 # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
883 # define PERL_ULONG_MAX ((unsigned long)MAXULONG)
885 # define PERL_ULONG_MAX (~(unsigned long)0)
889 #define PERL_ULONG_MIN ((unsigned long)0L)
892 # define PERL_LONG_MAX ((long)LONG_MAX)
894 # ifdef MAXLONG /* Often used in <values.h> */
895 # define PERL_LONG_MAX ((long)MAXLONG)
897 # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
902 # define PERL_LONG_MIN ((long)LONG_MIN)
905 # define PERL_LONG_MIN ((long)MINLONG)
907 # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
914 # define PERL_UQUAD_MAX ((UV)UQUAD_MAX)
916 # define PERL_UQUAD_MAX (~(UV)0)
919 # define PERL_UQUAD_MIN ((UV)0)
922 # define PERL_QUAD_MAX ((IV)QUAD_MAX)
924 # define PERL_QUAD_MAX ((IV) (PERL_UQUAD_MAX >> 1))
928 # define PERL_QUAD_MIN ((IV)QUAD_MIN)
930 # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
935 typedef MEM_SIZE STRLEN;
937 typedef struct op OP;
938 typedef struct cop COP;
939 typedef struct unop UNOP;
940 typedef struct binop BINOP;
941 typedef struct listop LISTOP;
942 typedef struct logop LOGOP;
943 typedef struct condop CONDOP;
944 typedef struct pmop PMOP;
945 typedef struct svop SVOP;
946 typedef struct gvop GVOP;
947 typedef struct pvop PVOP;
948 typedef struct loop LOOP;
950 typedef struct Outrec Outrec;
951 typedef struct interpreter PerlInterpreter;
953 typedef struct ff FF; /* XXX not defined anywhere, should go? */
955 typedef struct sv SV;
956 typedef struct av AV;
957 typedef struct hv HV;
958 typedef struct cv CV;
959 typedef struct regexp REGEXP;
960 typedef struct gp GP;
961 typedef struct gv GV;
962 typedef struct io IO;
963 typedef struct context PERL_CONTEXT;
964 typedef struct block BLOCK;
966 typedef struct magic MAGIC;
967 typedef struct xrv XRV;
968 typedef struct xpv XPV;
969 typedef struct xpviv XPVIV;
970 typedef struct xpvuv XPVUV;
971 typedef struct xpvnv XPVNV;
972 typedef struct xpvmg XPVMG;
973 typedef struct xpvlv XPVLV;
974 typedef struct xpvav XPVAV;
975 typedef struct xpvhv XPVHV;
976 typedef struct xpvgv XPVGV;
977 typedef struct xpvcv XPVCV;
978 typedef struct xpvbm XPVBM;
979 typedef struct xpvfm XPVFM;
980 typedef struct xpvio XPVIO;
981 typedef struct mgvtbl MGVTBL;
982 typedef union any ANY;
986 typedef I32 (*filter_t) _((int, SV *, int));
987 #define FILTER_READ(idx, sv, len) filter_read(idx, sv, len)
988 #define FILTER_DATA(idx) (AvARRAY(rsfp_filters)[idx])
989 #define FILTER_ISREADER(idx) (idx >= AvFILLp(rsfp_filters))
1002 # include "./plan9/plan9ish.h"
1004 # include "unixish.h"
1010 * USE_THREADS needs to be after unixish.h as <pthread.h> includes
1011 * <sys/signal.h> which defines NSIG - which will stop inclusion of <signal.h>
1012 * this results in many functions being undeclared which bothers C++
1013 * May make sense to have threads after "*ish.h" anyway
1017 # ifdef FAKE_THREADS
1018 # include "fakethr.h"
1021 # include <win32thread.h>
1024 # include "os2thread.h"
1026 # include <pthread.h>
1027 typedef pthread_t perl_os_thread;
1028 typedef pthread_mutex_t perl_mutex;
1029 typedef pthread_cond_t perl_cond;
1030 typedef pthread_key_t perl_key;
1033 # endif /* FAKE_THREADS */
1034 #endif /* USE_THREADS */
1039 # define STATUS_NATIVE statusvalue_vms
1040 # define STATUS_NATIVE_EXPORT \
1041 ((I32)statusvalue_vms == -1 ? 44 : statusvalue_vms)
1042 # define STATUS_NATIVE_SET(n) \
1044 statusvalue_vms = (n); \
1045 if ((I32)statusvalue_vms == -1) \
1047 else if (statusvalue_vms & STS$M_SUCCESS) \
1049 else if ((statusvalue_vms & STS$M_SEVERITY) == 0) \
1050 statusvalue = 1 << 8; \
1052 statusvalue = (statusvalue_vms & STS$M_SEVERITY) << 8; \
1054 # define STATUS_POSIX statusvalue
1055 # ifdef VMSISH_STATUS
1056 # define STATUS_CURRENT (VMSISH_STATUS ? STATUS_NATIVE : STATUS_POSIX)
1058 # define STATUS_CURRENT STATUS_POSIX
1060 # define STATUS_POSIX_SET(n) \
1062 statusvalue = (n); \
1063 if (statusvalue != -1) { \
1064 statusvalue &= 0xFFFF; \
1065 statusvalue_vms = statusvalue ? 44 : 1; \
1067 else statusvalue_vms = -1; \
1069 # define STATUS_ALL_SUCCESS (statusvalue = 0, statusvalue_vms = 1)
1070 # define STATUS_ALL_FAILURE (statusvalue = 1, statusvalue_vms = 44)
1072 # define STATUS_NATIVE STATUS_POSIX
1073 # define STATUS_NATIVE_EXPORT STATUS_POSIX
1074 # define STATUS_NATIVE_SET STATUS_POSIX_SET
1075 # define STATUS_POSIX statusvalue
1076 # define STATUS_POSIX_SET(n) \
1078 statusvalue = (n); \
1079 if (statusvalue != -1) \
1080 statusvalue &= 0xFFFF; \
1082 # define STATUS_CURRENT STATUS_POSIX
1083 # define STATUS_ALL_SUCCESS (statusvalue = 0)
1084 # define STATUS_ALL_FAILURE (statusvalue = 1)
1087 /* Some unistd.h's give a prototype for pause() even though
1088 HAS_PAUSE ends up undefined. This causes the #define
1089 below to be rejected by the compmiler. Sigh.
1094 #define Pause() sleep((32767<<16)+32767)
1098 # ifdef IOCPARM_MASK
1099 /* on BSDish systes we're safe */
1100 # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
1102 /* otherwise guess at what's safe */
1103 # define IOCPARM_LEN(x) 256
1112 void (CPERLscope(*any_dptr)) _((void*));
1116 #define ARGSproto struct perl_thread *thr
1118 #define ARGSproto void
1119 #endif /* USE_THREADS */
1121 /* Work around some cygwin32 problems with importing global symbols */
1122 #if defined(CYGWIN32) && defined(DLLIMPORT)
1123 # include "cw32imp.h"
1140 /* Current curly descriptor */
1141 typedef struct curcur CURCUR;
1143 int parenfloor; /* how far back to strip paren data */
1144 int cur; /* how many instances of scan we've matched */
1145 int min; /* the minimal number of scans to match */
1146 int max; /* the maximal number of scans to match */
1147 int minmod; /* whether to work our way up or down */
1148 regnode * scan; /* the thing to match */
1149 regnode * next; /* what has to match after it */
1150 char * lastloc; /* where we started matching this scan */
1151 CURCUR * oldcc; /* current curly before we started this one */
1154 typedef struct _sublex_info SUBLEXINFO;
1155 struct _sublex_info {
1156 I32 super_state; /* lexer state to save */
1157 I32 sub_inwhat; /* "lex_inwhat" to use */
1158 OP *sub_op; /* "lex_op" to use */
1162 struct magic_state {
1166 typedef struct magic_state MGS;
1174 I32 last_end; /* min value, <0 unless valid. */
1177 SV **longest; /* Either &l_fixed, or &l_float. */
1181 I32 offset_float_min;
1182 I32 offset_float_max;
1186 typedef I32 CHECKPOINT;
1187 #endif /* PERL_OBJECT */
1189 /* work around some libPW problems */
1194 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
1198 #if defined(htonl) && !defined(HAS_HTONL)
1201 #if defined(htons) && !defined(HAS_HTONS)
1204 #if defined(ntohl) && !defined(HAS_NTOHL)
1207 #if defined(ntohs) && !defined(HAS_NTOHS)
1211 #if (BYTEORDER & 0xffff) != 0x4321
1217 #define htons my_swap
1218 #define htonl my_htonl
1219 #define ntohs my_swap
1220 #define ntohl my_ntohl
1223 #if (BYTEORDER & 0xffff) == 0x4321
1232 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
1235 #if BYTEORDER != 0x1234
1240 # if BYTEORDER == 0x4321
1241 # define vtohl(x) ((((x)&0xFF)<<24) \
1243 +(((x)&0x0000FF00)<<8) \
1244 +(((x)&0x00FF0000)>>8) )
1245 # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
1246 # define htovl(x) vtohl(x)
1247 # define htovs(x) vtohs(x)
1249 /* otherwise default to functions in util.c */
1253 #define U_S(what) ((U16)(what))
1254 #define U_I(what) ((unsigned int)(what))
1255 #define U_L(what) ((U32)(what))
1257 EXTERN_C U32 cast_ulong _((double));
1258 #define U_S(what) ((U16)cast_ulong((double)(what)))
1259 #define U_I(what) ((unsigned int)cast_ulong((double)(what)))
1260 #define U_L(what) (cast_ulong((double)(what)))
1264 #define I_32(what) ((I32)(what))
1265 #define I_V(what) ((IV)(what))
1266 #define U_V(what) ((UV)(what))
1269 I32 cast_i32 _((double));
1270 IV cast_iv _((double));
1271 UV cast_uv _((double));
1273 #define I_32(what) (cast_i32((double)(what)))
1274 #define I_V(what) (cast_iv((double)(what)))
1275 #define U_V(what) (cast_uv((double)(what)))
1289 # define TMPPATH "/tmp/perl-eXXXXXX"
1293 Uid_t getuid _((void));
1294 Uid_t geteuid _((void));
1295 Gid_t getgid _((void));
1296 Gid_t getegid _((void));
1300 #ifndef Perl_debug_log
1301 #define Perl_debug_log PerlIO_stderr()
1305 #define DEBUG(a) if (debug) a
1306 #define DEBUG_p(a) if (debug & 1) a
1307 #define DEBUG_s(a) if (debug & 2) a
1308 #define DEBUG_l(a) if (debug & 4) a
1309 #define DEBUG_t(a) if (debug & 8) a
1310 #define DEBUG_o(a) if (debug & 16) a
1311 #define DEBUG_c(a) if (debug & 32) a
1312 #define DEBUG_P(a) if (debug & 64) a
1313 #define DEBUG_m(a) if (curinterp && debug & 128) a
1314 #define DEBUG_f(a) if (debug & 256) a
1315 #define DEBUG_r(a) if (debug & 512) a
1316 #define DEBUG_x(a) if (debug & 1024) a
1317 #define DEBUG_u(a) if (debug & 2048) a
1318 #define DEBUG_L(a) if (debug & 4096) a
1319 #define DEBUG_H(a) if (debug & 8192) a
1320 #define DEBUG_X(a) if (debug & 16384) a
1321 #define DEBUG_D(a) if (debug & 32768) a
1342 #define YYMAXDEPTH 300
1344 #ifndef assert /* <assert.h> might have been included somehow */
1345 #define assert(what) DEB( { \
1347 croak("Assertion failed: file \"%s\", line %d", \
1348 __FILE__, __LINE__); \
1354 I32 (*uf_val)_((IV, SV*));
1355 I32 (*uf_set)_((IV, SV*));
1359 /* Fix these up for __STDC__ */
1360 #ifndef DONT_DECLARE_STD
1361 char *mktemp _((char*));
1362 double atof _((const char*));
1366 /* All of these are in stdlib.h or time.h for ANSI C */
1368 struct tm *gmtime(), *localtime();
1369 char *strchr(), *strrchr();
1370 char *strcpy(), *strcat();
1371 #endif /* ! STANDARD_C */
1378 double exp _((double));
1379 double log _((double));
1380 double log10 _((double));
1381 double sqrt _((double));
1382 double frexp _((double,int*));
1383 double ldexp _((double,int));
1384 double modf _((double,double*));
1385 double sin _((double));
1386 double cos _((double));
1387 double atan2 _((double,double));
1388 double pow _((double,double));
1393 # ifdef __NeXT__ /* or whatever catches all NeXTs */
1394 char *crypt (); /* Maybe more hosts will need the unprototyped version */
1396 # if !defined(WIN32) || !defined(HAVE_DES_FCRYPT)
1397 char *crypt _((const char*, const char*));
1398 # endif /* !WIN32 && !HAVE_CRYPT_SOURCE */
1399 # endif /* !__NeXT__ */
1400 # ifndef DONT_DECLARE_STD
1402 char *getenv _((const char*));
1403 # endif /* !getenv */
1404 Off_t lseek _((int,Off_t,int));
1405 # endif /* !DONT_DECLARE_STD */
1406 char *getlogin _((void));
1407 #endif /* !__cplusplus */
1409 #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
1410 #define UNLINK unlnk
1411 I32 unlnk _((char*));
1413 #define UNLINK unlink
1416 #ifndef HAS_SETREUID
1417 # ifdef HAS_SETRESUID
1418 # define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
1419 # define HAS_SETREUID
1422 #ifndef HAS_SETREGID
1423 # ifdef HAS_SETRESGID
1424 # define setregid(r,e) setresgid(r,e,(Gid_t)-1)
1425 # define HAS_SETREGID
1429 typedef Signal_t (*Sighandler_t) _((int));
1431 #ifdef HAS_SIGACTION
1432 typedef struct sigaction Sigsave_t;
1434 typedef Sighandler_t Sigsave_t;
1445 # define PAD_SV(po) pad_sv(po)
1446 # define RUNOPS_DEFAULT runops_debug
1448 # define PAD_SV(po) curpad[po]
1449 # define RUNOPS_DEFAULT runops_standard
1453 # define MALLOC_INIT MUTEX_INIT(&malloc_mutex)
1454 # define MALLOC_TERM MUTEX_DESTROY(&malloc_mutex)
1456 # define MALLOC_INIT
1457 # define MALLOC_TERM
1462 * These need prototyping here because <proto.h> isn't
1463 * included until after runops is initialised.
1467 typedef int runops_proc_t _((void));
1468 int runops_standard _((void));
1470 int runops_debug _((void));
1472 #endif /* PERL_OBJECT */
1474 /* _ (for $_) must be first in the following list (DEFSV requires it) */
1475 #define THREADSV_NAMES "_123456789&`'+/.,\\\";^-%=|~:\001\005!@"
1477 /* VMS doesn't use environ array and NeXT has problems with crt0.o globals */
1478 #if !defined(VMS) && !(defined(NeXT) && defined(__DYNAMIC__))
1479 #if !defined(DONT_DECLARE_STD) \
1480 || (defined(__svr4__) && defined(__GNUC__) && defined(sun)) \
1481 || defined(__sgi) || defined(__DGUX)
1482 extern char ** environ; /* environment variables supplied via exec */
1485 # if defined(NeXT) && defined(__DYNAMIC__)
1487 # include <mach-o/dyld.h>
1488 EXT char *** environ_pointer;
1489 # define environ (*environ_pointer)
1491 #endif /* environ processing */
1494 /* for tmp use in stupid debuggers */
1499 /* handy constants */
1500 EXTCONST char warn_uninit[]
1501 INIT("Use of uninitialized value");
1502 EXTCONST char warn_nosemi[]
1503 INIT("Semicolon seems to be missing");
1504 EXTCONST char warn_reserved[]
1505 INIT("Unquoted string \"%s\" may clash with future reserved word");
1506 EXTCONST char warn_nl[]
1507 INIT("Unsuccessful %s on filename containing newline");
1508 EXTCONST char no_wrongref[]
1509 INIT("Can't use %s ref as %s ref");
1510 EXTCONST char no_symref[]
1511 INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
1512 EXTCONST char no_usym[]
1513 INIT("Can't use an undefined value as %s reference");
1514 EXTCONST char no_aelem[]
1515 INIT("Modification of non-creatable array value attempted, subscript %d");
1516 EXTCONST char no_helem[]
1517 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
1518 EXTCONST char no_modify[]
1519 INIT("Modification of a read-only value attempted");
1520 EXTCONST char no_mem[]
1521 INIT("Out of memory!\n");
1522 EXTCONST char no_security[]
1523 INIT("Insecure dependency in %s%s");
1524 EXTCONST char no_sock_func[]
1525 INIT("Unsupported socket function \"%s\" called");
1526 EXTCONST char no_dir_func[]
1527 INIT("Unsupported directory function \"%s\" called");
1528 EXTCONST char no_func[]
1529 INIT("The %s function is unimplemented");
1530 EXTCONST char no_myglob[]
1531 INIT("\"my\" variable %s can't be in a package");
1534 EXT char *sig_name[] = { SIG_NAME };
1535 EXT int sig_num[] = { SIG_NUM };
1536 EXT SV * psig_ptr[sizeof(sig_num)/sizeof(*sig_num)];
1537 EXT SV * psig_name[sizeof(sig_num)/sizeof(*sig_num)];
1539 EXT char *sig_name[];
1541 EXT SV * psig_ptr[];
1542 EXT SV * psig_name[];
1545 /* fast case folding tables */
1548 EXTCONST unsigned char fold[] = {
1549 0, 1, 2, 3, 4, 5, 6, 7,
1550 8, 9, 10, 11, 12, 13, 14, 15,
1551 16, 17, 18, 19, 20, 21, 22, 23,
1552 24, 25, 26, 27, 28, 29, 30, 31,
1553 32, 33, 34, 35, 36, 37, 38, 39,
1554 40, 41, 42, 43, 44, 45, 46, 47,
1555 48, 49, 50, 51, 52, 53, 54, 55,
1556 56, 57, 58, 59, 60, 61, 62, 63,
1557 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1558 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1559 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1560 'x', 'y', 'z', 91, 92, 93, 94, 95,
1561 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1562 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1563 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1564 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1565 128, 129, 130, 131, 132, 133, 134, 135,
1566 136, 137, 138, 139, 140, 141, 142, 143,
1567 144, 145, 146, 147, 148, 149, 150, 151,
1568 152, 153, 154, 155, 156, 157, 158, 159,
1569 160, 161, 162, 163, 164, 165, 166, 167,
1570 168, 169, 170, 171, 172, 173, 174, 175,
1571 176, 177, 178, 179, 180, 181, 182, 183,
1572 184, 185, 186, 187, 188, 189, 190, 191,
1573 192, 193, 194, 195, 196, 197, 198, 199,
1574 200, 201, 202, 203, 204, 205, 206, 207,
1575 208, 209, 210, 211, 212, 213, 214, 215,
1576 216, 217, 218, 219, 220, 221, 222, 223,
1577 224, 225, 226, 227, 228, 229, 230, 231,
1578 232, 233, 234, 235, 236, 237, 238, 239,
1579 240, 241, 242, 243, 244, 245, 246, 247,
1580 248, 249, 250, 251, 252, 253, 254, 255
1583 EXTCONST unsigned char fold[];
1587 EXT unsigned char fold_locale[] = {
1588 0, 1, 2, 3, 4, 5, 6, 7,
1589 8, 9, 10, 11, 12, 13, 14, 15,
1590 16, 17, 18, 19, 20, 21, 22, 23,
1591 24, 25, 26, 27, 28, 29, 30, 31,
1592 32, 33, 34, 35, 36, 37, 38, 39,
1593 40, 41, 42, 43, 44, 45, 46, 47,
1594 48, 49, 50, 51, 52, 53, 54, 55,
1595 56, 57, 58, 59, 60, 61, 62, 63,
1596 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1597 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1598 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1599 'x', 'y', 'z', 91, 92, 93, 94, 95,
1600 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1601 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1602 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1603 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1604 128, 129, 130, 131, 132, 133, 134, 135,
1605 136, 137, 138, 139, 140, 141, 142, 143,
1606 144, 145, 146, 147, 148, 149, 150, 151,
1607 152, 153, 154, 155, 156, 157, 158, 159,
1608 160, 161, 162, 163, 164, 165, 166, 167,
1609 168, 169, 170, 171, 172, 173, 174, 175,
1610 176, 177, 178, 179, 180, 181, 182, 183,
1611 184, 185, 186, 187, 188, 189, 190, 191,
1612 192, 193, 194, 195, 196, 197, 198, 199,
1613 200, 201, 202, 203, 204, 205, 206, 207,
1614 208, 209, 210, 211, 212, 213, 214, 215,
1615 216, 217, 218, 219, 220, 221, 222, 223,
1616 224, 225, 226, 227, 228, 229, 230, 231,
1617 232, 233, 234, 235, 236, 237, 238, 239,
1618 240, 241, 242, 243, 244, 245, 246, 247,
1619 248, 249, 250, 251, 252, 253, 254, 255
1622 EXT unsigned char fold_locale[];
1626 EXTCONST unsigned char freq[] = { /* letter frequencies for mixed English/C */
1627 1, 2, 84, 151, 154, 155, 156, 157,
1628 165, 246, 250, 3, 158, 7, 18, 29,
1629 40, 51, 62, 73, 85, 96, 107, 118,
1630 129, 140, 147, 148, 149, 150, 152, 153,
1631 255, 182, 224, 205, 174, 176, 180, 217,
1632 233, 232, 236, 187, 235, 228, 234, 226,
1633 222, 219, 211, 195, 188, 193, 185, 184,
1634 191, 183, 201, 229, 181, 220, 194, 162,
1635 163, 208, 186, 202, 200, 218, 198, 179,
1636 178, 214, 166, 170, 207, 199, 209, 206,
1637 204, 160, 212, 216, 215, 192, 175, 173,
1638 243, 172, 161, 190, 203, 189, 164, 230,
1639 167, 248, 227, 244, 242, 255, 241, 231,
1640 240, 253, 169, 210, 245, 237, 249, 247,
1641 239, 168, 252, 251, 254, 238, 223, 221,
1642 213, 225, 177, 197, 171, 196, 159, 4,
1643 5, 6, 8, 9, 10, 11, 12, 13,
1644 14, 15, 16, 17, 19, 20, 21, 22,
1645 23, 24, 25, 26, 27, 28, 30, 31,
1646 32, 33, 34, 35, 36, 37, 38, 39,
1647 41, 42, 43, 44, 45, 46, 47, 48,
1648 49, 50, 52, 53, 54, 55, 56, 57,
1649 58, 59, 60, 61, 63, 64, 65, 66,
1650 67, 68, 69, 70, 71, 72, 74, 75,
1651 76, 77, 78, 79, 80, 81, 82, 83,
1652 86, 87, 88, 89, 90, 91, 92, 93,
1653 94, 95, 97, 98, 99, 100, 101, 102,
1654 103, 104, 105, 106, 108, 109, 110, 111,
1655 112, 113, 114, 115, 116, 117, 119, 120,
1656 121, 122, 123, 124, 125, 126, 127, 128,
1657 130, 131, 132, 133, 134, 135, 136, 137,
1658 138, 139, 141, 142, 143, 144, 145, 146
1661 EXTCONST unsigned char freq[];
1666 EXTCONST char* block_type[] = {
1675 EXTCONST char* block_type[];
1679 /*****************************************************************************/
1680 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1681 /*****************************************************************************/
1682 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
1686 #define LEX_NOTPARSING 11 /* borrowed from toke.c */
1698 /* Note: the lowest 8 bits are reserved for
1699 stuffing into op->op_private */
1700 #define HINT_INTEGER 0x00000001
1701 #define HINT_STRICT_REFS 0x00000002
1703 #define HINT_BLOCK_SCOPE 0x00000100
1704 #define HINT_STRICT_SUBS 0x00000200
1705 #define HINT_STRICT_VARS 0x00000400
1706 #define HINT_LOCALE 0x00000800
1708 /* Various states of an input record separator SV (rs, nrs) */
1709 #define RsSNARF(sv) (! SvOK(sv))
1710 #define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv))
1711 #define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv))
1713 /* Set up PERLVAR macros for populating structs */
1714 #define PERLVAR(var,type) type var;
1715 #define PERLVARI(var,type,init) type var;
1716 #define PERLVARIC(var,type,init) type var;
1719 extern "C" CPerlObj* perl_alloc _((IPerlMem*, IPerlEnv*, IPerlStdIO*, IPerlLIO*, IPerlDir*, IPerlSock*, IPerlProc*));
1721 typedef int (CPerlObj::*runops_proc_t) _((void));
1731 CPerlObj(IPerlMem*, IPerlEnv*, IPerlStdIO*, IPerlLIO*, IPerlDir*, IPerlSock*, IPerlProc*);
1733 void* operator new(size_t nSize, IPerlMem *pvtbl);
1734 #endif /* PERL_OBJECT */
1736 #ifdef PERL_GLOBAL_STRUCT
1738 #include "perlvars.h"
1742 EXT struct perl_vars Perl_Vars;
1743 EXT struct perl_vars *Perl_VarsPtr INIT(&Perl_Vars);
1745 #if !defined(__GNUC__) || !defined(WIN32)
1748 struct perl_vars *Perl_VarsPtr;
1749 #define Perl_Vars (*((Perl_VarsPtr) ? Perl_VarsPtr : (Perl_VarsPtr = Perl_GetVars())))
1751 #endif /* PERL_GLOBAL_STRUCT */
1754 /* If we have multiple interpreters define a struct
1755 holding variables which must be per-interpreter
1756 If we don't have threads anything that would have
1757 be per-thread is per-interpreter.
1760 struct interpreter {
1762 #include "thrdvar.h"
1764 #include "intrpvar.h"
1768 struct interpreter {
1774 /* If we have threads define a struct with all the variables
1775 * that have to be per-thread
1779 struct perl_thread {
1780 #include "thrdvar.h"
1783 typedef struct perl_thread *Thread;
1786 typedef void *Thread;
1789 /* Done with PERLVAR macros for now ... */
1799 #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1800 #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1802 #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1803 #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1806 /* The following must follow proto.h as #defines mess up syntax */
1808 #include "embedvar.h"
1810 /* Now include all the 'global' variables
1811 * If we don't have threads or multiple interpreters
1812 * these include variables that would have been their struct-s
1815 #define PERLVAR(var,type) EXT type var;
1816 #define PERLVARI(var,type,init) EXT type var INIT(init);
1817 #define PERLVARIC(var,type,init) EXTCONST type var INIT(init);
1819 #ifndef PERL_GLOBAL_STRUCT
1820 #include "perlvars.h"
1823 #ifndef MULTIPLICITY
1826 #include "thrdvar.h"
1829 #include "intrpvar.h"
1844 #endif /* PERL_OBJECT */
1851 #if defined(HASATTRIBUTE) && defined(WIN32)
1853 * This provides a layer of functions and macros to ensure extensions will
1854 * get to use the same RTL functions as the core.
1855 * It has to go here or #define of printf messes up __attribute__
1859 # include <win32iop.h>
1860 #endif /* PERL_OBJECT */
1865 EXT MGVTBL vtbl_sv = {magic_get,
1869 EXT MGVTBL vtbl_env = {0, magic_set_all_env,
1870 0, magic_clear_all_env,
1872 EXT MGVTBL vtbl_envelem = {0, magic_setenv,
1875 EXT MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1876 EXT MGVTBL vtbl_sigelem = {magic_getsig,
1880 EXT MGVTBL vtbl_pack = {0, 0, magic_sizepack, magic_wipepack,
1882 EXT MGVTBL vtbl_packelem = {magic_getpack,
1886 EXT MGVTBL vtbl_dbline = {0, magic_setdbline,
1888 EXT MGVTBL vtbl_isa = {0, magic_setisa,
1891 EXT MGVTBL vtbl_isaelem = {0, magic_setisa,
1893 EXT MGVTBL vtbl_arylen = {magic_getarylen,
1896 EXT MGVTBL vtbl_glob = {magic_getglob,
1899 EXT MGVTBL vtbl_mglob = {0, magic_setmglob,
1901 EXT MGVTBL vtbl_nkeys = {0, magic_setnkeys,
1903 EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1905 EXT MGVTBL vtbl_substr = {0, magic_setsubstr,
1907 EXT MGVTBL vtbl_vec = {0, magic_setvec,
1909 EXT MGVTBL vtbl_pos = {magic_getpos,
1912 EXT MGVTBL vtbl_bm = {0, magic_setbm,
1914 EXT MGVTBL vtbl_fm = {0, magic_setfm,
1916 EXT MGVTBL vtbl_uvar = {magic_getuvar,
1920 EXT MGVTBL vtbl_mutex = {0, 0, 0, 0, magic_mutexfree};
1921 #endif /* USE_THREADS */
1922 EXT MGVTBL vtbl_defelem = {magic_getdefelem,magic_setdefelem,
1923 0, 0, magic_freedefelem};
1925 EXT MGVTBL vtbl_regexp = {0,0,0,0, magic_freeregexp};
1927 #ifdef USE_LOCALE_COLLATE
1928 EXT MGVTBL vtbl_collxfrm = {0,
1934 EXT MGVTBL vtbl_amagic = {0, magic_setamagic,
1935 0, 0, magic_setamagic};
1936 EXT MGVTBL vtbl_amagicelem = {0, magic_setamagic,
1937 0, 0, magic_setamagic};
1938 #endif /* OVERLOAD */
1943 EXT MGVTBL vtbl_env;
1944 EXT MGVTBL vtbl_envelem;
1945 EXT MGVTBL vtbl_sig;
1946 EXT MGVTBL vtbl_sigelem;
1947 EXT MGVTBL vtbl_pack;
1948 EXT MGVTBL vtbl_packelem;
1949 EXT MGVTBL vtbl_dbline;
1950 EXT MGVTBL vtbl_isa;
1951 EXT MGVTBL vtbl_isaelem;
1952 EXT MGVTBL vtbl_arylen;
1953 EXT MGVTBL vtbl_glob;
1954 EXT MGVTBL vtbl_mglob;
1955 EXT MGVTBL vtbl_nkeys;
1956 EXT MGVTBL vtbl_taint;
1957 EXT MGVTBL vtbl_substr;
1958 EXT MGVTBL vtbl_vec;
1959 EXT MGVTBL vtbl_pos;
1962 EXT MGVTBL vtbl_uvar;
1965 EXT MGVTBL vtbl_mutex;
1966 #endif /* USE_THREADS */
1968 EXT MGVTBL vtbl_defelem;
1969 EXT MGVTBL vtbl_regexp;
1971 #ifdef USE_LOCALE_COLLATE
1972 EXT MGVTBL vtbl_collxfrm;
1976 EXT MGVTBL vtbl_amagic;
1977 EXT MGVTBL vtbl_amagicelem;
1978 #endif /* OVERLOAD */
1980 #endif /* !DOINIT */
1984 #define NofAMmeth 58
1986 EXTCONST char * AMG_names[NofAMmeth] = {
1987 "fallback", "abs", /* "fallback" should be the first. */
2018 EXTCONST char * AMG_names[NofAMmeth];
2019 #endif /* def INITAMAGIC */
2025 CV* table[NofAMmeth];
2028 struct am_table_short {
2033 typedef struct am_table AMT;
2034 typedef struct am_table_short AMTS;
2036 #define AMGfallNEVER 1
2038 #define AMGfallYES 3
2040 #define AMTf_AMAGIC 1
2041 #define AMT_AMAGIC(amt) ((amt)->flags & AMTf_AMAGIC)
2042 #define AMT_AMAGIC_on(amt) ((amt)->flags |= AMTf_AMAGIC)
2043 #define AMT_AMAGIC_off(amt) ((amt)->flags &= ~AMTf_AMAGIC)
2046 fallback_amg, abs_amg,
2047 bool__amg, nomethod_amg,
2048 string_amg, numer_amg,
2049 add_amg, add_ass_amg,
2050 subtr_amg, subtr_ass_amg,
2051 mult_amg, mult_ass_amg,
2052 div_amg, div_ass_amg,
2053 modulo_amg, modulo_ass_amg,
2054 pow_amg, pow_ass_amg,
2055 lshift_amg, lshift_ass_amg,
2056 rshift_amg, rshift_ass_amg,
2057 band_amg, band_ass_amg,
2058 bor_amg, bor_ass_amg,
2059 bxor_amg, bxor_ass_amg,
2072 repeat_amg, repeat_ass_amg,
2073 concat_amg, concat_ass_amg,
2078 * some compilers like to redefine cos et alia as faster
2079 * (and less accurate?) versions called F_cos et cetera (Quidquid
2080 * latine dictum sit, altum viditur.) This trick collides with
2081 * the Perl overloading (amg). The following #defines fool both.
2086 # define F_atan2_amg atan2_amg
2089 # define F_cos_amg cos_amg
2092 # define F_exp_amg exp_amg
2095 # define F_log_amg log_amg
2098 # define F_pow_amg pow_amg
2101 # define F_sin_amg sin_amg
2104 # define F_sqrt_amg sqrt_amg
2106 #endif /* _FASTMATH */
2108 #endif /* OVERLOAD */
2110 #define PERLDB_ALL 0xff
2111 #define PERLDBf_SUB 0x01 /* Debug sub enter/exit. */
2112 #define PERLDBf_LINE 0x02 /* Keep line #. */
2113 #define PERLDBf_NOOPT 0x04 /* Switch off optimizations. */
2114 #define PERLDBf_INTER 0x08 /* Preserve more data for
2115 later inspections. */
2116 #define PERLDBf_SUBLINE 0x10 /* Keep subr source lines. */
2117 #define PERLDBf_SINGLE 0x20 /* Start with single-step on. */
2119 #define PERLDB_SUB (perldb && (perldb & PERLDBf_SUB))
2120 #define PERLDB_LINE (perldb && (perldb & PERLDBf_LINE))
2121 #define PERLDB_NOOPT (perldb && (perldb & PERLDBf_NOOPT))
2122 #define PERLDB_INTER (perldb && (perldb & PERLDBf_INTER))
2123 #define PERLDB_SUBLINE (perldb && (perldb & PERLDBf_SUBLINE))
2124 #define PERLDB_SINGLE (perldb && (perldb & PERLDBf_SINGLE))
2127 #ifdef USE_LOCALE_NUMERIC
2129 #define SET_NUMERIC_STANDARD() \
2131 if (! numeric_standard) \
2132 perl_set_numeric_standard(); \
2135 #define SET_NUMERIC_LOCAL() \
2137 if (! numeric_local) \
2138 perl_set_numeric_local(); \
2141 #else /* !USE_LOCALE_NUMERIC */
2143 #define SET_NUMERIC_STANDARD() /**/
2144 #define SET_NUMERIC_LOCAL() /**/
2146 #endif /* !USE_LOCALE_NUMERIC */
2148 #if !defined(PERLIO_IS_STDIO) && defined(HAS_ATTRIBUTE)
2150 * Now we have __attribute__ out of the way
2153 #define printf PerlIO_stdoutf
2156 #ifndef PERL_SCRIPT_MODE
2157 #define PERL_SCRIPT_MODE "r"
2161 * nice_chunk and nice_chunk size need to be set
2162 * and queried under the protection of sv_mutex
2164 #define offer_nice_chunk(chunk, chunk_size) do { \
2166 if (!nice_chunk) { \
2167 nice_chunk = (char*)(chunk); \
2168 nice_chunk_size = (chunk_size); \
2174 #endif /* Include guard */