This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
integrate change#2904 from maint-5.005
[perl5.git] / perl.h
diff --git a/perl.h b/perl.h
index ed72d40..af64d64 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -8,7 +8,6 @@
  */
 #ifndef H_PERL
 #define H_PERL 1
-#define OVERLOAD
 
 #ifdef PERL_FOR_X2P
 /*
@@ -385,47 +384,30 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
  * library prototypes; we'll use our own in proto.h instead. */
 
 #ifdef MYMALLOC
-
-#   ifdef HIDEMYMALLOC
-#      define malloc  Mymalloc
-#      define calloc  Mycalloc
-#      define realloc Myrealloc
-#      define free    Myfree
-Malloc_t Mymalloc _((MEM_SIZE nbytes));
-Malloc_t Mycalloc _((MEM_SIZE elements, MEM_SIZE size));
-Malloc_t Myrealloc _((Malloc_t where, MEM_SIZE nbytes));
-Free_t   Myfree _((Malloc_t where));
-#   endif
-#   ifdef EMBEDMYMALLOC
-#      define malloc  Perl_malloc
-#      define calloc  Perl_calloc
-#      define realloc Perl_realloc
-/* VMS' external symbols are case-insensitive, and there's already a */
-/* perl_free in perl.h */
-#ifdef VMS
-#      define free    Perl_myfree
-#else
-#      define free    Perl_free
-#endif
+#  ifdef PERL_POLLUTE_MALLOC
+#    define Perl_malloc                malloc
+#    define Perl_calloc                calloc
+#    define Perl_realloc       realloc
+#    define Perl_mfree         free
+#  else
+#    define EMBEDMYMALLOC      /* for compatibility */
+#  endif
 Malloc_t Perl_malloc _((MEM_SIZE nbytes));
 Malloc_t Perl_calloc _((MEM_SIZE elements, MEM_SIZE size));
 Malloc_t Perl_realloc _((Malloc_t where, MEM_SIZE nbytes));
-#ifdef VMS
-Free_t   Perl_myfree _((Malloc_t where));
-#else
-Free_t   Perl_free _((Malloc_t where));
-#endif
-#   endif
-
-#   undef safemalloc
-#   undef safecalloc
-#   undef saferealloc
-#   undef safefree
-#   define safemalloc  malloc
-#   define safecalloc  calloc
-#   define saferealloc realloc
-#   define safefree    free
-
+/* 'mfree' rather than 'free', since there is already a 'perl_free'
+ * that causes clashes with case-insensitive linkers */
+Free_t   Perl_mfree _((Malloc_t where));
+
+#  define safemalloc  Perl_malloc
+#  define safecalloc  Perl_calloc
+#  define saferealloc Perl_realloc
+#  define safefree    Perl_mfree
+#else  /* MYMALLOC */
+#  define safemalloc  safesysmalloc
+#  define safecalloc  safesyscalloc
+#  define saferealloc safesysrealloc
+#  define safefree    safesysfree
 #endif /* MYMALLOC */
 
 #if defined(STANDARD_C) && defined(I_STDDEF)
@@ -855,6 +837,7 @@ Free_t   Perl_free _((Malloc_t where));
 #ifndef Quad_t
 #    if LONGSIZE == 8
 #       define Quad_t  long
+#       define Uquad_t unsigned long
 #       define PERL_QUAD_IS_LONG
 #    endif
 #endif
@@ -862,6 +845,7 @@ Free_t   Perl_free _((Malloc_t where));
 #ifndef Quad_t
 #    if INTSIZE == 8
 #       define Quad_t  int
+#       define Uquad_t unsigned int
 #       define PERL_QUAD_IS_INT
 #    endif
 #endif
@@ -870,6 +854,7 @@ Free_t   Perl_free _((Malloc_t where));
 #    ifdef USE_LONG_LONG /* See above note about LP32. --jhi */
 #       if defined(HAS_LONG_LONG) && LONGLONGSIZE == 8
 #          define Quad_t  long long
+#           define Uquad_t unsigned long long
 #           define PERL_QUAD_IS_LONG_LONG
 #       endif
 #    endif
@@ -886,8 +871,9 @@ Free_t   Perl_free _((Malloc_t where));
 #ifdef Quad_t
 #   define HAS_QUAD
 #   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. */
+    /* Note that if your Quad_t is a typedef (not a #define) you *MUST*
+     * have defined by now Uquad_t yourself because 'unsigned type'
+     * is illegal. */
 #       define Uquad_t unsigned Quad_t
 #   endif
 #endif
