Epoc update
[p5sagit/p5-mst-13.2.git] / perl.h
diff --git a/perl.h b/perl.h
index b26d6f4..8f19950 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -168,8 +168,8 @@ class CPerlObj;
 #define aTHXo_                 this,
 #define PERL_OBJECT_THIS       aTHXo
 #define PERL_OBJECT_THIS_      aTHXo_
-#define dTHXoa(a)              pTHXo = a
-#define dTHXo                  dTHXoa(PERL_GET_THX)
+#define dTHXoa(a)              pTHXo = (CPerlObj*)a
+#define dTHXo                  pTHXo = PERL_GET_THX
 
 #define pTHXx          void
 #define pTHXx_
@@ -184,15 +184,16 @@ struct perl_thread;
 #    define pTHX       register struct perl_thread *thr
 #    define aTHX       thr
 #    define dTHR       dNOOP
+#    define dTHXa(a)   pTHX = (struct perl_thread*)a
 #  else
 #    ifndef MULTIPLICITY
 #      define MULTIPLICITY
 #    endif
 #    define pTHX       register PerlInterpreter *my_perl
 #    define aTHX       my_perl
+#    define dTHXa(a)   pTHX = (PerlInterpreter*)a
 #  endif
-#  define dTHXa(a)     pTHX = a
-#  define dTHX         dTHXa(PERL_GET_THX)
+#  define dTHX         pTHX = PERL_GET_THX
 #  define pTHX_                pTHX,
 #  define aTHX_                aTHX,
 #  define pTHX_1       2       
@@ -1078,6 +1079,11 @@ typedef UVTYPE UV;
 #define PTR2IV(p)      INT2PTR(IV,p)
 #define PTR2UV(p)      INT2PTR(UV,p)
 #define PTR2NV(p)      NUM2PTR(NV,p)
+#if PTRSIZE == LONGSIZE 
+#  define PTR2ul(p)    (unsigned long)(p)
+#else
+#  define PTR2ul(p)    INT2PTR(unsigned long,p)        
+#endif
   
 #ifdef USE_LONG_DOUBLE
 #  if !(defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE))
@@ -1163,6 +1169,18 @@ typedef NVTYPE NV;
 #   ifdef LDBL_MANT_DIG
 #       define NV_MANT_DIG LDBL_MANT_DIG
 #   endif
+#   ifdef LDBL_MAX
+#       define NV_MAX LDBL_MAX
+#       define NV_MIN LDBL_MIN
+#   else
+#       ifdef HUGE_VALL
+#           define NV_MAX HUGE_VALL
+#       else
+#           ifdef HUGE_VAL
+#               define NV_MAX ((NV)HUGE_VAL)
+#           endif
+#       endif
+#   endif
 #   ifdef HAS_SQRTL
 #       define Perl_cos cosl
 #       define Perl_sin sinl
@@ -1199,6 +1217,14 @@ typedef NVTYPE NV;
 #   ifdef DBL_MANT_DIG
 #       define NV_MANT_DIG DBL_MANT_DIG
 #   endif
+#   ifdef DBL_MAX
+#       define NV_MAX DBL_MAX
+#       define NV_MIN DBL_MIN
+#   else
+#       ifdef HUGE_VAL
+#           define NV_MAX HUGE_VAL
+#       endif
+#   endif
 #   define Perl_cos cos
 #   define Perl_sin sin
 #   define Perl_sqrt sqrt
@@ -1219,15 +1245,22 @@ typedef NVTYPE NV;
 
 #if !defined(Perl_atof) && defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
 #   if !defined(Perl_atof) && defined(HAS_STRTOLD) 
-#       define Perl_atof(s) strtold(s, (char**)NULL)
+#       define Perl_atof(s) (NV)strtold(s, (char**)NULL)
 #   endif
 #   if !defined(Perl_atof) && defined(HAS_ATOLF)
-#       define Perl_atof atolf
+#       define Perl_atof (NV)atolf
+#   endif
+#   if !defined(Perl_atof) && defined(PERL_SCNfldbl)
+#       define Perl_atof PERL_SCNfldbl
+#       define Perl_atof2(s,f) sscanf((s), "%"PERL_SCNfldbl, &(f))
 #   endif
 #endif
 #if !defined(Perl_atof)
 #   define Perl_atof atof /* we assume atof being available anywhere */
 #endif
