integrate change#11847 from maint-5.6
[p5sagit/p5-mst-13.2.git] / perl.h
diff --git a/perl.h b/perl.h
index 36b1939..7009f16 100644 (file)
--- a/perl.h
+++ b/perl.h
 /* 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
  * PERL_IMPLICIT_CONTEXT and PERL_IMPLICIT_SYS */
 
 #ifdef USE_ITHREADS
-#  if !defined(MULTIPLICITY) && !defined(PERL_OBJECT)
+#  if !defined(MULTIPLICITY)
 #    define MULTIPLICITY
 #  endif
 #endif
 
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 #  ifndef PERL_IMPLICIT_CONTEXT
 #    define PERL_IMPLICIT_CONTEXT
 #  endif
 #  endif
 #endif
 
-#ifdef PERL_CAPI
-#  undef PERL_OBJECT
-#  ifndef MULTIPLICITY
-#    define MULTIPLICITY
-#  endif
-#  ifndef PERL_IMPLICIT_CONTEXT
-#    define PERL_IMPLICIT_CONTEXT
-#  endif
-#  ifndef PERL_IMPLICIT_SYS
-#    define PERL_IMPLICIT_SYS
-#  endif
-#endif
-
-#ifdef PERL_OBJECT
-#  ifndef PERL_IMPLICIT_CONTEXT
-#    define PERL_IMPLICIT_CONTEXT
-#  endif
-#  ifndef PERL_IMPLICIT_SYS
-#    define PERL_IMPLICIT_SYS
-#  endif
-#endif
-
-#ifdef PERL_OBJECT
-
-/* PERL_OBJECT explained  - DickH and DougL @ ActiveState.com
-
-Defining PERL_OBJECT turns on creation of a C++ object that
-contains all writable core perl global variables and functions.
-Stated another way, all necessary global variables and functions
-are members of a big C++ object. This object's class is CPerlObj.
-This allows a Perl Host to have multiple, independent perl
-interpreters in the same process space. This is very important on
-Win32 systems as the overhead of process creation is quite high --
-this could be even higher than the script compile and execute time
-for small scripts.
-
-The perl executable implementation on Win32 is composed of perl.exe
-(the Perl Host) and perlX.dll. (the Perl Core). This allows the
-same Perl Core to easily be embedded in other applications that use
-the perl interpreter.
-
-+-----------+
-| Perl Host |
-+-----------+
-      ^
-      |
-      v
-+-----------+   +-----------+
-| Perl Core |<->| Extension |
-+-----------+   +-----------+ ...
-
-Defining PERL_OBJECT has the following effects:
-
-PERL CORE
-1. CPerlObj is defined (this is the PERL_OBJECT)
-2. all static functions that needed to access either global
-variables or functions needed are made member functions
-3. all writable static variables are made member variables
-4. all global variables and functions are defined as:
-       #define var CPerlObj::PL_var
-       #define func CPerlObj::Perl_func
-       * these are in embed.h
-This necessitated renaming some local variables and functions that
-had the same name as a global variable or function. This was
-probably a _good_ thing anyway.
-
-
-EXTENSIONS
-1. Access to global variables and perl functions is through a
-pointer to the PERL_OBJECT. This pointer type is CPerlObj*. This is
-made transparent to extension developers by the following macros:
-       #define var pPerl->PL_var
-       #define func pPerl->Perl_func
-       * these are done in objXSUB.h
-This requires that the extension be compiled as C++, which means
-that the code must be ANSI C and not K&R C. For K&R extensions,
-please see the C API notes located in Win32/GenCAPI.pl. This script
-creates a perlCAPI.lib that provides a K & R compatible C interface
-to the PERL_OBJECT.
-2. Local variables and functions cannot have the same name as perl's
-variables or functions since the macros will redefine these. Look for
-this if you get some strange error message and it does not look like
-the code that you had written. This often happens with variables that
-are local to a function.
-
-PERL HOST
-1. The perl host is linked with perlX.lib to get perl_alloc. This
-function will return a pointer to CPerlObj (the PERL_OBJECT). It
-takes pointers to the various PerlXXX_YYY interfaces (see iperlsys.h
-for more information on this).
-2. The perl host calls the same functions as normally would be
-called in setting up and running a perl script, except that the
-functions are now member functions of the PERL_OBJECT.
-
-*/
-
-
-class CPerlObj;
-
-#define STATIC
-#define CPERLscope(x)          CPerlObj::x
-#define CALL_FPTR(fptr)                (aTHXo->*fptr)
-
-#define pTHXo                  CPerlObj *pPerl
-#define pTHXo_                 pTHXo,
-#define aTHXo                  this
-#define aTHXo_                 this,
-#define PERL_OBJECT_THIS       aTHXo
-#define PERL_OBJECT_THIS_      aTHXo_
-#define dTHXoa(a)              pTHXo = (CPerlObj*)a
-#define dTHXo                  pTHXo = PERL_GET_THX
-
-#define pTHXx          void
-#define pTHXx_
-#define aTHXx
-#define aTHXx_
-
-#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
@@ -212,8 +93,6 @@ struct perl_thread;
 #define PERL_OBJECT_THIS_
 #define CALL_FPTR(fptr) (*fptr)
 
