Introduces SvREPADTMP(sv) that marks a repad SvIV as a offset
[p5sagit/p5-mst-13.2.git] / perl.h
diff --git a/perl.h b/perl.h
index f2f0eda..a699fd1 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -34,8 +34,8 @@
 /* XXX This next guard can disappear if the sources are revised
    to use USE_5005THREADS throughout. -- A.D  1/6/2000
 */
-#if defined(USE_ITHREADS) && defined(USE_THREADS)
-#  include "error: USE_ITHREADS and USE_THREADS are incompatible"
+#if defined(USE_ITHREADS) && defined(USE_5005THREADS)
+#  include "error: USE_ITHREADS and USE_5005THREADS are incompatible"
 #endif
 
 /* See L<perlguts/"The Perl API"> for detailed notes on
@@ -47,7 +47,7 @@
 #  endif
 #endif
 
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 #  ifndef PERL_IMPLICIT_CONTEXT
 #    define PERL_IMPLICIT_CONTEXT
 #  endif
@@ -179,7 +179,7 @@ class CPerlObj;
 #else /* !PERL_OBJECT */
 
 #ifdef PERL_IMPLICIT_CONTEXT
-#  ifdef USE_THREADS
+#  ifdef USE_5005THREADS
 struct perl_thread;
 #    define pTHX       register struct perl_thread *thr
 #    define aTHX       thr
@@ -438,10 +438,16 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
 #  endif
 #endif
 
+/* Use the reentrant APIs like localtime_r and getpwent_r */
+/* Win32 has naturally threadsafe libraries, no need to use any _r variants. */
+#if defined(USE_ITHREADS) && !defined(USE_REENTRANT_API) && !defined(WIN32)
+#   define USE_REENTRANT_API
+#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(USE_ITHREADS)) \
+#if (defined(USE_5005THREADS) || defined(USE_ITHREADS)) \
     && defined(PTHREAD_H_FIRST) && defined(I_PTHREAD)
 #  include <pthread.h>
 #endif
@@ -752,23 +758,23 @@ typedef struct perl_mstats perl_mstats_t;
 #  define _SOCKADDR_LEN
 #endif
 
-#if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */
+#if defined(HAS_SOCKET) && !defined(VMS) && !defined(WIN32) /* VMS/WIN32 handle sockets via vmsish.h/win32.h */
 # include <sys/socket.h>
 # if defined(USE_SOCKS) && defined(I_SOCKS)
 #   if !defined(INCLUDE_PROTOTYPES)
 #       define INCLUDE_PROTOTYPES /* for <socks.h> */
 #       define PERL_SOCKS_NEED_PROTOTYPES
 #   endif
-#   ifdef USE_THREADS
+#   ifdef USE_5005THREADS
 #       define PERL_USE_THREADS /* store our value */
-#       undef USE_THREADS
+#       undef USE_5005THREADS
 #   endif
 #   include <socks.h>
-#   ifdef USE_THREADS
-#       undef USE_THREADS /* socks.h does this on its own */
+#   ifdef USE_5005THREADS
+#       undef USE_5005THREADS /* socks.h does this on its own */
 #   endif
 #   ifdef PERL_USE_THREADS
-#       define USE_THREADS /* restore our value */
+#       define USE_5005THREADS /* restore our value */
 #       undef PERL_USE_THREADS
 #   endif
 #   ifdef PERL_SOCKS_NEED_PROTOTYPES /* keep cpp space clean */
@@ -809,7 +815,7 @@ int sockatmark(int);
 #   define SETERRNO(errcode,vmserrcode) (errno = (errcode))
 #endif
 
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 #  define ERRSV (thr->errsv)
 #  define DEFSV THREADSV(0)
 #  define SAVE_DEFSV save_threadsv(0)
@@ -817,7 +823,7 @@ int sockatmark(int);
 #  define ERRSV GvSV(PL_errgv)
 #  define DEFSV GvSV(PL_defgv)
 #  define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
-#endif /* USE_THREADS */
+#endif /* USE_5005THREADS */
 
 #define ERRHV GvHV(PL_errgv)   /* XXX unused, here for compatibility */
 
@@ -1066,6 +1072,10 @@ int sockatmark(int);
 #undef UV
 #endif
 