+#if !defined(Perl_atof2)
+#   define Perl_atof2(s,f) ((f) = (NV)Perl_atof(s))
+#endif
 
 /* Previously these definitions used hardcoded figures. 
  * It is hoped these formula are more portable, although
@@ -1400,25 +1433,10 @@ typedef NVTYPE NV;
 
 #ifdef UV_IS_QUAD
 
-#  ifdef UQUAD_MAX
-#    define PERL_UQUAD_MAX ((UV)UQUAD_MAX)
-#  else
 #    define PERL_UQUAD_MAX     (~(UV)0)
-#  endif
-
-#  define PERL_UQUAD_MIN ((UV)0)
-
-#  ifdef QUAD_MAX
-#    define PERL_QUAD_MAX ((IV)QUAD_MAX)
-#  else
+#    define PERL_UQUAD_MIN     ((UV)0)
 #    define PERL_QUAD_MAX      ((IV) (PERL_UQUAD_MAX >> 1))
-#  endif
-
-#  ifdef QUAD_MIN
-#    define PERL_QUAD_MIN ((IV)QUAD_MIN)
-#  else
 #    define PERL_QUAD_MIN      (-PERL_QUAD_MAX - ((3 & -1) == 3))
-#  endif
 
 #endif
 
@@ -1612,11 +1630,6 @@ typedef struct ptr_tbl PTR_TBL_t;
 # endif
 #endif         
 
-#ifdef PERL_MICRO
-#   undef HAS_PASSWD
-#   undef HAS_GROUP
-#endif
-
 #ifndef PERL_SYS_INIT3
 #  define PERL_SYS_INIT3(argvp,argcp,envp) PERL_SYS_INIT(argvp,argcp)
 #endif
@@ -1805,9 +1818,25 @@ typedef pthread_key_t    perl_key;
 #  endif 
 #endif
 
+#ifndef UVf
+#  ifdef CHECK_FORMAT
+#    define UVf UVuf
+#  else
+#    define UVf "Vu"
+#  endif 
+#endif
+
+#ifndef VDf
+#  ifdef CHECK_FORMAT
+#    define VDf "p"
+#  else
+#    define VDf "vd"
+#  endif 
+#endif
+
 /* Some unistd.h's give a prototype for pause() even though
    HAS_PAUSE ends up undefined.  This causes the #define
-   below to be rejected by the compmiler.  Sigh.
+   below to be rejected by the compiler.  Sigh.
 */
 #ifdef HAS_PAUSE
 #define Pause  pause
@@ -2027,6 +2056,7 @@ Gid_t getegid (void);
 
 #ifndef Perl_error_log
 #  define Perl_error_log       (PL_stderrgv                    \
+                                && GvIOp(PL_stderrgv)          \
                                 && IoOFP(GvIOp(PL_stderrgv))   \
                                 ? IoOFP(GvIOp(PL_stderrgv))    \
                                 : PerlIO_stderr())
@@ -2242,7 +2272,7 @@ typedef OP* (CPERLscope(*PPADDR_t)[]) (pTHX);
 #    define environ (*environ_pointer)
 EXT char *** environ_pointer;
 #  else
-#    if defined(__APPLE__)
+#    if defined(__APPLE__) && defined(PERL_CORE)
 #      include <crt_externs.h> /* for the env array */
 #      define environ (*_NSGetEnviron())
 #    endif
@@ -2253,7 +2283,7 @@ EXT char *** environ_pointer;
 #    if !defined(DONT_DECLARE_STD) || \
         (defined(__svr4__) && defined(__GNUC__) && defined(sun)) || \
         defined(__sgi) || \
-        defined(__DGUX) || defined(EPOC)
+        defined(__DGUX) 
 extern char ** environ;        /* environment variables supplied via exec */
 #    endif
 #  endif
@@ -2814,10 +2844,14 @@ EXT MGVTBL PL_vtbl_envelem =    {0,     MEMBER_TO_FPTR(Perl_magic_setenv),
                                        0,      MEMBER_TO_FPTR(Perl_magic_clearenv),
                                                        0};
 EXT MGVTBL PL_vtbl_sig =       {0,     0,               0, 0, 0};