-#endif /* PERL_OBJECT */
-
 #define CALLRUNOPS  CALL_FPTR(PL_runops)
 #define CALLREGCOMP CALL_FPTR(PL_regcompp)
 #define CALLREGEXEC CALL_FPTR(PL_regexecp)
@@ -253,7 +132,8 @@ struct perl_thread;
 #  define pTHX_4       4
 #endif
 
-#ifndef pTHXo
+/* these are only defined for compatibility; should not be used internally */
+#if !defined(pTHXo) && !defined(PERL_CORE)
 #  define pTHXo                pTHX
 #  define pTHXo_       pTHX_
 #  define aTHXo                aTHX
@@ -439,22 +319,15 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
 #endif
 
 /* Use the reentrant APIs like localtime_r and getpwent_r */
-#if defined(USE_THREADS) && defined(USE_ITHREADS) && !defined(USE_REENTRANT_API)
+/* 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
 
-/* Win32 has naturally threadsafe libraries,
- * no need to use any _r variants. */
-#ifdef USE_REENTRANT_API
-#   ifdef WIN32
-#       undef USE_REEENTRANT_API
-#   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(USE_ITHREADS)) \
+#if (defined(USE_5005THREADS) || defined(USE_ITHREADS)) \
     && defined(PTHREAD_H_FIRST) && defined(I_PTHREAD)
 #  include <pthread.h>
 #endif
@@ -756,7 +629,7 @@ typedef struct perl_mstats perl_mstats_t;
 
 #include <errno.h>
 
-#if defined(WIN32) && (defined(PERL_OBJECT) || defined(PERL_IMPLICIT_SYS) || defined(PERL_CAPI))
+#if defined(WIN32) && defined(PERL_IMPLICIT_SYS)
 #  define WIN32SCK_IS_STDSCK           /* don't pull in custom wsock layer */
 #endif
 
@@ -772,16 +645,16 @@ typedef struct perl_mstats perl_mstats_t;
 #       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 */
@@ -822,7 +695,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)
@@ -830,7 +703,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 */
 
@@ -1963,14 +1836,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
@@ -2009,7 +1882,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"
@@ -2113,15 +1986,11 @@ 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
 #    define PERL_GET_THX               ((PerlInterpreter *)PERL_GET_CONTEXT)
-#  else
-#  ifdef PERL_OBJECT
-#    define PERL_GET_THX               ((CPerlObj *)PERL_GET_CONTEXT)
-#  endif
 #  endif
 #  endif
 #  define PERL_SET_THX(t)              PERL_SET_CONTEXT(t)
@@ -2192,17 +2061,17 @@ union any {
     IV         any_iv;
     long       any_long;
     void       (*any_dptr) (void*);
-    void       (*any_dxptr) (pTHXo_ void*);
+    void       (*any_dxptr) (pTHX_ void*);
 };
 #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);
+typedef I32 (*filter_t) (pTHX_ int, SV *, int);
 
 #define FILTER_READ(idx, sv, len)  filter_read(idx, sv, len)
 #define FILTER_DATA(idx)          (AvARRAY(PL_rsfp_filters)[idx])
@@ -2470,16 +2339,12 @@ Gid_t getegid (void);
 #  define DEBUG_c(a) if (DEBUG_c_TEST) a
 #  define DEBUG_P(a) if (DEBUG_P_TEST) a
 
-#  if defined(PERL_OBJECT)
-#    define DEBUG_m(a) if (DEBUG_m_TEST) a
-#  else
      /* Temporarily turn off memory debugging in case the a
       * does memory allocation, either directly or indirectly. */
-#    define DEBUG_m(a)  \
+#  define DEBUG_m(a)  \
     STMT_START {                                                       \
         if (PERL_GET_INTERP) { dTHX; if (DEBUG_m_TEST) {PL_debug&=~DEBUG_m_FLAG; a; PL_debug|=DEBUG_m_FLAG;} } \
     } STMT_END
-#  endif
 
 #  define DEBUG__(t, a) \
        STMT_START { \
@@ -2495,7 +2360,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)
@@ -3158,7 +3023,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,
@@ -3214,12 +3079,12 @@ typedef SV*     (CPERLscope(*re_intuit_string_t)) (pTHX_ regexp *prog);
 typedef void   (CPERLscope(*regfree_t)) (pTHX_ struct regexp* r);
 
 typedef void (*DESTRUCTORFUNC_NOCONTEXT_t) (void*);