+#ifdef SPRINTF_E_BUG
+#  define sprintf UTS_sprintf_wrap
+#endif
+
 /* Configure gets this right but the UTS compiler gets it wrong.
    -- Hal Morris <hom00@utsglobal.com> */
 #ifdef UTS
@@ -1131,23 +1141,9 @@ typedef UVTYPE UV;
 #  endif
 #endif
 
-/*
-  I've tracked down a weird bug in Perl5.6.1 to the UTS compiler's
-  mishandling of MY_UV_MAX in util.c.  It is defined as
-    #ifndef MY_UV_MAX
-    #  define MY_UV_MAX ((UV)IV_MAX * (UV)2 + (UV)1)
-    #endif
-  The compiler handles {double floating point value} >= MY_UV_MAX as if
-  MY_UV_MAX were the signed integer -1.  In fact it will do the same
-  thing with (UV)(0xffffffff), in place of MY_UV_MAX, though 0xffffffff
-  *without* the typecast to UV works fine.
-
-  hom00@utsglobal.com (Hal Morris) 2001-05-02
-
-  */
-
-#ifdef UTS
-#  define MY_UV_MAX 0xffffffff 
+#if defined(uts) || defined(UTS)
+#      undef UV_MAX
+#      define UV_MAX (4294967295u)
 #endif
 
 #define IV_DIG (BIT_DIGITS(IVSIZE * 8))
@@ -1275,6 +1271,21 @@ typedef NVTYPE NV;
 #   ifdef LDBL_MANT_DIG
 #       define NV_MANT_DIG LDBL_MANT_DIG
 #   endif
+#   ifdef LDBL_MIN
+#       define NV_MIN LDBL_MIN
+#   endif
+#   ifdef LDBL_MAX
+#       define NV_MAX LDBL_MAX
+#   endif
+#   ifdef LDBL_MIN_10_EXP
+#       define NV_MIN_10_EXP LDBL_MIN_10_EXP
+#   endif
+#   ifdef LDBL_MAX_10_EXP
+#       define NV_MAX_10_EXP LDBL_MAX_10_EXP
+#   endif
+#   ifdef LDBL_EPSILON
+#       define NV_EPSILON LDBL_EPSILON
+#   endif
 #   ifdef LDBL_MAX
 #       define NV_MAX LDBL_MAX
 #       define NV_MIN LDBL_MIN
@@ -1309,13 +1320,14 @@ typedef NVTYPE NV;
 #   else
 #       define Perl_frexp(x,y) ((long double)frexp((double)(x),y))
 #   endif
-#   ifdef HAS_ISNANL
-#       define Perl_isnan(x) isnanl(x)
-#   else
-#       ifdef HAS_ISNAN
-#           define Perl_isnan(x) isnan((double)(x))
-#       else
-#           define Perl_isnan(x) ((x)!=(x))
+#   ifndef Perl_isinf
+#       ifdef HAS_ISNANL
+#           define Perl_isnan(x) isnanl(x)
+#       endif
+#   endif
+#   ifndef Perl_isinf
+#       ifdef HAS_FINITEL
+#           define Perl_isinf(x) !(finitel(x)||Perl_isnan(x))
 #       endif
 #   endif
 #else
@@ -1323,6 +1335,21 @@ typedef NVTYPE NV;
 #   ifdef DBL_MANT_DIG
 #       define NV_MANT_DIG DBL_MANT_DIG
 #   endif
+#   ifdef DBL_MIN
+#       define NV_MIN DBL_MIN
+#   endif
+#   ifdef DBL_MAX
+#       define NV_MAX DBL_MAX
+#   endif
+#   ifdef DBL_MIN_10_EXP
+#       define NV_MIN_10_EXP DBL_MIN_10_EXP
+#   endif
+#   ifdef DBL_MAX_10_EXP
+#       define NV_MAX_10_EXP DBL_MAX_10_EXP
+#   endif
+#   ifdef DBL_EPSILON
+#       define NV_EPSILON DBL_EPSILON
+#   endif
 #   ifdef DBL_MAX
 #       define NV_MAX DBL_MAX
 #       define NV_MIN DBL_MIN
@@ -1342,10 +1369,139 @@ typedef NVTYPE NV;
 #   define Perl_fmod fmod
 #   define Perl_modf(x,y) modf(x,y)
 #   define Perl_frexp(x,y) frexp(x,y)