+#ifdef PERL_MICRO
+EXT MGVTBL PL_vtbl_sigelem =   {0,     0,               0, 0, 0};
+#else
 EXT MGVTBL PL_vtbl_sigelem =   {MEMBER_TO_FPTR(Perl_magic_getsig),
                                        MEMBER_TO_FPTR(Perl_magic_setsig),
                                        0,      MEMBER_TO_FPTR(Perl_magic_clearsig),
                                                        0};
+#endif
 EXT MGVTBL PL_vtbl_pack =      {0,     0,      MEMBER_TO_FPTR(Perl_magic_sizepack),    MEMBER_TO_FPTR(Perl_magic_wipepack),
                                                        0};
 EXT MGVTBL PL_vtbl_packelem =  {MEMBER_TO_FPTR(Perl_magic_getpack),
@@ -2867,7 +2901,8 @@ EXT MGVTBL PL_vtbl_defelem = {MEMBER_TO_FPTR(Perl_magic_getdefelem),MEMBER_TO_FP
 
 EXT MGVTBL PL_vtbl_regexp = {0,0,0,0, MEMBER_TO_FPTR(Perl_magic_freeregexp)};
 EXT MGVTBL PL_vtbl_regdata = {0, 0, MEMBER_TO_FPTR(Perl_magic_regdata_cnt), 0, 0};
-EXT MGVTBL PL_vtbl_regdatum = {MEMBER_TO_FPTR(Perl_magic_regdatum_get), 0, 0, 0, 0};
+EXT MGVTBL PL_vtbl_regdatum = {MEMBER_TO_FPTR(Perl_magic_regdatum_get),
+                              MEMBER_TO_FPTR(Perl_magic_regdatum_set), 0, 0, 0};
 
 #ifdef USE_LOCALE_COLLATE
 EXT MGVTBL PL_vtbl_collxfrm = {0,
@@ -3110,8 +3145,20 @@ typedef struct am_table_short AMTS;
        ((PL_hints & HINT_LOCALE) && \
          PL_numeric_radix && (c) == PL_numeric_radix)
 
-#define RESTORE_NUMERIC_LOCAL()                if ((PL_hints & HINT_LOCALE) && PL_numeric_standard) SET_NUMERIC_LOCAL()
-#define RESTORE_NUMERIC_STANDARD()     if ((PL_hints & HINT_LOCALE) && PL_numeric_local) SET_NUMERIC_STANDARD()
+#define STORE_NUMERIC_LOCAL_SET_STANDARD() \
+       bool was_local = (PL_hints & HINT_LOCALE) && PL_numeric_local; \
+       if (!was_local) SET_NUMERIC_STANDARD();
+
+#define STORE_NUMERIC_STANDARD_SET_LOCAL() \
+       bool was_standard = !(PL_hints & HINT_LOCALE) || PL_numeric_standard; \
+       if (!was_standard) SET_NUMERIC_LOCAL();
+
+#define RESTORE_NUMERIC_LOCAL() \
+       if (was_local) SET_NUMERIC_LOCAL();
+
+#define RESTORE_NUMERIC_STANDARD() \
+       if (was_standard) SET_NUMERIC_STANDARD();
+
 #define Atof                           my_atof
 
 #else /* !USE_LOCALE_NUMERIC */
@@ -3119,6 +3166,8 @@ typedef struct am_table_short AMTS;
 #define SET_NUMERIC_STANDARD()         /**/
 #define SET_NUMERIC_LOCAL()            /**/
 #define IS_NUMERIC_RADIX(c)            (0)
+#define STORE_NUMERIC_LOCAL_SET_STANDARD()     /**/
+#define STORE_NUMERIC_STANDARD_SET_LOCAL()     /**/
 #define RESTORE_NUMERIC_LOCAL()                /**/
 #define RESTORE_NUMERIC_STANDARD()     /**/
 #define Atof                           Perl_atof
@@ -3339,6 +3388,10 @@ typedef struct am_table_short AMTS;
 
 #endif /* IAMSUID */
 
+#ifdef I_LIBUTIL
+#   include <libutil.h>                /* setproctitle() in some FreeBSDs */
+#endif
+
 /* and finally... */
 #define PERL_PATCHLEVEL_H_IMPLICIT
 #include "patchlevel.h"
@@ -3365,6 +3418,10 @@ typedef struct am_table_short AMTS;
    I_SYSMMAN
    Mmap_t
 
+   NVef
+   NVff
+   NVgf
+
    so that Configure picks them up. */
 
 #endif /* Include guard */