While awaiting a good test program to detect the broken gcc.
[p5sagit/p5-mst-13.2.git] / perl.h
diff --git a/perl.h b/perl.h
index 21b8e66..e8c9c1e 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -389,7 +389,7 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
 /* 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)
+#if defined(USE_THREADS) && defined(PTHREAD_H_FIRST) && defined(I_PTHREAD)
 #  include <pthread.h>
 #endif
 
@@ -684,16 +684,16 @@ Free_t   Perl_mfree (Malloc_t where);
 
 #ifdef USE_THREADS
 #  define ERRSV (thr->errsv)
-#  define ERRHV (thr->errhv)
 #  define DEFSV THREADSV(0)
 #  define SAVE_DEFSV save_threadsv(0)
 #else
 #  define ERRSV GvSV(PL_errgv)
-#  define ERRHV GvHV(PL_errgv)
 #  define DEFSV GvSV(PL_defgv)
 #  define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
 #endif /* USE_THREADS */
 
+#define ERRHV GvHV(PL_errgv)   /* XXX unused, here for compatibility */
+
 #ifndef errno
        extern int errno;     /* ANSI allows errno to be an lvalue expr.
                               * For example in multithreaded environments
@@ -1044,7 +1044,7 @@ Free_t   Perl_mfree (Malloc_t where);
 #  define IVSIZE LONGSIZE
 #endif
 #define IV_DIG (BIT_DIGITS(IVSIZE * 8))
-#define UV_DIG (BIT_DIGITS(IVSIZE * 8))
+#define UV_DIG (BIT_DIGITS(UVSIZE * 8))
 
 /*   
  *  The macros INT2PTR and NUM2PTR are (despite their names)
@@ -1422,17 +1422,13 @@ typedef union any ANY;
 
 #include "handy.h"
 
-#ifdef USE_64_BITS
-#   define USE_64_BIT_FILES
-#endif
-
-#if defined(USE_64_BIT_FILES) || defined(USE_LARGE_FILES)
-#   define USE_64_BIT_OFFSETS /* Explicit */
+#if defined(USE_LARGE_FILES)
+#   define USE_64_BIT_RAWIO /* Explicit */
 #   define USE_64_BIT_STDIO
 #endif
 
-#if LSEEKSIZE == 8 && !defined(USE_64_BIT_OFFSETS)
-#   define USE_64_BIT_OFFSETS /* Implicit */
+#if LSEEKSIZE == 8 && !defined(USE_64_BIT_RAWIO)
+#   define USE_64_BIT_RAWIO /* Implicit */
 #endif
 
 /* Do we need FSEEKSIZE? */
@@ -1449,7 +1445,7 @@ typedef union any ANY;
 #define USE_FREOPEN64
 #endif
 
-#ifdef USE_64_BIT_OFFSETS
+#ifdef USE_64_BIT_RAWIO
 #   ifdef HAS_OFF64_T
 #       undef Off_t
 #       define Off_t off64_t
@@ -1458,7 +1454,7 @@ typedef union any ANY;
 #   endif
 /* Most 64-bit environments have defines like _LARGEFILE_SOURCE that
  * will trigger defines like the ones below.  Some 64-bit environments,
- * however, do not. */
+ * however, do not.  Therefore we have to explicitly mix and match. */
 #   if defined(USE_OPEN64)
 #       define open open64
 #   endif
@@ -1616,7 +1612,9 @@ typedef mutex_t           perl_mutex;
 typedef condition_t    perl_cond;
 typedef void *         perl_key;
 #        else /* Posix threads */
-#          include <pthread.h>
+#          ifdef I_PTHREAD
+#            include <pthread.h>
+#          endif
 typedef pthread_t      perl_os_thread;
 typedef pthread_mutex_t        perl_mutex;
 typedef pthread_cond_t perl_cond;
@@ -1934,6 +1932,22 @@ typedef I32 CHECKPOINT;
 #   endif
 #endif
 
+#ifdef IV_IS_QUAD
+#  define UVuf PERL_PRIu64
+#  define IVdf PERL_PRId64
+#  define UVof PERL_PRIo64
+#  define UVxf PERL_PRIx64
+#else
+#   if LONGSIZE == 4
+#       define UVuf "lu"
+#       define IVdf "ld"
+#       define UVof "lo"
+#       define UVxf "lx"
+#   else
+        /* Any good ideas? */
+#   endif
+#endif
+
 /* Used with UV/IV arguments: */
                                        /* XXXX: need to speed it up */
 #define CLUMP_2UV(iv)  ((iv) < 0 ? 0 : (UV)(iv))
@@ -1961,7 +1975,13 @@ Gid_t getegid (void);
 #endif
 
 #ifndef Perl_debug_log
-#define Perl_debug_log PerlIO_stderr()
+#  define Perl_debug_log       PerlIO_stderr()
+#endif
+
+#ifndef Perl_error_log
+#  define Perl_error_log       (PL_stderrgv                    \
+                                ? IoOFP(GvIOp(PL_stderrgv))    \
+                                : PerlIO_stderr())
 #endif
 
 #ifdef DEBUGGING
@@ -3134,12 +3154,21 @@ typedef struct am_table_short AMTS;
 #   include <sys/sem.h>
 #   ifndef HAS_UNION_SEMUN     /* Provide the union semun. */
     union semun {
-       int val;
-       struct semid_ds *buf;
-       unsigned short *array;
+       int             val;
+       struct semid_ds *buf;
+       unsigned short  *array;
     };
 #   endif
 #   ifdef USE_SEMCTL_SEMUN
+#      ifdef IRIX32_SEMUN_BROKEN_BY_GCC
+            union gccbug_semun {
+               int             val;
+               struct semid_ds *buf;
+               unsigned short  *array;
+               char            __dummy[5];
+           };
+#           define semun gccbug_semun
+#      endif
 #       define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun)
 #   else
 #       ifdef USE_SEMCTL_SEMID_DS