+#endif
+
+/* rumor has it that Win32 has _fpclass() */
+
+#if !defined(Perl_fp_class) && (defined(HAS_FPCLASS)||defined(HAS_FPCLASSL))
+#    ifdef I_IEEFP
+#        include <ieeefp.h>
+#    endif
+#    ifdef I_FP
+#        include <fp.h>
+#    endif
+#    if defined(USE_LONG_DOUBLE) && defined(HAS_FPCLASSL)
+#        define Perl_fp_class()                fpclassl(x)
+#    else
+#        define Perl_fp_class()                fpclass(x)
+#    endif
+#    define Perl_fp_class_snan(x)      (Perl_fp_class(x)==FP_CLASS_SNAN)
+#    define Perl_fp_class_qnan(x)      (Perl_fp_class(x)==FP_CLASS_QNAN)
+#    define Perl_fp_class_nan(x)       (Perl_fp_class(x)==FP_CLASS_SNAN||Perl_fp_class(x)==FP_CLASS_QNAN)
+#    define Perl_fp_class_ninf(x)      (Perl_fp_class(x)==FP_CLASS_NINF)
+#    define Perl_fp_class_pinf(x)      (Perl_fp_class(x)==FP_CLASS_PINF)
+#    define Perl_fp_class_inf(x)       (Perl_fp_class(x)==FP_CLASS_NINF||Perl_fp_class(x)==FP_CLASS_PINF)
+#    define Perl_fp_class_nnorm(x)     (Perl_fp_class(x)==FP_CLASS_NNORM)
+#    define Perl_fp_class_pnorm(x)     (Perl_fp_class(x)==FP_CLASS_PNORM)
+#    define Perl_fp_class_norm(x)      (Perl_fp_class(x)==FP_CLASS_NNORM||Perl_fp_class(x)==FP_CLASS_PNORM)
+#    define Perl_fp_class_ndenorm(x)   (Perl_fp_class(x)==FP_CLASS_NDENORM)
+#    define Perl_fp_class_pdenorm(x)   (Perl_fp_class(x)==FP_CLASS_PDENORM)
+#    define Perl_fp_class_denorm(x)    (Perl_fp_class(x)==FP_CLASS_NDENORM||Perl_fp_class(x)==FP_CLASS_PDENORM)
+#    define Perl_fp_class_nzero(x)     (Perl_fp_class(x)==FP_CLASS_NZERO)
+#    define Perl_fp_class_pzero(x)     (Perl_fp_class(x)==FP_CLASS_PZERO)
+#    define Perl_fp_class_zero(x)      (Perl_fp_class(x)==FP_CLASS_NZERO||Perl_fp_class(x)==FP_CLASS_PZERO)
+#endif
+
+#if !defined(Perl_fp_class) && defined(HAS_FP_CLASS)
+#    include <math.h>
+#    if !defined(FP_SNAN) && defined(I_FP_CLASS)
+#        include <fp_class.h>
+#    endif
+#    define Perl_fp_class(x)           fp_class(x)
+#    define Perl_fp_class_snan(x)      (fp_class(x)==FP_SNAN)
+#    define Perl_fp_class_qnan(x)      (fp_class(x)==FP_QNAN)
+#    define Perl_fp_class_nan(x)       (fp_class(x)==FP_SNAN||fp_class(x)==FP_QNAN)
+#    define Perl_fp_class_ninf(x)      (fp_class(x)==FP_NEG_INF)
+#    define Perl_fp_class_pinf(x)      (fp_class(x)==FP_POS_INF)
+#    define Perl_fp_class_inf(x)       (fp_class(x)==FP_NEG_INF||fp_class(x)==FP_POS_INF)
+#    define Perl_fp_class_nnorm(x)     (fp_class(x)==FP_NEG_NORM)
+#    define Perl_fp_class_pnorm(x)     (fp_class(x)==FP_POS_NORM)
+#    define Perl_fp_class_norm(x)      (fp_class(x)==FP_NEG_NORM||fp_class(x)==FP_POS_NORM)
+#    define Perl_fp_class_ndenorm(x)   (fp_class(x)==FP_NEG_DENORM)
+#    define Perl_fp_class_pdenorm(x)   (fp_class(x)==FP_POS_DENORM)
+#    define Perl_fp_class_denorm(x)    (fp_class(x)==FP_NEG_DENORM||fp_class(x)==FP_POS_DENORM)
+#    define Perl_fp_class_nzero(x)     (fp_class(x)==FP_NEG_ZERO)
+#    define Perl_fp_class_pzero(x)     (fp_class(x)==FP_POS_ZERO)
+#    define Perl_fp_class_zero(x)      (fp_class(x)==FP_NEG_ZERO||fp_class(x)==FP_POS_ZERO)
+#endif
+
+#if !defined(Perl_fp_class) && defined(HAS_FPCLASSIFY)
+#    include <math.h>
+#    define Perl_fp_class(x)           fpclassify(x)
+#    define Perl_fp_class_nan(x)       (fp_classify(x)==FP_SNAN|FP|_fp_classify(x)==QNAN)
+#    define Perl_fp_class_inf(x)       (fp_classify(x)==FP_INFINITE)
+#    define Perl_fp_class_norm(x)      (fp_classify(x)==FP_NORMAL)
+#    define Perl_fp_class_denorm(x)    (fp_classify(x)==FP_SUBNORMAL)
+#    define Perl_fp_class_zero(x)      (fp_classify(x)==FP_ZERO)
+#endif
+
+#if !defined(Perl_fp_class) && defined(HAS_CLASS)
+#    include <math.h>
+#    ifndef _cplusplus
+#        define Perl_fp_class(x)       class(x)
+#    else
+#        define Perl_fp_class(x)       _class(x)
+#    endif
+#    define Perl_fp_class_snan(x)      (Perl_fp_class(x)==FP_NANS)
+#    define Perl_fp_class_qnan(x)      (Perl_fp_class(x)==FP_NANQ)
+#    define Perl_fp_class_nan(x)       (Perl_fp_class(x)==FP_SNAN||Perl_fp_class(x)==FP_QNAN)
+#    define Perl_fp_class_ninf(x)      (Perl_fp_class(x)==FP_MINUS_INF)
+#    define Perl_fp_class_pinf(x)      (Perl_fp_class(x)==FP_PLUS_INF)
+#    define Perl_fp_class_inf(x)       (Perl_fp_class(x)==FP_MINUS_INF||Perl_fp_class(x)==FP_PLUS_INF)
+#    define Perl_fp_class_nnorm(x)     (Perl_fp_class(x)==FP_MINUS_NORM)
+#    define Perl_fp_class_pnorm(x)     (Perl_fp_class(x)==FP_PLUS_NORM)
+#    define Perl_fp_class_norm(x)      (Perl_fp_class(x)==FP_MINUS_NORM||Perl_fp_class(x)==FP_PLUS_NORM)
+#    define Perl_fp_class_ndenorm(x)   (Perl_fp_class(x)==FP_MINUS_DENORM)
+#    define Perl_fp_class_pdenorm(x)   (Perl_fp_class(x)==FP_PLUS_DENORM)
+#    define Perl_fp_class_denorm(x)    (Perl_fp_class(x)==FP_MINUS_DENORM||Perl_fp_class(x)==FP_PLUS_DENORM)
+#    define Perl_fp_class_nzero(x)     (Perl_fp_class(x)==FP_MINUS_ZERO)
+#    define Perl_fp_class_pzero(x)     (Perl_fp_class(x)==FP_PLUS_ZERO)
+#    define Perl_fp_class_zero(x)      (Perl_fp_class(x)==FP_MINUS_ZERO||Perl_fp_class(x)==FP_PLUS_ZERO)
+#endif
+
+/* rumor has it that Win32 has _isnan() */
+
+#ifndef Perl_isnan
 #   ifdef HAS_ISNAN