-typedef void (*DESTRUCTORFUNC_t) (pTHXo_ void*);
-typedef void (*SVFUNC_t) (pTHXo_ SV*);
-typedef I32  (*SVCOMPARE_t) (pTHXo_ SV*, SV*);
-typedef void (*XSINIT_t) (pTHXo);
-typedef void (*ATEXIT_t) (pTHXo_ void*);
-typedef void (*XSUBADDR_t) (pTHXo_ CV *);
+typedef void (*DESTRUCTORFUNC_t) (pTHX_ void*);
+typedef void (*SVFUNC_t) (pTHX_ SV*);
+typedef I32  (*SVCOMPARE_t) (pTHX_ SV*, SV*);
+typedef void (*XSINIT_t) (pTHX);
+typedef void (*ATEXIT_t) (pTHX_ void*);
+typedef void (*XSUBADDR_t) (pTHX_ CV *);
 
 /* Set up PERLVAR macros for populating structs */
 #define PERLVAR(var,type) type var;
@@ -3229,7 +3094,7 @@ typedef void (*XSUBADDR_t) (pTHXo_ CV *);
 
 /* Interpreter exitlist entry */
 typedef struct exitlistentry {
-    void (*fn) (pTHXo_ void*);
+    void (*fn) (pTHX_ void*);
     void *ptr;
 } PerlExitListEntry;
 
@@ -3251,7 +3116,7 @@ struct perl_vars *PL_VarsPtr;
 #  endif /* PERL_CORE */
 #endif /* PERL_GLOBAL_STRUCT */
 
-#if defined(MULTIPLICITY) || defined(PERL_OBJECT)
+#if defined(MULTIPLICITY)
 /* If we have multiple interpreters define a struct
    holding variables which must be per-interpreter
    If we don't have threads anything that would have
@@ -3259,13 +3124,13 @@ struct perl_vars *PL_VarsPtr;
 */
 
 struct interpreter {
-#  ifndef USE_THREADS
+#  ifndef USE_5005THREADS
 #    include "thrdvar.h"
 #  endif
 #  include "intrpvar.h"
 /*
  * The following is a buffer where new variables must
- * be defined to maintain binary compatibility with PERL_OBJECT
+ * be defined to maintain binary compatibility with previous versions
  */
 PERLVARA(object_compatibility,30,      char)
 };
@@ -3274,9 +3139,9 @@ PERLVARA(object_compatibility,30, char)
 struct interpreter {
     char broiled;
 };
-#endif /* MULTIPLICITY || PERL_OBJECT */
+#endif /* MULTIPLICITY */
 
-#ifdef USE_THREADS
+#ifdef USE_5005THREADS
 /* If we have threads define a struct with all the variables
  * that have to be per-thread
  */
@@ -3314,10 +3179,6 @@ typedef void *Thread;
 #  endif
 #endif
 
-#ifdef PERL_OBJECT
-#  define PERL_DECL_PROT
-#endif
-
 #undef PERL_CKDEF
 #undef PERL_PPDEF
 #define PERL_CKDEF(s)  OP *s (pTHX_ OP *o);
@@ -3325,14 +3186,8 @@ typedef void *Thread;
 
 #include "proto.h"
 
-#ifdef PERL_OBJECT
-#  undef PERL_DECL_PROT
-#endif
-
-#ifndef PERL_OBJECT
 /* this has structure inits, so it cannot be included before here */
-#  include "opcode.h"
-#endif
+#include "opcode.h"
 
 /* The following must follow proto.h as #defines mess up syntax */
 
@@ -3350,32 +3205,18 @@ typedef void *Thread;
 #define PERLVARI(var,type,init) EXT type  PL_##var INIT(init);
 #define PERLVARIC(var,type,init) EXTCONST type PL_##var INIT(init);
 
-#if !defined(MULTIPLICITY) && !defined(PERL_OBJECT)
+#if !defined(MULTIPLICITY)
 START_EXTERN_C
 #  include "intrpvar.h"
-#  ifndef USE_THREADS
+#  ifndef USE_5005THREADS
 #    include "thrdvar.h"
 #  endif
 END_EXTERN_C
 #endif
 
-#ifdef PERL_OBJECT
+#if defined(WIN32)
 #  include "embed.h"
-
-#  ifdef DOINIT
-#    include "INTERN.h"
-#  else
-#    include "EXTERN.h"
-#  endif
-
-/* this has structure inits, so it cannot be included before here */
-#  include "opcode.h"
-
-#else
-#  if defined(WIN32)
-#    include "embed.h"
-#  endif
-#endif  /* PERL_OBJECT */
+#endif
 
 #ifndef PERL_GLOBAL_STRUCT
 START_EXTERN_C
@@ -3454,9 +3295,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};
 
@@ -3507,9 +3348,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;