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