-#       define Perl_isnan(x) isnan(x)
+#       define Perl_isnan(x) isnan((NV)x)
 #   else
-#       define Perl_isnan(x) ((x)!=(x))
+#       ifdef Perl_fp_class_nan
+#           define Perl_isnan(x) Perl_fp_class_nan(x)
+#       else
+#           ifdef HAS_UNORDERED
+#               define Perl_isnan(x) unordered((x), 0.0)
+#           else
+#               define Perl_isnan(x) ((x)!=(x))
+#           endif
+#       endif
+#   endif
+#endif
+
+#ifndef Perl_isinf
+#   ifdef HAS_ISINF
+#       define Perl_isinf(x) isinf((NV)x)
+#   else
+#       ifdef Perl_fp_class_inf
+#           define Perl_isinf(x) Perl_fp_class_inf(x)
+#       else
+#           define Perl_isinf(x) ((x)==NV_INF)
+#       endif
+#   endif
+#endif
+
+#ifndef Perl_isfinite
+#   ifdef HAS_FINITE
+#       define Perl_isfinite(x) finite((NV)x)
+#   else
+#       ifdef HAS_ISFINITE
+#           define Perl_isfinite(x) isfinite(x)
+#       else
+#           ifdef Perl_fp_class_finite
+#               define Perl_isfinite(x) Perl_fp_class_finite(x)
+#           else
+#               define Perl_isfinite(x) !(Perl_is_inf(x)||Perl_is_nan(x))
+#           endif
+#       endif
 #   endif
 #endif
 