@@ -1345,6 +1331,28 @@ typedef I32 (*filter_t) _((int, SV *, int));
 # endif
 #endif         
 
+#ifndef MAXPATHLEN
+#  ifdef PATH_MAX
+#    ifdef _POSIX_PATH_MAX
+#       if PATH_MAX > _POSIX_PATH_MAX
+/* MAXPATHLEN is supposed to include the final null character,
+ * as opposed to PATH_MAX and _POSIX_PATH_MAX. */
+#         define MAXPATHLEN (PATH_MAX+1)
+#       else
+#         define MAXPATHLEN (_POSIX_PATH_MAX+1)
+#       endif
+#    else
+#      define MAXPATHLEN (PATH_MAX+1)
+#    endif
+#  else
+#    ifdef _POSIX_PATH_MAX
+#       define MAXPATHLEN (_POSIX_PATH_MAX+1)
+#    else
+#       define MAXPATHLEN 1024 /* Err on the large side. */
+#    endif
+#  endif
+#endif
+
 #ifndef FUNC_NAME_TO_PTR
 #define FUNC_NAME_TO_PTR(name)         name
 #endif
@@ -1371,6 +1379,10 @@ typedef I32 (*filter_t) _((int, SV *, int));
 #        include "os2thread.h"
 #      else
 #        ifdef I_MACH_CTHREADS
+#          include <mach/cthreads.h>
+#          if defined(__NeXT__) && defined(PERL_POLLUTE_MALLOC)
+#            define MUTEX_INIT_CALLS_MALLOC
+#          endif
 typedef cthread_t      perl_os_thread;
 typedef mutex_t                perl_mutex;
 typedef condition_t    perl_cond;
