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