@@ -1558,8 +1714,11 @@ typedef struct pvop PVOP;
 typedef struct loop LOOP;
 
 typedef struct interpreter PerlInterpreter;
-#ifdef UTS
-#   define STRUCT_SV perl_sv /* Amdahl's <ksync.h> has struct sv */
+
+/* Amdahl's <ksync.h> has struct sv */
+/* SGI's <sys/sema.h> has struct sv */
+#if defined(UTS) || defined(__sgi)
+#   define STRUCT_SV perl_sv
 #else
 #   define STRUCT_SV sv
 #endif
@@ -1761,10 +1920,12 @@ typedef struct ptr_tbl PTR_TBL_t;
 #      include <floatingpoint.h>
 #    endif
 #    define PERL_FPU_INIT fpsetmask(0);
-#  elif PERL_IGNORE_FPUSIG
-#    define PERL_FPU_INIT signal(PERL_IGNORE_FPUSIG, SIG_IGN);
 #  else
-#    define PERL_FPU_INIT
+#    if defined(SIGFPE) && defined(SIG_IGN)
+#      define PERL_FPU_INIT signal(SIGFPE, SIG_IGN);
+#    else
+#      define PERL_FPU_INIT
+#    endif
 #  endif
 #endif
 
@@ -1795,14 +1956,14 @@ typedef struct ptr_tbl PTR_TBL_t;
 #endif
 
 /*
- * USE_THREADS needs to be after unixish.h as <pthread.h> includes
+ * USE_5005THREADS needs to be after unixish.h as <pthread.h> includes
  * <sys/signal.h> which defines NSIG - which will stop inclusion of <signal.h>
  * this results in many functions being undeclared which bothers C++
  * May make sense to have threads after "*ish.h" anyway
  */
 
-#if defined(USE_THREADS) || defined(USE_ITHREADS)
-#  if defined(USE_THREADS)
+#if defined(USE_5005THREADS) || defined(USE_ITHREADS)
+#  if defined(USE_5005THREADS)
    /* pending resolution of licensing issues, we avoid the erstwhile
     * atomic.h everywhere */
 #  define EMULATE_ATOMIC_REFCOUNTS
@@ -1841,7 +2002,7 @@ typedef pthread_key_t     perl_key;
 #    endif /* WIN32 */
 #  endif /* FAKE_THREADS */
 #endif /* NETWARE */
-#endif /* USE_THREADS || USE_ITHREADS */
+#endif /* USE_5005THREADS || USE_ITHREADS */
 
 #ifdef WIN32
 #  include "win32.h"
@@ -1902,6 +2063,7 @@ typedef pthread_key_t     perl_key;
 
 /* flags in PL_exit_flags for nature of exit() */
 #define PERL_EXIT_EXPECTED     0x01
+#define PERL_EXIT_DESTRUCT_END  0x02  /* Run END in perl_destruct */
 
 #ifndef MEMBER_TO_FPTR
 #  define MEMBER_TO_FPTR(name)         name
@@ -1944,7 +2106,7 @@ typedef pthread_key_t     perl_key;
 #endif
 
 #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_GET_THX)
-#  ifdef USE_THREADS
+#  ifdef USE_5005THREADS
 #    define PERL_GET_THX               ((struct perl_thread *)PERL_GET_CONTEXT)
 #  else
 #  ifdef MULTIPLICITY
@@ -2027,11 +2189,11 @@ union any {
 };
 #endif
 
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 #define ARGSproto struct perl_thread *thr
 #else
 #define ARGSproto
-#endif /* USE_THREADS */
+#endif /* USE_5005THREADS */
 
 typedef I32 (*filter_t) (pTHXo_ int, SV *, int);
 
