This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
64-bitness, based on
[perl5.git] / perl.h
diff --git a/perl.h b/perl.h
index c6cc872..7e9fd94 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -209,6 +209,12 @@ register struct op *op asm(stringify(OP_IN_REGISTER));
 #   define LIBERAL 1
 #endif
 
+#if 'A' == 65 && 'I' == 73 && 'J' == 74 && 'Z' == 90
+#define ASCIIish
+#else
+#undef  ASCIIish
+#endif
+
 /*
  * The following contortions are brought to you on behalf of all the
  * standards, semi-standards, de facto standards, not-so-de-facto standards
@@ -296,6 +302,19 @@ register struct op *op asm(stringify(OP_IN_REGISTER));
 #  endif
 #endif
 
+/* HP-UX 10.X CMA (Common Multithreaded Architecure) insists that
+   pthread.h must be included before all other header files.
+*/
+#if defined(USE_THREADS) && defined(PTHREAD_H_FIRST)
+#  include <pthread.h>
+#endif
+
+/* HP-UX 10.X CMA (Common Multithreaded Architecure) insists that
+   pthread.h must be included before all other header files.
+*/
+#if defined(USE_THREADS) && defined(PTHREAD_H_FIRST)
+#  include <pthread.h>
+#endif
 #ifndef _TYPES_                /* If types.h defines this it's easy. */
 #   ifndef major               /* Does everyone's types.h define this? */
 #      include <sys/types.h>
@@ -320,11 +339,15 @@ register struct op *op asm(stringify(OP_IN_REGISTER));
 
 #ifdef USE_NEXT_CTYPE
 
-#if NX_CURRENT_COMPILER_RELEASE >= 400
-#include <objc/NXCType.h>
-#else /*  NX_CURRENT_COMPILER_RELEASE < 400 */
-#include <appkit/NXCType.h>
-#endif /*  NX_CURRENT_COMPILER_RELEASE >= 400 */
+#if NX_CURRENT_COMPILER_RELEASE >= 500
+#  include <bsd/ctypes.h>
+#else
+#  if NX_CURRENT_COMPILER_RELEASE >= 400
+#    include <objc/NXCType.h>
+#  else /*  NX_CURRENT_COMPILER_RELEASE < 400 */
+#    include <appkit/NXCType.h>
+#  endif /*  NX_CURRENT_COMPILER_RELEASE >= 400 */
+#endif /*  NX_CURRENT_COMPILER_RELEASE >= 500 */
 
 #else /* !USE_NEXT_CTYPE */
 #include <ctype.h>
@@ -585,7 +608,7 @@ Free_t   Perl_free _((Malloc_t where));
            set_vaxc_errno(vmserrcode); \
        } STMT_END
 #else
-#   define SETERRNO(errcode,vmserrcode) errno = (errcode)
+#   define SETERRNO(errcode,vmserrcode) (errno = (errcode))
 #endif
 
 #ifdef USE_THREADS
@@ -601,7 +624,11 @@ Free_t   Perl_free _((Malloc_t where));
 #endif /* USE_THREADS */
 
 #ifndef errno
-       extern int errno;     /* ANSI allows errno to be an lvalue expr */
+       extern int errno;     /* ANSI allows errno to be an lvalue expr.
+                              * For example in multithreaded environments
+                              * something like this might happen:
+                              * extern int *_errno(void);
+                              * #define errno (*_errno()) */
 #endif
 
 #ifdef HAS_STRERROR
@@ -788,6 +815,10 @@ Free_t   Perl_free _((Malloc_t where));
 #undef UV
 #endif
 
+#ifdef I_INTTYPES
+#include <inttypes.h>
+#endif
+
 /*  XXX QUAD stuff is not currently supported on most systems.
     Specifically, perl internals don't support long long.  Among
     the many problems is that some compilers support long long,
@@ -801,42 +832,122 @@ Free_t   Perl_free _((Malloc_t where));
     --Andy Dougherty   August 1996
 */
 
