This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
various tweaks for PERL_OBJECT build & test
[perl5.git] / perl.h
CommitLineData
a0d0e21e 1/* perl.h
a687059c 2 *
9607fc9c 3 * Copyright (c) 1987-1997, Larry Wall
a687059c 4 *
352d5a3a
LW
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
8d063cd8 7 *
8d063cd8 8 */
85e6fe83
LW
9#ifndef H_PERL
10#define H_PERL 1
a0d0e21e 11#define OVERLOAD
8d063cd8 12
760ac839
LW
13#ifdef PERL_FOR_X2P
14/*
15 * This file is being used for x2p stuff.
16 * Above symbol is defined via -D in 'x2p/Makefile.SH'
17 * Decouple x2p stuff from some of perls more extreme eccentricities.
18 */
760ac839 19#undef EMBED
55497cff 20#undef NO_EMBED
21#define NO_EMBED
22#undef MULTIPLICITY
760ac839
LW
23#undef USE_STDIO
24#define USE_STDIO
25#endif /* PERL_FOR_X2P */
26
76e3520e 27#ifdef PERL_OBJECT
3dfd1da1
GS
28
29/* PERL_OBJECT explained - DickH and DougL @ ActiveState.com
30
31Defining PERL_OBJECT turns on creation of a C++ object that
32contains all writable core perl global variables and functions.
33Stated another way, all necessary global variables and functions
34are members of a big C++ object. This object's class is CPerlObj.
35This allows a Perl Host to have multiple, independent perl
36interpreters in the same process space. This is very important on
37Win32 systems as the overhead of process creation is quite high --
38this could be even higher than the script compile and execute time
39for small scripts.
40
41The perl executable implementation on Win32 is composed of perl.exe
42(the Perl Host) and perlX.dll. (the Perl Core). This allows the
43same Perl Core to easily be embedded in other applications that use
44the perl interpreter.
45
46+-----------+
47| Perl Host |
48+-----------+
49 ^
50 |
51 v
52+-----------+ +-----------+
53| Perl Core |<->| Extension |
54+-----------+ +-----------+ ...
55
56Defining PERL_OBJECT has the following effects:
57
58PERL CORE
591. CPerlObj is defined (this is the PERL_OBJECT)
602. all static functions that needed to access either global
61variables or functions needed are made member functions
623. all writable static variables are made member variables
634. all global variables and functions are defined as:
64 #define var CPerlObj::Perl_var
65 #define func CPerlObj::Perl_func
66 * these are in objpp.h
67This necessitated renaming some local variables and functions that
68had the same name as a global variable or function. This was
69probably a _good_ thing anyway.
70
71
72EXTENSIONS
731. Access to global variables and perl functions is through a
74pointer to the PERL_OBJECT. This pointer type is CPerlObj*. This is
75made transparent to extension developers by the following macros:
76 #define var pPerl->Perl_var
77 #define func pPerl->Perl_func
78 * these are done in ObjXSub.h
79This requires that the extension be compiled as C++, which means
80that the code must be ANSI C and not K&R C. For K&R extensions,
81please see the C API notes located in Win32/GenCAPI.pl. This script
82creates a PerlCAPI.lib that provides a K & R compatible C interface
83to the PERL_OBJECT.
842. Local variables and functions cannot have the same name as perl's
85variables or functions since the macros will redefine these. Look for
86this if you get some strange error message and it does not look like
87the code that you had written. This often happens with variables that
88are local to a function.
89
90PERL HOST
911. The perl host is linked with perlX.lib to get perl_alloc. This
92function will return a pointer to CPerlObj (the PERL_OBJECT). It
0f4eea8f
DL
93takes pointers to the various PerlXXX_YYY interfaces (see iperlsys.h
94for more information on this).
3dfd1da1
GS
952. The perl host calls the same functions as normally would be
96called in setting up and running a perl script, except that the
97functions are now member functions of the PERL_OBJECT.
98
99*/
100
101
76e3520e
GS
102class CPerlObj;
103
104#define STATIC
105#define CPERLscope(x) CPerlObj::x
106#define CPERLproto CPerlObj *
e3b8966e 107#define _CPERLproto ,CPERLproto
76e3520e
GS
108#define CPERLarg CPerlObj *pPerl
109#define CPERLarg_ CPERLarg,
e3b8966e 110#define _CPERLarg ,CPERLarg
1d583055
GS
111#define PERL_OBJECT_THIS this
112#define _PERL_OBJECT_THIS ,this
113#define PERL_OBJECT_THIS_ this,
76e3520e 114#define CALLRUNOPS (this->*runops)
15e52e56
GS
115#define CALLREGCOMP (this->*regcompp)
116#define CALLREGEXEC (this->*regexecp)
76e3520e
GS
117
118#else /* !PERL_OBJECT */
119
120#define STATIC static
121#define CPERLscope(x) x
122#define CPERLproto
e3b8966e 123#define _CPERLproto
565764a8 124#define CPERLarg void
76e3520e 125#define CPERLarg_
e3b8966e 126#define _CPERLarg
1d583055
GS
127#define PERL_OBJECT_THIS
128#define _PERL_OBJECT_THIS
129#define PERL_OBJECT_THIS_
76e3520e 130#define CALLRUNOPS runops
15e52e56
GS
131#define CALLREGCOMP (*regcompp)
132#define CALLREGEXEC (*regexecp)
76e3520e
GS
133
134#endif /* PERL_OBJECT */
135
71be2cbc 136#define VOIDUSED 1
137#include "config.h"
138
139#include "embed.h"
140
326b05e3
GS
141#undef START_EXTERN_C
142#undef END_EXTERN_C
143#undef EXTERN_C
32f822de
GS
144#ifdef __cplusplus
145# define START_EXTERN_C extern "C" {
146# define END_EXTERN_C }
147# define EXTERN_C extern "C"
148#else
149# define START_EXTERN_C
150# define END_EXTERN_C
151# define EXTERN_C
152#endif
153
462e5cf6
MB
154#ifdef OP_IN_REGISTER
155# ifdef __GNUC__
156# define stringify_immed(s) #s
157# define stringify(s) stringify_immed(s)
d1ca3daa
GA
158#ifdef EMBED
159register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
160#else
462e5cf6 161register struct op *op asm(stringify(OP_IN_REGISTER));
d1ca3daa 162#endif
462e5cf6
MB
163# endif
164#endif
165
728e2803 166/*
167 * STMT_START { statements; } STMT_END;
168 * can be used as a single statement, as in
169 * if (x) STMT_START { ... } STMT_END; else ...
170 *
171 * Trying to select a version that gives no warnings...
172 */
173#if !(defined(STMT_START) && defined(STMT_END))
169d69b2 174# if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(__cplusplus)
728e2803 175# define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
176# define STMT_END )
177# else
178 /* Now which other defined()s do we need here ??? */
179# if (VOIDFLAGS) && (defined(sun) || defined(__sun__))
180# define STMT_START if (1)
181# define STMT_END else (void)0
182# else
183# define STMT_START do
184# define STMT_END while (0)
185# endif
186# endif
187#endif
188
462e5cf6
MB
189#define NOOP (void)0
190
61bb5906 191#define WITH_THR(s) STMT_START { dTHR; s; } STMT_END
ea0efc06 192
55497cff 193/*
194 * SOFT_CAST can be used for args to prototyped functions to retain some
195 * type checking; it only casts if the compiler does not know prototypes.
196 */
197#if defined(CAN_PROTOTYPE) && defined(DEBUGGING_COMPILE)
198#define SOFT_CAST(type)
199#else
200#define SOFT_CAST(type) (type)
201#endif
79072805 202
6ee623d5 203#ifndef BYTEORDER /* Should never happen -- byteorder is in config.h */
79072805
LW
204# define BYTEORDER 0x1234
205#endif
206
207/* Overall memory policy? */
208#ifndef CONSERVATIVE
209# define LIBERAL 1
210#endif
211
212/*
213 * The following contortions are brought to you on behalf of all the
214 * standards, semi-standards, de facto standards, not-so-de-facto standards
215 * of the world, as well as all the other botches anyone ever thought of.
216 * The basic theory is that if we work hard enough here, the rest of the
217 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
218 */
ac58e20f 219
ee0007ab 220/* define this once if either system, instead of cluttering up the src */
68dc0745 221#if defined(MSDOS) || defined(atarist) || defined(WIN32)
ee0007ab
LW
222#define DOSISH 1
223#endif
224
a0d0e21e 225#if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
352d5a3a
LW
226# define STANDARD_C 1
227#endif
228
09b7f37c 229#if defined(__cplusplus) || defined(WIN32) || defined(__sgi) || defined(OS2) || defined(__DGUX)
68dc0745 230# define DONT_DECLARE_STD 1
231#endif
232
352d5a3a 233#if defined(HASVOLATILE) || defined(STANDARD_C)
79072805
LW
234# ifdef __cplusplus
235# define VOL // to temporarily suppress warnings
236# else
237# define VOL volatile
238# endif
663a0e37 239#else
79072805 240# define VOL
663a0e37
LW
241#endif
242
bbce6d69 243#define TAINT (tainted = TRUE)
244#define TAINT_NOT (tainted = FALSE)
245#define TAINT_IF(c) if (c) { tainted = TRUE; }
246#define TAINT_ENV() if (tainting) { taint_env(); }
247#define TAINT_PROPER(s) if (tainting) { taint_proper(no_security, s); }
a687059c 248
a6e633de 249/* XXX All process group stuff is handled in pp_sys.c. Should these
250 defines move there? If so, I could simplify this a lot. --AD 9/96.
251*/
252/* Process group stuff changed from traditional BSD to POSIX.
253 perlfunc.pod documents the traditional BSD-style syntax, so we'll
254 try to preserve that, if possible.
255*/
256#ifdef HAS_SETPGID
257# define BSD_SETPGRP(pid, pgrp) setpgid((pid), (pgrp))
c07a80fd 258#else
a6e633de 259# if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
260# define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
261# else
262# ifdef HAS_SETPGRP2 /* DG/UX */
263# define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
264# endif
265# endif
266#endif
267#if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
268# define HAS_SETPGRP /* Well, effectively it does . . . */
269#endif
270
271/* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
272 our life easier :-) so we'll try it.
273*/
274#ifdef HAS_GETPGID
275# define BSD_GETPGRP(pid) getpgid((pid))
276#else
277# if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
278# define BSD_GETPGRP(pid) getpgrp((pid))
279# else
280# ifdef HAS_GETPGRP2 /* DG/UX */
281# define BSD_GETPGRP(pid) getpgrp2((pid))
282# endif
283# endif
284#endif
285#if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
286# define HAS_GETPGRP /* Well, effectively it does . . . */
287#endif
288
289/* These are not exact synonyms, since setpgrp() and getpgrp() may
290 have different behaviors, but perl.h used to define USE_BSDPGRP
291 (prior to 5.003_05) so some extension might depend on it.
292*/
293#if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
294# ifndef USE_BSDPGRP
295# define USE_BSDPGRP
296# endif
663a0e37
LW
297#endif
298
760ac839
LW
299#ifndef _TYPES_ /* If types.h defines this it's easy. */
300# ifndef major /* Does everyone's types.h define this? */
301# include <sys/types.h>
c07a80fd 302# endif
663a0e37
LW
303#endif
304
760ac839
LW
305#ifdef __cplusplus
306# ifndef I_STDARG
307# define I_STDARG 1
308# endif
309#endif
310
311#ifdef I_STDARG
312# include <stdarg.h>
313#else
314# ifdef I_VARARGS
315# include <varargs.h>
316# endif
317#endif
318
0f4eea8f 319#include "iperlsys.h"
0c30d9ec 320
4633a7c4 321#ifdef USE_NEXT_CTYPE
0c30d9ec 322
323#if NX_CURRENT_COMPILER_RELEASE >= 400
324#include <objc/NXCType.h>
325#else /* NX_CURRENT_COMPILER_RELEASE < 400 */
a0d0e21e 326#include <appkit/NXCType.h>
0c30d9ec 327#endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
328
329#else /* !USE_NEXT_CTYPE */
fe14fcc3 330#include <ctype.h>
0c30d9ec 331#endif /* USE_NEXT_CTYPE */
a0d0e21e
LW
332
333#ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
334#undef METHOD
a0d0e21e
LW
335#endif
336
4633a7c4 337#ifdef I_LOCALE
36477c24 338# include <locale.h>
4633a7c4
LW
339#endif
340
36477c24 341#if !defined(NO_LOCALE) && defined(HAS_SETLOCALE)
342# define USE_LOCALE
343# if !defined(NO_LOCALE_COLLATE) && defined(LC_COLLATE) \
344 && defined(HAS_STRXFRM)
345# define USE_LOCALE_COLLATE
346# endif
347# if !defined(NO_LOCALE_CTYPE) && defined(LC_CTYPE)
348# define USE_LOCALE_CTYPE
349# endif
350# if !defined(NO_LOCALE_NUMERIC) && defined(LC_NUMERIC)
351# define USE_LOCALE_NUMERIC
352# endif
353#endif /* !NO_LOCALE && HAS_SETLOCALE */
a0d0e21e 354
fe14fcc3 355#include <setjmp.h>
79072805 356
a0d0e21e 357#ifdef I_SYS_PARAM
79072805
LW
358# ifdef PARAM_NEEDS_TYPES
359# include <sys/types.h>
360# endif
361# include <sys/param.h>
352d5a3a 362#endif
79072805
LW
363
364
365/* Use all the "standard" definitions? */
a0d0e21e 366#if defined(STANDARD_C) && defined(I_STDLIB)
79072805 367# include <stdlib.h>
ff68c719 368#endif
03a14243 369
c31fac66
GS
370#define MEM_SIZE Size_t
371
55497cff 372/* This comes after <stdlib.h> so we don't try to change the standard
373 * library prototypes; we'll use our own in proto.h instead. */
03a14243 374
4633a7c4 375#ifdef MYMALLOC
55497cff 376
4633a7c4 377# ifdef HIDEMYMALLOC
55497cff 378# define malloc Mymalloc
379# define calloc Mycalloc
429a5e67 380# define realloc Myrealloc
55497cff 381# define free Myfree
c31fac66
GS
382Malloc_t Mymalloc _((MEM_SIZE nbytes));
383Malloc_t Mycalloc _((MEM_SIZE elements, MEM_SIZE size));
384Malloc_t Myrealloc _((Malloc_t where, MEM_SIZE nbytes));
385Free_t Myfree _((Malloc_t where));
55497cff 386# endif
387# ifdef EMBEDMYMALLOC
388# define malloc Perl_malloc
389# define calloc Perl_calloc
390# define realloc Perl_realloc
429a5e67
DS
391/* VMS' external symbols are case-insensitive, and there's already a */
392/* perl_free in perl.h */
393#ifdef VMS
394# define free Perl_myfree
395#else
55497cff 396# define free Perl_free
429a5e67 397#endif
c31fac66
GS
398Malloc_t Perl_malloc _((MEM_SIZE nbytes));
399Malloc_t Perl_calloc _((MEM_SIZE elements, MEM_SIZE size));
400Malloc_t Perl_realloc _((Malloc_t where, MEM_SIZE nbytes));
429a5e67
DS
401#ifdef VMS
402Free_t Perl_myfree _((Malloc_t where));
403#else
c31fac66 404Free_t Perl_free _((Malloc_t where));
429a5e67 405#endif
4633a7c4 406# endif
55497cff 407
408# undef safemalloc
409# undef safecalloc
410# undef saferealloc
411# undef safefree
412# define safemalloc malloc
413# define safecalloc calloc
4633a7c4 414# define saferealloc realloc
55497cff 415# define safefree free
416
417#endif /* MYMALLOC */
4633a7c4 418
ff68c719 419#if defined(STANDARD_C) && defined(I_STDDEF)
420# include <stddef.h>
71be2cbc 421# define STRUCT_OFFSET(s,m) offsetof(s,m)
ff68c719 422#else
71be2cbc 423# define STRUCT_OFFSET(s,m) (Size_t)(&(((s *)0)->m))
ff68c719 424#endif
425
a0d0e21e
LW
426#if defined(I_STRING) || defined(__cplusplus)
427# include <string.h>
428#else
429# include <strings.h>
430#endif
431
432#if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
433#define strchr index
434#define strrchr rindex
435#endif
436
16d20bd9
AD
437#ifdef I_MEMORY
438# include <memory.h>
439#endif
440
fe14fcc3 441#ifdef HAS_MEMCPY
85e6fe83 442# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
fe14fcc3 443# ifndef memcpy
a0d0e21e 444 extern char * memcpy _((char*, char*, int));
ee0007ab
LW
445# endif
446# endif
447#else
448# ifndef memcpy
449# ifdef HAS_BCOPY
450# define memcpy(d,s,l) bcopy(s,d,l)
451# else
452# define memcpy(d,s,l) my_bcopy(s,d,l)
453# endif
454# endif
455#endif /* HAS_MEMCPY */
fe14fcc3 456
ee0007ab 457#ifdef HAS_MEMSET
85e6fe83 458# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 459# ifndef memset
a0d0e21e 460 extern char *memset _((char*, int, int));
ee0007ab
LW
461# endif
462# endif
ee0007ab 463#else
fc36a67e 464# define memset(d,c,l) my_memset(d,c,l)
ee0007ab
LW
465#endif /* HAS_MEMSET */
466
85e6fe83 467#if !defined(HAS_MEMMOVE) && !defined(memmove)
2304df62 468# if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
79072805
LW
469# define memmove(d,s,l) bcopy(s,d,l)
470# else
2304df62 471# if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
79072805 472# define memmove(d,s,l) memcpy(d,s,l)
ee0007ab 473# else
79072805 474# define memmove(d,s,l) my_bcopy(s,d,l)
ee0007ab 475# endif
352d5a3a 476# endif
d9d8d8de 477#endif
ee0007ab 478
36477c24 479#if defined(mips) && defined(ultrix) && !defined(__STDC__)
480# undef HAS_MEMCMP
481#endif
482
483#if defined(HAS_MEMCMP) && defined(HAS_SANE_MEMCMP)
85e6fe83 484# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 485# ifndef memcmp
a0d0e21e 486 extern int memcmp _((char*, char*, int));
ee0007ab
LW
487# endif
488# endif
36477c24 489# ifdef BUGGY_MSC
490 # pragma function(memcmp)
491# endif
ee0007ab
LW
492#else
493# ifndef memcmp
ecfc5424 494# define memcmp my_memcmp
352d5a3a 495# endif
36477c24 496#endif /* HAS_MEMCMP && HAS_SANE_MEMCMP */
8d063cd8 497
fc36a67e 498#ifndef memzero
c635e13b 499# ifdef HAS_MEMSET
500# define memzero(d,l) memset(d,0,l)
79072805 501# else
c635e13b 502# ifdef HAS_BZERO
503# define memzero(d,l) bzero(d,l)
79072805 504# else
fc36a67e 505# define memzero(d,l) my_bzero(d,l)
79072805
LW
506# endif
507# endif
d9d8d8de 508#endif
378cc40b 509
36477c24 510#ifndef HAS_BCMP
511# ifndef bcmp
512# define bcmp(s1,s2,l) memcmp(s1,s2,l)
79072805 513# endif
36477c24 514#endif /* !HAS_BCMP */
378cc40b 515
ae986130 516#ifdef I_NETINET_IN
79072805 517# include <netinet/in.h>
ae986130
LW
518#endif
519
84902520
TB
520#if defined(SF_APPEND) && defined(USE_SFIO) && defined(I_SFIO)
521/* <sfio.h> defines SF_APPEND and <sys/stat.h> might define SF_APPEND
522 * (the neo-BSD seem to do this). */
523# undef SF_APPEND
524#endif
525
1aef975c 526#ifdef I_SYS_STAT
84902520 527# include <sys/stat.h>
1aef975c 528#endif
79072805 529
a0d0e21e
LW
530/* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
531 like UTekV) are broken, sometimes giving false positives. Undefine
532 them here and let the code below set them to proper values.
533
534 The ghs macro stands for GreenHills Software C-1.8.5 which
535 is the C compiler for sysV88 and the various derivatives.
536 This header file bug is corrected in gcc-2.5.8 and later versions.
537 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
538
539#if defined(uts) || (defined(m88k) && defined(ghs))
79072805
LW
540# undef S_ISDIR
541# undef S_ISCHR
542# undef S_ISBLK
543# undef S_ISREG
544# undef S_ISFIFO
545# undef S_ISLNK
ee0007ab 546#endif
135863df 547
663a0e37
LW
548#ifdef I_TIME
549# include <time.h>
ffed7fef 550#endif
663a0e37 551
fe14fcc3 552#ifdef I_SYS_TIME
85e6fe83 553# ifdef I_SYS_TIME_KERNEL
663a0e37
LW
554# define KERNEL
555# endif
556# include <sys/time.h>
85e6fe83 557# ifdef I_SYS_TIME_KERNEL
663a0e37
LW
558# undef KERNEL
559# endif
a687059c 560#endif
135863df 561
55497cff 562#if defined(HAS_TIMES) && defined(I_SYS_TIMES)
85e6fe83 563# include <sys/times.h>
d9d8d8de 564#endif
8d063cd8 565
fe14fcc3 566#if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
79072805 567# undef HAS_STRERROR
663a0e37
LW
568#endif
569
570#include <errno.h>
ed6116ce 571#ifdef HAS_SOCKET
85e6fe83 572# ifdef I_NET_ERRNO
ed6116ce
LW
573# include <net/errno.h>
574# endif
575#endif
f86702cc 576
577#ifdef VMS
578# define SETERRNO(errcode,vmserrcode) \
579 STMT_START { \
580 set_errno(errcode); \
581 set_vaxc_errno(vmserrcode); \
582 } STMT_END
748a9306 583#else
f86702cc 584# define SETERRNO(errcode,vmserrcode) errno = (errcode)
748a9306 585#endif
ed6116ce 586
38a03e6e
MB
587#ifdef USE_THREADS
588# define ERRSV (thr->errsv)
589# define ERRHV (thr->errhv)
940cb80d
MB
590# define DEFSV THREADSV(0)
591# define SAVE_DEFSV save_threadsv(0)
38a03e6e
MB
592#else
593# define ERRSV GvSV(errgv)
594# define ERRHV GvHV(errgv)
54b9620d
MB
595# define DEFSV GvSV(defgv)
596# define SAVE_DEFSV SAVESPTR(GvSV(defgv))
38a03e6e
MB
597#endif /* USE_THREADS */
598
55497cff 599#ifndef errno
79072805 600 extern int errno; /* ANSI allows errno to be an lvalue expr */
d9d8d8de 601#endif
663a0e37 602
2304df62 603#ifdef HAS_STRERROR
a0d0e21e
LW
604# ifdef VMS
605 char *strerror _((int,...));
606# else
68dc0745 607#ifndef DONT_DECLARE_STD
a0d0e21e 608 char *strerror _((int));
68dc0745 609#endif
a0d0e21e 610# endif
2304df62
AD
611# ifndef Strerror
612# define Strerror strerror
613# endif
614#else
615# ifdef HAS_SYS_ERRLIST
79072805
LW
616 extern int sys_nerr;
617 extern char *sys_errlist[];
2304df62
AD
618# ifndef Strerror
619# define Strerror(e) \
79072805 620 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
2304df62 621# endif
79072805 622# endif
35c8bce7 623#endif
663a0e37 624
2304df62 625#ifdef I_SYS_IOCTL
79072805
LW
626# ifndef _IOCTL_
627# include <sys/ioctl.h>
628# endif
a687059c
LW
629#endif
630
ee0007ab 631#if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
79072805
LW
632# ifdef HAS_SOCKETPAIR
633# undef HAS_SOCKETPAIR
634# endif
2304df62
AD
635# ifdef I_NDBM
636# undef I_NDBM
79072805 637# endif
a687059c
LW
638#endif
639
a687059c 640#if INTSIZE == 2
79072805
LW
641# define htoni htons
642# define ntohi ntohs
a687059c 643#else
79072805
LW
644# define htoni htonl
645# define ntohi ntohl
a687059c
LW
646#endif
647
a0d0e21e 648/* Configure already sets Direntry_t */
35c8bce7 649#if defined(I_DIRENT)
663a0e37 650# include <dirent.h>
a0d0e21e
LW
651# if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
652# include <sys/dir.h>
653# endif
ae986130 654#else
fe14fcc3 655# ifdef I_SYS_NDIR
79a0689e 656# include <sys/ndir.h>
663a0e37 657# else
fe14fcc3 658# ifdef I_SYS_DIR
79a0689e
LW
659# ifdef hp9000s500
660# include <ndir.h> /* may be wrong in the future */
661# else
662# include <sys/dir.h>
663# endif
663a0e37
LW
664# endif
665# endif
4633a7c4 666#endif
a687059c 667
352d5a3a
LW
668#ifdef FPUTS_BOTCH
669/* work around botch in SunOS 4.0.1 and 4.0.2 */
670# ifndef fputs
79072805 671# define fputs(sv,fp) fprintf(fp,"%s",sv)
352d5a3a
LW
672# endif
673#endif
674
c623bd54
LW
675/*
676 * The following gobbledygook brought to you on behalf of __STDC__.
677 * (I could just use #ifndef __STDC__, but this is more bulletproof
678 * in the face of half-implementations.)
679 */
680
681#ifndef S_IFMT
682# ifdef _S_IFMT
683# define S_IFMT _S_IFMT
684# else
685# define S_IFMT 0170000
686# endif
687#endif
688
689#ifndef S_ISDIR
690# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
691#endif
692
693#ifndef S_ISCHR
694# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
695#endif
696
697#ifndef S_ISBLK
fe14fcc3
LW
698# ifdef S_IFBLK
699# define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
700# else
701# define S_ISBLK(m) (0)
702# endif
c623bd54
LW
703#endif
704
705#ifndef S_ISREG
706# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
707#endif
708
709#ifndef S_ISFIFO
fe14fcc3
LW
710# ifdef S_IFIFO
711# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
712# else
713# define S_ISFIFO(m) (0)
714# endif
c623bd54
LW
715#endif
716
717#ifndef S_ISLNK
718# ifdef _S_ISLNK
719# define S_ISLNK(m) _S_ISLNK(m)
720# else
721# ifdef _S_IFLNK
722# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
723# else
724# ifdef S_IFLNK
725# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
726# else
727# define S_ISLNK(m) (0)
728# endif
729# endif
730# endif
731#endif
732
733#ifndef S_ISSOCK
734# ifdef _S_ISSOCK
735# define S_ISSOCK(m) _S_ISSOCK(m)
736# else
737# ifdef _S_IFSOCK
738# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
739# else
740# ifdef S_IFSOCK
741# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
742# else
743# define S_ISSOCK(m) (0)
744# endif
745# endif
746# endif
747#endif
748
749#ifndef S_IRUSR
750# ifdef S_IREAD
751# define S_IRUSR S_IREAD
752# define S_IWUSR S_IWRITE
753# define S_IXUSR S_IEXEC
754# else
755# define S_IRUSR 0400
756# define S_IWUSR 0200
757# define S_IXUSR 0100
758# endif
759# define S_IRGRP (S_IRUSR>>3)
760# define S_IWGRP (S_IWUSR>>3)
761# define S_IXGRP (S_IXUSR>>3)
762# define S_IROTH (S_IRUSR>>6)
763# define S_IWOTH (S_IWUSR>>6)
764# define S_IXOTH (S_IXUSR>>6)
765#endif
766
767#ifndef S_ISUID
768# define S_ISUID 04000
769#endif
770
771#ifndef S_ISGID
772# define S_ISGID 02000
773#endif
774
79072805
LW
775#ifdef ff_next
776# undef ff_next
352d5a3a
LW
777#endif
778
a0d0e21e 779#if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
45d8adaa
LW
780# define SLOPPYDIVIDE
781#endif
782
748a9306
LW
783#ifdef UV
784#undef UV
785#endif
786
27d4fb96 787/* XXX QUAD stuff is not currently supported on most systems.
788 Specifically, perl internals don't support long long. Among
789 the many problems is that some compilers support long long,
790 but the underlying library functions (such as sprintf) don't.
791 Some things do work (such as quad pack/unpack on convex);
792 also some systems use long long for the fpos_t typedef. That
793 seems to work too.
794
795 The IV type is supposed to be long enough to hold any integral
796 value or a pointer.
797 --Andy Dougherty August 1996
798*/
799
f86702cc 800#ifdef cray
801# define Quad_t int
802#else
803# ifdef convex
804# define Quad_t long long
45d8adaa 805# else
6ee623d5 806# if LONGSIZE == 8
ecfc5424 807# define Quad_t long
45d8adaa
LW
808# endif
809# endif
f86702cc 810#endif
811
6ee623d5
GS
812/* XXX Experimental set-up for long long. Just add -DUSE_LONG_LONG
813 to your ccflags. --Andy Dougherty 4/1998
814*/
815#ifdef USE_LONG_LONG
816# if defined(HAS_LONG_LONG) && LONGLONGSIZE == 8
817# define Quad_t long long
818# endif
819#endif
820
f86702cc 821#ifdef Quad_t
822# define HAS_QUAD
748a9306
LW
823 typedef Quad_t IV;
824 typedef unsigned Quad_t UV;
27d4fb96 825# define IV_MAX PERL_QUAD_MAX
826# define IV_MIN PERL_QUAD_MIN
827# define UV_MAX PERL_UQUAD_MAX
828# define UV_MIN PERL_UQUAD_MIN
79072805 829#else
748a9306
LW
830 typedef long IV;
831 typedef unsigned long UV;
27d4fb96 832# define IV_MAX PERL_LONG_MAX
833# define IV_MIN PERL_LONG_MIN
834# define UV_MAX PERL_ULONG_MAX
835# define UV_MIN PERL_ULONG_MIN
79072805
LW
836#endif
837
760ac839
LW
838/* Previously these definitions used hardcoded figures.
839 * It is hoped these formula are more portable, although
840 * no data one way or another is presently known to me.
841 * The "PERL_" names are used because these calculated constants
842 * do not meet the ANSI requirements for LONG_MAX, etc., which
843 * need to be constants acceptable to #if - kja
844 * define PERL_LONG_MAX 2147483647L
845 * define PERL_LONG_MIN (-LONG_MAX - 1)
846 * define PERL ULONG_MAX 4294967295L
847 */
848
849#ifdef I_LIMITS /* Needed for cast_xxx() functions below. */
850# include <limits.h>
851#else
852#ifdef I_VALUES
853# include <values.h>
854#endif
855#endif
856
99abf803 857/*
858 * Try to figure out max and min values for the integral types. THE CORRECT
859 * SOLUTION TO THIS MESS: ADAPT enquire.c FROM GCC INTO CONFIGURE. The
860 * following hacks are used if neither limits.h or values.h provide them:
861 * U<TYPE>_MAX: for types >= int: ~(unsigned TYPE)0
862 * for types < int: (unsigned TYPE)~(unsigned)0
863 * The argument to ~ must be unsigned so that later signed->unsigned
864 * conversion can't modify the value's bit pattern (e.g. -0 -> +0),
865 * and it must not be smaller than int because ~ does integral promotion.
866 * <type>_MAX: (<type>) (U<type>_MAX >> 1)
867 * <type>_MIN: -<type>_MAX - <is_twos_complement_architecture: (3 & -1) == 3>.
868 * The latter is a hack which happens to work on some machines but
869 * does *not* catch any random system, or things like integer types
870 * with NaN if that is possible.
871 *
872 * All of the types are explicitly cast to prevent accidental loss of
873 * numeric range, and in the hope that they will be less likely to confuse
874 * over-eager optimizers.
875 *
876 */
27d4fb96 877
99abf803 878#define PERL_UCHAR_MIN ((unsigned char)0)
879
880#ifdef UCHAR_MAX
881# define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
27d4fb96 882#else
99abf803 883# ifdef MAXUCHAR
884# define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
27d4fb96 885# else
99abf803 886# define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
27d4fb96 887# endif
888#endif
99abf803 889
890/*
891 * CHAR_MIN and CHAR_MAX are not included here, as the (char) type may be
892 * ambiguous. It may be equivalent to (signed char) or (unsigned char)
893 * depending on local options. Until Configure detects this (or at least
894 * detects whether the "signed" keyword is available) the CHAR ranges
895 * will not be included. UCHAR functions normally.
896 * - kja
897 */
27d4fb96 898
99abf803 899#define PERL_USHORT_MIN ((unsigned short)0)
900
901#ifdef USHORT_MAX
902# define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
27d4fb96 903#else
99abf803 904# ifdef MAXUSHORT
905# define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
27d4fb96 906# else
ef2f54b0
CB
907# ifdef USHRT_MAX
908# define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
909# else
910# define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
911# endif
27d4fb96 912# endif
913#endif
914
27d4fb96 915#ifdef SHORT_MAX
99abf803 916# define PERL_SHORT_MAX ((short)SHORT_MAX)
27d4fb96 917#else
918# ifdef MAXSHORT /* Often used in <values.h> */
99abf803 919# define PERL_SHORT_MAX ((short)MAXSHORT)
27d4fb96 920# else
ef2f54b0
CB
921# ifdef SHRT_MAX
922# define PERL_SHORT_MAX ((short)SHRT_MAX)
923# else
924# define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
925# endif
27d4fb96 926# endif
927#endif
928
929#ifdef SHORT_MIN
99abf803 930# define PERL_SHORT_MIN ((short)SHORT_MIN)
27d4fb96 931#else
932# ifdef MINSHORT
99abf803 933# define PERL_SHORT_MIN ((short)MINSHORT)
27d4fb96 934# else
ef2f54b0
CB
935# ifdef SHRT_MIN
936# define PERL_SHORT_MIN ((short)SHRT_MIN)
937# else
938# define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
939# endif
27d4fb96 940# endif
941#endif
942
99abf803 943#ifdef UINT_MAX
944# define PERL_UINT_MAX ((unsigned int)UINT_MAX)
27d4fb96 945#else
99abf803 946# ifdef MAXUINT
947# define PERL_UINT_MAX ((unsigned int)MAXUINT)
27d4fb96 948# else
99abf803 949# define PERL_UINT_MAX (~(unsigned int)0)
27d4fb96 950# endif
951#endif
952
99abf803 953#define PERL_UINT_MIN ((unsigned int)0)
27d4fb96 954
955#ifdef INT_MAX
99abf803 956# define PERL_INT_MAX ((int)INT_MAX)
27d4fb96 957#else
958# ifdef MAXINT /* Often used in <values.h> */
99abf803 959# define PERL_INT_MAX ((int)MAXINT)
27d4fb96 960# else
99abf803 961# define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
27d4fb96 962# endif
963#endif
964
965#ifdef INT_MIN
99abf803 966# define PERL_INT_MIN ((int)INT_MIN)
27d4fb96 967#else
968# ifdef MININT
99abf803 969# define PERL_INT_MIN ((int)MININT)
27d4fb96 970# else
971# define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
972# endif
973#endif
974
99abf803 975#ifdef ULONG_MAX
976# define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
27d4fb96 977#else
99abf803 978# ifdef MAXULONG
979# define PERL_ULONG_MAX ((unsigned long)MAXULONG)
27d4fb96 980# else
99abf803 981# define PERL_ULONG_MAX (~(unsigned long)0)
27d4fb96 982# endif
983#endif
984
99abf803 985#define PERL_ULONG_MIN ((unsigned long)0L)
27d4fb96 986
760ac839 987#ifdef LONG_MAX
99abf803 988# define PERL_LONG_MAX ((long)LONG_MAX)
760ac839
LW
989#else
990# ifdef MAXLONG /* Often used in <values.h> */
99abf803 991# define PERL_LONG_MAX ((long)MAXLONG)
760ac839 992# else
99abf803 993# define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
760ac839
LW
994# endif
995#endif
996
997#ifdef LONG_MIN
99abf803 998# define PERL_LONG_MIN ((long)LONG_MIN)
760ac839
LW
999#else
1000# ifdef MINLONG
99abf803 1001# define PERL_LONG_MIN ((long)MINLONG)
760ac839 1002# else
27d4fb96 1003# define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
760ac839
LW
1004# endif
1005#endif
1006
99abf803 1007#ifdef HAS_QUAD
1008
1009# ifdef UQUAD_MAX
1010# define PERL_UQUAD_MAX ((UV)UQUAD_MAX)
760ac839 1011# else
99abf803 1012# define PERL_UQUAD_MAX (~(UV)0)
760ac839 1013# endif
760ac839 1014
99abf803 1015# define PERL_UQUAD_MIN ((UV)0)
27d4fb96 1016
27d4fb96 1017# ifdef QUAD_MAX
99abf803 1018# define PERL_QUAD_MAX ((IV)QUAD_MAX)
27d4fb96 1019# else
99abf803 1020# define PERL_QUAD_MAX ((IV) (PERL_UQUAD_MAX >> 1))
27d4fb96 1021# endif
1022
1023# ifdef QUAD_MIN
99abf803 1024# define PERL_QUAD_MIN ((IV)QUAD_MIN)
27d4fb96 1025# else
a6e633de 1026# define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
27d4fb96 1027# endif
1028
79072805
LW
1029#endif
1030
ee0007ab 1031typedef MEM_SIZE STRLEN;
450a55e4 1032
79072805
LW
1033typedef struct op OP;
1034typedef struct cop COP;
1035typedef struct unop UNOP;
1036typedef struct binop BINOP;
1037typedef struct listop LISTOP;
1038typedef struct logop LOGOP;
1039typedef struct condop CONDOP;
1040typedef struct pmop PMOP;
1041typedef struct svop SVOP;
1042typedef struct gvop GVOP;
1043typedef struct pvop PVOP;
79072805
LW
1044typedef struct loop LOOP;
1045
1046typedef struct Outrec Outrec;
93a17b20 1047typedef struct interpreter PerlInterpreter;
3e3baf6d
TB
1048#ifndef __BORLANDC__
1049typedef struct ff FF; /* XXX not defined anywhere, should go? */
1050#endif
79072805
LW
1051typedef struct sv SV;
1052typedef struct av AV;
1053typedef struct hv HV;
1054typedef struct cv CV;
378cc40b 1055typedef struct regexp REGEXP;
79072805 1056typedef struct gp GP;
0c30d9ec 1057typedef struct gv GV;
8990e307 1058typedef struct io IO;
c09156bb 1059typedef struct context PERL_CONTEXT;
79072805
LW
1060typedef struct block BLOCK;
1061
1062typedef struct magic MAGIC;
ed6116ce 1063typedef struct xrv XRV;
79072805
LW
1064typedef struct xpv XPV;
1065typedef struct xpviv XPVIV;
ff68c719 1066typedef struct xpvuv XPVUV;
79072805
LW
1067typedef struct xpvnv XPVNV;
1068typedef struct xpvmg XPVMG;
1069typedef struct xpvlv XPVLV;
1070typedef struct xpvav XPVAV;
1071typedef struct xpvhv XPVHV;
1072typedef struct xpvgv XPVGV;
1073typedef struct xpvcv XPVCV;
1074typedef struct xpvbm XPVBM;
1075typedef struct xpvfm XPVFM;
8990e307 1076typedef struct xpvio XPVIO;
79072805
LW
1077typedef struct mgvtbl MGVTBL;
1078typedef union any ANY;
8d063cd8 1079
378cc40b 1080#include "handy.h"
a0d0e21e 1081
873ef191
GS
1082#ifdef PERL_OBJECT
1083typedef I32 (*filter_t) _((CPerlObj*, int, SV *, int));
1084#else
16d20bd9 1085typedef I32 (*filter_t) _((int, SV *, int));
873ef191
GS
1086#endif
1087
16d20bd9
AD
1088#define FILTER_READ(idx, sv, len) filter_read(idx, sv, len)
1089#define FILTER_DATA(idx) (AvARRAY(rsfp_filters)[idx])
93965878 1090#define FILTER_ISREADER(idx) (idx >= AvFILLp(rsfp_filters))
16d20bd9 1091
748a9306 1092#ifdef DOSISH
4633a7c4
LW
1093# if defined(OS2)
1094# include "os2ish.h"
1095# else
748a9306 1096# include "dosish.h"
4633a7c4 1097# endif
a0d0e21e 1098#else
748a9306
LW
1099# if defined(VMS)
1100# include "vmsish.h"
1101# else
0c30d9ec 1102# if defined(PLAN9)
1103# include "./plan9/plan9ish.h"
1104# else
1105# include "unixish.h"
1106# endif
748a9306 1107# endif
32f822de
GS
1108#endif
1109
ac4c12e7
GS
1110#ifndef FUNC_NAME_TO_PTR
1111#define FUNC_NAME_TO_PTR(name) name
1112#endif
1113
32f822de 1114/*
dd96f567
IZ
1115 * USE_THREADS needs to be after unixish.h as <pthread.h> includes
1116 * <sys/signal.h> which defines NSIG - which will stop inclusion of <signal.h>
32f822de
GS
1117 * this results in many functions being undeclared which bothers C++
1118 * May make sense to have threads after "*ish.h" anyway
1119 */
1120
1121#ifdef USE_THREADS
79d59c5f
GS
1122 /* pending resolution of licensing issues, we avoid the erstwhile
1123 * atomic.h everywhere */
1124# define EMULATE_ATOMIC_REFCOUNTS
1125
32f822de
GS
1126# ifdef FAKE_THREADS
1127# include "fakethr.h"
1128# else
1129# ifdef WIN32
1130# include <win32thread.h>
1131# else
dd96f567
IZ
1132# ifdef OS2
1133# include "os2thread.h"
1134# else
1135# include <pthread.h>
c6ee37c5 1136typedef pthread_t perl_os_thread;
32f822de
GS
1137typedef pthread_mutex_t perl_mutex;
1138typedef pthread_cond_t perl_cond;
1139typedef pthread_key_t perl_key;
dd96f567 1140# endif /* OS2 */
32f822de
GS
1141# endif /* WIN32 */
1142# endif /* FAKE_THREADS */
1143#endif /* USE_THREADS */
1144
1145
3fc1aec6 1146
68dc0745 1147#ifdef VMS
1148# define STATUS_NATIVE statusvalue_vms
1149# define STATUS_NATIVE_EXPORT \
1150 ((I32)statusvalue_vms == -1 ? 44 : statusvalue_vms)
1151# define STATUS_NATIVE_SET(n) \
1152 STMT_START { \
1153 statusvalue_vms = (n); \
1154 if ((I32)statusvalue_vms == -1) \
1155 statusvalue = -1; \
1156 else if (statusvalue_vms & STS$M_SUCCESS) \
1157 statusvalue = 0; \
1158 else if ((statusvalue_vms & STS$M_SEVERITY) == 0) \
1159 statusvalue = 1 << 8; \
1160 else \
1161 statusvalue = (statusvalue_vms & STS$M_SEVERITY) << 8; \
1162 } STMT_END
1163# define STATUS_POSIX statusvalue
1164# ifdef VMSISH_STATUS
1165# define STATUS_CURRENT (VMSISH_STATUS ? STATUS_NATIVE : STATUS_POSIX)
1166# else
1167# define STATUS_CURRENT STATUS_POSIX
1168# endif
1169# define STATUS_POSIX_SET(n) \
1170 STMT_START { \
1171 statusvalue = (n); \
1172 if (statusvalue != -1) { \
1173 statusvalue &= 0xFFFF; \
1174 statusvalue_vms = statusvalue ? 44 : 1; \
1175 } \
1176 else statusvalue_vms = -1; \
1177 } STMT_END
1178# define STATUS_ALL_SUCCESS (statusvalue = 0, statusvalue_vms = 1)
1179# define STATUS_ALL_FAILURE (statusvalue = 1, statusvalue_vms = 44)
1180#else
1181# define STATUS_NATIVE STATUS_POSIX
1182# define STATUS_NATIVE_EXPORT STATUS_POSIX
1183# define STATUS_NATIVE_SET STATUS_POSIX_SET
1184# define STATUS_POSIX statusvalue
1185# define STATUS_POSIX_SET(n) \
1186 STMT_START { \
1187 statusvalue = (n); \
1188 if (statusvalue != -1) \
1189 statusvalue &= 0xFFFF; \
1190 } STMT_END
1191# define STATUS_CURRENT STATUS_POSIX
1192# define STATUS_ALL_SUCCESS (statusvalue = 0)
1193# define STATUS_ALL_FAILURE (statusvalue = 1)
1194#endif
1195
3fc1aec6 1196/* Some unistd.h's give a prototype for pause() even though
1197 HAS_PAUSE ends up undefined. This causes the #define
1198 below to be rejected by the compmiler. Sigh.
1199*/
1200#ifdef HAS_PAUSE
1201#define Pause pause
1202#else
1203#define Pause() sleep((32767<<16)+32767)
748a9306
LW
1204#endif
1205
1206#ifndef IOCPARM_LEN
1207# ifdef IOCPARM_MASK
1208 /* on BSDish systes we're safe */
1209# define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
1210# else
1211 /* otherwise guess at what's safe */
1212# define IOCPARM_LEN(x) 256
1213# endif
a0d0e21e
LW
1214#endif
1215
0f4eea8f
DL
1216#ifdef UNION_ANY_DEFINITION
1217UNION_ANY_DEFINITION;
1218#else
79072805
LW
1219union any {
1220 void* any_ptr;
1221 I32 any_i32;
a0d0e21e 1222 IV any_iv;
85e6fe83 1223 long any_long;
565764a8 1224 void (CPERLscope(*any_dptr)) _((void*));
79072805 1225};
0f4eea8f 1226#endif
79072805 1227
11343788 1228#ifdef USE_THREADS
52e1cb5e 1229#define ARGSproto struct perl_thread *thr
11343788
MB
1230#else
1231#define ARGSproto void
1232#endif /* USE_THREADS */
1233
5aabfad6 1234/* Work around some cygwin32 problems with importing global symbols */
1235#if defined(CYGWIN32) && defined(DLLIMPORT)
1236# include "cw32imp.h"
1237#endif
1238
378cc40b 1239#include "regexp.h"
79072805 1240#include "sv.h"
378cc40b 1241#include "util.h"
8d063cd8 1242#include "form.h"
79072805
LW
1243#include "gv.h"
1244#include "cv.h"
1245#include "opcode.h"
1246#include "op.h"
1247#include "cop.h"
1248#include "av.h"
1249#include "hv.h"
1250#include "mg.h"
1251#include "scope.h"
d613ef02
GS
1252#include "bytecode.h"
1253#include "byterun.h"
8d063cd8 1254
7fae4e64
GS
1255/* Current curly descriptor */
1256typedef struct curcur CURCUR;
1257struct curcur {
1258 int parenfloor; /* how far back to strip paren data */
1259 int cur; /* how many instances of scan we've matched */
1260 int min; /* the minimal number of scans to match */
1261 int max; /* the maximal number of scans to match */
1262 int minmod; /* whether to work our way up or down */
1263 regnode * scan; /* the thing to match */
1264 regnode * next; /* what has to match after it */
1265 char * lastloc; /* where we started matching this scan */
1266 CURCUR * oldcc; /* current curly before we started this one */
1267};
1268
1269typedef struct _sublex_info SUBLEXINFO;
1270struct _sublex_info {
1271 I32 super_state; /* lexer state to save */
1272 I32 sub_inwhat; /* "lex_inwhat" to use */
1273 OP *sub_op; /* "lex_op" to use */
1274};
1275
76e3520e
GS
1276#ifdef PERL_OBJECT
1277struct magic_state {
1278 SV* mgs_sv;
1279 U32 mgs_flags;
1280};
1281typedef struct magic_state MGS;
1282
1283typedef struct {
1284 I32 len_min;
1285 I32 len_delta;
1286 I32 pos_min;
1287 I32 pos_delta;
1288 SV *last_found;
1289 I32 last_end; /* min value, <0 unless valid. */
1290 I32 last_start_min;
1291 I32 last_start_max;
1292 SV **longest; /* Either &l_fixed, or &l_float. */
1293 SV *longest_fixed;
1294 I32 offset_fixed;
1295 SV *longest_float;
1296 I32 offset_float_min;
1297 I32 offset_float_max;
1298 I32 flags;
1299} scan_data_t;
1300
1301typedef I32 CHECKPOINT;
1302#endif /* PERL_OBJECT */
1303
4633a7c4
LW
1304/* work around some libPW problems */
1305#ifdef DOINIT
1306EXT char Error[1];
1307#endif
1308
450a55e4 1309#if defined(iAPX286) || defined(M_I286) || defined(I80286)
a687059c
LW
1310# define I286
1311#endif
1312
fe14fcc3
LW
1313#if defined(htonl) && !defined(HAS_HTONL)
1314#define HAS_HTONL
ae986130 1315#endif
fe14fcc3
LW
1316#if defined(htons) && !defined(HAS_HTONS)
1317#define HAS_HTONS
ae986130 1318#endif
fe14fcc3
LW
1319#if defined(ntohl) && !defined(HAS_NTOHL)
1320#define HAS_NTOHL
ae986130 1321#endif
fe14fcc3
LW
1322#if defined(ntohs) && !defined(HAS_NTOHS)
1323#define HAS_NTOHS
ae986130 1324#endif
fe14fcc3 1325#ifndef HAS_HTONL
d9d8d8de 1326#if (BYTEORDER & 0xffff) != 0x4321
fe14fcc3
LW
1327#define HAS_HTONS
1328#define HAS_HTONL
1329#define HAS_NTOHS
1330#define HAS_NTOHL
a687059c
LW
1331#define MYSWAP
1332#define htons my_swap
1333#define htonl my_htonl
1334#define ntohs my_swap
1335#define ntohl my_ntohl
1336#endif
1337#else
d9d8d8de 1338#if (BYTEORDER & 0xffff) == 0x4321
fe14fcc3
LW
1339#undef HAS_HTONS
1340#undef HAS_HTONL
1341#undef HAS_NTOHS
1342#undef HAS_NTOHL
a687059c
LW
1343#endif
1344#endif
1345
988174c1
LW
1346/*
1347 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
1348 * -DWS
1349 */
1350#if BYTEORDER != 0x1234
1351# define HAS_VTOHL
1352# define HAS_VTOHS
1353# define HAS_HTOVL
1354# define HAS_HTOVS
1355# if BYTEORDER == 0x4321
1356# define vtohl(x) ((((x)&0xFF)<<24) \
1357 +(((x)>>24)&0xFF) \
1358 +(((x)&0x0000FF00)<<8) \
1359 +(((x)&0x00FF0000)>>8) )
1360# define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
1361# define htovl(x) vtohl(x)
1362# define htovs(x) vtohs(x)
1363# endif
1364 /* otherwise default to functions in util.c */
1365#endif
1366
0f85fab0 1367#ifdef CASTNEGFLOAT
79072805 1368#define U_S(what) ((U16)(what))
0f85fab0 1369#define U_I(what) ((unsigned int)(what))
79072805 1370#define U_L(what) ((U32)(what))
0f85fab0 1371#else
32f822de 1372EXTERN_C U32 cast_ulong _((double));
232e078e
AD
1373#define U_S(what) ((U16)cast_ulong((double)(what)))
1374#define U_I(what) ((unsigned int)cast_ulong((double)(what)))
1375#define U_L(what) (cast_ulong((double)(what)))
ee0007ab
LW
1376#endif
1377
ed6116ce
LW
1378#ifdef CASTI32
1379#define I_32(what) ((I32)(what))
a0d0e21e 1380#define I_V(what) ((IV)(what))
5d94fbed 1381#define U_V(what) ((UV)(what))
ed6116ce 1382#else
32f822de 1383START_EXTERN_C
a0d0e21e 1384I32 cast_i32 _((double));
a0d0e21e 1385IV cast_iv _((double));
5d94fbed 1386UV cast_uv _((double));
32f822de 1387END_EXTERN_C
a6e633de 1388#define I_32(what) (cast_i32((double)(what)))
1389#define I_V(what) (cast_iv((double)(what)))
5d94fbed 1390#define U_V(what) (cast_uv((double)(what)))
ed6116ce
LW
1391#endif
1392
79072805
LW
1393struct Outrec {
1394 I32 o_lines;
d9d8d8de 1395 char *o_str;
79072805 1396 U32 o_len;
8d063cd8
LW
1397};
1398
352d5a3a
LW
1399#ifndef MAXSYSFD
1400# define MAXSYSFD 2
1401#endif
ee0007ab 1402
f82b3d41 1403#ifndef TMPPATH
1404# define TMPPATH "/tmp/perl-eXXXXXX"
a0d0e21e 1405#endif
79072805
LW
1406
1407#ifndef __cplusplus
a0d0e21e
LW
1408Uid_t getuid _((void));
1409Uid_t geteuid _((void));
1410Gid_t getgid _((void));
1411Gid_t getegid _((void));
79072805 1412#endif
8d063cd8
LW
1413
1414#ifdef DEBUGGING
0c30d9ec 1415#ifndef Perl_debug_log
760ac839 1416#define Perl_debug_log PerlIO_stderr()
0c30d9ec 1417#endif
d96024cf 1418#define YYDEBUG 1
79072805
LW
1419#define DEB(a) a
1420#define DEBUG(a) if (debug) a
1421#define DEBUG_p(a) if (debug & 1) a
1422#define DEBUG_s(a) if (debug & 2) a
1423#define DEBUG_l(a) if (debug & 4) a
1424#define DEBUG_t(a) if (debug & 8) a
1425#define DEBUG_o(a) if (debug & 16) a
1426#define DEBUG_c(a) if (debug & 32) a
1427#define DEBUG_P(a) if (debug & 64) a
0c30d9ec 1428#define DEBUG_m(a) if (curinterp && debug & 128) a
79072805
LW
1429#define DEBUG_f(a) if (debug & 256) a
1430#define DEBUG_r(a) if (debug & 512) a
1431#define DEBUG_x(a) if (debug & 1024) a
1432#define DEBUG_u(a) if (debug & 2048) a
1433#define DEBUG_L(a) if (debug & 4096) a
1434#define DEBUG_H(a) if (debug & 8192) a
1435#define DEBUG_X(a) if (debug & 16384) a
8990e307 1436#define DEBUG_D(a) if (debug & 32768) a
79072805
LW
1437#else
1438#define DEB(a)
1439#define DEBUG(a)
1440#define DEBUG_p(a)
1441#define DEBUG_s(a)
1442#define DEBUG_l(a)
1443#define DEBUG_t(a)
1444#define DEBUG_o(a)
1445#define DEBUG_c(a)
1446#define DEBUG_P(a)
1447#define DEBUG_m(a)
1448#define DEBUG_f(a)
1449#define DEBUG_r(a)
1450#define DEBUG_x(a)
1451#define DEBUG_u(a)
1452#define DEBUG_L(a)
1453#define DEBUG_H(a)
1454#define DEBUG_X(a)
8990e307 1455#define DEBUG_D(a)
8d063cd8 1456#endif
fe14fcc3 1457#define YYMAXDEPTH 300
8d063cd8 1458
a6e633de 1459#ifndef assert /* <assert.h> might have been included somehow */
79072805
LW
1460#define assert(what) DEB( { \
1461 if (!(what)) { \
463ee0b2 1462 croak("Assertion failed: file \"%s\", line %d", \
79072805 1463 __FILE__, __LINE__); \
6ad3d225 1464 PerlProc_exit(1); \
79072805 1465 }})
a6e633de 1466#endif
8d063cd8 1467
450a55e4 1468struct ufuncs {
a0d0e21e
LW
1469 I32 (*uf_val)_((IV, SV*));
1470 I32 (*uf_set)_((IV, SV*));
1471 IV uf_index;
450a55e4
LW
1472};
1473
fe14fcc3 1474/* Fix these up for __STDC__ */
68dc0745 1475#ifndef DONT_DECLARE_STD
a0d0e21e
LW
1476char *mktemp _((char*));
1477double atof _((const char*));
1478#endif
79072805 1479
352d5a3a 1480#ifndef STANDARD_C
fe14fcc3 1481/* All of these are in stdlib.h or time.h for ANSI C */
85e6fe83 1482Time_t time();
8d063cd8 1483struct tm *gmtime(), *localtime();
93a17b20 1484char *strchr(), *strrchr();
378cc40b 1485char *strcpy(), *strcat();
352d5a3a 1486#endif /* ! STANDARD_C */
8d063cd8 1487
79072805
LW
1488
1489#ifdef I_MATH
1490# include <math.h>
1491#else
32f822de 1492START_EXTERN_C
a0d0e21e 1493 double exp _((double));
a0d0e21e 1494 double log _((double));
c635e13b 1495 double log10 _((double));
a0d0e21e 1496 double sqrt _((double));
c635e13b 1497 double frexp _((double,int*));
1498 double ldexp _((double,int));
a0d0e21e
LW
1499 double modf _((double,double*));
1500 double sin _((double));
1501 double cos _((double));
1502 double atan2 _((double,double));
1503 double pow _((double,double));
32f822de 1504END_EXTERN_C
79072805
LW
1505#endif
1506
a0d0e21e 1507#ifndef __cplusplus
26618a56 1508# ifdef __NeXT__ /* or whatever catches all NeXTs */
3fc1aec6 1509char *crypt (); /* Maybe more hosts will need the unprototyped version */
26618a56
GS
1510# else
1511# if !defined(WIN32) || !defined(HAVE_DES_FCRYPT)
a0d0e21e 1512char *crypt _((const char*, const char*));
26618a56
GS
1513# endif /* !WIN32 && !HAVE_CRYPT_SOURCE */
1514# endif /* !__NeXT__ */
1515# ifndef DONT_DECLARE_STD
1516# ifndef getenv
a0d0e21e 1517char *getenv _((const char*));
26618a56 1518# endif /* !getenv */
a0d0e21e 1519Off_t lseek _((int,Off_t,int));
26618a56 1520# endif /* !DONT_DECLARE_STD */
a0d0e21e 1521char *getlogin _((void));
26618a56 1522#endif /* !__cplusplus */
79072805 1523
16d20bd9 1524#ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
378cc40b 1525#define UNLINK unlnk
a0d0e21e 1526I32 unlnk _((char*));
8d063cd8
LW
1527#else
1528#define UNLINK unlink
1529#endif
a687059c 1530
fe14fcc3 1531#ifndef HAS_SETREUID
85e6fe83
LW
1532# ifdef HAS_SETRESUID
1533# define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
1534# define HAS_SETREUID
1535# endif
a687059c 1536#endif
fe14fcc3 1537#ifndef HAS_SETREGID
85e6fe83
LW
1538# ifdef HAS_SETRESGID
1539# define setregid(r,e) setresgid(r,e,(Gid_t)-1)
1540# define HAS_SETREGID
1541# endif
a687059c 1542#endif
ee0007ab 1543
ff68c719 1544typedef Signal_t (*Sighandler_t) _((int));
1545
1546#ifdef HAS_SIGACTION
1547typedef struct sigaction Sigsave_t;
1548#else
1549typedef Sighandler_t Sigsave_t;
1550#endif
1551
ee0007ab
LW
1552#define SCAN_DEF 0
1553#define SCAN_TR 1
1554#define SCAN_REPL 2
79072805
LW
1555
1556#ifdef DEBUGGING
4633a7c4 1557# ifndef register
a0d0e21e
LW
1558# define register
1559# endif
1560# define PAD_SV(po) pad_sv(po)
2ddcc7aa 1561# define RUNOPS_DEFAULT runops_debug
79072805 1562#else
a0d0e21e 1563# define PAD_SV(po) curpad[po]
2ddcc7aa 1564# define RUNOPS_DEFAULT runops_standard
79072805
LW
1565#endif
1566
18f739ee
IZ
1567#ifdef MYMALLOC
1568# define MALLOC_INIT MUTEX_INIT(&malloc_mutex)
1569# define MALLOC_TERM MUTEX_DESTROY(&malloc_mutex)
1570#else
1571# define MALLOC_INIT
1572# define MALLOC_TERM
1573#endif
1574
b6d9d515 1575
44a0ac01
MB
1576/*
1577 * These need prototyping here because <proto.h> isn't
1578 * included until after runops is initialised.
1579 */
1580
76e3520e 1581#ifndef PERL_OBJECT
49f531da 1582typedef int runops_proc_t _((void));
44a0ac01
MB
1583int runops_standard _((void));
1584#ifdef DEBUGGING
1585int runops_debug _((void));
1586#endif
76e3520e 1587#endif /* PERL_OBJECT */
44a0ac01 1588
940cb80d 1589/* _ (for $_) must be first in the following list (DEFSV requires it) */
54b9620d 1590#define THREADSV_NAMES "_123456789&`'+/.,\\\";^-%=|~:\001\005!@"
a863c7d1 1591
0c30d9ec 1592/* VMS doesn't use environ array and NeXT has problems with crt0.o globals */
1593#if !defined(VMS) && !(defined(NeXT) && defined(__DYNAMIC__))
16de4a3e
RS
1594#if !defined(DONT_DECLARE_STD) \
1595 || (defined(__svr4__) && defined(__GNUC__) && defined(sun)) \
1596 || defined(__sgi) || defined(__DGUX)
79072805 1597extern char ** environ; /* environment variables supplied via exec */
a0d0e21e 1598#endif
0c30d9ec 1599#else
1600# if defined(NeXT) && defined(__DYNAMIC__)
1601
1602# include <mach-o/dyld.h>
1603EXT char *** environ_pointer;
1604# define environ (*environ_pointer)
1605# endif
1606#endif /* environ processing */
1607
79072805
LW
1608
1609/* for tmp use in stupid debuggers */
1610EXT int * di;
1611EXT short * ds;
1612EXT char * dc;
1613
1614/* handy constants */
3e3baf6d 1615EXTCONST char warn_uninit[]
a0d0e21e 1616 INIT("Use of uninitialized value");
3e3baf6d 1617EXTCONST char warn_nosemi[]
463ee0b2 1618 INIT("Semicolon seems to be missing");
3e3baf6d 1619EXTCONST char warn_reserved[]
463ee0b2 1620 INIT("Unquoted string \"%s\" may clash with future reserved word");
3e3baf6d 1621EXTCONST char warn_nl[]
93a17b20 1622 INIT("Unsuccessful %s on filename containing newline");
3e3baf6d 1623EXTCONST char no_wrongref[]
a0d0e21e 1624 INIT("Can't use %s ref as %s ref");
3e3baf6d 1625EXTCONST char no_symref[]
748a9306 1626 INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
3e3baf6d 1627EXTCONST char no_usym[]
8990e307 1628 INIT("Can't use an undefined value as %s reference");
3e3baf6d 1629EXTCONST char no_aelem[]
93a17b20 1630 INIT("Modification of non-creatable array value attempted, subscript %d");
3e3baf6d 1631EXTCONST char no_helem[]
93a17b20 1632 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
3e3baf6d 1633EXTCONST char no_modify[]
93a17b20 1634 INIT("Modification of a read-only value attempted");
3e3baf6d 1635EXTCONST char no_mem[]
93a17b20 1636 INIT("Out of memory!\n");
3e3baf6d 1637EXTCONST char no_security[]
463ee0b2 1638 INIT("Insecure dependency in %s%s");
3e3baf6d 1639EXTCONST char no_sock_func[]
93a17b20 1640 INIT("Unsupported socket function \"%s\" called");
3e3baf6d 1641EXTCONST char no_dir_func[]
93a17b20 1642 INIT("Unsupported directory function \"%s\" called");
3e3baf6d 1643EXTCONST char no_func[]
93a17b20 1644 INIT("The %s function is unimplemented");
3e3baf6d 1645EXTCONST char no_myglob[]
748a9306 1646 INIT("\"my\" variable %s can't be in a package");
93a17b20 1647
79072805 1648#ifdef DOINIT
8e07c86e
AD
1649EXT char *sig_name[] = { SIG_NAME };
1650EXT int sig_num[] = { SIG_NUM };
0c30d9ec 1651EXT SV * psig_ptr[sizeof(sig_num)/sizeof(*sig_num)];
1652EXT SV * psig_name[sizeof(sig_num)/sizeof(*sig_num)];
79072805
LW
1653#else
1654EXT char *sig_name[];
8e07c86e 1655EXT int sig_num[];
0c30d9ec 1656EXT SV * psig_ptr[];
1657EXT SV * psig_name[];
79072805
LW
1658#endif
1659
bbce6d69 1660/* fast case folding tables */
1661
79072805 1662#ifdef DOINIT
36477c24 1663EXTCONST unsigned char fold[] = {
79072805
LW
1664 0, 1, 2, 3, 4, 5, 6, 7,
1665 8, 9, 10, 11, 12, 13, 14, 15,
1666 16, 17, 18, 19, 20, 21, 22, 23,
1667 24, 25, 26, 27, 28, 29, 30, 31,
1668 32, 33, 34, 35, 36, 37, 38, 39,
1669 40, 41, 42, 43, 44, 45, 46, 47,
1670 48, 49, 50, 51, 52, 53, 54, 55,
1671 56, 57, 58, 59, 60, 61, 62, 63,
1672 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1673 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1674 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1675 'x', 'y', 'z', 91, 92, 93, 94, 95,
1676 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1677 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1678 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1679 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1680 128, 129, 130, 131, 132, 133, 134, 135,
1681 136, 137, 138, 139, 140, 141, 142, 143,
1682 144, 145, 146, 147, 148, 149, 150, 151,
1683 152, 153, 154, 155, 156, 157, 158, 159,
1684 160, 161, 162, 163, 164, 165, 166, 167,
1685 168, 169, 170, 171, 172, 173, 174, 175,
1686 176, 177, 178, 179, 180, 181, 182, 183,
1687 184, 185, 186, 187, 188, 189, 190, 191,
1688 192, 193, 194, 195, 196, 197, 198, 199,
1689 200, 201, 202, 203, 204, 205, 206, 207,
1690 208, 209, 210, 211, 212, 213, 214, 215,
1691 216, 217, 218, 219, 220, 221, 222, 223,
1692 224, 225, 226, 227, 228, 229, 230, 231,
1693 232, 233, 234, 235, 236, 237, 238, 239,
1694 240, 241, 242, 243, 244, 245, 246, 247,
1695 248, 249, 250, 251, 252, 253, 254, 255
1696};
1697#else
71be2cbc 1698EXTCONST unsigned char fold[];
79072805
LW
1699#endif
1700
1701#ifdef DOINIT
bbce6d69 1702EXT unsigned char fold_locale[] = {
79072805
LW
1703 0, 1, 2, 3, 4, 5, 6, 7,
1704 8, 9, 10, 11, 12, 13, 14, 15,
1705 16, 17, 18, 19, 20, 21, 22, 23,
1706 24, 25, 26, 27, 28, 29, 30, 31,
1707 32, 33, 34, 35, 36, 37, 38, 39,
1708 40, 41, 42, 43, 44, 45, 46, 47,
1709 48, 49, 50, 51, 52, 53, 54, 55,
1710 56, 57, 58, 59, 60, 61, 62, 63,
1711 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1712 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1713 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1714 'x', 'y', 'z', 91, 92, 93, 94, 95,
1715 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1716 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1717 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1718 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1719 128, 129, 130, 131, 132, 133, 134, 135,
1720 136, 137, 138, 139, 140, 141, 142, 143,
1721 144, 145, 146, 147, 148, 149, 150, 151,
1722 152, 153, 154, 155, 156, 157, 158, 159,
1723 160, 161, 162, 163, 164, 165, 166, 167,
1724 168, 169, 170, 171, 172, 173, 174, 175,
1725 176, 177, 178, 179, 180, 181, 182, 183,
1726 184, 185, 186, 187, 188, 189, 190, 191,
1727 192, 193, 194, 195, 196, 197, 198, 199,
1728 200, 201, 202, 203, 204, 205, 206, 207,
1729 208, 209, 210, 211, 212, 213, 214, 215,
1730 216, 217, 218, 219, 220, 221, 222, 223,
1731 224, 225, 226, 227, 228, 229, 230, 231,
1732 232, 233, 234, 235, 236, 237, 238, 239,
1733 240, 241, 242, 243, 244, 245, 246, 247,
1734 248, 249, 250, 251, 252, 253, 254, 255
1735};
1736#else
bbce6d69 1737EXT unsigned char fold_locale[];
79072805
LW
1738#endif
1739
1740#ifdef DOINIT
71be2cbc 1741EXTCONST unsigned char freq[] = { /* letter frequencies for mixed English/C */
79072805
LW
1742 1, 2, 84, 151, 154, 155, 156, 157,
1743 165, 246, 250, 3, 158, 7, 18, 29,
1744 40, 51, 62, 73, 85, 96, 107, 118,
1745 129, 140, 147, 148, 149, 150, 152, 153,
1746 255, 182, 224, 205, 174, 176, 180, 217,
1747 233, 232, 236, 187, 235, 228, 234, 226,
1748 222, 219, 211, 195, 188, 193, 185, 184,
1749 191, 183, 201, 229, 181, 220, 194, 162,
1750 163, 208, 186, 202, 200, 218, 198, 179,
1751 178, 214, 166, 170, 207, 199, 209, 206,
1752 204, 160, 212, 216, 215, 192, 175, 173,
1753 243, 172, 161, 190, 203, 189, 164, 230,
1754 167, 248, 227, 244, 242, 255, 241, 231,
1755 240, 253, 169, 210, 245, 237, 249, 247,
1756 239, 168, 252, 251, 254, 238, 223, 221,
1757 213, 225, 177, 197, 171, 196, 159, 4,
1758 5, 6, 8, 9, 10, 11, 12, 13,
1759 14, 15, 16, 17, 19, 20, 21, 22,
1760 23, 24, 25, 26, 27, 28, 30, 31,
1761 32, 33, 34, 35, 36, 37, 38, 39,
1762 41, 42, 43, 44, 45, 46, 47, 48,
1763 49, 50, 52, 53, 54, 55, 56, 57,
1764 58, 59, 60, 61, 63, 64, 65, 66,
1765 67, 68, 69, 70, 71, 72, 74, 75,
1766 76, 77, 78, 79, 80, 81, 82, 83,
1767 86, 87, 88, 89, 90, 91, 92, 93,
1768 94, 95, 97, 98, 99, 100, 101, 102,
1769 103, 104, 105, 106, 108, 109, 110, 111,
1770 112, 113, 114, 115, 116, 117, 119, 120,
1771 121, 122, 123, 124, 125, 126, 127, 128,
1772 130, 131, 132, 133, 134, 135, 136, 137,
1773 138, 139, 141, 142, 143, 144, 145, 146
1774};
1775#else
71be2cbc 1776EXTCONST unsigned char freq[];
79072805
LW
1777#endif
1778
8990e307
LW
1779#ifdef DEBUGGING
1780#ifdef DOINIT
71be2cbc 1781EXTCONST char* block_type[] = {
8990e307
LW
1782 "NULL",
1783 "SUB",
1784 "EVAL",
1785 "LOOP",
1786 "SUBST",
1787 "BLOCK",
1788};
1789#else
71be2cbc 1790EXTCONST char* block_type[];
8990e307
LW
1791#endif
1792#endif
1793
79072805
LW
1794/*****************************************************************************/
1795/* This lexer/parser stuff is currently global since yacc is hard to reenter */
1796/*****************************************************************************/
8990e307 1797/* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
79072805 1798
a0d0e21e
LW
1799#include "perly.h"
1800
fb73857a 1801#define LEX_NOTPARSING 11 /* borrowed from toke.c */
1802
79072805
LW
1803typedef enum {
1804 XOPERATOR,
1805 XTERM,
79072805 1806 XREF,
8990e307 1807 XSTATE,
a0d0e21e
LW
1808 XBLOCK,
1809 XTERMBLOCK
79072805
LW
1810} expectation;
1811
85e6fe83
LW
1812
1813 /* Note: the lowest 8 bits are reserved for
1814 stuffing into op->op_private */
1815#define HINT_INTEGER 0x00000001
1816#define HINT_STRICT_REFS 0x00000002
1817
1818#define HINT_BLOCK_SCOPE 0x00000100
1819#define HINT_STRICT_SUBS 0x00000200
1820#define HINT_STRICT_VARS 0x00000400
bbce6d69 1821#define HINT_LOCALE 0x00000800
85e6fe83 1822
b3ac6de7
IZ
1823#define HINT_NEW_INTEGER 0x00001000
1824#define HINT_NEW_FLOAT 0x00002000
1825#define HINT_NEW_BINARY 0x00004000
1826#define HINT_NEW_STRING 0x00008000
1827#define HINT_NEW_RE 0x00010000
1828#define HINT_LOCALIZE_HH 0x00020000 /* %^H needs to be copied */
1829
b3eb6a9b 1830#define HINT_RE_TAINT 0x00100000
e4d48cc9 1831#define HINT_RE_EVAL 0x00200000
b3eb6a9b 1832
d4cce5f1
NIS
1833/* Various states of an input record separator SV (rs, nrs) */
1834#define RsSNARF(sv) (! SvOK(sv))
1835#define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv))
1836#define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv))
5b2b9c68 1837#define RsRECORD(sv) (SvROK(sv) && (SvIV(SvRV(sv)) > 0))
79072805 1838
56953603 1839/* Enable variables which are pointers to functions */
15e52e56
GS
1840#ifdef PERL_OBJECT
1841typedef regexp*(CPerlObj::*regcomp_t) _((char* exp, char* xend, PMOP* pm));
1842typedef I32 (CPerlObj::*regexec_t) _((regexp* prog, char* stringarg,
1843 char* strend, char* strbeg,
1844 I32 minend, SV* screamer, void* data,
1845 U32 flags));
1846#else
56953603
IZ
1847typedef regexp*(*regcomp_t) _((char* exp, char* xend, PMOP* pm));
1848typedef I32 (*regexec_t) _((regexp* prog, char* stringarg, char* strend, char*
1849 strbeg, I32 minend, SV* screamer, void* data,
1850 U32 flags));
1851
15e52e56
GS
1852EXT regexp* pregcomp _((char* exp, char* xend, PMOP* pm));
1853EXT I32 regexec_flags _((regexp* prog, char* stringarg, char* strend,
1854 char* strbeg, I32 minend, SV* screamer,
1855 void* data, U32 flags));
1856#endif
1857
22239a37
NIS
1858/* Set up PERLVAR macros for populating structs */
1859#define PERLVAR(var,type) type var;
1860#define PERLVARI(var,type,init) type var;
3fe35a81 1861#define PERLVARIC(var,type,init) type var;
22239a37 1862
58a50f62
GS
1863/* Interpreter exitlist entry */
1864typedef struct exitlistentry {
1865#ifdef PERL_OBJECT
1866 void (*fn) _((CPerlObj*, void*));
1867#else
1868 void (*fn) _((void*));
1869#endif
1870 void *ptr;
1871} PerlExitListEntry;
1872
76e3520e
GS
1873#ifdef PERL_OBJECT
1874extern "C" CPerlObj* perl_alloc _((IPerlMem*, IPerlEnv*, IPerlStdIO*, IPerlLIO*, IPerlDir*, IPerlSock*, IPerlProc*));
1875
1876typedef int (CPerlObj::*runops_proc_t) _((void));
1877#undef EXT
1878#define EXT
1879#undef EXTCONST
1880#define EXTCONST
1881#undef INIT
1882#define INIT(x)
1883
1884class CPerlObj {
1885public:
1886 CPerlObj(IPerlMem*, IPerlEnv*, IPerlStdIO*, IPerlLIO*, IPerlDir*, IPerlSock*, IPerlProc*);
1887 void Init(void);
1888 void* operator new(size_t nSize, IPerlMem *pvtbl);
1889#endif /* PERL_OBJECT */
1890
22239a37
NIS
1891#ifdef PERL_GLOBAL_STRUCT
1892struct perl_vars {
1893#include "perlvars.h"
1894};
1895
1896#ifdef PERL_CORE
1897EXT struct perl_vars Perl_Vars;
1898EXT struct perl_vars *Perl_VarsPtr INIT(&Perl_Vars);
1899#else
1900#if !defined(__GNUC__) || !defined(WIN32)
1901EXT
1902#endif
1903struct perl_vars *Perl_VarsPtr;
1904#define Perl_Vars (*((Perl_VarsPtr) ? Perl_VarsPtr : (Perl_VarsPtr = Perl_GetVars())))
1905#endif
1906#endif /* PERL_GLOBAL_STRUCT */
1907
8990e307 1908#ifdef MULTIPLICITY
d4cce5f1
NIS
1909/* If we have multiple interpreters define a struct
1910 holding variables which must be per-interpreter
1911 If we don't have threads anything that would have
1912 be per-thread is per-interpreter.
1913*/
1914
79072805 1915struct interpreter {
d4cce5f1
NIS
1916#ifndef USE_THREADS
1917#include "thrdvar.h"
1918#endif
1919#include "intrpvar.h"
49f531da 1920};
d4cce5f1 1921
79072805 1922#else
49f531da
NIS
1923struct interpreter {
1924 char broiled;
1925};
79072805
LW
1926#endif
1927
d4cce5f1
NIS
1928#ifdef USE_THREADS
1929/* If we have threads define a struct with all the variables
1930 * that have to be per-thread
49f531da 1931 */
8023c3ce 1932
79072805 1933
49f531da 1934struct perl_thread {
49f531da 1935#include "thrdvar.h"
79072805 1936};
d4cce5f1 1937
22fae026
TM
1938typedef struct perl_thread *Thread;
1939
1940#else
1941typedef void *Thread;
22239a37
NIS
1942#endif
1943
1944/* Done with PERLVAR macros for now ... */
d4cce5f1
NIS
1945#undef PERLVAR
1946#undef PERLVARI
3fe35a81 1947#undef PERLVARIC
79072805 1948
22239a37 1949#include "thread.h"
79072805 1950#include "pp.h"
79072805
LW
1951#include "proto.h"
1952
a0d0e21e
LW
1953#ifdef EMBED
1954#define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1955#define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1956#else
1957#define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1958#define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1959#endif
1960
d4cce5f1
NIS
1961/* The following must follow proto.h as #defines mess up syntax */
1962
1963#include "embedvar.h"
1964
1965/* Now include all the 'global' variables
1966 * If we don't have threads or multiple interpreters
1967 * these include variables that would have been their struct-s
1968 */
1969
1970#define PERLVAR(var,type) EXT type var;
1971#define PERLVARI(var,type,init) EXT type var INIT(init);
3fe35a81 1972#define PERLVARIC(var,type,init) EXTCONST type var INIT(init);
d4cce5f1 1973
22239a37 1974#ifndef PERL_GLOBAL_STRUCT
d4cce5f1 1975#include "perlvars.h"
22239a37 1976#endif
d4cce5f1
NIS
1977
1978#ifndef MULTIPLICITY
d4cce5f1 1979
066ef5b5
GS
1980# include "intrpvar.h"
1981# ifndef USE_THREADS
1982# include "thrdvar.h"
1983# endif
d4cce5f1 1984
22239a37
NIS
1985#endif
1986
76e3520e 1987#ifdef PERL_OBJECT
76e3520e
GS
1988};
1989
1990#include "objpp.h"
1991#ifdef DOINIT
1992#include "INTERN.h"
1993#else
1994#include "EXTERN.h"
1995#endif
1996#endif /* PERL_OBJECT */
1997
22239a37 1998
d4cce5f1
NIS
1999#undef PERLVAR
2000#undef PERLVARI
0f3f18a6 2001#undef PERLVARIC
79072805 2002
a835ef8a
NIS
2003#if defined(HASATTRIBUTE) && defined(WIN32)
2004/*
2005 * This provides a layer of functions and macros to ensure extensions will
2006 * get to use the same RTL functions as the core.
2007 * It has to go here or #define of printf messes up __attribute__
2008 * stuff in proto.h
2009 */
76e3520e 2010#ifndef PERL_OBJECT
a835ef8a 2011# include <win32iop.h>
76e3520e 2012#endif /* PERL_OBJECT */
a835ef8a
NIS
2013#endif /* WIN32 */
2014
79072805 2015#ifdef DOINIT
bbce6d69 2016
4633a7c4 2017EXT MGVTBL vtbl_sv = {magic_get,
463ee0b2
LW
2018 magic_set,
2019 magic_len,
2020 0, 0};
fb73857a 2021EXT MGVTBL vtbl_env = {0, magic_set_all_env,
2022 0, magic_clear_all_env,
66b1d557 2023 0};
4633a7c4 2024EXT MGVTBL vtbl_envelem = {0, magic_setenv,
85e6fe83
LW
2025 0, magic_clearenv,
2026 0};
4633a7c4 2027EXT MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
0c30d9ec 2028EXT MGVTBL vtbl_sigelem = {magic_getsig,
2029 magic_setsig,
2030 0, magic_clearsig,
2031 0};
93965878 2032EXT MGVTBL vtbl_pack = {0, 0, magic_sizepack, magic_wipepack,
a0d0e21e 2033 0};
4633a7c4 2034EXT MGVTBL vtbl_packelem = {magic_getpack,
463ee0b2
LW
2035 magic_setpack,
2036 0, magic_clearpack,
2037 0};
4633a7c4 2038EXT MGVTBL vtbl_dbline = {0, magic_setdbline,
463ee0b2 2039 0, 0, 0};
4633a7c4 2040EXT MGVTBL vtbl_isa = {0, magic_setisa,
fb73857a 2041 0, magic_setisa,
2042 0};
4633a7c4 2043EXT MGVTBL vtbl_isaelem = {0, magic_setisa,
463ee0b2 2044 0, 0, 0};
4633a7c4 2045EXT MGVTBL vtbl_arylen = {magic_getarylen,
463ee0b2
LW
2046 magic_setarylen,
2047 0, 0, 0};
4633a7c4 2048EXT MGVTBL vtbl_glob = {magic_getglob,
463ee0b2
LW
2049 magic_setglob,
2050 0, 0, 0};
4633a7c4 2051EXT MGVTBL vtbl_mglob = {0, magic_setmglob,
463ee0b2 2052 0, 0, 0};
6ff81951
GS
2053EXT MGVTBL vtbl_nkeys = {magic_getnkeys,
2054 magic_setnkeys,
99abf803 2055 0, 0, 0};
4633a7c4 2056EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
463ee0b2 2057 0, 0, 0};
6ff81951 2058EXT MGVTBL vtbl_substr = {magic_getsubstr, magic_setsubstr,
463ee0b2 2059 0, 0, 0};
6ff81951
GS
2060EXT MGVTBL vtbl_vec = {magic_getvec,
2061 magic_setvec,
463ee0b2 2062 0, 0, 0};
4633a7c4 2063EXT MGVTBL vtbl_pos = {magic_getpos,
a0d0e21e
LW
2064 magic_setpos,
2065 0, 0, 0};
4633a7c4 2066EXT MGVTBL vtbl_bm = {0, magic_setbm,
463ee0b2 2067 0, 0, 0};
55497cff 2068EXT MGVTBL vtbl_fm = {0, magic_setfm,
2069 0, 0, 0};
4633a7c4 2070EXT MGVTBL vtbl_uvar = {magic_getuvar,
463ee0b2
LW
2071 magic_setuvar,
2072 0, 0, 0};
f93b4edd
MB
2073#ifdef USE_THREADS
2074EXT MGVTBL vtbl_mutex = {0, 0, 0, 0, magic_mutexfree};
2075#endif /* USE_THREADS */
68dc0745 2076EXT MGVTBL vtbl_defelem = {magic_getdefelem,magic_setdefelem,
2077 0, 0, magic_freedefelem};
a0d0e21e 2078
227a8b4b 2079EXT MGVTBL vtbl_regexp = {0,0,0,0, magic_freeregexp};
c277df42 2080
36477c24 2081#ifdef USE_LOCALE_COLLATE
bbce6d69 2082EXT MGVTBL vtbl_collxfrm = {0,
2083 magic_setcollxfrm,
2084 0, 0, 0};
2085#endif
a0d0e21e
LW
2086
2087#ifdef OVERLOAD
4633a7c4 2088EXT MGVTBL vtbl_amagic = {0, magic_setamagic,
748a9306 2089 0, 0, magic_setamagic};
4633a7c4 2090EXT MGVTBL vtbl_amagicelem = {0, magic_setamagic,
748a9306 2091 0, 0, magic_setamagic};
a0d0e21e
LW
2092#endif /* OVERLOAD */
2093
bbce6d69 2094#else /* !DOINIT */
2095
79072805
LW
2096EXT MGVTBL vtbl_sv;
2097EXT MGVTBL vtbl_env;
2098EXT MGVTBL vtbl_envelem;
2099EXT MGVTBL vtbl_sig;
2100EXT MGVTBL vtbl_sigelem;
463ee0b2
LW
2101EXT MGVTBL vtbl_pack;
2102EXT MGVTBL vtbl_packelem;
79072805 2103EXT MGVTBL vtbl_dbline;
463ee0b2
LW
2104EXT MGVTBL vtbl_isa;
2105EXT MGVTBL vtbl_isaelem;
79072805
LW
2106EXT MGVTBL vtbl_arylen;
2107EXT MGVTBL vtbl_glob;
93a17b20 2108EXT MGVTBL vtbl_mglob;
99abf803 2109EXT MGVTBL vtbl_nkeys;
463ee0b2 2110EXT MGVTBL vtbl_taint;
79072805
LW
2111EXT MGVTBL vtbl_substr;
2112EXT MGVTBL vtbl_vec;
a0d0e21e 2113EXT MGVTBL vtbl_pos;
79072805 2114EXT MGVTBL vtbl_bm;
55497cff 2115EXT MGVTBL vtbl_fm;
79072805 2116EXT MGVTBL vtbl_uvar;
a0d0e21e 2117
f93b4edd
MB
2118#ifdef USE_THREADS
2119EXT MGVTBL vtbl_mutex;
2120#endif /* USE_THREADS */
2121
68dc0745 2122EXT MGVTBL vtbl_defelem;
c277df42 2123EXT MGVTBL vtbl_regexp;
a0d0e21e 2124
36477c24 2125#ifdef USE_LOCALE_COLLATE
bbce6d69 2126EXT MGVTBL vtbl_collxfrm;
2127#endif
a0d0e21e
LW
2128
2129#ifdef OVERLOAD
2130EXT MGVTBL vtbl_amagic;
2131EXT MGVTBL vtbl_amagicelem;
2132#endif /* OVERLOAD */
2133
bbce6d69 2134#endif /* !DOINIT */
85e6fe83 2135
a0d0e21e 2136#ifdef OVERLOAD
c0315cdf 2137
a6006777 2138#define NofAMmeth 58
a0d0e21e 2139#ifdef DOINIT
a6006777 2140EXTCONST char * AMG_names[NofAMmeth] = {
2141 "fallback", "abs", /* "fallback" should be the first. */
2142 "bool", "nomethod",
2143 "\"\"", "0+",
2144 "+", "+=",
2145 "-", "-=",
2146 "*", "*=",
2147 "/", "/=",
2148 "%", "%=",
2149 "**", "**=",
2150 "<<", "<<=",
2151 ">>", ">>=",
2152 "&", "&=",
2153 "|", "|=",
2154 "^", "^=",
2155 "<", "<=",
2156 ">", ">=",
2157 "==", "!=",
2158 "<=>", "cmp",
2159 "lt", "le",
2160 "gt", "ge",
2161 "eq", "ne",
2162 "!", "~",
2163 "++", "--",
2164 "atan2", "cos",
2165 "sin", "exp",
2166 "log", "sqrt",
2167 "x", "x=",
2168 ".", ".=",
2169 "=", "neg"
a0d0e21e
LW
2170};
2171#else
a6006777 2172EXTCONST char * AMG_names[NofAMmeth];
a0d0e21e
LW
2173#endif /* def INITAMAGIC */
2174
a6006777 2175struct am_table {
a0d0e21e
LW
2176 long was_ok_sub;
2177 long was_ok_am;
a6006777 2178 U32 flags;
2179 CV* table[NofAMmeth];
a0d0e21e
LW
2180 long fallback;
2181};
a6006777 2182struct am_table_short {
2183 long was_ok_sub;
2184 long was_ok_am;
2185 U32 flags;
2186};
a0d0e21e 2187typedef struct am_table AMT;
a6006777 2188typedef struct am_table_short AMTS;
a0d0e21e
LW
2189
2190#define AMGfallNEVER 1
2191#define AMGfallNO 2
2192#define AMGfallYES 3
2193
a6006777 2194#define AMTf_AMAGIC 1
2195#define AMT_AMAGIC(amt) ((amt)->flags & AMTf_AMAGIC)
2196#define AMT_AMAGIC_on(amt) ((amt)->flags |= AMTf_AMAGIC)
2197#define AMT_AMAGIC_off(amt) ((amt)->flags &= ~AMTf_AMAGIC)
2198
a0d0e21e
LW
2199enum {
2200 fallback_amg, abs_amg,
2201 bool__amg, nomethod_amg,
2202 string_amg, numer_amg,
2203 add_amg, add_ass_amg,
2204 subtr_amg, subtr_ass_amg,
2205 mult_amg, mult_ass_amg,
2206 div_amg, div_ass_amg,
76e3520e 2207 modulo_amg, modulo_ass_amg,
a0d0e21e
LW
2208 pow_amg, pow_ass_amg,
2209 lshift_amg, lshift_ass_amg,
2210 rshift_amg, rshift_ass_amg,
748a9306
LW
2211 band_amg, band_ass_amg,
2212 bor_amg, bor_ass_amg,
2213 bxor_amg, bxor_ass_amg,
a0d0e21e
LW
2214 lt_amg, le_amg,
2215 gt_amg, ge_amg,
2216 eq_amg, ne_amg,
2217 ncmp_amg, scmp_amg,
2218 slt_amg, sle_amg,
2219 sgt_amg, sge_amg,
2220 seq_amg, sne_amg,
a0d0e21e
LW
2221 not_amg, compl_amg,
2222 inc_amg, dec_amg,
2223 atan2_amg, cos_amg,
2224 sin_amg, exp_amg,
2225 log_amg, sqrt_amg,
2226 repeat_amg, repeat_ass_amg,
748a9306
LW
2227 concat_amg, concat_ass_amg,
2228 copy_amg, neg_amg
a0d0e21e 2229};
c0315cdf
JH
2230
2231/*
2232 * some compilers like to redefine cos et alia as faster
2233 * (and less accurate?) versions called F_cos et cetera (Quidquid
2234 * latine dictum sit, altum viditur.) This trick collides with
2235 * the Perl overloading (amg). The following #defines fool both.
2236 */
2237
2238#ifdef _FASTMATH
2239# ifdef atan2
2240# define F_atan2_amg atan2_amg
2241# endif
2242# ifdef cos
2243# define F_cos_amg cos_amg
2244# endif
2245# ifdef exp
2246# define F_exp_amg exp_amg
2247# endif
2248# ifdef log
2249# define F_log_amg log_amg
2250# endif
2251# ifdef pow
2252# define F_pow_amg pow_amg
2253# endif
2254# ifdef sin
2255# define F_sin_amg sin_amg
2256# endif
2257# ifdef sqrt
2258# define F_sqrt_amg sqrt_amg
2259# endif
2260#endif /* _FASTMATH */
2261
a0d0e21e
LW
2262#endif /* OVERLOAD */
2263
491527d0 2264#define PERLDB_ALL 0x3f /* No _NONAME, _GOTO */
84902520
TB
2265#define PERLDBf_SUB 0x01 /* Debug sub enter/exit. */
2266#define PERLDBf_LINE 0x02 /* Keep line #. */
2267#define PERLDBf_NOOPT 0x04 /* Switch off optimizations. */
2268#define PERLDBf_INTER 0x08 /* Preserve more data for
2269 later inspections. */
2270#define PERLDBf_SUBLINE 0x10 /* Keep subr source lines. */
2271#define PERLDBf_SINGLE 0x20 /* Start with single-step on. */
491527d0
GS
2272#define PERLDBf_NONAME 0x40 /* For _SUB: no name of the subr. */
2273#define PERLDBf_GOTO 0x80 /* Report goto: call DB::goto. */
84902520
TB
2274
2275#define PERLDB_SUB (perldb && (perldb & PERLDBf_SUB))
2276#define PERLDB_LINE (perldb && (perldb & PERLDBf_LINE))
2277#define PERLDB_NOOPT (perldb && (perldb & PERLDBf_NOOPT))
2278#define PERLDB_INTER (perldb && (perldb & PERLDBf_INTER))
2279#define PERLDB_SUBLINE (perldb && (perldb & PERLDBf_SUBLINE))
2280#define PERLDB_SINGLE (perldb && (perldb & PERLDBf_SINGLE))
491527d0
GS
2281#define PERLDB_SUB_NN (perldb && (perldb & (PERLDBf_NONAME)))
2282#define PERLDB_GOTO (perldb && (perldb & PERLDBf_GOTO))
84902520 2283
bbce6d69 2284
36477c24 2285#ifdef USE_LOCALE_NUMERIC
bbce6d69 2286
36477c24 2287#define SET_NUMERIC_STANDARD() \
2288 STMT_START { \
2289 if (! numeric_standard) \
2290 perl_set_numeric_standard(); \
2291 } STMT_END
2292
2293#define SET_NUMERIC_LOCAL() \
2294 STMT_START { \
2295 if (! numeric_local) \
2296 perl_set_numeric_local(); \
2297 } STMT_END
bbce6d69 2298
36477c24 2299#else /* !USE_LOCALE_NUMERIC */
bbce6d69 2300
36477c24 2301#define SET_NUMERIC_STANDARD() /**/
2302#define SET_NUMERIC_LOCAL() /**/
bbce6d69 2303
36477c24 2304#endif /* !USE_LOCALE_NUMERIC */
a0d0e21e 2305
e5c9fcd0 2306#if !defined(PERLIO_IS_STDIO) && defined(HASATTRIBUTE)
760ac839
LW
2307/*
2308 * Now we have __attribute__ out of the way
2309 * Remap printf
2310 */
2311#define printf PerlIO_stdoutf
2312#endif
2313
a868473f
NIS
2314#ifndef PERL_SCRIPT_MODE
2315#define PERL_SCRIPT_MODE "r"
2316#endif
2317
fba3b22e
MB
2318/*
2319 * nice_chunk and nice_chunk size need to be set
2320 * and queried under the protection of sv_mutex
2321 */
2322#define offer_nice_chunk(chunk, chunk_size) do { \
940cb80d 2323 LOCK_SV_MUTEX; \
fba3b22e
MB
2324 if (!nice_chunk) { \
2325 nice_chunk = (char*)(chunk); \
2326 nice_chunk_size = (chunk_size); \
2327 } \
fc80cf79
GS
2328 else { \
2329 Safefree(chunk); \
2330 } \
940cb80d 2331 UNLOCK_SV_MUTEX; \
fba3b22e
MB
2332 } while (0)
2333
bd89102f
AD
2334#ifdef HAS_SEM
2335# include <sys/ipc.h>
2336# include <sys/sem.h>
2337# ifndef HAS_UNION_SEMUN /* Provide the union semun. */
2338 union semun {
2339 int val;
2340 struct semid_ds *buf;
2341 unsigned short *array;
2342 };
2343# endif
2344# ifdef USE_SEMCTL_SEMUN
2345# define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun)
2346# else
2347# ifdef USE_SEMCTL_SEMID_DS
2348# define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun.buf)
2349# endif
2350# endif
2351# ifndef Semctl /* Place our bets on the semun horse. */
2352# define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun)
2353# endif
2354#endif
49f531da 2355
85e6fe83 2356#endif /* Include guard */