Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3570 lines
97 KiB

  1. /* perl.h
  2. *
  3. * Copyright (c) 1987-2001, Larry Wall
  4. *
  5. * You may distribute under the terms of either the GNU General Public
  6. * License or the Artistic License, as specified in the README file.
  7. *
  8. */
  9. #ifndef H_PERL
  10. #define H_PERL 1
  11. #ifdef PERL_FOR_X2P
  12. /*
  13. * This file is being used for x2p stuff.
  14. * Above symbol is defined via -D in 'x2p/Makefile.SH'
  15. * Decouple x2p stuff from some of perls more extreme eccentricities.
  16. */
  17. #undef MULTIPLICITY
  18. #undef USE_STDIO
  19. #define USE_STDIO
  20. #endif /* PERL_FOR_X2P */
  21. #define VOIDUSED 1
  22. #include "config.h"
  23. #if defined(USE_ITHREADS) && defined(USE_5005THREADS)
  24. # include "error: USE_ITHREADS and USE_5005THREADS are incompatible"
  25. #endif
  26. /* XXX This next guard can disappear if the sources are revised
  27. to use USE_5005THREADS throughout. -- A.D 1/6/2000
  28. */
  29. #if defined(USE_ITHREADS) && defined(USE_THREADS)
  30. # include "error: USE_ITHREADS and USE_THREADS are incompatible"
  31. #endif
  32. /* See L<perlguts/"The Perl API"> for detailed notes on
  33. * PERL_IMPLICIT_CONTEXT and PERL_IMPLICIT_SYS */
  34. #ifdef USE_ITHREADS
  35. # if !defined(MULTIPLICITY) && !defined(PERL_OBJECT)
  36. # define MULTIPLICITY
  37. # endif
  38. #endif
  39. #ifdef USE_THREADS
  40. # ifndef PERL_IMPLICIT_CONTEXT
  41. # define PERL_IMPLICIT_CONTEXT
  42. # endif
  43. #endif
  44. #if defined(MULTIPLICITY)
  45. # ifndef PERL_IMPLICIT_CONTEXT
  46. # define PERL_IMPLICIT_CONTEXT
  47. # endif
  48. #endif
  49. #ifdef PERL_CAPI
  50. # undef PERL_OBJECT
  51. # ifndef MULTIPLICITY
  52. # define MULTIPLICITY
  53. # endif
  54. # ifndef PERL_IMPLICIT_CONTEXT
  55. # define PERL_IMPLICIT_CONTEXT
  56. # endif
  57. # ifndef PERL_IMPLICIT_SYS
  58. # define PERL_IMPLICIT_SYS
  59. # endif
  60. #endif
  61. #ifdef PERL_OBJECT
  62. # ifndef PERL_IMPLICIT_CONTEXT
  63. # define PERL_IMPLICIT_CONTEXT
  64. # endif
  65. # ifndef PERL_IMPLICIT_SYS
  66. # define PERL_IMPLICIT_SYS
  67. # endif
  68. #endif
  69. #ifdef PERL_OBJECT
  70. /* PERL_OBJECT explained - DickH and DougL @ ActiveState.com
  71. Defining PERL_OBJECT turns on creation of a C++ object that
  72. contains all writable core perl global variables and functions.
  73. Stated another way, all necessary global variables and functions
  74. are members of a big C++ object. This object's class is CPerlObj.
  75. This allows a Perl Host to have multiple, independent perl
  76. interpreters in the same process space. This is very important on
  77. Win32 systems as the overhead of process creation is quite high --
  78. this could be even higher than the script compile and execute time
  79. for small scripts.
  80. The perl executable implementation on Win32 is composed of perl.exe
  81. (the Perl Host) and perlX.dll. (the Perl Core). This allows the
  82. same Perl Core to easily be embedded in other applications that use
  83. the perl interpreter.
  84. +-----------+
  85. | Perl Host |
  86. +-----------+
  87. ^
  88. |
  89. v
  90. +-----------+ +-----------+
  91. | Perl Core |<->| Extension |
  92. +-----------+ +-----------+ ...
  93. Defining PERL_OBJECT has the following effects:
  94. PERL CORE
  95. 1. CPerlObj is defined (this is the PERL_OBJECT)
  96. 2. all static functions that needed to access either global
  97. variables or functions needed are made member functions
  98. 3. all writable static variables are made member variables
  99. 4. all global variables and functions are defined as:
  100. #define var CPerlObj::PL_var
  101. #define func CPerlObj::Perl_func
  102. * these are in embed.h
  103. This necessitated renaming some local variables and functions that
  104. had the same name as a global variable or function. This was
  105. probably a _good_ thing anyway.
  106. EXTENSIONS
  107. 1. Access to global variables and perl functions is through a
  108. pointer to the PERL_OBJECT. This pointer type is CPerlObj*. This is
  109. made transparent to extension developers by the following macros:
  110. #define var pPerl->PL_var
  111. #define func pPerl->Perl_func
  112. * these are done in objXSUB.h
  113. This requires that the extension be compiled as C++, which means
  114. that the code must be ANSI C and not K&R C. For K&R extensions,
  115. please see the C API notes located in Win32/GenCAPI.pl. This script
  116. creates a perlCAPI.lib that provides a K & R compatible C interface
  117. to the PERL_OBJECT.
  118. 2. Local variables and functions cannot have the same name as perl's
  119. variables or functions since the macros will redefine these. Look for
  120. this if you get some strange error message and it does not look like
  121. the code that you had written. This often happens with variables that
  122. are local to a function.
  123. PERL HOST
  124. 1. The perl host is linked with perlX.lib to get perl_alloc. This
  125. function will return a pointer to CPerlObj (the PERL_OBJECT). It
  126. takes pointers to the various PerlXXX_YYY interfaces (see iperlsys.h
  127. for more information on this).
  128. 2. The perl host calls the same functions as normally would be
  129. called in setting up and running a perl script, except that the
  130. functions are now member functions of the PERL_OBJECT.
  131. */
  132. class CPerlObj;
  133. #define STATIC
  134. #define CPERLscope(x) CPerlObj::x
  135. #define CALL_FPTR(fptr) (aTHXo->*fptr)
  136. #define pTHXo CPerlObj *pPerl
  137. #define pTHXo_ pTHXo,
  138. #define aTHXo this
  139. #define aTHXo_ this,
  140. #define PERL_OBJECT_THIS aTHXo
  141. #define PERL_OBJECT_THIS_ aTHXo_
  142. #define dTHXoa(a) pTHXo = (CPerlObj*)a
  143. #define dTHXo pTHXo = PERL_GET_THX
  144. #define pTHXx void
  145. #define pTHXx_
  146. #define aTHXx
  147. #define aTHXx_
  148. #else /* !PERL_OBJECT */
  149. #ifdef PERL_IMPLICIT_CONTEXT
  150. # ifdef USE_THREADS
  151. struct perl_thread;
  152. # define pTHX register struct perl_thread *thr
  153. # define aTHX thr
  154. # define dTHR dNOOP /* only backward compatibility */
  155. # define dTHXa(a) pTHX = (struct perl_thread*)a
  156. # else
  157. # ifndef MULTIPLICITY
  158. # define MULTIPLICITY
  159. # endif
  160. # define pTHX register PerlInterpreter *my_perl
  161. # define aTHX my_perl
  162. # define dTHXa(a) pTHX = (PerlInterpreter*)a
  163. # endif
  164. # define dTHX pTHX = PERL_GET_THX
  165. # define pTHX_ pTHX,
  166. # define aTHX_ aTHX,
  167. # define pTHX_1 2
  168. # define pTHX_2 3
  169. # define pTHX_3 4
  170. # define pTHX_4 5
  171. #endif
  172. #define STATIC static
  173. #define CPERLscope(x) x
  174. #define CPERLarg void
  175. #define CPERLarg_
  176. #define _CPERLarg
  177. #define PERL_OBJECT_THIS
  178. #define _PERL_OBJECT_THIS
  179. #define PERL_OBJECT_THIS_
  180. #define CALL_FPTR(fptr) (*fptr)
  181. #endif /* PERL_OBJECT */
  182. #define CALLRUNOPS CALL_FPTR(PL_runops)
  183. #define CALLREGCOMP CALL_FPTR(PL_regcompp)
  184. #define CALLREGEXEC CALL_FPTR(PL_regexecp)
  185. #define CALLREG_INTUIT_START CALL_FPTR(PL_regint_start)
  186. #define CALLREG_INTUIT_STRING CALL_FPTR(PL_regint_string)
  187. #define CALLREGFREE CALL_FPTR(PL_regfree)
  188. #ifdef PERL_FLEXIBLE_EXCEPTIONS
  189. # define CALLPROTECT CALL_FPTR(PL_protect)
  190. #endif
  191. #define NOOP (void)0
  192. #define dNOOP extern int Perl___notused
  193. #ifndef pTHX
  194. # define pTHX void
  195. # define pTHX_
  196. # define aTHX
  197. # define aTHX_
  198. # define dTHXa(a) dNOOP
  199. # define dTHX dNOOP
  200. # define pTHX_1 1
  201. # define pTHX_2 2
  202. # define pTHX_3 3
  203. # define pTHX_4 4
  204. #endif
  205. #ifndef pTHXo
  206. # define pTHXo pTHX
  207. # define pTHXo_ pTHX_
  208. # define aTHXo aTHX
  209. # define aTHXo_ aTHX_
  210. # define dTHXo dTHX
  211. # define dTHXoa(x) dTHXa(x)
  212. #endif
  213. #ifndef pTHXx
  214. # define pTHXx register PerlInterpreter *my_perl
  215. # define pTHXx_ pTHXx,
  216. # define aTHXx my_perl
  217. # define aTHXx_ aTHXx,
  218. # define dTHXx dTHX
  219. #endif
  220. /* Under PERL_IMPLICIT_SYS (used in Windows for fork emulation)
  221. * PerlIO_foo() expands to PL_StdIO->pFOO(PL_StdIO, ...).
  222. * dTHXs is therefore needed for all functions using PerlIO_foo(). */
  223. #ifdef PERL_IMPLICIT_SYS
  224. # define dTHXs dTHX
  225. #else
  226. # define dTHXs dNOOP
  227. #endif
  228. #undef START_EXTERN_C
  229. #undef END_EXTERN_C
  230. #undef EXTERN_C
  231. #ifdef __cplusplus
  232. # define START_EXTERN_C extern "C" {
  233. # define END_EXTERN_C }
  234. # define EXTERN_C extern "C"
  235. #else
  236. # define START_EXTERN_C
  237. # define END_EXTERN_C
  238. # define EXTERN_C extern
  239. #endif
  240. #ifdef OP_IN_REGISTER
  241. # ifdef __GNUC__
  242. # define stringify_immed(s) #s
  243. # define stringify(s) stringify_immed(s)
  244. register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
  245. # endif
  246. #endif
  247. /*
  248. * STMT_START { statements; } STMT_END;
  249. * can be used as a single statement, as in
  250. * if (x) STMT_START { ... } STMT_END; else ...
  251. *
  252. * Trying to select a version that gives no warnings...
  253. */
  254. #if !(defined(STMT_START) && defined(STMT_END))
  255. # if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(__cplusplus)
  256. # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
  257. # define STMT_END )
  258. # else
  259. /* Now which other defined()s do we need here ??? */
  260. # if (VOIDFLAGS) && (defined(sun) || defined(__sun__))
  261. # define STMT_START if (1)
  262. # define STMT_END else (void)0
  263. # else
  264. # define STMT_START do
  265. # define STMT_END while (0)
  266. # endif
  267. # endif
  268. #endif
  269. #define WITH_THX(s) STMT_START { dTHX; s; } STMT_END
  270. #define WITH_THR(s) WITH_THX(s)
  271. /*
  272. * SOFT_CAST can be used for args to prototyped functions to retain some
  273. * type checking; it only casts if the compiler does not know prototypes.
  274. */
  275. #if defined(CAN_PROTOTYPE) && defined(DEBUGGING_COMPILE)
  276. #define SOFT_CAST(type)
  277. #else
  278. #define SOFT_CAST(type) (type)
  279. #endif
  280. #ifndef BYTEORDER /* Should never happen -- byteorder is in config.h */
  281. # define BYTEORDER 0x1234
  282. #endif
  283. /* Overall memory policy? */
  284. #ifndef CONSERVATIVE
  285. # define LIBERAL 1
  286. #endif
  287. #if 'A' == 65 && 'I' == 73 && 'J' == 74 && 'Z' == 90
  288. #define ASCIIish
  289. #else
  290. #undef ASCIIish
  291. #endif
  292. /*
  293. * The following contortions are brought to you on behalf of all the
  294. * standards, semi-standards, de facto standards, not-so-de-facto standards
  295. * of the world, as well as all the other botches anyone ever thought of.
  296. * The basic theory is that if we work hard enough here, the rest of the
  297. * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
  298. */
  299. /* define this once if either system, instead of cluttering up the src */
  300. #if defined(MSDOS) || defined(atarist) || defined(WIN32)
  301. #define DOSISH 1
  302. #endif
  303. #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus) || defined( EPOC)
  304. # define STANDARD_C 1
  305. #endif
  306. #if defined(__cplusplus) || defined(WIN32) || defined(__sgi) || defined(OS2) || defined(__DGUX) || defined( EPOC) || defined(__QNX__)
  307. # define DONT_DECLARE_STD 1
  308. #endif
  309. #if defined(HASVOLATILE) || defined(STANDARD_C)
  310. # ifdef __cplusplus
  311. # define VOL // to temporarily suppress warnings
  312. # else
  313. # define VOL volatile
  314. # endif
  315. #else
  316. # define VOL
  317. #endif
  318. #define TAINT (PL_tainted = TRUE)
  319. #define TAINT_NOT (PL_tainted = FALSE)
  320. #define TAINT_IF(c) if (c) { PL_tainted = TRUE; }
  321. #define TAINT_ENV() if (PL_tainting) { taint_env(); }
  322. #define TAINT_PROPER(s) if (PL_tainting) { taint_proper(Nullch, s); }
  323. /* XXX All process group stuff is handled in pp_sys.c. Should these
  324. defines move there? If so, I could simplify this a lot. --AD 9/96.
  325. */
  326. /* Process group stuff changed from traditional BSD to POSIX.
  327. perlfunc.pod documents the traditional BSD-style syntax, so we'll
  328. try to preserve that, if possible.
  329. */
  330. #ifdef HAS_SETPGID
  331. # define BSD_SETPGRP(pid, pgrp) setpgid((pid), (pgrp))
  332. #else
  333. # if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
  334. # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
  335. # else
  336. # ifdef HAS_SETPGRP2 /* DG/UX */
  337. # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
  338. # endif
  339. # endif
  340. #endif
  341. #if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
  342. # define HAS_SETPGRP /* Well, effectively it does . . . */
  343. #endif
  344. /* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
  345. our life easier :-) so we'll try it.
  346. */
  347. #ifdef HAS_GETPGID
  348. # define BSD_GETPGRP(pid) getpgid((pid))
  349. #else
  350. # if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
  351. # define BSD_GETPGRP(pid) getpgrp((pid))
  352. # else
  353. # ifdef HAS_GETPGRP2 /* DG/UX */
  354. # define BSD_GETPGRP(pid) getpgrp2((pid))
  355. # endif
  356. # endif
  357. #endif
  358. #if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
  359. # define HAS_GETPGRP /* Well, effectively it does . . . */
  360. #endif
  361. /* These are not exact synonyms, since setpgrp() and getpgrp() may
  362. have different behaviors, but perl.h used to define USE_BSDPGRP
  363. (prior to 5.003_05) so some extension might depend on it.
  364. */
  365. #if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
  366. # ifndef USE_BSDPGRP
  367. # define USE_BSDPGRP
  368. # endif
  369. #endif
  370. /* HP-UX 10.X CMA (Common Multithreaded Architecure) insists that
  371. pthread.h must be included before all other header files.
  372. */
  373. #if (defined(USE_THREADS) || defined(USE_ITHREADS)) \
  374. && defined(PTHREAD_H_FIRST) && defined(I_PTHREAD)
  375. # include <pthread.h>
  376. #endif
  377. #ifndef _TYPES_ /* If types.h defines this it's easy. */
  378. # ifndef major /* Does everyone's types.h define this? */
  379. # include <sys/types.h>
  380. # endif
  381. #endif
  382. #ifdef __cplusplus
  383. # ifndef I_STDARG
  384. # define I_STDARG 1
  385. # endif
  386. #endif
  387. #ifdef I_STDARG
  388. # include <stdarg.h>
  389. #else
  390. # ifdef I_VARARGS
  391. # include <varargs.h>
  392. # endif
  393. #endif
  394. #ifdef USE_NEXT_CTYPE
  395. #if NX_CURRENT_COMPILER_RELEASE >= 500
  396. # include <bsd/ctypes.h>
  397. #else
  398. # if NX_CURRENT_COMPILER_RELEASE >= 400
  399. # include <objc/NXCType.h>
  400. # else /* NX_CURRENT_COMPILER_RELEASE < 400 */
  401. # include <appkit/NXCType.h>
  402. # endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
  403. #endif /* NX_CURRENT_COMPILER_RELEASE >= 500 */
  404. #else /* !USE_NEXT_CTYPE */
  405. #include <ctype.h>
  406. #endif /* USE_NEXT_CTYPE */
  407. #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
  408. #undef METHOD
  409. #endif
  410. #ifdef I_LOCALE
  411. # include <locale.h>
  412. #endif
  413. #if !defined(NO_LOCALE) && defined(HAS_SETLOCALE)
  414. # define USE_LOCALE
  415. # if !defined(NO_LOCALE_COLLATE) && defined(LC_COLLATE) \
  416. && defined(HAS_STRXFRM)
  417. # define USE_LOCALE_COLLATE
  418. # endif
  419. # if !defined(NO_LOCALE_CTYPE) && defined(LC_CTYPE)
  420. # define USE_LOCALE_CTYPE
  421. # endif
  422. # if !defined(NO_LOCALE_NUMERIC) && defined(LC_NUMERIC)
  423. # define USE_LOCALE_NUMERIC
  424. # endif
  425. #endif /* !NO_LOCALE && HAS_SETLOCALE */
  426. #include <setjmp.h>
  427. #ifdef I_SYS_PARAM
  428. # ifdef PARAM_NEEDS_TYPES
  429. # include <sys/types.h>
  430. # endif
  431. # include <sys/param.h>
  432. #endif
  433. /* Use all the "standard" definitions? */
  434. #if defined(STANDARD_C) && defined(I_STDLIB)
  435. # include <stdlib.h>
  436. #endif
  437. /* If this causes problems, set i_unistd=undef in the hint file. */
  438. #ifdef I_UNISTD
  439. # include <unistd.h>
  440. #endif
  441. #ifdef PERL_MICRO /* Last chance to export Perl_my_swap */
  442. # define MYSWAP
  443. #endif
  444. #if !defined(PERL_FOR_X2P) && !defined(WIN32)
  445. # include "embed.h"
  446. #endif
  447. #define MEM_SIZE Size_t
  448. #if defined(STANDARD_C) && defined(I_STDDEF)
  449. # include <stddef.h>
  450. # define STRUCT_OFFSET(s,m) offsetof(s,m)
  451. #else
  452. # define STRUCT_OFFSET(s,m) (Size_t)(&(((s *)0)->m))
  453. #endif
  454. #if defined(I_STRING) || defined(__cplusplus)
  455. # include <string.h>
  456. #else
  457. # include <strings.h>
  458. #endif
  459. /* This comes after <stdlib.h> so we don't try to change the standard
  460. * library prototypes; we'll use our own in proto.h instead. */
  461. #ifdef MYMALLOC
  462. # ifdef PERL_POLLUTE_MALLOC
  463. # ifndef PERL_EXTMALLOC_DEF
  464. # define Perl_malloc malloc
  465. # define Perl_calloc calloc
  466. # define Perl_realloc realloc
  467. # define Perl_mfree free
  468. # endif
  469. # else
  470. # define EMBEDMYMALLOC /* for compatibility */
  471. # endif
  472. Malloc_t Perl_malloc (MEM_SIZE nbytes);
  473. Malloc_t Perl_calloc (MEM_SIZE elements, MEM_SIZE size);
  474. Malloc_t Perl_realloc (Malloc_t where, MEM_SIZE nbytes);
  475. /* 'mfree' rather than 'free', since there is already a 'perl_free'
  476. * that causes clashes with case-insensitive linkers */
  477. Free_t Perl_mfree (Malloc_t where);
  478. typedef struct perl_mstats perl_mstats_t;
  479. # define safemalloc Perl_malloc
  480. # define safecalloc Perl_calloc
  481. # define saferealloc Perl_realloc
  482. # define safefree Perl_mfree
  483. #else /* MYMALLOC */
  484. # define safemalloc safesysmalloc
  485. # define safecalloc safesyscalloc
  486. # define saferealloc safesysrealloc
  487. # define safefree safesysfree
  488. #endif /* MYMALLOC */
  489. #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
  490. #define strchr index
  491. #define strrchr rindex
  492. #endif
  493. #ifdef I_MEMORY
  494. # include <memory.h>
  495. #endif
  496. #ifdef HAS_MEMCPY
  497. # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
  498. # ifndef memcpy
  499. extern char * memcpy (char*, char*, int);
  500. # endif
  501. # endif
  502. #else
  503. # ifndef memcpy
  504. # ifdef HAS_BCOPY
  505. # define memcpy(d,s,l) bcopy(s,d,l)
  506. # else
  507. # define memcpy(d,s,l) my_bcopy(s,d,l)
  508. # endif
  509. # endif
  510. #endif /* HAS_MEMCPY */
  511. #ifdef HAS_MEMSET
  512. # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
  513. # ifndef memset
  514. extern char *memset (char*, int, int);
  515. # endif
  516. # endif
  517. #else
  518. # define memset(d,c,l) my_memset(d,c,l)
  519. #endif /* HAS_MEMSET */
  520. #if !defined(HAS_MEMMOVE) && !defined(memmove)
  521. # if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
  522. # define memmove(d,s,l) bcopy(s,d,l)
  523. # else
  524. # if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
  525. # define memmove(d,s,l) memcpy(d,s,l)
  526. # else
  527. # define memmove(d,s,l) my_bcopy(s,d,l)
  528. # endif
  529. # endif
  530. #endif
  531. #if defined(mips) && defined(ultrix) && !defined(__STDC__)
  532. # undef HAS_MEMCMP
  533. #endif
  534. #if defined(HAS_MEMCMP) && defined(HAS_SANE_MEMCMP)
  535. # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
  536. # ifndef memcmp
  537. extern int memcmp (char*, char*, int);
  538. # endif
  539. # endif
  540. # ifdef BUGGY_MSC
  541. # pragma function(memcmp)
  542. # endif
  543. #else
  544. # ifndef memcmp
  545. # define memcmp my_memcmp
  546. # endif
  547. #endif /* HAS_MEMCMP && HAS_SANE_MEMCMP */
  548. #ifndef memzero
  549. # ifdef HAS_MEMSET
  550. # define memzero(d,l) memset(d,0,l)
  551. # else
  552. # ifdef HAS_BZERO
  553. # define memzero(d,l) bzero(d,l)
  554. # else
  555. # define memzero(d,l) my_bzero(d,l)
  556. # endif
  557. # endif
  558. #endif
  559. #ifndef memchr
  560. # ifndef HAS_MEMCHR
  561. # define memchr(s,c,n) ninstr((char*)(s), ((char*)(s)) + n, &(c), &(c) + 1)
  562. # endif
  563. #endif
  564. #ifndef HAS_BCMP
  565. # ifndef bcmp
  566. # define bcmp(s1,s2,l) memcmp(s1,s2,l)
  567. # endif
  568. #endif /* !HAS_BCMP */
  569. #ifdef I_NETINET_IN
  570. # include <netinet/in.h>
  571. #endif
  572. #ifdef I_ARPA_INET
  573. # include <arpa/inet.h>
  574. #endif
  575. #if defined(SF_APPEND) && defined(USE_SFIO) && defined(I_SFIO)
  576. /* <sfio.h> defines SF_APPEND and <sys/stat.h> might define SF_APPEND
  577. * (the neo-BSD seem to do this). */
  578. # undef SF_APPEND
  579. #endif
  580. #ifdef I_SYS_STAT
  581. # include <sys/stat.h>
  582. #endif
  583. /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
  584. like UTekV) are broken, sometimes giving false positives. Undefine
  585. them here and let the code below set them to proper values.
  586. The ghs macro stands for GreenHills Software C-1.8.5 which
  587. is the C compiler for sysV88 and the various derivatives.
  588. This header file bug is corrected in gcc-2.5.8 and later versions.
  589. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
  590. #if defined(uts) || (defined(m88k) && defined(ghs))
  591. # undef S_ISDIR
  592. # undef S_ISCHR
  593. # undef S_ISBLK
  594. # undef S_ISREG
  595. # undef S_ISFIFO
  596. # undef S_ISLNK
  597. #endif
  598. #ifdef I_TIME
  599. # include <time.h>
  600. #endif
  601. #ifdef I_SYS_TIME
  602. # ifdef I_SYS_TIME_KERNEL
  603. # define KERNEL
  604. # endif
  605. # include <sys/time.h>
  606. # ifdef I_SYS_TIME_KERNEL
  607. # undef KERNEL
  608. # endif
  609. #endif
  610. #if defined(HAS_TIMES) && defined(I_SYS_TIMES)
  611. # include <sys/times.h>
  612. #endif
  613. #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
  614. # undef HAS_STRERROR
  615. #endif
  616. #include <errno.h>
  617. #if defined(WIN32) && (defined(PERL_OBJECT) || defined(PERL_IMPLICIT_SYS) || defined(PERL_CAPI))
  618. # define WIN32SCK_IS_STDSCK /* don't pull in custom wsock layer */
  619. #endif
  620. #if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */
  621. # include <sys/socket.h>
  622. # if defined(USE_SOCKS) && defined(I_SOCKS)
  623. # if !defined(INCLUDE_PROTOTYPES)
  624. # define INCLUDE_PROTOTYPES /* for <socks.h> */
  625. # define PERL_SOCKS_NEED_PROTOTYPES
  626. # endif
  627. # ifdef USE_THREADS
  628. # define PERL_USE_THREADS /* store our value */
  629. # undef USE_THREADS
  630. # endif
  631. # include <socks.h>
  632. # ifdef USE_THREADS
  633. # undef USE_THREADS /* socks.h does this on its own */
  634. # endif
  635. # ifdef PERL_USE_THREADS
  636. # define USE_THREADS /* restore our value */
  637. # undef PERL_USE_THREADS
  638. # endif
  639. # ifdef PERL_SOCKS_NEED_PROTOTYPES /* keep cpp space clean */
  640. # undef INCLUDE_PROTOTYPES
  641. # undef PERL_SOCKS_NEED_PROTOTYPES
  642. # endif
  643. # ifdef USE_64_BIT_ALL
  644. # define SOCKS_64BIT_BUG /* until proven otherwise */
  645. # endif
  646. # endif
  647. # ifdef I_NETDB
  648. # include <netdb.h>
  649. # endif
  650. # ifndef ENOTSOCK
  651. # ifdef I_NET_ERRNO
  652. # include <net/errno.h>
  653. # endif
  654. # endif
  655. #endif
  656. #ifdef SETERRNO
  657. # undef SETERRNO /* SOCKS might have defined this */
  658. #endif
  659. #ifdef VMS
  660. # define SETERRNO(errcode,vmserrcode) \
  661. STMT_START { \
  662. set_errno(errcode); \
  663. set_vaxc_errno(vmserrcode); \
  664. } STMT_END
  665. #else
  666. # define SETERRNO(errcode,vmserrcode) (errno = (errcode))
  667. #endif
  668. #ifdef USE_THREADS
  669. # define ERRSV (thr->errsv)
  670. # define DEFSV THREADSV(0)
  671. # define SAVE_DEFSV save_threadsv(0)
  672. #else
  673. # define ERRSV GvSV(PL_errgv)
  674. # define DEFSV GvSV(PL_defgv)
  675. # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
  676. #endif /* USE_THREADS */
  677. #define ERRHV GvHV(PL_errgv) /* XXX unused, here for compatibility */
  678. #ifndef errno
  679. extern int errno; /* ANSI allows errno to be an lvalue expr.
  680. * For example in multithreaded environments
  681. * something like this might happen:
  682. * extern int *_errno(void);
  683. * #define errno (*_errno()) */
  684. #endif
  685. #ifdef HAS_STRERROR
  686. # ifdef VMS
  687. char *strerror (int,...);
  688. # else
  689. #ifndef DONT_DECLARE_STD
  690. char *strerror (int);
  691. #endif
  692. # endif
  693. # ifndef Strerror
  694. # define Strerror strerror
  695. # endif
  696. #else
  697. # ifdef HAS_SYS_ERRLIST
  698. extern int sys_nerr;
  699. extern char *sys_errlist[];
  700. # ifndef Strerror
  701. # define Strerror(e) \
  702. ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
  703. # endif
  704. # endif
  705. #endif
  706. #ifdef I_SYS_IOCTL
  707. # ifndef _IOCTL_
  708. # include <sys/ioctl.h>
  709. # endif
  710. #endif
  711. #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
  712. # ifdef HAS_SOCKETPAIR
  713. # undef HAS_SOCKETPAIR
  714. # endif
  715. # ifdef I_NDBM
  716. # undef I_NDBM
  717. # endif
  718. #endif
  719. #if INTSIZE == 2
  720. # define htoni htons
  721. # define ntohi ntohs
  722. #else
  723. # define htoni htonl
  724. # define ntohi ntohl
  725. #endif
  726. /* Configure already sets Direntry_t */
  727. #if defined(I_DIRENT)
  728. # include <dirent.h>
  729. /* NeXT needs dirent + sys/dir.h */
  730. # if defined(I_SYS_DIR) && (defined(NeXT) || defined(__NeXT__))
  731. # include <sys/dir.h>
  732. # endif
  733. #else
  734. # ifdef I_SYS_NDIR
  735. # include <sys/ndir.h>
  736. # else
  737. # ifdef I_SYS_DIR
  738. # ifdef hp9000s500
  739. # include <ndir.h> /* may be wrong in the future */
  740. # else
  741. # include <sys/dir.h>
  742. # endif
  743. # endif
  744. # endif
  745. #endif
  746. #ifdef FPUTS_BOTCH
  747. /* work around botch in SunOS 4.0.1 and 4.0.2 */
  748. # ifndef fputs
  749. # define fputs(sv,fp) fprintf(fp,"%s",sv)
  750. # endif
  751. #endif
  752. /*
  753. * The following gobbledygook brought to you on behalf of __STDC__.
  754. * (I could just use #ifndef __STDC__, but this is more bulletproof
  755. * in the face of half-implementations.)
  756. */
  757. #ifdef I_SYSMODE
  758. #include <sys/mode.h>
  759. #endif
  760. #ifndef S_IFMT
  761. # ifdef _S_IFMT
  762. # define S_IFMT _S_IFMT
  763. # else
  764. # define S_IFMT 0170000
  765. # endif
  766. #endif
  767. #ifndef S_ISDIR
  768. # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
  769. #endif
  770. #ifndef S_ISCHR
  771. # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
  772. #endif
  773. #ifndef S_ISBLK
  774. # ifdef S_IFBLK
  775. # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
  776. # else
  777. # define S_ISBLK(m) (0)
  778. # endif
  779. #endif
  780. #ifndef S_ISREG
  781. # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  782. #endif
  783. #ifndef S_ISFIFO
  784. # ifdef S_IFIFO
  785. # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
  786. # else
  787. # define S_ISFIFO(m) (0)
  788. # endif
  789. #endif
  790. #ifndef S_ISLNK
  791. # ifdef _S_ISLNK
  792. # define S_ISLNK(m) _S_ISLNK(m)
  793. # else
  794. # ifdef _S_IFLNK
  795. # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
  796. # else
  797. # ifdef S_IFLNK
  798. # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  799. # else
  800. # define S_ISLNK(m) (0)
  801. # endif
  802. # endif
  803. # endif
  804. #endif
  805. #ifndef S_ISSOCK
  806. # ifdef _S_ISSOCK
  807. # define S_ISSOCK(m) _S_ISSOCK(m)
  808. # else
  809. # ifdef _S_IFSOCK
  810. # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
  811. # else
  812. # ifdef S_IFSOCK
  813. # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
  814. # else
  815. # define S_ISSOCK(m) (0)
  816. # endif
  817. # endif
  818. # endif
  819. #endif
  820. #ifndef S_IRUSR
  821. # ifdef S_IREAD
  822. # define S_IRUSR S_IREAD
  823. # define S_IWUSR S_IWRITE
  824. # define S_IXUSR S_IEXEC
  825. # else
  826. # define S_IRUSR 0400
  827. # define S_IWUSR 0200
  828. # define S_IXUSR 0100
  829. # endif
  830. #endif
  831. #ifndef S_IRGRP
  832. # ifdef S_IRUSR
  833. # define S_IRGRP (S_IRUSR>>3)
  834. # define S_IWGRP (S_IWUSR>>3)
  835. # define S_IXGRP (S_IXUSR>>3)
  836. # else
  837. # define S_IRGRP 0040
  838. # define S_IWGRP 0020
  839. # define S_IXGRP 0010
  840. # endif
  841. #endif
  842. #ifndef S_IROTH
  843. # ifdef S_IRUSR
  844. # define S_IROTH (S_IRUSR>>6)
  845. # define S_IWOTH (S_IWUSR>>6)
  846. # define S_IXOTH (S_IXUSR>>6)
  847. # else
  848. # define S_IROTH 0040
  849. # define S_IWOTH 0020
  850. # define S_IXOTH 0010
  851. # endif
  852. #endif
  853. #ifndef S_ISUID
  854. # define S_ISUID 04000
  855. #endif
  856. #ifndef S_ISGID
  857. # define S_ISGID 02000
  858. #endif
  859. #ifndef S_IRWXU
  860. # define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
  861. #endif
  862. #ifndef S_IRWXG
  863. # define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
  864. #endif
  865. #ifndef S_IRWXO
  866. # define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
  867. #endif
  868. #ifndef S_IREAD
  869. # define S_IREAD S_IRUSR
  870. #endif
  871. #ifndef S_IWRITE
  872. # define S_IWRITE S_IWUSR
  873. #endif
  874. #ifndef S_IEXEC
  875. # define S_IEXEC S_IXUSR
  876. #endif
  877. #ifdef ff_next
  878. # undef ff_next
  879. #endif
  880. #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
  881. # define SLOPPYDIVIDE
  882. #endif
  883. #ifdef UV
  884. #undef UV
  885. #endif
  886. /*
  887. The IV type is supposed to be long enough to hold any integral
  888. value or a pointer.
  889. --Andy Dougherty August 1996
  890. */
  891. typedef IVTYPE IV;
  892. typedef UVTYPE UV;
  893. #if defined(USE_64_BIT_INT) && defined(HAS_QUAD)
  894. # if QUADKIND == QUAD_IS_INT64_T && defined(INT64_MAX)
  895. # define IV_MAX INT64_MAX
  896. # define IV_MIN INT64_MIN
  897. # define UV_MAX UINT64_MAX
  898. # ifndef UINT64_MIN
  899. # define UINT64_MIN 0
  900. # endif
  901. # define UV_MIN UINT64_MIN
  902. # else
  903. # define IV_MAX PERL_QUAD_MAX
  904. # define IV_MIN PERL_QUAD_MIN
  905. # define UV_MAX PERL_UQUAD_MAX
  906. # define UV_MIN PERL_UQUAD_MIN
  907. # endif
  908. # define IV_IS_QUAD
  909. # define UV_IS_QUAD
  910. #else
  911. # if defined(INT32_MAX) && IVSIZE == 4
  912. # define IV_MAX INT32_MAX
  913. # define IV_MIN INT32_MIN
  914. # ifndef UINT32_MAX_BROKEN /* e.g. HP-UX with gcc messes this up */
  915. # define UV_MAX UINT32_MAX
  916. # else
  917. # define UV_MAX 4294967295U
  918. # endif
  919. # ifndef UINT32_MIN
  920. # define UINT32_MIN 0
  921. # endif
  922. # define UV_MIN UINT32_MIN
  923. # else
  924. # define IV_MAX PERL_LONG_MAX
  925. # define IV_MIN PERL_LONG_MIN
  926. # define UV_MAX PERL_ULONG_MAX
  927. # define UV_MIN PERL_ULONG_MIN
  928. # endif
  929. # if IVSIZE == 8
  930. # define IV_IS_QUAD
  931. # define UV_IS_QUAD
  932. # ifndef HAS_QUAD
  933. # define HAS_QUAD
  934. # endif
  935. # else
  936. # undef IV_IS_QUAD
  937. # undef UV_IS_QUAD
  938. # undef HAS_QUAD
  939. # endif
  940. #endif
  941. #define IV_DIG (BIT_DIGITS(IVSIZE * 8))
  942. #define UV_DIG (BIT_DIGITS(UVSIZE * 8))
  943. /*
  944. * The macros INT2PTR and NUM2PTR are (despite their names)
  945. * bi-directional: they will convert int/float to or from pointers.
  946. * However the conversion to int/float are named explicitly:
  947. * PTR2IV, PTR2UV, PTR2NV.
  948. *
  949. * For int conversions we do not need two casts if pointers are
  950. * the same size as IV and UV. Otherwise we need an explicit
  951. * cast (PTRV) to avoid compiler warnings.
  952. */
  953. #if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
  954. # define PTRV UV
  955. # define INT2PTR(any,d) (any)(d)
  956. #else
  957. # if PTRSIZE == LONGSIZE
  958. # define PTRV unsigned long
  959. # else
  960. # define PTRV unsigned
  961. # endif
  962. # define INT2PTR(any,d) (any)(PTRV)(d)
  963. #endif
  964. #define NUM2PTR(any,d) (any)(PTRV)(d)
  965. #define PTR2IV(p) INT2PTR(IV,p)
  966. #define PTR2UV(p) INT2PTR(UV,p)
  967. #define PTR2NV(p) NUM2PTR(NV,p)
  968. #if PTRSIZE == LONGSIZE
  969. # define PTR2ul(p) (unsigned long)(p)
  970. #else
  971. # define PTR2ul(p) INT2PTR(unsigned long,p)
  972. #endif
  973. #ifdef USE_LONG_DOUBLE
  974. # if defined(HAS_LONG_DOUBLE) && LONG_DOUBLESIZE == DOUBLESIZE
  975. # define LONG_DOUBLE_EQUALS_DOUBLE
  976. # endif
  977. # if !(defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE))
  978. # undef USE_LONG_DOUBLE /* Ouch! */
  979. # endif
  980. #endif
  981. #ifdef OVR_DBL_DIG
  982. /* Use an overridden DBL_DIG */
  983. # ifdef DBL_DIG
  984. # undef DBL_DIG
  985. # endif
  986. # define DBL_DIG OVR_DBL_DIG
  987. #else
  988. /* The following is all to get DBL_DIG, in order to pick a nice
  989. default value for printing floating point numbers in Gconvert.
  990. (see config.h)
  991. */
  992. #ifdef I_LIMITS
  993. #include <limits.h>
  994. #endif
  995. #ifdef I_FLOAT
  996. #include <float.h>
  997. #endif
  998. #ifndef HAS_DBL_DIG
  999. #define DBL_DIG 15 /* A guess that works lots of places */
  1000. #endif
  1001. #endif
  1002. #ifdef I_FLOAT
  1003. #include <float.h>
  1004. #endif
  1005. #ifndef HAS_DBL_DIG
  1006. #define DBL_DIG 15 /* A guess that works lots of places */
  1007. #endif
  1008. #ifdef OVR_LDBL_DIG
  1009. /* Use an overridden LDBL_DIG */
  1010. # ifdef LDBL_DIG
  1011. # undef LDBL_DIG
  1012. # endif
  1013. # define LDBL_DIG OVR_LDBL_DIG
  1014. #else
  1015. /* The following is all to get LDBL_DIG, in order to pick a nice
  1016. default value for printing floating point numbers in Gconvert.
  1017. (see config.h)
  1018. */
  1019. # ifdef I_LIMITS
  1020. # include <limits.h>
  1021. # endif
  1022. # ifdef I_FLOAT
  1023. # include <float.h>
  1024. # endif
  1025. # ifndef HAS_LDBL_DIG
  1026. # if LONG_DOUBLESIZE == 10
  1027. # define LDBL_DIG 18 /* assume IEEE */
  1028. # else
  1029. # if LONG_DOUBLESIZE == 12
  1030. # define LDBL_DIG 18 /* gcc? */
  1031. # else
  1032. # if LONG_DOUBLESIZE == 16
  1033. # define LDBL_DIG 33 /* assume IEEE */
  1034. # else
  1035. # if LONG_DOUBLESIZE == DOUBLESIZE
  1036. # define LDBL_DIG DBL_DIG /* bummer */
  1037. # endif
  1038. # endif
  1039. # endif
  1040. # endif
  1041. # endif
  1042. #endif
  1043. typedef NVTYPE NV;
  1044. #ifdef I_IEEEFP
  1045. # include <ieeefp.h>
  1046. #endif
  1047. #ifdef USE_LONG_DOUBLE
  1048. # ifdef I_SUNMATH
  1049. # include <sunmath.h>
  1050. # endif
  1051. # define NV_DIG LDBL_DIG
  1052. # ifdef LDBL_MANT_DIG
  1053. # define NV_MANT_DIG LDBL_MANT_DIG
  1054. # endif
  1055. # ifdef LDBL_MAX
  1056. # define NV_MAX LDBL_MAX
  1057. # define NV_MIN LDBL_MIN
  1058. # else
  1059. # ifdef HUGE_VALL
  1060. # define NV_MAX HUGE_VALL
  1061. # else
  1062. # ifdef HUGE_VAL
  1063. # define NV_MAX ((NV)HUGE_VAL)
  1064. # endif
  1065. # endif
  1066. # endif
  1067. # ifdef HAS_SQRTL
  1068. # define Perl_cos cosl
  1069. # define Perl_sin sinl
  1070. # define Perl_sqrt sqrtl
  1071. # define Perl_exp expl
  1072. # define Perl_log logl
  1073. # define Perl_atan2 atan2l
  1074. # define Perl_pow powl
  1075. # define Perl_floor floorl
  1076. # define Perl_fmod fmodl
  1077. # endif
  1078. /* e.g. libsunmath doesn't have modfl and frexpl as of mid-March 2000 */
  1079. # ifdef HAS_MODFL
  1080. # define Perl_modf(x,y) modfl(x,y)
  1081. # else
  1082. # define Perl_modf(x,y) ((long double)modf((double)(x),(double*)(y)))
  1083. # endif
  1084. # ifdef HAS_FREXPL
  1085. # define Perl_frexp(x,y) frexpl(x,y)
  1086. # else
  1087. # define Perl_frexp(x,y) ((long double)frexp((double)(x),y))
  1088. # endif
  1089. # ifdef HAS_ISNANL
  1090. # define Perl_isnan(x) isnanl(x)
  1091. # else
  1092. # ifdef HAS_ISNAN
  1093. # define Perl_isnan(x) isnan((double)(x))
  1094. # else
  1095. # define Perl_isnan(x) ((x)!=(x))
  1096. # endif
  1097. # endif
  1098. #else
  1099. # define NV_DIG DBL_DIG
  1100. # ifdef DBL_MANT_DIG
  1101. # define NV_MANT_DIG DBL_MANT_DIG
  1102. # endif
  1103. # ifdef DBL_MAX
  1104. # define NV_MAX DBL_MAX
  1105. # define NV_MIN DBL_MIN
  1106. # else
  1107. # ifdef HUGE_VAL
  1108. # define NV_MAX HUGE_VAL
  1109. # endif
  1110. # endif
  1111. # define Perl_cos cos
  1112. # define Perl_sin sin
  1113. # define Perl_sqrt sqrt
  1114. # define Perl_exp exp
  1115. # define Perl_log log
  1116. # define Perl_atan2 atan2
  1117. # define Perl_pow pow
  1118. # define Perl_floor floor
  1119. # define Perl_fmod fmod
  1120. # define Perl_modf(x,y) modf(x,y)
  1121. # define Perl_frexp(x,y) frexp(x,y)
  1122. # ifdef HAS_ISNAN
  1123. # define Perl_isnan(x) isnan(x)
  1124. # else
  1125. # define Perl_isnan(x) ((x)!=(x))
  1126. # endif
  1127. #endif
  1128. #if !defined(Perl_atof) && defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
  1129. # if !defined(Perl_atof) && defined(HAS_STRTOLD)
  1130. # define Perl_atof(s) (NV)strtold(s, (char**)NULL)
  1131. # endif
  1132. # if !defined(Perl_atof) && defined(HAS_ATOLF)
  1133. # define Perl_atof (NV)atolf
  1134. # endif
  1135. # if !defined(Perl_atof) && defined(PERL_SCNfldbl)
  1136. # define Perl_atof PERL_SCNfldbl
  1137. # define Perl_atof2(s,f) sscanf((s), "%"PERL_SCNfldbl, &(f))
  1138. # endif
  1139. #endif
  1140. #if !defined(Perl_atof)
  1141. # define Perl_atof atof /* we assume atof being available anywhere */
  1142. #endif
  1143. #if !defined(Perl_atof2)
  1144. # define Perl_atof2(s,f) ((f) = (NV)Perl_atof(s))
  1145. #endif
  1146. /* Previously these definitions used hardcoded figures.
  1147. * It is hoped these formula are more portable, although
  1148. * no data one way or another is presently known to me.
  1149. * The "PERL_" names are used because these calculated constants
  1150. * do not meet the ANSI requirements for LONG_MAX, etc., which
  1151. * need to be constants acceptable to #if - kja
  1152. * define PERL_LONG_MAX 2147483647L
  1153. * define PERL_LONG_MIN (-LONG_MAX - 1)
  1154. * define PERL ULONG_MAX 4294967295L
  1155. */
  1156. #ifdef I_LIMITS /* Needed for cast_xxx() functions below. */
  1157. # include <limits.h>
  1158. #else
  1159. #ifdef I_VALUES
  1160. # include <values.h>
  1161. #endif
  1162. #endif
  1163. /*
  1164. * Try to figure out max and min values for the integral types. THE CORRECT
  1165. * SOLUTION TO THIS MESS: ADAPT enquire.c FROM GCC INTO CONFIGURE. The
  1166. * following hacks are used if neither limits.h or values.h provide them:
  1167. * U<TYPE>_MAX: for types >= int: ~(unsigned TYPE)0
  1168. * for types < int: (unsigned TYPE)~(unsigned)0
  1169. * The argument to ~ must be unsigned so that later signed->unsigned
  1170. * conversion can't modify the value's bit pattern (e.g. -0 -> +0),
  1171. * and it must not be smaller than int because ~ does integral promotion.
  1172. * <type>_MAX: (<type>) (U<type>_MAX >> 1)
  1173. * <type>_MIN: -<type>_MAX - <is_twos_complement_architecture: (3 & -1) == 3>.
  1174. * The latter is a hack which happens to work on some machines but
  1175. * does *not* catch any random system, or things like integer types
  1176. * with NaN if that is possible.
  1177. *
  1178. * All of the types are explicitly cast to prevent accidental loss of
  1179. * numeric range, and in the hope that they will be less likely to confuse
  1180. * over-eager optimizers.
  1181. *
  1182. */
  1183. #define PERL_UCHAR_MIN ((unsigned char)0)
  1184. #ifdef UCHAR_MAX
  1185. # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
  1186. #else
  1187. # ifdef MAXUCHAR
  1188. # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
  1189. # else
  1190. # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
  1191. # endif
  1192. #endif
  1193. /*
  1194. * CHAR_MIN and CHAR_MAX are not included here, as the (char) type may be
  1195. * ambiguous. It may be equivalent to (signed char) or (unsigned char)
  1196. * depending on local options. Until Configure detects this (or at least
  1197. * detects whether the "signed" keyword is available) the CHAR ranges
  1198. * will not be included. UCHAR functions normally.
  1199. * - kja
  1200. */
  1201. #define PERL_USHORT_MIN ((unsigned short)0)
  1202. #ifdef USHORT_MAX
  1203. # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
  1204. #else
  1205. # ifdef MAXUSHORT
  1206. # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
  1207. # else
  1208. # ifdef USHRT_MAX
  1209. # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
  1210. # else
  1211. # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
  1212. # endif
  1213. # endif
  1214. #endif
  1215. #ifdef SHORT_MAX
  1216. # define PERL_SHORT_MAX ((short)SHORT_MAX)
  1217. #else
  1218. # ifdef MAXSHORT /* Often used in <values.h> */
  1219. # define PERL_SHORT_MAX ((short)MAXSHORT)
  1220. # else
  1221. # ifdef SHRT_MAX
  1222. # define PERL_SHORT_MAX ((short)SHRT_MAX)
  1223. # else
  1224. # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
  1225. # endif
  1226. # endif
  1227. #endif
  1228. #ifdef SHORT_MIN
  1229. # define PERL_SHORT_MIN ((short)SHORT_MIN)
  1230. #else
  1231. # ifdef MINSHORT
  1232. # define PERL_SHORT_MIN ((short)MINSHORT)
  1233. # else
  1234. # ifdef SHRT_MIN
  1235. # define PERL_SHORT_MIN ((short)SHRT_MIN)
  1236. # else
  1237. # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
  1238. # endif
  1239. # endif
  1240. #endif
  1241. #ifdef UINT_MAX
  1242. # define PERL_UINT_MAX ((unsigned int)UINT_MAX)
  1243. #else
  1244. # ifdef MAXUINT
  1245. # define PERL_UINT_MAX ((unsigned int)MAXUINT)
  1246. # else
  1247. # define PERL_UINT_MAX (~(unsigned int)0)
  1248. # endif
  1249. #endif
  1250. #define PERL_UINT_MIN ((unsigned int)0)
  1251. #ifdef INT_MAX
  1252. # define PERL_INT_MAX ((int)INT_MAX)
  1253. #else
  1254. # ifdef MAXINT /* Often used in <values.h> */
  1255. # define PERL_INT_MAX ((int)MAXINT)
  1256. # else
  1257. # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
  1258. # endif
  1259. #endif
  1260. #ifdef INT_MIN
  1261. # define PERL_INT_MIN ((int)INT_MIN)
  1262. #else
  1263. # ifdef MININT
  1264. # define PERL_INT_MIN ((int)MININT)
  1265. # else
  1266. # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
  1267. # endif
  1268. #endif
  1269. #ifdef ULONG_MAX
  1270. # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
  1271. #else
  1272. # ifdef MAXULONG
  1273. # define PERL_ULONG_MAX ((unsigned long)MAXULONG)
  1274. # else
  1275. # define PERL_ULONG_MAX (~(unsigned long)0)
  1276. # endif
  1277. #endif
  1278. #define PERL_ULONG_MIN ((unsigned long)0L)
  1279. #ifdef LONG_MAX
  1280. # define PERL_LONG_MAX ((long)LONG_MAX)
  1281. #else
  1282. # ifdef MAXLONG /* Often used in <values.h> */
  1283. # define PERL_LONG_MAX ((long)MAXLONG)
  1284. # else
  1285. # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
  1286. # endif
  1287. #endif
  1288. #ifdef LONG_MIN
  1289. # define PERL_LONG_MIN ((long)LONG_MIN)
  1290. #else
  1291. # ifdef MINLONG
  1292. # define PERL_LONG_MIN ((long)MINLONG)
  1293. # else
  1294. # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
  1295. # endif
  1296. #endif
  1297. #ifdef UV_IS_QUAD
  1298. # define PERL_UQUAD_MAX (~(UV)0)
  1299. # define PERL_UQUAD_MIN ((UV)0)
  1300. # define PERL_QUAD_MAX ((IV) (PERL_UQUAD_MAX >> 1))
  1301. # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
  1302. #endif
  1303. struct perl_mstats {
  1304. UV *nfree;
  1305. UV *ntotal;
  1306. IV topbucket, topbucket_ev, topbucket_odd, totfree, total, total_chain;
  1307. IV total_sbrk, sbrks, sbrk_good, sbrk_slack, start_slack, sbrked_remains;
  1308. IV minbucket;
  1309. /* Level 1 info */
  1310. UV *bucket_mem_size;
  1311. UV *bucket_available_size;
  1312. UV nbuckets;
  1313. };
  1314. typedef MEM_SIZE STRLEN;
  1315. typedef struct op OP;
  1316. typedef struct cop COP;
  1317. typedef struct unop UNOP;
  1318. typedef struct binop BINOP;
  1319. typedef struct listop LISTOP;
  1320. typedef struct logop LOGOP;
  1321. typedef struct pmop PMOP;
  1322. typedef struct svop SVOP;
  1323. typedef struct padop PADOP;
  1324. typedef struct pvop PVOP;
  1325. typedef struct loop LOOP;
  1326. typedef struct interpreter PerlInterpreter;
  1327. #ifdef UTS
  1328. # define STRUCT_SV perl_sv /* Amdahl's <ksync.h> has struct sv */
  1329. #else
  1330. # define STRUCT_SV sv
  1331. #endif
  1332. typedef struct STRUCT_SV SV;
  1333. typedef struct av AV;
  1334. typedef struct hv HV;
  1335. typedef struct cv CV;
  1336. typedef struct regexp REGEXP;
  1337. typedef struct gp GP;
  1338. typedef struct gv GV;
  1339. typedef struct io IO;
  1340. typedef struct context PERL_CONTEXT;
  1341. typedef struct block BLOCK;
  1342. typedef struct magic MAGIC;
  1343. typedef struct xrv XRV;
  1344. typedef struct xpv XPV;
  1345. typedef struct xpviv XPVIV;
  1346. typedef struct xpvuv XPVUV;
  1347. typedef struct xpvnv XPVNV;
  1348. typedef struct xpvmg XPVMG;
  1349. typedef struct xpvlv XPVLV;
  1350. typedef struct xpvav XPVAV;
  1351. typedef struct xpvhv XPVHV;
  1352. typedef struct xpvgv XPVGV;
  1353. typedef struct xpvcv XPVCV;
  1354. typedef struct xpvbm XPVBM;
  1355. typedef struct xpvfm XPVFM;
  1356. typedef struct xpvio XPVIO;
  1357. typedef struct mgvtbl MGVTBL;
  1358. typedef union any ANY;
  1359. typedef struct ptr_tbl_ent PTR_TBL_ENT_t;
  1360. typedef struct ptr_tbl PTR_TBL_t;
  1361. #include "handy.h"
  1362. #if defined(USE_LARGE_FILES) && !defined(NO_64_BIT_RAWIO)
  1363. # if LSEEKSIZE == 8 && !defined(USE_64_BIT_RAWIO)
  1364. # define USE_64_BIT_RAWIO /* implicit */
  1365. # endif
  1366. #endif
  1367. /* Notice the use of HAS_FSEEKO: now we are obligated to always use
  1368. * fseeko/ftello if possible. Don't go #defining ftell to ftello yourself,
  1369. * however, because operating systems like to do that themself. */
  1370. #ifndef FSEEKSIZE
  1371. # ifdef HAS_FSEEKO
  1372. # define FSEEKSIZE LSEEKSIZE
  1373. # else
  1374. # define FSEEKSIZE LONGSIZE
  1375. # endif
  1376. #endif
  1377. #if defined(USE_LARGE_FILES) && !defined(NO_64_BIT_STDIO)
  1378. # if FSEEKSIZE == 8 && !defined(USE_64_BIT_STDIO)
  1379. # define USE_64_BIT_STDIO /* implicit */
  1380. # endif
  1381. #endif
  1382. #ifdef USE_64_BIT_RAWIO
  1383. # ifdef HAS_OFF64_T
  1384. # undef Off_t
  1385. # define Off_t off64_t
  1386. # undef LSEEKSIZE
  1387. # define LSEEKSIZE 8
  1388. # endif
  1389. /* Most 64-bit environments have defines like _LARGEFILE_SOURCE that
  1390. * will trigger defines like the ones below. Some 64-bit environments,
  1391. * however, do not. Therefore we have to explicitly mix and match. */
  1392. # if defined(USE_OPEN64)
  1393. # define open open64
  1394. # endif
  1395. # if defined(USE_LSEEK64)
  1396. # define lseek lseek64
  1397. # else
  1398. # if defined(USE_LLSEEK)
  1399. # define lseek llseek
  1400. # endif
  1401. # endif
  1402. # if defined(USE_STAT64)
  1403. # define stat stat64
  1404. # endif
  1405. # if defined(USE_FSTAT64)
  1406. # define fstat fstat64
  1407. # endif
  1408. # if defined(USE_LSTAT64)
  1409. # define lstat lstat64
  1410. # endif
  1411. # if defined(USE_FLOCK64)
  1412. # define flock flock64
  1413. # endif
  1414. # if defined(USE_LOCKF64)
  1415. # define lockf lockf64
  1416. # endif
  1417. # if defined(USE_FCNTL64)
  1418. # define fcntl fcntl64
  1419. # endif
  1420. # if defined(USE_TRUNCATE64)
  1421. # define truncate truncate64
  1422. # endif
  1423. # if defined(USE_FTRUNCATE64)
  1424. # define ftruncate ftruncate64
  1425. # endif
  1426. #endif
  1427. #ifdef USE_64_BIT_STDIO
  1428. # ifdef HAS_FPOS64_T
  1429. # undef Fpos_t
  1430. # define Fpos_t fpos64_t
  1431. # endif
  1432. /* Most 64-bit environments have defines like _LARGEFILE_SOURCE that
  1433. * will trigger defines like the ones below. Some 64-bit environments,
  1434. * however, do not. */
  1435. # if defined(USE_FOPEN64)
  1436. # define fopen fopen64
  1437. # endif
  1438. # if defined(USE_FSEEK64)
  1439. # define fseek fseek64 /* don't do fseeko here, see perlio.c */
  1440. # endif
  1441. # if defined(USE_FTELL64)
  1442. # define ftell ftell64 /* don't do ftello here, see perlio.c */
  1443. # endif
  1444. # if defined(USE_FSETPOS64)
  1445. # define fsetpos fsetpos64
  1446. # endif
  1447. # if defined(USE_FGETPOS64)
  1448. # define fgetpos fgetpos64
  1449. # endif
  1450. # if defined(USE_TMPFILE64)
  1451. # define tmpfile tmpfile64
  1452. # endif
  1453. # if defined(USE_FREOPEN64)
  1454. # define freopen freopen64
  1455. # endif
  1456. #endif
  1457. #if defined(OS2)
  1458. # include "iperlsys.h"
  1459. #endif
  1460. #if defined(__OPEN_VM)
  1461. # include "vmesa/vmesaish.h"
  1462. #endif
  1463. #ifdef DOSISH
  1464. # if defined(OS2)
  1465. # include "os2ish.h"
  1466. # else
  1467. # include "dosish.h"
  1468. # endif
  1469. #else
  1470. # if defined(VMS)
  1471. # include "vmsish.h"
  1472. # else
  1473. # if defined(PLAN9)
  1474. # include "./plan9/plan9ish.h"
  1475. # else
  1476. # if defined(MPE)
  1477. # include "mpeix/mpeixish.h"
  1478. # else
  1479. # if defined(__VOS__)
  1480. # include "vosish.h"
  1481. # else
  1482. # if defined(EPOC)
  1483. # include "epocish.h"
  1484. # else
  1485. # if defined(MACOS_TRADITIONAL)
  1486. # include "macos/macish.h"
  1487. # ifndef NO_ENVIRON_ARRAY
  1488. # define NO_ENVIRON_ARRAY
  1489. # endif
  1490. # else
  1491. # include "unixish.h"
  1492. # endif
  1493. # endif
  1494. # endif
  1495. # endif
  1496. # endif
  1497. # endif
  1498. #endif
  1499. #ifndef NO_ENVIRON_ARRAY
  1500. # define USE_ENVIRON_ARRAY
  1501. #endif
  1502. #ifdef JPL
  1503. /* E.g. JPL needs to operate on a copy of the real environment.
  1504. * JDK 1.2 and 1.3 seem to get upset if the original environment
  1505. * is diddled with. */
  1506. # define NEED_ENVIRON_DUP_FOR_MODIFY
  1507. #endif
  1508. #ifndef PERL_SYS_INIT3
  1509. # define PERL_SYS_INIT3(argvp,argcp,envp) PERL_SYS_INIT(argvp,argcp)
  1510. #endif
  1511. #ifndef MAXPATHLEN
  1512. # ifdef PATH_MAX
  1513. # ifdef _POSIX_PATH_MAX
  1514. # if PATH_MAX > _POSIX_PATH_MAX
  1515. /* MAXPATHLEN is supposed to include the final null character,
  1516. * as opposed to PATH_MAX and _POSIX_PATH_MAX. */
  1517. # define MAXPATHLEN (PATH_MAX+1)
  1518. # else
  1519. # define MAXPATHLEN (_POSIX_PATH_MAX+1)
  1520. # endif
  1521. # else
  1522. # define MAXPATHLEN (PATH_MAX+1)
  1523. # endif
  1524. # else
  1525. # ifdef _POSIX_PATH_MAX
  1526. # define MAXPATHLEN (_POSIX_PATH_MAX+1)
  1527. # else
  1528. # define MAXPATHLEN 1024 /* Err on the large side. */
  1529. # endif
  1530. # endif
  1531. #endif
  1532. /*
  1533. * USE_THREADS needs to be after unixish.h as <pthread.h> includes
  1534. * <sys/signal.h> which defines NSIG - which will stop inclusion of <signal.h>
  1535. * this results in many functions being undeclared which bothers C++
  1536. * May make sense to have threads after "*ish.h" anyway
  1537. */
  1538. #if defined(USE_THREADS) || defined(USE_ITHREADS)
  1539. # if defined(USE_THREADS)
  1540. /* pending resolution of licensing issues, we avoid the erstwhile
  1541. * atomic.h everywhere */
  1542. # define EMULATE_ATOMIC_REFCOUNTS
  1543. # endif
  1544. # ifdef FAKE_THREADS
  1545. # include "fakethr.h"
  1546. # else
  1547. # ifdef WIN32
  1548. # include <win32thread.h>
  1549. # else
  1550. # ifdef OS2
  1551. # include "os2thread.h"
  1552. # else
  1553. # ifdef I_MACH_CTHREADS
  1554. # include <mach/cthreads.h>
  1555. # if (defined(NeXT) || defined(__NeXT__)) && defined(PERL_POLLUTE_MALLOC)
  1556. # define MUTEX_INIT_CALLS_MALLOC
  1557. # endif
  1558. typedef cthread_t perl_os_thread;
  1559. typedef mutex_t perl_mutex;
  1560. typedef condition_t perl_cond;
  1561. typedef void * perl_key;
  1562. # else /* Posix threads */
  1563. # ifdef I_PTHREAD
  1564. # include <pthread.h>
  1565. # endif
  1566. typedef pthread_t perl_os_thread;
  1567. typedef pthread_mutex_t perl_mutex;
  1568. typedef pthread_cond_t perl_cond;
  1569. typedef pthread_key_t perl_key;
  1570. # endif /* I_MACH_CTHREADS */
  1571. # endif /* OS2 */
  1572. # endif /* WIN32 */
  1573. # endif /* FAKE_THREADS */
  1574. #endif /* USE_THREADS || USE_ITHREADS */
  1575. #ifdef WIN32
  1576. # include "win32.h"
  1577. #endif
  1578. #ifdef VMS
  1579. # define STATUS_NATIVE PL_statusvalue_vms
  1580. # define STATUS_NATIVE_EXPORT \
  1581. (((I32)PL_statusvalue_vms == -1 ? 44 : PL_statusvalue_vms) | (VMSISH_HUSHED ? 0x10000000 : 0))
  1582. # define STATUS_NATIVE_SET(n) \
  1583. STMT_START { \
  1584. PL_statusvalue_vms = (n); \
  1585. if ((I32)PL_statusvalue_vms == -1) \
  1586. PL_statusvalue = -1; \
  1587. else if (PL_statusvalue_vms & STS$M_SUCCESS) \
  1588. PL_statusvalue = 0; \
  1589. else if ((PL_statusvalue_vms & STS$M_SEVERITY) == 0) \
  1590. PL_statusvalue = 1 << 8; \
  1591. else \
  1592. PL_statusvalue = (PL_statusvalue_vms & STS$M_SEVERITY) << 8; \
  1593. } STMT_END
  1594. # define STATUS_POSIX PL_statusvalue
  1595. # ifdef VMSISH_STATUS
  1596. # define STATUS_CURRENT (VMSISH_STATUS ? STATUS_NATIVE : STATUS_POSIX)
  1597. # else
  1598. # define STATUS_CURRENT STATUS_POSIX
  1599. # endif
  1600. # define STATUS_POSIX_SET(n) \
  1601. STMT_START { \
  1602. PL_statusvalue = (n); \
  1603. if (PL_statusvalue != -1) { \
  1604. PL_statusvalue &= 0xFFFF; \
  1605. PL_statusvalue_vms = PL_statusvalue ? 44 : 1; \
  1606. } \
  1607. else PL_statusvalue_vms = -1; \
  1608. } STMT_END
  1609. # define STATUS_ALL_SUCCESS (PL_statusvalue = 0, PL_statusvalue_vms = 1)
  1610. # define STATUS_ALL_FAILURE (PL_statusvalue = 1, PL_statusvalue_vms = 44)
  1611. #else
  1612. # define STATUS_NATIVE STATUS_POSIX
  1613. # define STATUS_NATIVE_EXPORT STATUS_POSIX
  1614. # define STATUS_NATIVE_SET STATUS_POSIX_SET
  1615. # define STATUS_POSIX PL_statusvalue
  1616. # define STATUS_POSIX_SET(n) \
  1617. STMT_START { \
  1618. PL_statusvalue = (n); \
  1619. if (PL_statusvalue != -1) \
  1620. PL_statusvalue &= 0xFFFF; \
  1621. } STMT_END
  1622. # define STATUS_CURRENT STATUS_POSIX
  1623. # define STATUS_ALL_SUCCESS (PL_statusvalue = 0)
  1624. # define STATUS_ALL_FAILURE (PL_statusvalue = 1)
  1625. #endif
  1626. /* flags in PL_exit_flags for nature of exit() */
  1627. #define PERL_EXIT_EXPECTED 0x01
  1628. #ifndef MEMBER_TO_FPTR
  1629. # define MEMBER_TO_FPTR(name) name
  1630. #endif
  1631. /* format to use for version numbers in file/directory names */
  1632. /* XXX move to Configure? */
  1633. #ifndef PERL_FS_VER_FMT
  1634. # define PERL_FS_VER_FMT "%d.%d.%d"
  1635. #endif
  1636. /* This defines a way to flush all output buffers. This may be a
  1637. * performance issue, so we allow people to disable it.
  1638. */
  1639. #ifndef PERL_FLUSHALL_FOR_CHILD
  1640. # if defined(FFLUSH_NULL) || defined(USE_SFIO)
  1641. # define PERL_FLUSHALL_FOR_CHILD PerlIO_flush((PerlIO*)NULL)
  1642. # else
  1643. # ifdef FFLUSH_ALL
  1644. # define PERL_FLUSHALL_FOR_CHILD my_fflush_all()
  1645. # else
  1646. # define PERL_FLUSHALL_FOR_CHILD NOOP
  1647. # endif
  1648. # endif
  1649. #endif
  1650. #ifndef PERL_WAIT_FOR_CHILDREN
  1651. # define PERL_WAIT_FOR_CHILDREN NOOP
  1652. #endif
  1653. /* the traditional thread-unsafe notion of "current interpreter". */
  1654. #ifndef PERL_SET_INTERP
  1655. # define PERL_SET_INTERP(i) (PL_curinterp = (PerlInterpreter*)(i))
  1656. #endif
  1657. #ifndef PERL_GET_INTERP
  1658. # define PERL_GET_INTERP (PL_curinterp)
  1659. #endif
  1660. #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_GET_THX)
  1661. # ifdef USE_THREADS
  1662. # define PERL_GET_THX ((struct perl_thread *)PERL_GET_CONTEXT)
  1663. # else
  1664. # ifdef MULTIPLICITY
  1665. # define PERL_GET_THX ((PerlInterpreter *)PERL_GET_CONTEXT)
  1666. # else
  1667. # ifdef PERL_OBJECT
  1668. # define PERL_GET_THX ((CPerlObj *)PERL_GET_CONTEXT)
  1669. # endif
  1670. # endif
  1671. # endif
  1672. # define PERL_SET_THX(t) PERL_SET_CONTEXT(t)
  1673. #endif
  1674. #ifndef SVf
  1675. # ifdef CHECK_FORMAT
  1676. # define SVf "p"
  1677. # else
  1678. # define SVf "_"
  1679. # endif
  1680. #endif
  1681. #ifndef UVf
  1682. # ifdef CHECK_FORMAT
  1683. # define UVf UVuf
  1684. # else
  1685. # define UVf "Vu"
  1686. # endif
  1687. #endif
  1688. #ifndef VDf
  1689. # ifdef CHECK_FORMAT
  1690. # define VDf "p"
  1691. # else
  1692. # define VDf "vd"
  1693. # endif
  1694. #endif
  1695. /* Some unistd.h's give a prototype for pause() even though
  1696. HAS_PAUSE ends up undefined. This causes the #define
  1697. below to be rejected by the compiler. Sigh.
  1698. */
  1699. #ifdef HAS_PAUSE
  1700. #define Pause pause
  1701. #else
  1702. #define Pause() sleep((32767<<16)+32767)
  1703. #endif
  1704. #ifndef IOCPARM_LEN
  1705. # ifdef IOCPARM_MASK
  1706. /* on BSDish systes we're safe */
  1707. # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
  1708. # else
  1709. /* otherwise guess at what's safe */
  1710. # define IOCPARM_LEN(x) 256
  1711. # endif
  1712. #endif
  1713. #if defined(__CYGWIN__)
  1714. /* USEMYBINMODE
  1715. * This symbol, if defined, indicates that the program should
  1716. * use the routine my_binmode(FILE *fp, char iotype, int mode) to insure
  1717. * that a file is in "binary" mode -- that is, that no translation
  1718. * of bytes occurs on read or write operations.
  1719. */
  1720. # define USEMYBINMODE / **/
  1721. # define my_binmode(fp, iotype, mode) \
  1722. (PerlLIO_setmode(PerlIO_fileno(fp), mode) != -1 ? TRUE : FALSE)
  1723. #endif
  1724. #ifdef UNION_ANY_DEFINITION
  1725. UNION_ANY_DEFINITION;
  1726. #else
  1727. union any {
  1728. void* any_ptr;
  1729. I32 any_i32;
  1730. IV any_iv;
  1731. long any_long;
  1732. void (*any_dptr) (void*);
  1733. void (*any_dxptr) (pTHXo_ void*);
  1734. };
  1735. #endif
  1736. #ifdef USE_THREADS
  1737. #define ARGSproto struct perl_thread *thr
  1738. #else
  1739. #define ARGSproto
  1740. #endif /* USE_THREADS */
  1741. typedef I32 (*filter_t) (pTHXo_ int, SV *, int);
  1742. #define FILTER_READ(idx, sv, len) filter_read(idx, sv, len)
  1743. #define FILTER_DATA(idx) (AvARRAY(PL_rsfp_filters)[idx])
  1744. #define FILTER_ISREADER(idx) (idx >= AvFILLp(PL_rsfp_filters))
  1745. #if !defined(OS2)
  1746. # include "iperlsys.h"
  1747. #endif
  1748. #include "regexp.h"
  1749. #include "sv.h"
  1750. #include "util.h"
  1751. #include "form.h"
  1752. #include "gv.h"
  1753. #include "cv.h"
  1754. #include "opnames.h"
  1755. #include "op.h"
  1756. #include "cop.h"
  1757. #include "av.h"
  1758. #include "hv.h"
  1759. #include "mg.h"
  1760. #include "scope.h"
  1761. #include "warnings.h"
  1762. #include "utf8.h"
  1763. /* Current curly descriptor */
  1764. typedef struct curcur CURCUR;
  1765. struct curcur {
  1766. int parenfloor; /* how far back to strip paren data */
  1767. int cur; /* how many instances of scan we've matched */
  1768. int min; /* the minimal number of scans to match */
  1769. int max; /* the maximal number of scans to match */
  1770. int minmod; /* whether to work our way up or down */
  1771. regnode * scan; /* the thing to match */
  1772. regnode * next; /* what has to match after it */
  1773. char * lastloc; /* where we started matching this scan */
  1774. CURCUR * oldcc; /* current curly before we started this one */
  1775. };
  1776. typedef struct _sublex_info SUBLEXINFO;
  1777. struct _sublex_info {
  1778. I32 super_state; /* lexer state to save */
  1779. I32 sub_inwhat; /* "lex_inwhat" to use */
  1780. OP *sub_op; /* "lex_op" to use */
  1781. char *super_bufptr; /* PL_bufptr that was */
  1782. char *super_bufend; /* PL_bufend that was */
  1783. };
  1784. typedef struct magic_state MGS; /* struct magic_state defined in mg.c */
  1785. struct scan_data_t; /* Used in S_* functions in regcomp.c */
  1786. struct regnode_charclass_class; /* Used in S_* functions in regcomp.c */
  1787. typedef I32 CHECKPOINT;
  1788. struct ptr_tbl_ent {
  1789. struct ptr_tbl_ent* next;
  1790. void* oldval;
  1791. void* newval;
  1792. };
  1793. struct ptr_tbl {
  1794. struct ptr_tbl_ent** tbl_ary;
  1795. UV tbl_max;
  1796. UV tbl_items;
  1797. };
  1798. #if defined(iAPX286) || defined(M_I286) || defined(I80286)
  1799. # define I286
  1800. #endif
  1801. #if defined(htonl) && !defined(HAS_HTONL)
  1802. #define HAS_HTONL
  1803. #endif
  1804. #if defined(htons) && !defined(HAS_HTONS)
  1805. #define HAS_HTONS
  1806. #endif
  1807. #if defined(ntohl) && !defined(HAS_NTOHL)
  1808. #define HAS_NTOHL
  1809. #endif
  1810. #if defined(ntohs) && !defined(HAS_NTOHS)
  1811. #define HAS_NTOHS
  1812. #endif
  1813. #ifndef HAS_HTONL
  1814. #if (BYTEORDER & 0xffff) != 0x4321
  1815. #define HAS_HTONS
  1816. #define HAS_HTONL
  1817. #define HAS_NTOHS
  1818. #define HAS_NTOHL
  1819. #define MYSWAP
  1820. #define htons my_swap
  1821. #define htonl my_htonl
  1822. #define ntohs my_swap
  1823. #define ntohl my_ntohl
  1824. #endif
  1825. #else
  1826. #if (BYTEORDER & 0xffff) == 0x4321
  1827. #undef HAS_HTONS
  1828. #undef HAS_HTONL
  1829. #undef HAS_NTOHS
  1830. #undef HAS_NTOHL
  1831. #endif
  1832. #endif
  1833. /*
  1834. * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
  1835. * -DWS
  1836. */
  1837. #if BYTEORDER != 0x1234
  1838. # define HAS_VTOHL
  1839. # define HAS_VTOHS
  1840. # define HAS_HTOVL
  1841. # define HAS_HTOVS
  1842. # if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
  1843. # define vtohl(x) ((((x)&0xFF)<<24) \
  1844. +(((x)>>24)&0xFF) \
  1845. +(((x)&0x0000FF00)<<8) \
  1846. +(((x)&0x00FF0000)>>8) )
  1847. # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
  1848. # define htovl(x) vtohl(x)
  1849. # define htovs(x) vtohs(x)
  1850. # endif
  1851. /* otherwise default to functions in util.c */
  1852. #endif
  1853. #ifdef CASTNEGFLOAT
  1854. #define U_S(what) ((U16)(what))
  1855. #define U_I(what) ((unsigned int)(what))
  1856. #define U_L(what) ((U32)(what))
  1857. #else
  1858. #define U_S(what) ((U16)cast_ulong((NV)(what)))
  1859. #define U_I(what) ((unsigned int)cast_ulong((NV)(what)))
  1860. #define U_L(what) (cast_ulong((NV)(what)))
  1861. #endif
  1862. #ifdef CASTI32
  1863. #define I_32(what) ((I32)(what))
  1864. #define I_V(what) ((IV)(what))
  1865. #define U_V(what) ((UV)(what))
  1866. #else
  1867. #define I_32(what) (cast_i32((NV)(what)))
  1868. #define I_V(what) (cast_iv((NV)(what)))
  1869. #define U_V(what) (cast_uv((NV)(what)))
  1870. #endif
  1871. /* These do not care about the fractional part, only about the range. */
  1872. #define NV_WITHIN_IV(nv) (I_V(nv) >= IV_MIN && I_V(nv) <= IV_MAX)
  1873. #define NV_WITHIN_UV(nv) ((nv)>=0.0 && U_V(nv) >= UV_MIN && U_V(nv) <= UV_MAX)
  1874. /* Used with UV/IV arguments: */
  1875. /* XXXX: need to speed it up */
  1876. #define CLUMP_2UV(iv) ((iv) < 0 ? 0 : (UV)(iv))
  1877. #define CLUMP_2IV(uv) ((uv) > (UV)IV_MAX ? IV_MAX : (IV)(uv))
  1878. #ifndef MAXSYSFD
  1879. # define MAXSYSFD 2
  1880. #endif
  1881. #ifndef __cplusplus
  1882. Uid_t getuid (void);
  1883. Uid_t geteuid (void);
  1884. Gid_t getgid (void);
  1885. Gid_t getegid (void);
  1886. #endif
  1887. #ifndef Perl_debug_log
  1888. # define Perl_debug_log PerlIO_stderr()
  1889. #endif
  1890. #ifndef Perl_error_log
  1891. # define Perl_error_log (PL_stderrgv \
  1892. && GvIOp(PL_stderrgv) \
  1893. && IoOFP(GvIOp(PL_stderrgv)) \
  1894. ? IoOFP(GvIOp(PL_stderrgv)) \
  1895. : PerlIO_stderr())
  1896. #endif
  1897. #ifdef DEBUGGING
  1898. #undef YYDEBUG
  1899. #define YYDEBUG 1
  1900. #define DEB(a) a
  1901. #define DEBUG(a) if (PL_debug) a
  1902. #define DEBUG_p(a) if (PL_debug & 1) a
  1903. #define DEBUG_s(a) if (PL_debug & 2) a
  1904. #define DEBUG_l(a) if (PL_debug & 4) a
  1905. #define DEBUG_t(a) if (PL_debug & 8) a
  1906. #define DEBUG_o(a) if (PL_debug & 16) a
  1907. #define DEBUG_c(a) if (PL_debug & 32) a
  1908. #define DEBUG_P(a) if (PL_debug & 64) a
  1909. # if defined(PERL_OBJECT)
  1910. # define DEBUG_m(a) if (PL_debug & 128) a
  1911. # else
  1912. /* Temporarily turn off memory debugging in case the a
  1913. * does memory allocation, either directly or indirectly. */
  1914. # define DEBUG_m(a) \
  1915. STMT_START { \
  1916. if (PERL_GET_INTERP) { dTHX; if (PL_debug & 128) {PL_debug&=~128; a; PL_debug|=128;} } \
  1917. } STMT_END
  1918. # endif
  1919. #define DEBUG_f(a) if (PL_debug & 256) a
  1920. #define DEBUG_r(a) if (PL_debug & 512) a
  1921. #define DEBUG_x(a) if (PL_debug & 1024) a
  1922. #define DEBUG_u(a) if (PL_debug & 2048) a
  1923. #define DEBUG_L(a) if (PL_debug & 4096) a
  1924. #define DEBUG_H(a) if (PL_debug & 8192) a
  1925. #define DEBUG_X(a) if (PL_debug & 16384) a
  1926. #define DEBUG_D(a) if (PL_debug & 32768) a
  1927. # ifdef USE_THREADS
  1928. # define DEBUG_S(a) if (PL_debug & (1<<16)) a
  1929. # else
  1930. # define DEBUG_S(a)
  1931. # endif
  1932. #define DEBUG_T(a) if (PL_debug & (1<<17)) a
  1933. #else
  1934. #define DEB(a)
  1935. #define DEBUG(a)
  1936. #define DEBUG_p(a)
  1937. #define DEBUG_s(a)
  1938. #define DEBUG_l(a)
  1939. #define DEBUG_t(a)
  1940. #define DEBUG_o(a)
  1941. #define DEBUG_c(a)
  1942. #define DEBUG_P(a)
  1943. #define DEBUG_m(a)
  1944. #define DEBUG_f(a)
  1945. #define DEBUG_r(a)
  1946. #define DEBUG_x(a)
  1947. #define DEBUG_u(a)
  1948. #define DEBUG_S(a)
  1949. #define DEBUG_H(a)
  1950. #define DEBUG_X(a)
  1951. #define DEBUG_D(a)
  1952. #define DEBUG_S(a)
  1953. #define DEBUG_T(a)
  1954. #endif
  1955. #define YYMAXDEPTH 300
  1956. #ifndef assert /* <assert.h> might have been included somehow */
  1957. #define assert(what) DEB( { \
  1958. if (!(what)) { \
  1959. Perl_croak(aTHX_ "Assertion failed: file \"%s\", line %d", \
  1960. __FILE__, __LINE__); \
  1961. PerlProc_exit(1); \
  1962. }})
  1963. #endif
  1964. struct ufuncs {
  1965. I32 (*uf_val)(IV, SV*);
  1966. I32 (*uf_set)(IV, SV*);
  1967. IV uf_index;
  1968. };
  1969. /* Fix these up for __STDC__ */
  1970. #ifndef DONT_DECLARE_STD
  1971. char *mktemp (char*);
  1972. #ifndef atof
  1973. double atof (const char*);
  1974. #endif
  1975. #endif
  1976. #ifndef STANDARD_C
  1977. /* All of these are in stdlib.h or time.h for ANSI C */
  1978. Time_t time();
  1979. struct tm *gmtime(), *localtime();
  1980. #if defined(OEMVS) || defined(__OPEN_VM)
  1981. char *(strchr)(), *(strrchr)();
  1982. char *(strcpy)(), *(strcat)();
  1983. #else
  1984. char *strchr(), *strrchr();
  1985. char *strcpy(), *strcat();
  1986. #endif
  1987. #endif /* ! STANDARD_C */
  1988. #ifdef I_MATH
  1989. # include <math.h>
  1990. #else
  1991. START_EXTERN_C
  1992. double exp (double);
  1993. double log (double);
  1994. double log10 (double);
  1995. double sqrt (double);
  1996. double frexp (double,int*);
  1997. double ldexp (double,int);
  1998. double modf (double,double*);
  1999. double sin (double);
  2000. double cos (double);
  2001. double atan2 (double,double);
  2002. double pow (double,double);
  2003. END_EXTERN_C
  2004. #endif
  2005. #ifndef __cplusplus
  2006. # if defined(NeXT) || defined(__NeXT__) /* or whatever catches all NeXTs */
  2007. char *crypt (); /* Maybe more hosts will need the unprototyped version */
  2008. # else
  2009. # if !defined(WIN32)
  2010. char *crypt (const char*, const char*);
  2011. # endif /* !WIN32 */
  2012. # endif /* !NeXT && !__NeXT__ */
  2013. # ifndef DONT_DECLARE_STD
  2014. # ifndef getenv
  2015. char *getenv (const char*);
  2016. # endif /* !getenv */
  2017. # if !defined(HAS_LSEEK_PROTO) && !defined(EPOC) && !defined(__hpux)
  2018. # ifdef _FILE_OFFSET_BITS
  2019. # if _FILE_OFFSET_BITS == 64
  2020. Off_t lseek (int,Off_t,int);
  2021. # endif
  2022. # endif
  2023. # endif
  2024. # endif /* !DONT_DECLARE_STD */
  2025. char *getlogin (void);
  2026. #endif /* !__cplusplus */
  2027. #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
  2028. #define UNLINK unlnk
  2029. I32 unlnk (char*);
  2030. #else
  2031. #define UNLINK PerlLIO_unlink
  2032. #endif
  2033. #ifndef HAS_SETREUID
  2034. # ifdef HAS_SETRESUID
  2035. # define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
  2036. # define HAS_SETREUID
  2037. # endif
  2038. #endif
  2039. #ifndef HAS_SETREGID
  2040. # ifdef HAS_SETRESGID
  2041. # define setregid(r,e) setresgid(r,e,(Gid_t)-1)
  2042. # define HAS_SETREGID
  2043. # endif
  2044. #endif
  2045. /* Sighandler_t defined in iperlsys.h */
  2046. #ifdef HAS_SIGACTION
  2047. typedef struct sigaction Sigsave_t;
  2048. #else
  2049. typedef Sighandler_t Sigsave_t;
  2050. #endif
  2051. #define SCAN_DEF 0
  2052. #define SCAN_TR 1
  2053. #define SCAN_REPL 2
  2054. #ifdef DEBUGGING
  2055. # ifndef register
  2056. # define register
  2057. # endif
  2058. # define PAD_SV(po) pad_sv(po)
  2059. # define RUNOPS_DEFAULT Perl_runops_debug
  2060. #else
  2061. # define PAD_SV(po) PL_curpad[po]
  2062. # define RUNOPS_DEFAULT Perl_runops_standard
  2063. #endif
  2064. #ifdef MYMALLOC
  2065. # ifdef MUTEX_INIT_CALLS_MALLOC
  2066. # define MALLOC_INIT \
  2067. STMT_START { \
  2068. PL_malloc_mutex = NULL; \
  2069. MUTEX_INIT(&PL_malloc_mutex); \
  2070. } STMT_END
  2071. # define MALLOC_TERM \
  2072. STMT_START { \
  2073. perl_mutex tmp = PL_malloc_mutex; \
  2074. PL_malloc_mutex = NULL; \
  2075. MUTEX_DESTROY(&tmp); \
  2076. } STMT_END
  2077. # else
  2078. # define MALLOC_INIT MUTEX_INIT(&PL_malloc_mutex)
  2079. # define MALLOC_TERM MUTEX_DESTROY(&PL_malloc_mutex)
  2080. # endif
  2081. #else
  2082. # define MALLOC_INIT
  2083. # define MALLOC_TERM
  2084. #endif
  2085. typedef int (CPERLscope(*runops_proc_t)) (pTHX);
  2086. typedef OP* (CPERLscope(*PPADDR_t)[]) (pTHX);
  2087. /* _ (for $_) must be first in the following list (DEFSV requires it) */
  2088. #define THREADSV_NAMES "_123456789&`'+/.,\\\";^-%=|~:\001\005!@"
  2089. /* NeXT has problems with crt0.o globals */
  2090. #if defined(__DYNAMIC__) && \
  2091. (defined(NeXT) || defined(__NeXT__) || defined(__APPLE__))
  2092. # if defined(NeXT) || defined(__NeXT)
  2093. # include <mach-o/dyld.h>
  2094. # define environ (*environ_pointer)
  2095. EXT char *** environ_pointer;
  2096. # else
  2097. # if defined(__APPLE__) && defined(PERL_CORE)
  2098. # include <crt_externs.h> /* for the env array */
  2099. # define environ (*_NSGetEnviron())
  2100. # endif
  2101. # endif
  2102. #else
  2103. /* VMS and some other platforms don't use the environ array */
  2104. # ifdef USE_ENVIRON_ARRAY
  2105. # if !defined(DONT_DECLARE_STD) || \
  2106. (defined(__svr4__) && defined(__GNUC__) && defined(sun)) || \
  2107. defined(__sgi) || \
  2108. defined(__DGUX)
  2109. extern char ** environ; /* environment variables supplied via exec */
  2110. # endif
  2111. # endif
  2112. #endif
  2113. START_EXTERN_C
  2114. /* handy constants */
  2115. EXTCONST char PL_warn_uninit[]
  2116. INIT("Use of uninitialized value%s%s");
  2117. EXTCONST char PL_warn_nosemi[]
  2118. INIT("Semicolon seems to be missing");
  2119. EXTCONST char PL_warn_reserved[]
  2120. INIT("Unquoted string \"%s\" may clash with future reserved word");
  2121. EXTCONST char PL_warn_nl[]
  2122. INIT("Unsuccessful %s on filename containing newline");
  2123. EXTCONST char PL_no_wrongref[]
  2124. INIT("Can't use %s ref as %s ref");
  2125. EXTCONST char PL_no_symref[]
  2126. INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
  2127. EXTCONST char PL_no_usym[]
  2128. INIT("Can't use an undefined value as %s reference");
  2129. EXTCONST char PL_no_aelem[]
  2130. INIT("Modification of non-creatable array value attempted, subscript %d");
  2131. EXTCONST char PL_no_helem[]
  2132. INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
  2133. EXTCONST char PL_no_modify[]
  2134. INIT("Modification of a read-only value attempted");
  2135. EXTCONST char PL_no_mem[]
  2136. INIT("Out of memory!\n");
  2137. EXTCONST char PL_no_security[]
  2138. INIT("Insecure dependency in %s%s");
  2139. EXTCONST char PL_no_sock_func[]
  2140. INIT("Unsupported socket function \"%s\" called");
  2141. EXTCONST char PL_no_dir_func[]
  2142. INIT("Unsupported directory function \"%s\" called");
  2143. EXTCONST char PL_no_func[]
  2144. INIT("The %s function is unimplemented");
  2145. EXTCONST char PL_no_myglob[]
  2146. INIT("\"my\" variable %s can't be in a package");
  2147. EXTCONST char PL_uuemap[65]
  2148. INIT("`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_");
  2149. #ifdef DOINIT
  2150. EXT char *PL_sig_name[] = { SIG_NAME };
  2151. EXT int PL_sig_num[] = { SIG_NUM };
  2152. #else
  2153. EXT char *PL_sig_name[];
  2154. EXT int PL_sig_num[];
  2155. #endif
  2156. /* fast case folding tables */
  2157. #ifdef DOINIT
  2158. #ifdef EBCDIC
  2159. EXT unsigned char PL_fold[] = { /* fast EBCDIC case folding table */
  2160. 0, 1, 2, 3, 4, 5, 6, 7,
  2161. 8, 9, 10, 11, 12, 13, 14, 15,
  2162. 16, 17, 18, 19, 20, 21, 22, 23,
  2163. 24, 25, 26, 27, 28, 29, 30, 31,
  2164. 32, 33, 34, 35, 36, 37, 38, 39,
  2165. 40, 41, 42, 43, 44, 45, 46, 47,
  2166. 48, 49, 50, 51, 52, 53, 54, 55,
  2167. 56, 57, 58, 59, 60, 61, 62, 63,
  2168. 64, 65, 66, 67, 68, 69, 70, 71,
  2169. 72, 73, 74, 75, 76, 77, 78, 79,
  2170. 80, 81, 82, 83, 84, 85, 86, 87,
  2171. 88, 89, 90, 91, 92, 93, 94, 95,
  2172. 96, 97, 98, 99, 100, 101, 102, 103,
  2173. 104, 105, 106, 107, 108, 109, 110, 111,
  2174. 112, 113, 114, 115, 116, 117, 118, 119,
  2175. 120, 121, 122, 123, 124, 125, 126, 127,
  2176. 128, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
  2177. 'H', 'I', 138, 139, 140, 141, 142, 143,
  2178. 144, 'J', 'K', 'L', 'M', 'N', 'O', 'P',
  2179. 'Q', 'R', 154, 155, 156, 157, 158, 159,
  2180. 160, 161, 'S', 'T', 'U', 'V', 'W', 'X',
  2181. 'Y', 'Z', 170, 171, 172, 173, 174, 175,
  2182. 176, 177, 178, 179, 180, 181, 182, 183,
  2183. 184, 185, 186, 187, 188, 189, 190, 191,
  2184. 192, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
  2185. 'h', 'i', 202, 203, 204, 205, 206, 207,
  2186. 208, 'j', 'k', 'l', 'm', 'n', 'o', 'p',
  2187. 'q', 'r', 218, 219, 220, 221, 222, 223,
  2188. 224, 225, 's', 't', 'u', 'v', 'w', 'x',
  2189. 'y', 'z', 234, 235, 236, 237, 238, 239,
  2190. 240, 241, 242, 243, 244, 245, 246, 247,
  2191. 248, 249, 250, 251, 252, 253, 254, 255
  2192. };
  2193. #else /* ascii rather than ebcdic */
  2194. EXTCONST unsigned char PL_fold[] = {
  2195. 0, 1, 2, 3, 4, 5, 6, 7,
  2196. 8, 9, 10, 11, 12, 13, 14, 15,
  2197. 16, 17, 18, 19, 20, 21, 22, 23,
  2198. 24, 25, 26, 27, 28, 29, 30, 31,
  2199. 32, 33, 34, 35, 36, 37, 38, 39,
  2200. 40, 41, 42, 43, 44, 45, 46, 47,
  2201. 48, 49, 50, 51, 52, 53, 54, 55,
  2202. 56, 57, 58, 59, 60, 61, 62, 63,
  2203. 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
  2204. 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
  2205. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
  2206. 'x', 'y', 'z', 91, 92, 93, 94, 95,
  2207. 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
  2208. 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
  2209. 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
  2210. 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
  2211. 128, 129, 130, 131, 132, 133, 134, 135,
  2212. 136, 137, 138, 139, 140, 141, 142, 143,
  2213. 144, 145, 146, 147, 148, 149, 150, 151,
  2214. 152, 153, 154, 155, 156, 157, 158, 159,
  2215. 160, 161, 162, 163, 164, 165, 166, 167,
  2216. 168, 169, 170, 171, 172, 173, 174, 175,
  2217. 176, 177, 178, 179, 180, 181, 182, 183,
  2218. 184, 185, 186, 187, 188, 189, 190, 191,
  2219. 192, 193, 194, 195, 196, 197, 198, 199,
  2220. 200, 201, 202, 203, 204, 205, 206, 207,
  2221. 208, 209, 210, 211, 212, 213, 214, 215,
  2222. 216, 217, 218, 219, 220, 221, 222, 223,
  2223. 224, 225, 226, 227, 228, 229, 230, 231,
  2224. 232, 233, 234, 235, 236, 237, 238, 239,
  2225. 240, 241, 242, 243, 244, 245, 246, 247,
  2226. 248, 249, 250, 251, 252, 253, 254, 255
  2227. };
  2228. #endif /* !EBCDIC */
  2229. #else
  2230. EXTCONST unsigned char PL_fold[];
  2231. #endif
  2232. #ifdef DOINIT
  2233. EXT unsigned char PL_fold_locale[] = {
  2234. 0, 1, 2, 3, 4, 5, 6, 7,
  2235. 8, 9, 10, 11, 12, 13, 14, 15,
  2236. 16, 17, 18, 19, 20, 21, 22, 23,
  2237. 24, 25, 26, 27, 28, 29, 30, 31,
  2238. 32, 33, 34, 35, 36, 37, 38, 39,
  2239. 40, 41, 42, 43, 44, 45, 46, 47,
  2240. 48, 49, 50, 51, 52, 53, 54, 55,
  2241. 56, 57, 58, 59, 60, 61, 62, 63,
  2242. 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
  2243. 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
  2244. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
  2245. 'x', 'y', 'z', 91, 92, 93, 94, 95,
  2246. 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
  2247. 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
  2248. 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
  2249. 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
  2250. 128, 129, 130, 131, 132, 133, 134, 135,
  2251. 136, 137, 138, 139, 140, 141, 142, 143,
  2252. 144, 145, 146, 147, 148, 149, 150, 151,
  2253. 152, 153, 154, 155, 156, 157, 158, 159,
  2254. 160, 161, 162, 163, 164, 165, 166, 167,
  2255. 168, 169, 170, 171, 172, 173, 174, 175,
  2256. 176, 177, 178, 179, 180, 181, 182, 183,
  2257. 184, 185, 186, 187, 188, 189, 190, 191,
  2258. 192, 193, 194, 195, 196, 197, 198, 199,
  2259. 200, 201, 202, 203, 204, 205, 206, 207,
  2260. 208, 209, 210, 211, 212, 213, 214, 215,
  2261. 216, 217, 218, 219, 220, 221, 222, 223,
  2262. 224, 225, 226, 227, 228, 229, 230, 231,
  2263. 232, 233, 234, 235, 236, 237, 238, 239,
  2264. 240, 241, 242, 243, 244, 245, 246, 247,
  2265. 248, 249, 250, 251, 252, 253, 254, 255
  2266. };
  2267. #else
  2268. EXT unsigned char PL_fold_locale[];
  2269. #endif
  2270. #ifdef DOINIT
  2271. #ifdef EBCDIC
  2272. EXT unsigned char PL_freq[] = {/* EBCDIC frequencies for mixed English/C */
  2273. 1, 2, 84, 151, 154, 155, 156, 157,
  2274. 165, 246, 250, 3, 158, 7, 18, 29,
  2275. 40, 51, 62, 73, 85, 96, 107, 118,
  2276. 129, 140, 147, 148, 149, 150, 152, 153,
  2277. 255, 6, 8, 9, 10, 11, 12, 13,
  2278. 14, 15, 24, 25, 26, 27, 28, 226,
  2279. 29, 30, 31, 32, 33, 43, 44, 45,
  2280. 46, 47, 48, 49, 50, 76, 77, 78,
  2281. 79, 80, 81, 82, 83, 84, 85, 86,
  2282. 87, 94, 95, 234, 181, 233, 187, 190,
  2283. 180, 96, 97, 98, 99, 100, 101, 102,
  2284. 104, 112, 182, 174, 236, 232, 229, 103,
  2285. 228, 226, 114, 115, 116, 117, 118, 119,
  2286. 120, 121, 122, 235, 176, 230, 194, 162,
  2287. 130, 131, 132, 133, 134, 135, 136, 137,
  2288. 138, 139, 201, 205, 163, 217, 220, 224,
  2289. 5, 248, 227, 244, 242, 255, 241, 231,
  2290. 240, 253, 16, 197, 19, 20, 21, 187,
  2291. 23, 169, 210, 245, 237, 249, 247, 239,
  2292. 168, 252, 34, 196, 36, 37, 38, 39,
  2293. 41, 42, 251, 254, 238, 223, 221, 213,
  2294. 225, 177, 52, 53, 54, 55, 56, 57,
  2295. 58, 59, 60, 61, 63, 64, 65, 66,
  2296. 67, 68, 69, 70, 71, 72, 74, 75,
  2297. 205, 208, 186, 202, 200, 218, 198, 179,
  2298. 178, 214, 88, 89, 90, 91, 92, 93,
  2299. 217, 166, 170, 207, 199, 209, 206, 204,
  2300. 160, 212, 105, 106, 108, 109, 110, 111,
  2301. 203, 113, 216, 215, 192, 175, 193, 243,
  2302. 172, 161, 123, 124, 125, 126, 127, 128,
  2303. 222, 219, 211, 195, 188, 193, 185, 184,
  2304. 191, 183, 141, 142, 143, 144, 145, 146
  2305. };
  2306. #else /* ascii rather than ebcdic */
  2307. EXTCONST unsigned char PL_freq[] = { /* letter frequencies for mixed English/C */
  2308. 1, 2, 84, 151, 154, 155, 156, 157,
  2309. 165, 246, 250, 3, 158, 7, 18, 29,
  2310. 40, 51, 62, 73, 85, 96, 107, 118,
  2311. 129, 140, 147, 148, 149, 150, 152, 153,
  2312. 255, 182, 224, 205, 174, 176, 180, 217,
  2313. 233, 232, 236, 187, 235, 228, 234, 226,
  2314. 222, 219, 211, 195, 188, 193, 185, 184,
  2315. 191, 183, 201, 229, 181, 220, 194, 162,
  2316. 163, 208, 186, 202, 200, 218, 198, 179,
  2317. 178, 214, 166, 170, 207, 199, 209, 206,
  2318. 204, 160, 212, 216, 215, 192, 175, 173,
  2319. 243, 172, 161, 190, 203, 189, 164, 230,
  2320. 167, 248, 227, 244, 242, 255, 241, 231,
  2321. 240, 253, 169, 210, 245, 237, 249, 247,
  2322. 239, 168, 252, 251, 254, 238, 223, 221,
  2323. 213, 225, 177, 197, 171, 196, 159, 4,
  2324. 5, 6, 8, 9, 10, 11, 12, 13,
  2325. 14, 15, 16, 17, 19, 20, 21, 22,
  2326. 23, 24, 25, 26, 27, 28, 30, 31,
  2327. 32, 33, 34, 35, 36, 37, 38, 39,
  2328. 41, 42, 43, 44, 45, 46, 47, 48,
  2329. 49, 50, 52, 53, 54, 55, 56, 57,
  2330. 58, 59, 60, 61, 63, 64, 65, 66,
  2331. 67, 68, 69, 70, 71, 72, 74, 75,
  2332. 76, 77, 78, 79, 80, 81, 82, 83,
  2333. 86, 87, 88, 89, 90, 91, 92, 93,
  2334. 94, 95, 97, 98, 99, 100, 101, 102,
  2335. 103, 104, 105, 106, 108, 109, 110, 111,
  2336. 112, 113, 114, 115, 116, 117, 119, 120,
  2337. 121, 122, 123, 124, 125, 126, 127, 128,
  2338. 130, 131, 132, 133, 134, 135, 136, 137,
  2339. 138, 139, 141, 142, 143, 144, 145, 146
  2340. };
  2341. #endif
  2342. #else
  2343. EXTCONST unsigned char PL_freq[];
  2344. #endif
  2345. #ifdef DEBUGGING
  2346. #ifdef DOINIT
  2347. EXTCONST char* PL_block_type[] = {
  2348. "NULL",
  2349. "SUB",
  2350. "EVAL",
  2351. "LOOP",
  2352. "SUBST",
  2353. "BLOCK",
  2354. };
  2355. #else
  2356. EXTCONST char* PL_block_type[];
  2357. #endif
  2358. #endif
  2359. END_EXTERN_C
  2360. /*****************************************************************************/
  2361. /* This lexer/parser stuff is currently global since yacc is hard to reenter */
  2362. /*****************************************************************************/
  2363. /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
  2364. #include "perly.h"
  2365. #define LEX_NOTPARSING 11 /* borrowed from toke.c */
  2366. typedef enum {
  2367. XOPERATOR,
  2368. XTERM,
  2369. XREF,
  2370. XSTATE,
  2371. XBLOCK,
  2372. XATTRBLOCK,
  2373. XATTRTERM,
  2374. XTERMBLOCK
  2375. } expectation;
  2376. enum { /* pass one of these to get_vtbl */
  2377. want_vtbl_sv,
  2378. want_vtbl_env,
  2379. want_vtbl_envelem,
  2380. want_vtbl_sig,
  2381. want_vtbl_sigelem,
  2382. want_vtbl_pack,
  2383. want_vtbl_packelem,
  2384. want_vtbl_dbline,
  2385. want_vtbl_isa,
  2386. want_vtbl_isaelem,
  2387. want_vtbl_arylen,
  2388. want_vtbl_glob,
  2389. want_vtbl_mglob,
  2390. want_vtbl_nkeys,
  2391. want_vtbl_taint,
  2392. want_vtbl_substr,
  2393. want_vtbl_vec,
  2394. want_vtbl_pos,
  2395. want_vtbl_bm,
  2396. want_vtbl_fm,
  2397. want_vtbl_uvar,
  2398. want_vtbl_defelem,
  2399. want_vtbl_regexp,
  2400. want_vtbl_collxfrm,
  2401. want_vtbl_amagic,
  2402. want_vtbl_amagicelem,
  2403. #ifdef USE_THREADS
  2404. want_vtbl_mutex,
  2405. #endif
  2406. want_vtbl_regdata,
  2407. want_vtbl_regdatum,
  2408. want_vtbl_backref
  2409. };
  2410. /* Note: the lowest 8 bits are reserved for
  2411. stuffing into op->op_private */
  2412. #define HINT_PRIVATE_MASK 0x000000ff
  2413. #define HINT_INTEGER 0x00000001
  2414. #define HINT_STRICT_REFS 0x00000002
  2415. #define HINT_LOCALE 0x00000004
  2416. #define HINT_BYTE 0x00000008
  2417. /* #define HINT_notused10 0x00000010 */
  2418. /* Note: 20,40,80 used for NATIVE_HINTS */
  2419. #define HINT_BLOCK_SCOPE 0x00000100
  2420. #define HINT_STRICT_SUBS 0x00000200
  2421. #define HINT_STRICT_VARS 0x00000400
  2422. #define HINT_NEW_INTEGER 0x00001000
  2423. #define HINT_NEW_FLOAT 0x00002000
  2424. #define HINT_NEW_BINARY 0x00004000
  2425. #define HINT_NEW_STRING 0x00008000
  2426. #define HINT_NEW_RE 0x00010000
  2427. #define HINT_LOCALIZE_HH 0x00020000 /* %^H needs to be copied */
  2428. #define HINT_RE_TAINT 0x00100000
  2429. #define HINT_RE_EVAL 0x00200000
  2430. #define HINT_FILETEST_ACCESS 0x00400000
  2431. #define HINT_UTF8 0x00800000
  2432. /* Various states of an input record separator SV (rs, nrs) */
  2433. #define RsSNARF(sv) (! SvOK(sv))
  2434. #define RsSIMPLE(sv) (SvOK(sv) && (! SvPOK(sv) || SvCUR(sv)))
  2435. #define RsPARA(sv) (SvPOK(sv) && ! SvCUR(sv))
  2436. #define RsRECORD(sv) (SvROK(sv) && (SvIV(SvRV(sv)) > 0))
  2437. /* Enable variables which are pointers to functions */
  2438. typedef regexp*(CPERLscope(*regcomp_t)) (pTHX_ char* exp, char* xend, PMOP* pm);
  2439. typedef I32 (CPERLscope(*regexec_t)) (pTHX_ regexp* prog, char* stringarg,
  2440. char* strend, char* strbeg, I32 minend,
  2441. SV* screamer, void* data, U32 flags);
  2442. typedef char* (CPERLscope(*re_intuit_start_t)) (pTHX_ regexp *prog, SV *sv,
  2443. char *strpos, char *strend,
  2444. U32 flags,
  2445. struct re_scream_pos_data_s *d);
  2446. typedef SV* (CPERLscope(*re_intuit_string_t)) (pTHX_ regexp *prog);
  2447. typedef void (CPERLscope(*regfree_t)) (pTHX_ struct regexp* r);
  2448. typedef void (*DESTRUCTORFUNC_NOCONTEXT_t) (void*);
  2449. typedef void (*DESTRUCTORFUNC_t) (pTHXo_ void*);
  2450. typedef void (*SVFUNC_t) (pTHXo_ SV*);
  2451. typedef I32 (*SVCOMPARE_t) (pTHXo_ SV*, SV*);
  2452. typedef void (*XSINIT_t) (pTHXo);
  2453. typedef void (*ATEXIT_t) (pTHXo_ void*);
  2454. typedef void (*XSUBADDR_t) (pTHXo_ CV *);
  2455. /* Set up PERLVAR macros for populating structs */
  2456. #define PERLVAR(var,type) type var;
  2457. #define PERLVARA(var,n,type) type var[n];
  2458. #define PERLVARI(var,type,init) type var;
  2459. #define PERLVARIC(var,type,init) type var;
  2460. /* Interpreter exitlist entry */
  2461. typedef struct exitlistentry {
  2462. void (*fn) (pTHXo_ void*);
  2463. void *ptr;
  2464. } PerlExitListEntry;
  2465. #ifdef PERL_GLOBAL_STRUCT
  2466. struct perl_vars {
  2467. # include "perlvars.h"
  2468. };
  2469. # ifdef PERL_CORE
  2470. EXT struct perl_vars PL_Vars;
  2471. EXT struct perl_vars *PL_VarsPtr INIT(&PL_Vars);
  2472. # else /* PERL_CORE */
  2473. # if !defined(__GNUC__) || !defined(WIN32)
  2474. EXT
  2475. # endif /* WIN32 */
  2476. struct perl_vars *PL_VarsPtr;
  2477. # define PL_Vars (*((PL_VarsPtr) \
  2478. ? PL_VarsPtr : (PL_VarsPtr = Perl_GetVars(aTHX))))
  2479. # endif /* PERL_CORE */
  2480. #endif /* PERL_GLOBAL_STRUCT */
  2481. #if defined(MULTIPLICITY) || defined(PERL_OBJECT)
  2482. /* If we have multiple interpreters define a struct
  2483. holding variables which must be per-interpreter
  2484. If we don't have threads anything that would have
  2485. be per-thread is per-interpreter.
  2486. */
  2487. struct interpreter {
  2488. # ifndef USE_THREADS
  2489. # include "thrdvar.h"
  2490. # endif
  2491. # include "intrpvar.h"
  2492. /*
  2493. * The following is a buffer where new variables must
  2494. * be defined to maintain binary compatibility with PERL_OBJECT
  2495. */
  2496. PERLVARA(object_compatibility,30, char)
  2497. };
  2498. #else
  2499. struct interpreter {
  2500. char broiled;
  2501. };
  2502. #endif /* MULTIPLICITY || PERL_OBJECT */
  2503. #ifdef USE_THREADS
  2504. /* If we have threads define a struct with all the variables
  2505. * that have to be per-thread
  2506. */
  2507. struct perl_thread {
  2508. #include "thrdvar.h"
  2509. };
  2510. typedef struct perl_thread *Thread;
  2511. #else
  2512. typedef void *Thread;
  2513. #endif
  2514. /* Done with PERLVAR macros for now ... */
  2515. #undef PERLVAR
  2516. #undef PERLVARA
  2517. #undef PERLVARI
  2518. #undef PERLVARIC
  2519. #include "thread.h"
  2520. #include "pp.h"
  2521. #ifndef PERL_CALLCONV
  2522. # define PERL_CALLCONV
  2523. #endif
  2524. #ifndef NEXT30_NO_ATTRIBUTE
  2525. # ifndef HASATTRIBUTE /* disable GNU-cc attribute checking? */
  2526. # ifdef __attribute__ /* Avoid possible redefinition errors */
  2527. # undef __attribute__
  2528. # endif
  2529. # define __attribute__(attr)
  2530. # endif
  2531. #endif
  2532. #ifdef PERL_OBJECT
  2533. # define PERL_DECL_PROT
  2534. #endif
  2535. #undef PERL_CKDEF
  2536. #undef PERL_PPDEF
  2537. #define PERL_CKDEF(s) OP *s (pTHX_ OP *o);
  2538. #define PERL_PPDEF(s) OP *s (pTHX);
  2539. #include "proto.h"
  2540. #ifdef PERL_OBJECT
  2541. # undef PERL_DECL_PROT
  2542. #endif
  2543. #ifndef PERL_OBJECT
  2544. /* this has structure inits, so it cannot be included before here */
  2545. # include "opcode.h"
  2546. #endif
  2547. /* The following must follow proto.h as #defines mess up syntax */
  2548. #if !defined(PERL_FOR_X2P)
  2549. # include "embedvar.h"
  2550. #endif
  2551. /* Now include all the 'global' variables
  2552. * If we don't have threads or multiple interpreters
  2553. * these include variables that would have been their struct-s
  2554. */
  2555. #define PERLVAR(var,type) EXT type PL_##var;
  2556. #define PERLVARA(var,n,type) EXT type PL_##var[n];
  2557. #define PERLVARI(var,type,init) EXT type PL_##var INIT(init);
  2558. #define PERLVARIC(var,type,init) EXTCONST type PL_##var INIT(init);
  2559. #if !defined(MULTIPLICITY) && !defined(PERL_OBJECT)
  2560. START_EXTERN_C
  2561. # include "intrpvar.h"
  2562. # ifndef USE_THREADS
  2563. # include "thrdvar.h"
  2564. # endif
  2565. END_EXTERN_C
  2566. #endif
  2567. #ifdef PERL_OBJECT
  2568. # include "embed.h"
  2569. # ifdef DOINIT
  2570. # include "INTERN.h"
  2571. # else
  2572. # include "EXTERN.h"
  2573. # endif
  2574. /* this has structure inits, so it cannot be included before here */
  2575. # include "opcode.h"
  2576. #else
  2577. # if defined(WIN32)
  2578. # include "embed.h"
  2579. # endif
  2580. #endif /* PERL_OBJECT */
  2581. #ifndef PERL_GLOBAL_STRUCT
  2582. START_EXTERN_C
  2583. # include "perlvars.h"
  2584. END_EXTERN_C
  2585. #endif
  2586. #undef PERLVAR
  2587. #undef PERLVARA
  2588. #undef PERLVARI
  2589. #undef PERLVARIC
  2590. START_EXTERN_C
  2591. #ifdef DOINIT
  2592. EXT MGVTBL PL_vtbl_sv = {MEMBER_TO_FPTR(Perl_magic_get),
  2593. MEMBER_TO_FPTR(Perl_magic_set),
  2594. MEMBER_TO_FPTR(Perl_magic_len),
  2595. 0, 0};
  2596. EXT MGVTBL PL_vtbl_env = {0, MEMBER_TO_FPTR(Perl_magic_set_all_env),
  2597. 0, MEMBER_TO_FPTR(Perl_magic_clear_all_env),
  2598. 0};
  2599. EXT MGVTBL PL_vtbl_envelem = {0, MEMBER_TO_FPTR(Perl_magic_setenv),
  2600. 0, MEMBER_TO_FPTR(Perl_magic_clearenv),
  2601. 0};
  2602. EXT MGVTBL PL_vtbl_sig = {0, 0, 0, 0, 0};
  2603. EXT MGVTBL PL_vtbl_sigelem = {MEMBER_TO_FPTR(Perl_magic_getsig),
  2604. MEMBER_TO_FPTR(Perl_magic_setsig),
  2605. 0, MEMBER_TO_FPTR(Perl_magic_clearsig),
  2606. 0};
  2607. EXT MGVTBL PL_vtbl_pack = {0, 0, MEMBER_TO_FPTR(Perl_magic_sizepack), MEMBER_TO_FPTR(Perl_magic_wipepack),
  2608. 0};
  2609. EXT MGVTBL PL_vtbl_packelem = {MEMBER_TO_FPTR(Perl_magic_getpack),
  2610. MEMBER_TO_FPTR(Perl_magic_setpack),
  2611. 0, MEMBER_TO_FPTR(Perl_magic_clearpack),
  2612. 0};
  2613. EXT MGVTBL PL_vtbl_dbline = {0, MEMBER_TO_FPTR(Perl_magic_setdbline),
  2614. 0, 0, 0};
  2615. EXT MGVTBL PL_vtbl_isa = {0, MEMBER_TO_FPTR(Perl_magic_setisa),
  2616. 0, MEMBER_TO_FPTR(Perl_magic_setisa),
  2617. 0};
  2618. EXT MGVTBL PL_vtbl_isaelem = {0, MEMBER_TO_FPTR(Perl_magic_setisa),
  2619. 0, 0, 0};
  2620. EXT MGVTBL PL_vtbl_arylen = {MEMBER_TO_FPTR(Perl_magic_getarylen),
  2621. MEMBER_TO_FPTR(Perl_magic_setarylen),
  2622. 0, 0, 0};
  2623. EXT MGVTBL PL_vtbl_glob = {MEMBER_TO_FPTR(Perl_magic_getglob),
  2624. MEMBER_TO_FPTR(Perl_magic_setglob),
  2625. 0, 0, 0};
  2626. EXT MGVTBL PL_vtbl_mglob = {0, MEMBER_TO_FPTR(Perl_magic_setmglob),
  2627. 0, 0, 0};
  2628. EXT MGVTBL PL_vtbl_nkeys = {MEMBER_TO_FPTR(Perl_magic_getnkeys),
  2629. MEMBER_TO_FPTR(Perl_magic_setnkeys),
  2630. 0, 0, 0};
  2631. EXT MGVTBL PL_vtbl_taint = {MEMBER_TO_FPTR(Perl_magic_gettaint),MEMBER_TO_FPTR(Perl_magic_settaint),
  2632. 0, 0, 0};
  2633. EXT MGVTBL PL_vtbl_substr = {MEMBER_TO_FPTR(Perl_magic_getsubstr), MEMBER_TO_FPTR(Perl_magic_setsubstr),
  2634. 0, 0, 0};
  2635. EXT MGVTBL PL_vtbl_vec = {MEMBER_TO_FPTR(Perl_magic_getvec),
  2636. MEMBER_TO_FPTR(Perl_magic_setvec),
  2637. 0, 0, 0};
  2638. EXT MGVTBL PL_vtbl_pos = {MEMBER_TO_FPTR(Perl_magic_getpos),
  2639. MEMBER_TO_FPTR(Perl_magic_setpos),
  2640. 0, 0, 0};
  2641. EXT MGVTBL PL_vtbl_bm = {0, MEMBER_TO_FPTR(Perl_magic_setbm),
  2642. 0, 0, 0};
  2643. EXT MGVTBL PL_vtbl_fm = {0, MEMBER_TO_FPTR(Perl_magic_setfm),
  2644. 0, 0, 0};
  2645. EXT MGVTBL PL_vtbl_uvar = {MEMBER_TO_FPTR(Perl_magic_getuvar),
  2646. MEMBER_TO_FPTR(Perl_magic_setuvar),
  2647. 0, 0, 0};
  2648. #ifdef USE_THREADS
  2649. EXT MGVTBL PL_vtbl_mutex = {0, 0, 0, 0, MEMBER_TO_FPTR(Perl_magic_mutexfree)};
  2650. #endif /* USE_THREADS */
  2651. EXT MGVTBL PL_vtbl_defelem = {MEMBER_TO_FPTR(Perl_magic_getdefelem),MEMBER_TO_FPTR(Perl_magic_setdefelem),
  2652. 0, 0, 0};
  2653. EXT MGVTBL PL_vtbl_regexp = {0,0,0,0, MEMBER_TO_FPTR(Perl_magic_freeregexp)};
  2654. EXT MGVTBL PL_vtbl_regdata = {0, 0, MEMBER_TO_FPTR(Perl_magic_regdata_cnt), 0, 0};
  2655. EXT MGVTBL PL_vtbl_regdatum = {MEMBER_TO_FPTR(Perl_magic_regdatum_get),
  2656. MEMBER_TO_FPTR(Perl_magic_regdatum_set), 0, 0, 0};
  2657. #ifdef USE_LOCALE_COLLATE
  2658. EXT MGVTBL PL_vtbl_collxfrm = {0,
  2659. MEMBER_TO_FPTR(Perl_magic_setcollxfrm),
  2660. 0, 0, 0};
  2661. #endif
  2662. EXT MGVTBL PL_vtbl_amagic = {0, MEMBER_TO_FPTR(Perl_magic_setamagic),
  2663. 0, 0, MEMBER_TO_FPTR(Perl_magic_setamagic)};
  2664. EXT MGVTBL PL_vtbl_amagicelem = {0, MEMBER_TO_FPTR(Perl_magic_setamagic),
  2665. 0, 0, MEMBER_TO_FPTR(Perl_magic_setamagic)};
  2666. EXT MGVTBL PL_vtbl_backref = {0, 0,
  2667. 0, 0, MEMBER_TO_FPTR(Perl_magic_killbackrefs)};
  2668. #else /* !DOINIT */
  2669. EXT MGVTBL PL_vtbl_sv;
  2670. EXT MGVTBL PL_vtbl_env;
  2671. EXT MGVTBL PL_vtbl_envelem;
  2672. EXT MGVTBL PL_vtbl_sig;
  2673. EXT MGVTBL PL_vtbl_sigelem;
  2674. EXT MGVTBL PL_vtbl_pack;
  2675. EXT MGVTBL PL_vtbl_packelem;
  2676. EXT MGVTBL PL_vtbl_dbline;
  2677. EXT MGVTBL PL_vtbl_isa;
  2678. EXT MGVTBL PL_vtbl_isaelem;
  2679. EXT MGVTBL PL_vtbl_arylen;
  2680. EXT MGVTBL PL_vtbl_glob;
  2681. EXT MGVTBL PL_vtbl_mglob;
  2682. EXT MGVTBL PL_vtbl_nkeys;
  2683. EXT MGVTBL PL_vtbl_taint;
  2684. EXT MGVTBL PL_vtbl_substr;
  2685. EXT MGVTBL PL_vtbl_vec;
  2686. EXT MGVTBL PL_vtbl_pos;
  2687. EXT MGVTBL PL_vtbl_bm;
  2688. EXT MGVTBL PL_vtbl_fm;
  2689. EXT MGVTBL PL_vtbl_uvar;
  2690. #ifdef USE_THREADS
  2691. EXT MGVTBL PL_vtbl_mutex;
  2692. #endif /* USE_THREADS */
  2693. EXT MGVTBL PL_vtbl_defelem;
  2694. EXT MGVTBL PL_vtbl_regexp;
  2695. EXT MGVTBL PL_vtbl_regdata;
  2696. EXT MGVTBL PL_vtbl_regdatum;
  2697. #ifdef USE_LOCALE_COLLATE
  2698. EXT MGVTBL PL_vtbl_collxfrm;
  2699. #endif
  2700. EXT MGVTBL PL_vtbl_amagic;
  2701. EXT MGVTBL PL_vtbl_amagicelem;
  2702. EXT MGVTBL PL_vtbl_backref;
  2703. #endif /* !DOINIT */
  2704. enum {
  2705. fallback_amg, abs_amg,
  2706. bool__amg, nomethod_amg,
  2707. string_amg, numer_amg,
  2708. add_amg, add_ass_amg,
  2709. subtr_amg, subtr_ass_amg,
  2710. mult_amg, mult_ass_amg,
  2711. div_amg, div_ass_amg,
  2712. modulo_amg, modulo_ass_amg,
  2713. pow_amg, pow_ass_amg,
  2714. lshift_amg, lshift_ass_amg,
  2715. rshift_amg, rshift_ass_amg,
  2716. band_amg, band_ass_amg,
  2717. bor_amg, bor_ass_amg,
  2718. bxor_amg, bxor_ass_amg,
  2719. lt_amg, le_amg,
  2720. gt_amg, ge_amg,
  2721. eq_amg, ne_amg,
  2722. ncmp_amg, scmp_amg,
  2723. slt_amg, sle_amg,
  2724. sgt_amg, sge_amg,
  2725. seq_amg, sne_amg,
  2726. not_amg, compl_amg,
  2727. inc_amg, dec_amg,
  2728. atan2_amg, cos_amg,
  2729. sin_amg, exp_amg,
  2730. log_amg, sqrt_amg,
  2731. repeat_amg, repeat_ass_amg,
  2732. concat_amg, concat_ass_amg,
  2733. copy_amg, neg_amg,
  2734. to_sv_amg, to_av_amg,
  2735. to_hv_amg, to_gv_amg,
  2736. to_cv_amg, iter_amg,
  2737. max_amg_code
  2738. /* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
  2739. };
  2740. #define NofAMmeth max_amg_code
  2741. #ifdef DOINIT
  2742. EXTCONST char * PL_AMG_names[NofAMmeth] = {
  2743. "fallback", "abs", /* "fallback" should be the first. */
  2744. "bool", "nomethod",
  2745. "\"\"", "0+",
  2746. "+", "+=",
  2747. "-", "-=",
  2748. "*", "*=",
  2749. "/", "/=",
  2750. "%", "%=",
  2751. "**", "**=",
  2752. "<<", "<<=",
  2753. ">>", ">>=",
  2754. "&", "&=",
  2755. "|", "|=",
  2756. "^", "^=",
  2757. "<", "<=",
  2758. ">", ">=",
  2759. "==", "!=",
  2760. "<=>", "cmp",
  2761. "lt", "le",
  2762. "gt", "ge",
  2763. "eq", "ne",
  2764. "!", "~",
  2765. "++", "--",
  2766. "atan2", "cos",
  2767. "sin", "exp",
  2768. "log", "sqrt",
  2769. "x", "x=",
  2770. ".", ".=",
  2771. "=", "neg",
  2772. "${}", "@{}",
  2773. "%{}", "*{}",
  2774. "&{}", "<>",
  2775. };
  2776. #else
  2777. EXTCONST char * PL_AMG_names[NofAMmeth];
  2778. #endif /* def INITAMAGIC */
  2779. END_EXTERN_C
  2780. struct am_table {
  2781. long was_ok_sub;
  2782. long was_ok_am;
  2783. U32 flags;
  2784. CV* table[NofAMmeth];
  2785. long fallback;
  2786. };
  2787. struct am_table_short {
  2788. long was_ok_sub;
  2789. long was_ok_am;
  2790. U32 flags;
  2791. };
  2792. typedef struct am_table AMT;
  2793. typedef struct am_table_short AMTS;
  2794. #define AMGfallNEVER 1
  2795. #define AMGfallNO 2
  2796. #define AMGfallYES 3
  2797. #define AMTf_AMAGIC 1
  2798. #define AMT_AMAGIC(amt) ((amt)->flags & AMTf_AMAGIC)
  2799. #define AMT_AMAGIC_on(amt) ((amt)->flags |= AMTf_AMAGIC)
  2800. #define AMT_AMAGIC_off(amt) ((amt)->flags &= ~AMTf_AMAGIC)
  2801. /*
  2802. * some compilers like to redefine cos et alia as faster
  2803. * (and less accurate?) versions called F_cos et cetera (Quidquid
  2804. * latine dictum sit, altum viditur.) This trick collides with
  2805. * the Perl overloading (amg). The following #defines fool both.
  2806. */
  2807. #ifdef _FASTMATH
  2808. # ifdef atan2
  2809. # define F_atan2_amg atan2_amg
  2810. # endif
  2811. # ifdef cos
  2812. # define F_cos_amg cos_amg
  2813. # endif
  2814. # ifdef exp
  2815. # define F_exp_amg exp_amg
  2816. # endif
  2817. # ifdef log
  2818. # define F_log_amg log_amg
  2819. # endif
  2820. # ifdef pow
  2821. # define F_pow_amg pow_amg
  2822. # endif
  2823. # ifdef sin
  2824. # define F_sin_amg sin_amg
  2825. # endif
  2826. # ifdef sqrt
  2827. # define F_sqrt_amg sqrt_amg
  2828. # endif
  2829. #endif /* _FASTMATH */
  2830. #define PERLDB_ALL (PERLDBf_SUB | PERLDBf_LINE | \
  2831. PERLDBf_NOOPT | PERLDBf_INTER | \
  2832. PERLDBf_SUBLINE| PERLDBf_SINGLE| \
  2833. PERLDBf_NAMEEVAL| PERLDBf_NAMEANON)
  2834. /* No _NONAME, _GOTO */
  2835. #define PERLDBf_SUB 0x01 /* Debug sub enter/exit */
  2836. #define PERLDBf_LINE 0x02 /* Keep line # */
  2837. #define PERLDBf_NOOPT 0x04 /* Switch off optimizations */
  2838. #define PERLDBf_INTER 0x08 /* Preserve more data for
  2839. later inspections */
  2840. #define PERLDBf_SUBLINE 0x10 /* Keep subr source lines */
  2841. #define PERLDBf_SINGLE 0x20 /* Start with single-step on */
  2842. #define PERLDBf_NONAME 0x40 /* For _SUB: no name of the subr */
  2843. #define PERLDBf_GOTO 0x80 /* Report goto: call DB::goto */
  2844. #define PERLDBf_NAMEEVAL 0x100 /* Informative names for evals */
  2845. #define PERLDBf_NAMEANON 0x200 /* Informative names for anon subs */
  2846. #define PERLDB_SUB (PL_perldb && (PL_perldb & PERLDBf_SUB))
  2847. #define PERLDB_LINE (PL_perldb && (PL_perldb & PERLDBf_LINE))
  2848. #define PERLDB_NOOPT (PL_perldb && (PL_perldb & PERLDBf_NOOPT))
  2849. #define PERLDB_INTER (PL_perldb && (PL_perldb & PERLDBf_INTER))
  2850. #define PERLDB_SUBLINE (PL_perldb && (PL_perldb & PERLDBf_SUBLINE))
  2851. #define PERLDB_SINGLE (PL_perldb && (PL_perldb & PERLDBf_SINGLE))
  2852. #define PERLDB_SUB_NN (PL_perldb && (PL_perldb & (PERLDBf_NONAME)))
  2853. #define PERLDB_GOTO (PL_perldb && (PL_perldb & PERLDBf_GOTO))
  2854. #define PERLDB_NAMEEVAL (PL_perldb && (PL_perldb & PERLDBf_NAMEEVAL))
  2855. #define PERLDB_NAMEANON (PL_perldb && (PL_perldb & PERLDBf_NAMEANON))
  2856. #ifdef USE_LOCALE_NUMERIC
  2857. #define SET_NUMERIC_STANDARD() \
  2858. set_numeric_standard();
  2859. #define SET_NUMERIC_LOCAL() \
  2860. set_numeric_local();
  2861. #define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE)
  2862. #define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE)
  2863. #define IN_LOCALE \
  2864. (PL_curcop == &PL_compiling ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
  2865. #define IS_NUMERIC_RADIX(s, send) \
  2866. (PL_numeric_radix_sv \
  2867. && IN_LOCALE \
  2868. && SvCUR(PL_numeric_radix_sv) <= (STRLEN)((send)-(s)) \
  2869. && memEQ(s, SvPVX(PL_numeric_radix_sv), SvCUR(PL_numeric_radix_sv)))
  2870. #define STORE_NUMERIC_LOCAL_SET_STANDARD() \
  2871. bool was_local = PL_numeric_local && IN_LOCALE; \
  2872. if (was_local) SET_NUMERIC_STANDARD();
  2873. #define STORE_NUMERIC_STANDARD_SET_LOCAL() \
  2874. bool was_standard = PL_numeric_standard && IN_LOCALE; \
  2875. if (was_standard) SET_NUMERIC_LOCAL();
  2876. #define RESTORE_NUMERIC_LOCAL() \
  2877. if (was_local) SET_NUMERIC_LOCAL();
  2878. #define RESTORE_NUMERIC_STANDARD() \
  2879. if (was_standard) SET_NUMERIC_STANDARD();
  2880. #define Atof my_atof
  2881. #else /* !USE_LOCALE_NUMERIC */
  2882. #define SET_NUMERIC_STANDARD() /**/
  2883. #define SET_NUMERIC_LOCAL() /**/
  2884. #define IS_NUMERIC_RADIX(a, b) (0)
  2885. #define STORE_NUMERIC_LOCAL_SET_STANDARD() /**/
  2886. #define STORE_NUMERIC_STANDARD_SET_LOCAL() /**/
  2887. #define RESTORE_NUMERIC_LOCAL() /**/
  2888. #define RESTORE_NUMERIC_STANDARD() /**/
  2889. #define Atof Perl_atof
  2890. #endif /* !USE_LOCALE_NUMERIC */
  2891. #if !defined(Strtol) && defined(USE_64_BIT_INT) && defined(IV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG
  2892. # ifdef __hpux
  2893. # define strtoll __strtoll /* secret handshake */
  2894. # endif
  2895. # if !defined(Strtol) && defined(HAS_STRTOLL)
  2896. # define Strtol strtoll
  2897. # endif
  2898. /* is there atoq() anywhere? */
  2899. #endif
  2900. #if !defined(Strtol) && defined(HAS_STRTOL)
  2901. # define Strtol strtol
  2902. #endif
  2903. #ifndef Atol
  2904. /* It would be more fashionable to use Strtol() to define atol()
  2905. * (as is done for Atoul(), see below) but for backward compatibility
  2906. * we just assume atol(). */
  2907. # if defined(USE_64_BIT_INT) && defined(IV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG && defined(HAS_ATOLL)
  2908. # define Atol atoll
  2909. # else
  2910. # define Atol atol
  2911. # endif
  2912. #endif
  2913. #if !defined(Strtoul) && defined(USE_64_BIT_INT) && defined(UV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG
  2914. # ifdef __hpux
  2915. # define strtoull __strtoull /* secret handshake */
  2916. # endif
  2917. # if !defined(Strtoul) && defined(HAS_STRTOULL)
  2918. # define Strtoul strtoull
  2919. # endif
  2920. # if !defined(Strtoul) && defined(HAS_STRTOUQ)
  2921. # define Strtoul strtouq
  2922. # endif
  2923. /* is there atouq() anywhere? */
  2924. #endif
  2925. #if !defined(Strtoul) && defined(HAS_STRTOUL)
  2926. # define Strtoul strtoul
  2927. #endif
  2928. #ifndef Atoul
  2929. # define Atoul(s) Strtoul(s, (char **)NULL, 10)
  2930. #endif
  2931. #if !defined(PERLIO_IS_STDIO) && defined(HASATTRIBUTE)
  2932. /*
  2933. * Now we have __attribute__ out of the way
  2934. * Remap printf
  2935. */
  2936. #undef printf
  2937. #define printf PerlIO_stdoutf
  2938. #endif
  2939. /* if these never got defined, they need defaults */
  2940. #ifndef PERL_SET_CONTEXT
  2941. # define PERL_SET_CONTEXT(i) PERL_SET_INTERP(i)
  2942. #endif
  2943. #ifndef PERL_GET_CONTEXT
  2944. # define PERL_GET_CONTEXT PERL_GET_INTERP
  2945. #endif
  2946. #ifndef PERL_GET_THX
  2947. # define PERL_GET_THX ((void*)NULL)
  2948. #endif
  2949. #ifndef PERL_SET_THX
  2950. # define PERL_SET_THX(t) NOOP
  2951. #endif
  2952. #ifndef PERL_SCRIPT_MODE
  2953. #define PERL_SCRIPT_MODE "r"
  2954. #endif
  2955. /*
  2956. * Some operating systems are stingy with stack allocation,
  2957. * so perl may have to guard against stack overflow.
  2958. */
  2959. #ifndef PERL_STACK_OVERFLOW_CHECK
  2960. #define PERL_STACK_OVERFLOW_CHECK() NOOP
  2961. #endif
  2962. /*
  2963. * Some nonpreemptive operating systems find it convenient to
  2964. * check for asynchronous conditions after each op execution.
  2965. * Keep this check simple, or it may slow down execution
  2966. * massively.
  2967. */
  2968. #ifndef PERL_ASYNC_CHECK
  2969. #define PERL_ASYNC_CHECK() NOOP
  2970. #endif
  2971. /*
  2972. * On some operating systems, a memory allocation may succeed,
  2973. * but put the process too close to the system's comfort limit.
  2974. * In this case, PERL_ALLOC_CHECK frees the pointer and sets
  2975. * it to NULL.
  2976. */
  2977. #ifndef PERL_ALLOC_CHECK
  2978. #define PERL_ALLOC_CHECK(p) NOOP
  2979. #endif
  2980. /*
  2981. * nice_chunk and nice_chunk size need to be set
  2982. * and queried under the protection of sv_mutex
  2983. */
  2984. #define offer_nice_chunk(chunk, chunk_size) do { \
  2985. LOCK_SV_MUTEX; \
  2986. if (!PL_nice_chunk) { \
  2987. PL_nice_chunk = (char*)(chunk); \
  2988. PL_nice_chunk_size = (chunk_size); \
  2989. } \
  2990. else { \
  2991. Safefree(chunk); \
  2992. } \
  2993. UNLOCK_SV_MUTEX; \
  2994. } while (0)
  2995. #ifdef HAS_SEM
  2996. # include <sys/ipc.h>
  2997. # include <sys/sem.h>
  2998. # ifndef HAS_UNION_SEMUN /* Provide the union semun. */
  2999. union semun {
  3000. int val;
  3001. struct semid_ds *buf;
  3002. unsigned short *array;
  3003. };
  3004. # endif
  3005. # ifdef USE_SEMCTL_SEMUN
  3006. # ifdef IRIX32_SEMUN_BROKEN_BY_GCC
  3007. union gccbug_semun {
  3008. int val;
  3009. struct semid_ds *buf;
  3010. unsigned short *array;
  3011. char __dummy[5];
  3012. };
  3013. # define semun gccbug_semun
  3014. # endif
  3015. # define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun)
  3016. # else
  3017. # ifdef USE_SEMCTL_SEMID_DS
  3018. # ifdef EXTRA_F_IN_SEMUN_BUF
  3019. # define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun.buff)
  3020. # else
  3021. # define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun.buf)
  3022. # endif
  3023. # endif
  3024. # endif
  3025. #endif
  3026. /*
  3027. * Boilerplate macros for initializing and accessing interpreter-local
  3028. * data from C. All statics in extensions should be reworked to use
  3029. * this, if you want to make the extension thread-safe. See ext/re/re.xs
  3030. * for an example of the use of these macros.
  3031. *
  3032. * Code that uses these macros is responsible for the following:
  3033. * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
  3034. * 2. Declare a typedef named my_cxt_t that is a structure that contains
  3035. * all the data that needs to be interpreter-local.
  3036. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
  3037. * 4. Use the MY_CXT_INIT macro such that it is called exactly once
  3038. * (typically put in the BOOT: section).
  3039. * 5. Use the members of the my_cxt_t structure everywhere as
  3040. * MY_CXT.member.
  3041. * 6. Use the dMY_CXT macro (a declaration) in all the functions that
  3042. * access MY_CXT.
  3043. */
  3044. #if defined(USE_ITHREADS)
  3045. /* This must appear in all extensions that define a my_cxt_t structure,
  3046. * right after the definition (i.e. at file scope). The non-threads
  3047. * case below uses it to declare the data as static. */
  3048. #define START_MY_CXT
  3049. /* Fetches the SV that keeps the per-interpreter data. */
  3050. #define dMY_CXT_SV \
  3051. SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
  3052. sizeof(MY_CXT_KEY)-1, TRUE)
  3053. /* This declaration should be used within all functions that use the
  3054. * interpreter-local data. */
  3055. #define dMY_CXT \
  3056. dMY_CXT_SV; \
  3057. my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
  3058. /* Creates and zeroes the per-interpreter data.
  3059. * (We allocate my_cxtp in a Perl SV so that it will be released when
  3060. * the interpreter goes away.) */
  3061. #define MY_CXT_INIT \
  3062. dMY_CXT_SV; \
  3063. /* newSV() allocates one more than needed */ \
  3064. my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
  3065. Zero(my_cxtp, 1, my_cxt_t); \
  3066. sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
  3067. /* This macro must be used to access members of the my_cxt_t structure.
  3068. * e.g. MYCXT.some_data */
  3069. #define MY_CXT (*my_cxtp)
  3070. /* Judicious use of these macros can reduce the number of times dMY_CXT
  3071. * is used. Use is similar to pTHX, aTHX etc. */
  3072. #define pMY_CXT my_cxt_t *my_cxtp
  3073. #define pMY_CXT_ pMY_CXT,
  3074. #define _pMY_CXT ,pMY_CXT
  3075. #define aMY_CXT my_cxtp
  3076. #define aMY_CXT_ aMY_CXT,
  3077. #define _aMY_CXT ,aMY_CXT
  3078. #else /* USE_ITHREADS */
  3079. #define START_MY_CXT static my_cxt_t my_cxt;
  3080. #define dMY_CXT_SV dNOOP
  3081. #define dMY_CXT dNOOP
  3082. #define MY_CXT_INIT NOOP
  3083. #define MY_CXT my_cxt
  3084. #define pMY_CXT void
  3085. #define pMY_CXT_
  3086. #define _pMY_CXT
  3087. #define aMY_CXT
  3088. #define aMY_CXT_
  3089. #define _aMY_CXT
  3090. #endif /* !defined(USE_ITHREADS) */
  3091. #ifdef I_FCNTL
  3092. # include <fcntl.h>
  3093. #endif
  3094. #ifdef I_SYS_FILE
  3095. # include <sys/file.h>
  3096. #endif
  3097. #ifndef O_RDONLY
  3098. /* Assume UNIX defaults */
  3099. # define O_RDONLY 0000
  3100. # define O_WRONLY 0001
  3101. # define O_RDWR 0002
  3102. # define O_CREAT 0100
  3103. #endif
  3104. #ifndef O_BINARY
  3105. # define O_BINARY 0
  3106. #endif
  3107. #ifndef O_TEXT
  3108. # define O_TEXT 0
  3109. #endif
  3110. #ifdef IAMSUID
  3111. #ifdef I_SYS_STATVFS
  3112. # include <sys/statvfs.h> /* for f?statvfs() */
  3113. #endif
  3114. #ifdef I_SYS_MOUNT
  3115. # include <sys/mount.h> /* for *BSD f?statfs() */
  3116. #endif
  3117. #ifdef I_MNTENT
  3118. # include <mntent.h> /* for getmntent() */
  3119. #endif
  3120. #ifdef I_SYS_STATFS
  3121. # include <sys/statfs.h> /* for some statfs() */
  3122. #endif
  3123. #ifdef I_SYS_VFS
  3124. # ifdef __sgi
  3125. # define sv IRIX_sv /* kludge: IRIX has an sv of its own */
  3126. # endif
  3127. # include <sys/vfs.h> /* for some statfs() */
  3128. # ifdef __sgi
  3129. # undef IRIX_sv
  3130. # endif
  3131. #endif
  3132. #ifdef I_USTAT
  3133. # include <ustat.h> /* for ustat() */
  3134. #endif
  3135. #if !defined(PERL_MOUNT_NOSUID) && defined(MOUNT_NOSUID)
  3136. # define PERL_MOUNT_NOSUID MOUNT_NOSUID
  3137. #endif
  3138. #if !defined(PERL_MOUNT_NOSUID) && defined(MNT_NOSUID)
  3139. # define PERL_MOUNT_NOSUID MNT_NOSUID
  3140. #endif
  3141. #if !defined(PERL_MOUNT_NOSUID) && defined(MS_NOSUID)
  3142. # define PERL_MOUNT_NOSUID MS_NOSUID
  3143. #endif
  3144. #if !defined(PERL_MOUNT_NOSUID) && defined(M_NOSUID)
  3145. # define PERL_MOUNT_NOSUID M_NOSUID
  3146. #endif
  3147. #endif /* IAMSUID */
  3148. #ifdef I_LIBUTIL
  3149. # include <libutil.h> /* setproctitle() in some FreeBSDs */
  3150. #endif
  3151. #ifndef EXEC_ARGV_CAST
  3152. #define EXEC_ARGV_CAST(x) x
  3153. #endif
  3154. /* and finally... */
  3155. #define PERL_PATCHLEVEL_H_IMPLICIT
  3156. #include "patchlevel.h"
  3157. #undef PERL_PATCHLEVEL_H_IMPLICIT
  3158. /* Mention
  3159. NV_PRESERVES_UV
  3160. HAS_ICONV
  3161. I_ICONV
  3162. HAS_MKSTEMP
  3163. HAS_MKSTEMPS
  3164. HAS_MKDTEMP
  3165. HAS_GETCWD
  3166. HAS_MMAP
  3167. HAS_MPROTECT
  3168. HAS_MSYNC
  3169. HAS_MADVISE
  3170. HAS_MUNMAP
  3171. I_SYSMMAN
  3172. Mmap_t
  3173. NVef
  3174. NVff
  3175. NVgf
  3176. so that Configure picks them up. */
  3177. #endif /* Include guard */