-#ifdef cray
-#   define Quad_t int
-#else
-#   ifdef convex
-#      define Quad_t long long
-#   else
-#      if LONGSIZE == 8
-#          define Quad_t long
-#      endif
+/*  Much more 64-bit probing added.  Now we should get Quad_t
+    in most systems: int64_t, long long, long, int, will do.
+
+    Beware of LP32 systems (ILP32, ILP32LL64).  Such systems have been
+    used to sizeof(long) == sizeof(foo*).  This is a bad assumption
+    because then IV/UV have been 32 bits, too.  Which, in turn means
+    that even if the system has quads (e.g. long long), IV cannot be a
+    quad.  Introducing a 64-bit IV (because of long long existing)
+    will introduce binary incompatibility.
+
+    Summary: a long long system needs to add -DUSE_LONG_LONG to $ccflags
+    to get quads -- and if its pointers are still 32 bits, this will break
+    binary compatibility.  Casting an IV (a long long) to a pointer will
+    truncate half of the IV away.
+
+    --jhi              September 1998 */
+
+#if INTSIZE == 4 && LONGSIZE == 4 && PTRSIZE == 4
+#   define PERL_ILP32
+#   if defined(HAS_LONG_LONG) && LONGLONGSIZE == 8
+#       define PERL_ILP32LL64
 #   endif
 #endif
 
-/* XXX Experimental set-up for long long.  Just add -DUSE_LONG_LONG
-   to your ccflags.  --Andy Dougherty   4/1998
-*/
-#ifdef USE_LONG_LONG
-#  if defined(HAS_LONG_LONG) && LONGLONGSIZE == 8
-#    define Quad_t long long
-#  endif
+#if LONGSIZE == 8 && PTRSIZE == 8
+#   define PERL_LP64
+#   if INTSIZE == 8
+#        define PERL_ILP64
+#   endif
+#endif
+
+#ifndef Quad_t
+#    if LONGSIZE == 8
+#       define Quad_t  long
+#       define PERL_QUAD_IS_LONG
+#    endif
+#endif
+
+#ifndef Quad_t
+#    if INTSIZE == 8
+#       define Quad_t  int
+#       define PERL_QUAD_IS_INT
+#    endif
+#endif
+
+#ifndef Quad_t
+#    ifdef USE_LONG_LONG /* See above note about LP32. --jhi */
+#       if defined(HAS_LONG_LONG) && LONGLONGSIZE == 8
+#          define Quad_t  long long
+#           define PERL_QUAD_IS_LONG_LONG
+#       endif
+#    endif
+#endif
+
+#ifndef Quad_t
+#    ifdef HAS_INT64_T
+#        define Quad_t  int64_t
+#        define Uquad_t uint64_t
+#        define PERL_QUAD_IS_INT64_T
+#    endif
 #endif
 
 #ifdef Quad_t
 #   define HAS_QUAD