@@ -2057,6 +2219,7 @@ typedef I32 (*filter_t) (pTHXo_ int, SV *, int);
 #include "scope.h"
 #include "warnings.h"
 #include "utf8.h"
+#include "sharedsv.h"
 
 /* Current curly descriptor */
 typedef struct curcur CURCUR;
@@ -2219,11 +2382,13 @@ struct ptr_tbl {
 #endif
 
 #ifndef __cplusplus
+#ifndef UNDER_CE
 Uid_t getuid (void);
 Uid_t geteuid (void);
 Gid_t getgid (void);
 Gid_t getegid (void);
 #endif
+#endif
 
 #ifndef Perl_debug_log
 #  define Perl_debug_log       PerlIO_stderr()
@@ -2323,7 +2488,7 @@ Gid_t getegid (void);
 #  define DEBUG_X(a) DEBUG__(DEBUG_X_TEST, a)
 #  define DEBUG_D(a) DEBUG__(DEBUG_D_TEST, a)
 
-#  ifdef USE_THREADS
+#  ifdef USE_5005THREADS
 #    define DEBUG_S(a) DEBUG__(DEBUG_S_TEST, a)
 #  else
 #    define DEBUG_S(a)
@@ -2503,6 +2668,55 @@ START_EXTERN_C
 END_EXTERN_C
 #endif
 
+#if !defined(NV_INF) && defined(USE_LONG_DOUBLE) && defined(LDBL_INFINITY)
+#  define NV_INF LDBL_INFINITY
+#endif
+#if !defined(NV_INF) && defined(DBL_INFINITY)
+#  define NV_INF (NV)DBL_INFINITY
+#endif
+#if !defined(NV_INF) && defined(INFINITY)
+#  define NV_INF (NV)INFINITY
+#endif
+#if !defined(NV_INF) && defined(INF)
+#  define NV_INF (NV)INF
+#endif
+#if !defined(NV_INF) && defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
+#  define NV_INF (NV)HUGE_VALL
+#endif
+#if !defined(NV_INF) && defined(HUGE_VAL)
+#  define NV_INF (NV)HUGE_VAL
+#endif
+
+#if !defined(NV_NAN) && defined(USE_LONG_DOUBLE)
+#   if !defined(NV_NAN) && defined(LDBL_NAN)
+#       define NV_NAN LDBL_NAN
+#   endif
+#   if !defined(NV_NAN) && defined(LDBL_QNAN)
+#       define NV_NAN LDBL_QNAN
+#   endif
+#   if !defined(NV_NAN) && defined(LDBL_SNAN)
+#       define NV_NAN LDBL_SNAN
+#   endif
+#endif
+#if !defined(NV_NAN) && defined(DBL_NAN)
+#  define NV_NAN (NV)DBL_NAN
+#endif
+#if !defined(NV_NAN) && defined(DBL_QNAN)
+#  define NV_NAN (NV)DBL_QNAN
+#endif
+#if !defined(NV_NAN) && defined(DBL_SNAN)
+#  define NV_NAN (NV)DBL_SNAN
+#endif
+#if !defined(NV_NAN) && defined(QNAN)
+#  define NV_NAN (NV)QNAN
+#endif
+#if !defined(NV_NAN) && defined(SNAN)
+#  define NV_NAN (NV)SNAN
+#endif
+#if !defined(NV_NAN) && defined(NAN)
+#  define NV_NAN (NV)NAN
+#endif
+
 #ifndef __cplusplus
 #  if defined(NeXT) || defined(__NeXT__) /* or whatever catches all NeXTs */
 char *crypt ();       /* Maybe more hosts will need the unprototyped version */
@@ -2937,7 +3151,7 @@ enum {            /* pass one of these to get_vtbl */
     want_vtbl_collxfrm,
     want_vtbl_amagic,
     want_vtbl_amagicelem,
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
     want_vtbl_mutex,
 #endif
     want_vtbl_regdata,
@@ -2972,7 +3186,6 @@ enum {            /* pass one of these to get_vtbl */
 
 #define HINT_FILETEST_ACCESS   0x00400000
 #define HINT_UTF8              0x00800000
-#define HINT_UTF8_DISTINCT     0x01000000
 
 /* Various states of an input record separator SV (rs, nrs) */
 #define RsSNARF(sv)   (! SvOK(sv))
@@ -2981,6 +3194,7 @@ enum {            /* pass one of these to get_vtbl */
 #define RsRECORD(sv)  (SvROK(sv) && (SvIV(SvRV(sv)) > 0))
 
 /* Enable variables which are pointers to functions */
+typedef void (CPERLscope(*peep_t))(pTHX_ OP* o);
 typedef regexp*(CPERLscope(*regcomp_t)) (pTHX_ char* exp, char* xend, PMOP* pm);
 typedef I32 (CPERLscope(*regexec_t)) (pTHX_ regexp* prog, char* stringarg,
                                      char* strend, char* strbeg, I32 minend,
@@ -3038,7 +3252,7 @@ struct perl_vars *PL_VarsPtr;
 */
 
 struct interpreter {
-#  ifndef USE_THREADS
+#  ifndef USE_5005THREADS
 #    include "thrdvar.h"
 #  endif
 #  include "intrpvar.h"
@@ -3055,7 +3269,7 @@ struct interpreter {
 };
 #endif /* MULTIPLICITY || PERL_OBJECT */
 
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 /* If we have threads define a struct with all the variables
  * that have to be per-thread
  */
@@ -3132,7 +3346,7 @@ typedef void *Thread;
 #if !defined(MULTIPLICITY) && !defined(PERL_OBJECT)
 START_EXTERN_C
 #  include "intrpvar.h"
-#  ifndef USE_THREADS
+#  ifndef USE_5005THREADS
 #    include "thrdvar.h"
 #  endif
 END_EXTERN_C
@@ -3233,9 +3447,9 @@ EXT MGVTBL PL_vtbl_fm =   {0,     MEMBER_TO_FPTR(Perl_magic_setfm),
 EXT MGVTBL PL_vtbl_uvar =      {MEMBER_TO_FPTR(Perl_magic_getuvar),
                                MEMBER_TO_FPTR(Perl_magic_setuvar),
                                        0,      0,      0};
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 EXT MGVTBL PL_vtbl_mutex =     {0,     0,      0,      0,      MEMBER_TO_FPTR(Perl_magic_mutexfree)};
-#endif /* USE_THREADS */
+#endif /* USE_5005THREADS */
 EXT MGVTBL PL_vtbl_defelem = {MEMBER_TO_FPTR(Perl_magic_getdefelem),MEMBER_TO_FPTR(Perl_magic_setdefelem),
                                        0,      0,      0};
 
@@ -3286,9 +3500,9 @@ EXT MGVTBL PL_vtbl_fm;
 EXT MGVTBL PL_vtbl_uvar;
 EXT MGVTBL PL_vtbl_ovrld;
 
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 EXT MGVTBL PL_vtbl_mutex;
-#endif /* USE_THREADS */
+#endif /* USE_5005THREADS */
 
 EXT MGVTBL PL_vtbl_defelem;
 EXT MGVTBL PL_vtbl_regexp;
@@ -3524,13 +3738,10 @@ typedef struct am_table_short AMTS;
 #define RESTORE_NUMERIC_LOCAL()                /**/
 #define RESTORE_NUMERIC_STANDARD()     /**/
 #define Atof                           Perl_atof
+#define IN_LOCALE_RUNTIME              0
 
 #endif /* !USE_LOCALE_NUMERIC */
 
-#ifdef PERL_MICRO
-#   define IN_LOCALE_RUNTIME 0
-#endif
-
 #if !defined(Strtol) && defined(USE_64_BIT_INT) && defined(IV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG
 #    ifdef __hpux
 #        define strtoll __strtoll      /* secret handshake */
@@ -3787,6 +3998,7 @@ int flock(int fd, int op);
 #define IS_NUMBER_NOT_INT            0x04 /* saw . or E notation */
 #define IS_NUMBER_NEG                0x08 /* leading minus sign */
 #define IS_NUMBER_INFINITY           0x10 /* this is big */
+#define IS_NUMBER_NAN                 0x20 /* this is not */
 
 #define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send)
 
@@ -3842,8 +4054,12 @@ extern void moncontrol(int);
    HAS_STRUCT_MSGHDR
    HAS_STRUCT_CMSGHDR
 
-   USE_REENTRANT_API
+   HAS_NL_LANGINFO
 
    so that Configure picks them up. */
 
+#ifdef UNDER_CE
+#include "wince.h"
+#endif
+
 #endif /* Include guard */