@@ -1475,8 +1487,19 @@ union any {
 #endif /* USE_THREADS */
 
 /* Work around some cygwin32 problems with importing global symbols */
-#if defined(CYGWIN32) && defined(DLLIMPORT) 
+#if defined(CYGWIN32)
+#  if defined(DLLIMPORT) 
 #   include "cw32imp.h"
+#  endif
+/* USEMYBINMODE
+ *   This symbol, if defined, indicates that the program should
+ *   use the routine my_binmode(FILE *fp, char iotype) to insure
+ *   that a file is in "binary" mode -- that is, that no translation
+ *   of bytes occurs on read or write operations.
+ */
+#  define USEMYBINMODE / **/
+#  define my_binmode(fp, iotype) \
+            (PerlLIO_setmode(PerlIO_fileno(fp), O_BINARY) != -1 ? TRUE : NULL)
 #endif
 
 #include "regexp.h"
@@ -1590,7 +1613,7 @@ typedef I32 CHECKPOINT;
 # define HAS_VTOHS
 # define HAS_HTOVL
 # define HAS_HTOVS
-# if BYTEORDER == 0x4321
+# if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
 #  define vtohl(x)     ((((x)&0xFF)<<24)       \
                        +(((x)>>24)&0xFF)       \
                        +(((x)&0x0000FF00)<<8)  \
@@ -1649,10 +1672,11 @@ Gid_t getgid _((void));
 Gid_t getegid _((void));
 #endif
 
-#ifdef DEBUGGING
 #ifndef Perl_debug_log
 #define Perl_debug_log PerlIO_stderr()
 #endif
+
+#ifdef DEBUGGING
 #undef  YYDEBUG
 #define YYDEBUG 1
 #define DEB(a)                         a
@@ -1775,7 +1799,7 @@ char *getlogin _((void));
 #define UNLINK unlnk
 I32 unlnk _((char*));
 #else
-#define UNLINK unlink
+#define UNLINK PerlLIO_unlink
 #endif
 
 #ifndef HAS_SETREUID
@@ -1815,8 +1839,22 @@ typedef Sighandler_t Sigsave_t;
 #endif
 
 #ifdef MYMALLOC
-#  define MALLOC_INIT MUTEX_INIT(&PL_malloc_mutex)
-#  define MALLOC_TERM MUTEX_DESTROY(&PL_malloc_mutex)
+#  ifdef MUTEX_INIT_CALLS_MALLOC
+#    define MALLOC_INIT                                        \
+       STMT_START {                                    \
+               PL_malloc_mutex = NULL;                 \
+               MUTEX_INIT(&PL_malloc_mutex);           \
+       } STMT_END
+#    define MALLOC_TERM                                        \
+       STMT_START {                                    \
+               perl_mutex tmp = PL_malloc_mutex;       \
+               PL_malloc_mutex = NULL;                 \
+               MUTEX_DESTROY(&tmp);                    \
+       } STMT_END
+#  else
+#    define MALLOC_INIT MUTEX_INIT(&PL_malloc_mutex)
+#    define MALLOC_TERM MUTEX_DESTROY(&PL_malloc_mutex)
+#  endif
 #else
 #  define MALLOC_INIT
 #  define MALLOC_TERM
@@ -1891,6 +1929,10 @@ EXTCONST char PL_no_func[]
 EXTCONST char PL_no_myglob[]
   INIT("\"my\" variable %s can't be in a package");
 
+EXTCONST char PL_uuemap[65]
+  INIT("`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_");
+
+
 #ifdef DOINIT
 EXT char *PL_sig_name[] = { SIG_NAME };
 EXT int   PL_sig_num[]  = { SIG_NUM };
@@ -2129,6 +2171,39 @@ typedef enum {
     XTERMBLOCK
 } expectation;
 
+enum {         /* pass one of these to get_vtbl */
+    want_vtbl_sv,
+    want_vtbl_env,
+    want_vtbl_envelem,
+    want_vtbl_sig,
+    want_vtbl_sigelem,
+    want_vtbl_pack,
+    want_vtbl_packelem,
+    want_vtbl_dbline,
+    want_vtbl_isa,
+    want_vtbl_isaelem,
+    want_vtbl_arylen,
+    want_vtbl_glob,
+    want_vtbl_mglob,
+    want_vtbl_nkeys,
+    want_vtbl_taint,
+    want_vtbl_substr,
+    want_vtbl_vec,
+    want_vtbl_pos,
+    want_vtbl_bm,
+    want_vtbl_fm,
+    want_vtbl_uvar,
+    want_vtbl_defelem,
+    want_vtbl_regexp,
+    want_vtbl_collxfrm,
+    want_vtbl_amagic,
+    want_vtbl_amagicelem,
+#ifdef USE_THREADS
+    want_vtbl_mutex,
+#endif
+    want_vtbl_regdata,
+    want_vtbl_regdatum
+};
 
                                /* Note: the lowest 8 bits are reserved for
                                   stuffing into op->op_private */
@@ -2419,12 +2494,10 @@ EXT MGVTBL PL_vtbl_collxfrm = {0,
                                        0,      0,      0};
 #endif
 
-#ifdef OVERLOAD
 EXT MGVTBL PL_vtbl_amagic =       {0,     magic_setamagic,
                                         0,      0,      magic_setamagic};
 EXT MGVTBL PL_vtbl_amagicelem =   {0,     magic_setamagic,
                                         0,      0,      magic_setamagic};
-#endif /* OVERLOAD */
 
 #else /* !DOINIT */
 
@@ -2463,16 +2536,50 @@ EXT MGVTBL PL_vtbl_regdatum;
 EXT MGVTBL PL_vtbl_collxfrm;
 #endif
 
-#ifdef OVERLOAD
 EXT MGVTBL PL_vtbl_amagic;
 EXT MGVTBL PL_vtbl_amagicelem;
-#endif /* OVERLOAD */
 
 #endif /* !DOINIT */
 
-#ifdef OVERLOAD
+enum {
+  fallback_amg,        abs_amg,
+  bool__amg,   nomethod_amg,
+  string_amg,  numer_amg,
+  add_amg,     add_ass_amg,
+  subtr_amg,   subtr_ass_amg,
+  mult_amg,    mult_ass_amg,
+  div_amg,     div_ass_amg,
+  modulo_amg,  modulo_ass_amg,
+  pow_amg,     pow_ass_amg,
+  lshift_amg,  lshift_ass_amg,
+  rshift_amg,  rshift_ass_amg,
+  band_amg,    band_ass_amg,
+  bor_amg,     bor_ass_amg,
+  bxor_amg,    bxor_ass_amg,
+  lt_amg,      le_amg,
+  gt_amg,      ge_amg,
+  eq_amg,      ne_amg,
+  ncmp_amg,    scmp_amg,
+  slt_amg,     sle_amg,
+  sgt_amg,     sge_amg,
+  seq_amg,     sne_amg,
+  not_amg,     compl_amg,
+  inc_amg,     dec_amg,
+  atan2_amg,   cos_amg,
+  sin_amg,     exp_amg,
+  log_amg,     sqrt_amg,
+  repeat_amg,   repeat_ass_amg,
+  concat_amg,  concat_ass_amg,
+  copy_amg,    neg_amg,
+  to_sv_amg,   to_av_amg,
+  to_hv_amg,   to_gv_amg,
+  to_cv_amg,   iter_amg,    
+  max_amg_code
+  /* Do not leave a trailing comma here.  C9X allows it, C89 doesn't. */
+};
+
+#define NofAMmeth max_amg_code
 
-#define NofAMmeth 58
 #ifdef DOINIT
 EXTCONST char * PL_AMG_names[NofAMmeth] = {
   "fallback",  "abs",                  /* "fallback" should be the first. */
@@ -2503,7 +2610,10 @@ EXTCONST char * PL_AMG_names[NofAMmeth] = {
   "log",       "sqrt",
   "x",         "x=",
   ".",         ".=",
-  "=",         "neg"
+  "=",         "neg",
+  "${}",       "@{}",
+  "%{}",       "*{}",
+  "&{}",       "<>",
 };
 #else
 EXTCONST char * PL_AMG_names[NofAMmeth];
@@ -2533,37 +2643,6 @@ typedef struct am_table_short AMTS;
 #define AMT_AMAGIC_on(amt)     ((amt)->flags |= AMTf_AMAGIC)
 #define AMT_AMAGIC_off(amt)    ((amt)->flags &= ~AMTf_AMAGIC)
 
-enum {
-  fallback_amg,        abs_amg,
-  bool__amg,   nomethod_amg,
-  string_amg,  numer_amg,
-  add_amg,     add_ass_amg,
-  subtr_amg,   subtr_ass_amg,
-  mult_amg,    mult_ass_amg,
-  div_amg,     div_ass_amg,
-  modulo_amg,  modulo_ass_amg,
-  pow_amg,     pow_ass_amg,
-  lshift_amg,  lshift_ass_amg,
-  rshift_amg,  rshift_ass_amg,
-  band_amg,    band_ass_amg,
-  bor_amg,     bor_ass_amg,
-  bxor_amg,    bxor_ass_amg,
-  lt_amg,      le_amg,
-  gt_amg,      ge_amg,
-  eq_amg,      ne_amg,
-  ncmp_amg,    scmp_amg,
-  slt_amg,     sle_amg,
-  sgt_amg,     sge_amg,
-  seq_amg,     sne_amg,
-  not_amg,     compl_amg,
-  inc_amg,     dec_amg,
-  atan2_amg,   cos_amg,
-  sin_amg,     exp_amg,
-  log_amg,     sqrt_amg,
-  repeat_amg,   repeat_ass_amg,
-  concat_amg,  concat_ass_amg,
-  copy_amg,    neg_amg
-};
 
 /*
  * some compilers like to redefine cos et alia as faster
@@ -2596,8 +2675,6 @@ enum {
 #   endif
 #endif /* _FASTMATH */
 
-#endif /* OVERLOAD */
-
 #define PERLDB_ALL     0x3f            /* No _NONAME, _GOTO */
 #define PERLDBf_SUB    0x01            /* Debug sub enter/exit. */
 #define PERLDBf_LINE   0x02            /* Keep line #. */
@@ -2690,4 +2767,37 @@ enum {
 #   endif
 #endif
 
+/* Mention
+
+   INSTALL_USR_BIN_PERL
+
+   I_SYS_MMAN
+   HAS_MMAP
+   HAS_MUNMAP
+   HAS_MPROTECT
+   HAS_MSYNC
+   HAS_MADVISE
+   Mmap_t
+
+   here so that Configure picks them up. */
+
+#ifdef IAMSUID
+
+#ifdef I_SYS_STATVFS
+#   include <sys/statvfs.h>     /* for f?statvfs() */
+#endif
+#ifdef I_SYS_MOUNT
+#   include <sys/mount.h>       /* for *BSD f?statfs() */
+#endif
+#ifdef I_MNTENT
+#   include <mntent.h>          /* for getmntent() */
+#endif
+
+#endif /* IAMSUID */
+
+/* and finally... */
+#define PERL_PATCHLEVEL_H_IMPLICIT
+#include "patchlevel.h"
+#undef PERL_PATCHLEVEL_H_IMPLICIT
+
 #endif /* Include guard */