-    typedef Quad_t IV;
-    typedef unsigned Quad_t UV;
-#   define IV_MAX PERL_QUAD_MAX
-#   define IV_MIN PERL_QUAD_MIN
-#   define UV_MAX PERL_UQUAD_MAX
-#   define UV_MIN PERL_UQUAD_MIN
+#   ifndef Uquad_t
+    /* Note that if your Quad_t is a typedef you *must* have defined
+     * also Uquad_t yourself because 'unsigned type' is illegal. */
+#       define Uquad_t unsigned Quad_t
+#   endif
+#endif
+
+#if defined(USE_64_BITS) && defined(HAS_QUAD)
+#  ifdef PERL_QUAD_IS_LONG                     /* LP64 */
+   typedef          long               IV;
+   typedef         unsigned long      UV;
+#  else
+#      ifdef PERL_QUAD_IS_INT                  /* ILP64 */
+   typedef          int                IV;
+   typedef         unsigned int       UV;
+#      else
+#          ifdef PERL_QUAD_IS_LONG_LONG                /* LL64 */
+   typedef          long long          IV;
+   typedef         unsigned long long UV;
+#          else
+#              ifdef PERL_QUAD_IS_INT64_T      /* C9X */
+   typedef          int64_t            IV;
+   typedef         uint64_t           UV;
+#              endif
+#          endif
+#      endif
+#  endif     
+#  if defined(PERL_QUAD_IS_INT64_T) && defined(INT64_MAX)
+#    define IV_MAX INT64_MAX
+#    define IV_MIN INT64_MIN
+#    define UV_MAX UINT64_MAX
+#    define UV_MIN UINT64_MIN
+#  else
+#    define IV_MAX PERL_QUAD_MAX
+#    define IV_MIN PERL_QUAD_MIN
+#    define UV_MAX PERL_UQUAD_MAX
+#    define UV_MIN PERL_UQUAD_MIN
+#  endif
 #else
-    typedef long IV;
-    typedef unsigned long UV;
-#   define IV_MAX PERL_LONG_MAX
-#   define IV_MIN PERL_LONG_MIN
-#   define UV_MAX PERL_ULONG_MAX
-#   define UV_MIN PERL_ULONG_MIN
+   typedef          long               IV;
+   typedef         unsigned long      UV;
+#  if defined(INT32_MAX) && LONGSIZE == 4
+#    define IV_MAX INT32_MAX
+#    define IV_MIN INT32_MIN
+#    define UV_MAX UINT32_MAX
+#    define UV_MIN UINT32_MIN
+#  else
+#    define IV_MAX PERL_LONG_MAX
+#    define IV_MIN PERL_LONG_MIN
+#    define UV_MAX PERL_ULONG_MAX
+#    define UV_MIN PERL_ULONG_MIN
+#  endif
 #endif
 
 /* Previously these definitions used hardcoded figures. 
@@ -1083,6 +1194,128 @@ typedef union any ANY;
 
 #include "handy.h"
 
+/* Some day when we have more 64-bit experience under our belts we may
+ * be able to merge some of the USE_64_BIT_{FILES,OFFSETS,STDIO,DBM}. At
+ * the moment (Oct 1998), though, keep them separate. --jhi
+ */
+#ifdef USE_64_BITS
+#   ifdef USE_64_BIT_FILES
+#       ifndef USE_64_BIT_OFFSETS
+#          define USE_64_BIT_OFFSETS
+#       endif
+#       ifndef USE_64_BIT_STDIO
+#           define USE_64_BIT_STDIO
+#       endif
+#       ifndef USE_64_BIT_DBM
+#           define USE_64_BIT_DBM
+#       endif
+#   endif
+/* Mention LSEEKSIZE here to get it included in %Config. */
+#   ifdef USE_64_BIT_OFFSETS
+#       ifdef HAS_FSTAT64
+#           define fstat fstat64
+#       endif
+#       ifdef HAS_FTRUNCATE64
+#           define ftruncate ftruncate64
+#       endif
+#       ifdef HAS_LSEEK64
+#           define lseek lseek64
+#           ifdef HAS_OFF64_T
+#               undef Off_t
+#               define Off_t off64_t
+#           endif
+#       endif
+#       ifdef HAS_LSTAT64
+#           define lstat lstat64
+#       endif
+       /* Some systems have open64() in libc but use that only
+        * for true LP64 mode, in mixed mode (ILP32LL64, for example)
+        * they use the vanilla open().  Such systems should undefine
+        * d_open64 in their hints files. --jhi */
+#       if defined(HAS_OPEN64)
+#           define open open64
+#       endif
+#       ifdef HAS_OPENDIR64
+#           define opendir opendir64
+#       endif
+#       ifdef HAS_READDIR64
+#           define readdir readdir64
+#          ifdef HAS_STRUCT_DIRENT64
+#               define dirent dirent64
+#           endif
+#       endif
+#       ifdef HAS_SEEKDIR64
+#           define seekdir seekdir64
+#       endif
+#       ifdef HAS_STAT64
+#           define stat stat64 /* Affects also struct stat, hopefully okay. */
+#       endif
+#       ifdef HAS_TELLDIR64
+#           define telldir telldir64
+#       endif
+#       ifdef HAS_TRUNCATE64
+#           define truncate truncate64
+#       endif
+        /* flock is not #defined here to be flock64 because it seems
+          that a system may have struct flock64 but still use flock()
+          and not flock64().  The actual flocking code in pp_sys.c
+          must be changed.  Also lockf and lockf64 must be dealt
+          with in pp_sys.c. --jhi */
+#   endif
+#   ifdef USE_64_BIT_STDIO
+#       ifdef HAS_FGETPOS64
+#           define fgetpos fgetpos64
+#       endif
+#       ifdef HAS_FOPEN64
+#           define fopen fopen64
+#       endif
+#       ifdef HAS_FREOPEN64
+#           define freopen freopen64
+#       endif
+#       ifdef HAS_FSEEK64
+#           define fseek fseek64
+#       endif
+#       ifdef HAS_FSEEKO64
+#           define fseeko fseeko64
+#       endif
+#       ifdef HAS_FSETPOS64
+#           define fsetpos fsetpos64
+#       endif
+#       ifdef HAS_FTELL64
+#           define ftell ftell64
+#       endif
+#       ifdef HAS_FTELLO64
+#           define ftello ftello64
+#       endif
+#       ifdef HAS_TMPFILE64
+#           define tmpfile tmpfile64
+#       endif
+#   endif
+#   ifdef USE_64_BIT_DBM
+#       ifdef HAS_DBMINIT64
+#           define dbminit dbminit64
+#       endif
+#       ifdef HAS_DBMCLOSE64
+#           define dbmclose dbmclose64
+#       endif
+#       ifdef HAS_FETCH64
+#           define fetch fetch64
+#       endif
+#       ifdef HAS_DELETE64
+#           define delete delete64
+#       endif
+#       ifdef HAS_STORE64
+#           define store store64
+#       endif
+#       ifdef HAS_FIRSTKEY64
+#           define firstkey firstkey64
+#       endif
+#       ifdef HAS_NEXTKEY64
+#           define nextkey nextkey64
+#       endif
+#   endif
+#endif
+
 #ifdef PERL_OBJECT
 typedef I32 (*filter_t) _((CPerlObj*, int, SV *, int));
 #else
@@ -1093,6 +1326,10 @@ typedef I32 (*filter_t) _((int, SV *, int));
 #define FILTER_DATA(idx)          (AvARRAY(PL_rsfp_filters)[idx])
 #define FILTER_ISREADER(idx)      (idx >= AvFILLp(PL_rsfp_filters))
 
+#if defined(__OPEN_VM)
+# include "vmesa/vmesaish.h"
+#endif
+
 #ifdef DOSISH
 # if defined(OS2)
 #   include "os2ish.h"
@@ -1109,7 +1346,11 @@ typedef I32 (*filter_t) _((int, SV *, int));
 #     if defined(MPE)
 #       include "mpeix/mpeixish.h"
 #     else
-#       include "unixish.h"
+#       if defined(__VOS__)
+#         include "vosish.h"
+#       else
+#         include "unixish.h"
+#       endif
 #     endif
 #   endif
 # endif
@@ -1257,8 +1498,10 @@ union any {
 #include "hv.h"
 #include "mg.h"
 #include "scope.h"
+#include "warning.h"
 #include "bytecode.h"
 #include "byterun.h"
+#include "utf8.h"
 
 /* Current curly descriptor */
 typedef struct curcur CURCUR;
@@ -1281,13 +1524,9 @@ struct _sublex_info {
     OP *sub_op;                /* "lex_op" to use */
 };
 
-#ifdef PERL_OBJECT
-struct magic_state {
-    SV* mgs_sv;
-    U32 mgs_flags;
-};
-typedef struct magic_state MGS;
+typedef struct magic_state MGS;        /* struct magic_state defined in mg.c */
 
+#ifdef PERL_OBJECT
 typedef struct {
     I32 len_min;
     I32 len_delta;
@@ -1443,6 +1682,11 @@ Gid_t getegid _((void));
 #define DEBUG_H(a) if (PL_debug & 8192)        a
 #define DEBUG_X(a) if (PL_debug & 16384)       a
 #define DEBUG_D(a) if (PL_debug & 32768)       a
+#  ifdef USE_THREADS
+#    define DEBUG_S(a) if (PL_debug & (1<<16)) a
+#  else
+#    define DEBUG_S(a)
+#  endif
 #else
 #define DEB(a)
 #define DEBUG(a)
@@ -1458,10 +1702,11 @@ Gid_t getegid _((void));
 #define DEBUG_r(a)
 #define DEBUG_x(a)
 #define DEBUG_u(a)
-#define DEBUG_L(a)
+#define DEBUG_S(a)
 #define DEBUG_H(a)
 #define DEBUG_X(a)
 #define DEBUG_D(a)
+#define DEBUG_S(a)
 #endif
 #define YYMAXDEPTH 300
 
@@ -1490,7 +1735,7 @@ double atof _((const char*));
 /* All of these are in stdlib.h or time.h for ANSI C */
 Time_t time();
 struct tm *gmtime(), *localtime();
-#ifdef OEMVS
+#if defined(OEMVS) || defined(__OPEN_VM)
 char *(strchr)(), *(strrchr)();
 char *(strcpy)(), *(strcat)();
 #else
@@ -1902,6 +2147,10 @@ typedef enum {
                                   stuffing into op->op_private */
 #define HINT_INTEGER           0x00000001
 #define HINT_STRICT_REFS       0x00000002
+/* #define HINT_notused4       0x00000004 */
+#define HINT_UTF8              0x00000008
+/* #define HINT_notused10      0x00000010 */
+                               /* Note: 20,40,80 used for NATIVE_HINTS */
 
 #define HINT_BLOCK_SCOPE       0x00000100
 #define HINT_STRICT_SUBS       0x00000200
@@ -1918,6 +2167,8 @@ typedef enum {
 #define HINT_RE_TAINT          0x00100000
 #define HINT_RE_EVAL           0x00200000
 
+#define HINT_FILETEST_ACCESS   0x00400000
+
 /* Various states of an input record separator SV (rs, nrs) */
 #define RsSNARF(sv)   (! SvOK(sv))
 #define RsSIMPLE(sv)  (SvOK(sv) && SvCUR(sv))
@@ -2167,6 +2418,8 @@ EXT MGVTBL vtbl_defelem = {magic_getdefelem,magic_setdefelem,
                                        0,      0,      0};
 
 EXT MGVTBL vtbl_regexp = {0,0,0,0, magic_freeregexp};
+EXT MGVTBL vtbl_regdata = {0, 0, magic_regdata_cnt, 0, 0};
+EXT MGVTBL vtbl_regdatum = {magic_regdatum_get, 0, 0, 0, 0};
 
 #ifdef USE_LOCALE_COLLATE
 EXT MGVTBL vtbl_collxfrm = {0,
@@ -2211,6 +2464,8 @@ EXT MGVTBL vtbl_mutex;
 
 EXT MGVTBL vtbl_defelem;
 EXT MGVTBL vtbl_regexp;
+EXT MGVTBL vtbl_regdata;
+EXT MGVTBL vtbl_regdatum;
 
 #ifdef USE_LOCALE_COLLATE
 EXT MGVTBL vtbl_collxfrm;