This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Eliminate PL_dirty
[perl5.git] / perl.h
diff --git a/perl.h b/perl.h
index 44cf99e..22bb6d8 100644 (file)
--- a/perl.h
+++ b/perl.h
 #define _PERL_OBJECT_THIS
 #define PERL_OBJECT_THIS_
 #define CALL_FPTR(fptr) (*fptr)
+#define MEMBER_TO_FPTR(name) name
 #endif /* !PERL_CORE */
 
 #define CALLRUNOPS  PL_runops
@@ -2386,10 +2387,6 @@ int isnan(double d);
 
 #endif
 
-#ifdef MYMALLOC
-#  include "malloc_ctl.h"
-#endif
-
 struct RExC_state_t;
 struct _reg_trie_data;
 
@@ -3123,10 +3120,6 @@ typedef pthread_key_t    perl_key;
 #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
-#endif
-
 #ifndef PERL_CORE
 /* format to use for version numbers in file/directory names */
 /* XXX move to Configure? */
@@ -3904,6 +3897,7 @@ Gid_t getegid (void);
 #define PERL_MAGIC_rhash         '%' /* extra data for restricted hashes */
 #define PERL_MAGIC_arylen_p      '@' /* to move arylen out of XPVAV */
 #define PERL_MAGIC_ext           '~' /* Available for use by extensions */
+#define PERL_MAGIC_checkcall     ']' /* inlining/mutation of call to this CV */
 
 #if defined(DEBUGGING) && defined(I_ASSERT)
 #  include <assert.h>
@@ -4224,9 +4218,6 @@ typedef OP* (*PPADDR_t[]) (pTHX);
 typedef bool (*destroyable_proc_t) (pTHX_ SV *sv);
 typedef void (*despatch_signals_proc_t) (pTHX);
 
-/* _ (for $_) must be first in the following list (DEFSV requires it) */
-#define THREADSV_NAMES "_123456789&`'+/.,\\\";^-%=|~:\001\005!@"
-
 /* NeXT has problems with crt0.o globals */
 #if defined(__DYNAMIC__) && \
     (defined(NeXT) || defined(__NeXT__) || defined(PERL_DARWIN))
@@ -4713,11 +4704,47 @@ EXTCONST char PL_bincompat_options[] =
 #  ifdef VMS_WE_ARE_CASE_SENSITIVE
                             " VMS_SYMBOL_CASE_AS_IS"
 #  endif
+#  ifdef VMS_SHORTEN_LONG_SYMBOLS
+                            " VMS_SHORTEN_LONG_SYMBOLS"
+#  endif
   "";
 #else
 EXTCONST char PL_bincompat_options[];
 #endif
 
+/* The interpreter phases. If these ever change, PL_phase_names right below will
+ * need to be updated accordingly. */
+enum perl_phase {
+    PERL_PHASE_CONSTRUCT       = 0,
+    PERL_PHASE_START           = 1,
+    PERL_PHASE_CHECK           = 2,
+    PERL_PHASE_INIT            = 3,
+    PERL_PHASE_RUN             = 4,
+    PERL_PHASE_END             = 5,
+    PERL_PHASE_DESTRUCT                = 6
+};
+
+#ifdef DOINIT
+EXTCONST char *const PL_phase_names[] = {
+    "CONSTRUCT",
+    "START",
+    "CHECK",
+    "INIT",
+    "RUN",
+    "END",
+    "DESTRUCT"
+};
+#else
+EXTCONST char *const PL_phase_names[];
+#endif
+
+#ifndef PERL_CORE
+/* Do not use this macro. It only exists for extensions that rely on PL_dirty
+ * instead of using the newer PL_phase, which provides everything PL_dirty
+ * provided, and more. */
+#  define PL_dirty (PL_phase == PERL_PHASE_DESTRUCT)
+#endif /* !PERL_CORE */
+
 END_EXTERN_C
 
 /*****************************************************************************/
@@ -4822,6 +4849,8 @@ enum {            /* pass one of these to get_vtbl */
 
 #define HINT_NO_AMAGIC         0x01000000 /* overloading pragma */
 
+#define HINT_RE_FLAGS          0x02000000 /* re '/xism' pragma */
+
 /* The following are stored in $^H{sort}, not in PL_hints */
 #define HINT_SORT_SORT_BITS    0x000000FF /* allow 256 different ones */
 #define HINT_SORT_QUICKSORT    0x00000001
@@ -4976,6 +5005,10 @@ struct tempsym; /* defined in pp_pack.c */
 #define PERL_CKDEF(s)  PERL_CALLCONV OP *s (pTHX_ OP *o);
 #define PERL_PPDEF(s)  PERL_CALLCONV OP *s (pTHX);
 
+#ifdef MYMALLOC
+#  include "malloc_ctl.h"
+#endif
+
 #include "proto.h"
 
 /* this has structure inits, so it cannot be included before here */
@@ -5078,9 +5111,9 @@ START_EXTERN_C
 
 MGVTBL_SET(
     PL_vtbl_sv,
-    MEMBER_TO_FPTR(Perl_magic_get),
-    MEMBER_TO_FPTR(Perl_magic_set),
-    MEMBER_TO_FPTR(Perl_magic_len),
+    Perl_magic_get,
+    Perl_magic_set,
+    Perl_magic_len,
     0,
     0,
     0,
@@ -5091,9 +5124,9 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_env,
     0,
-    MEMBER_TO_FPTR(Perl_magic_set_all_env),
+    Perl_magic_set_all_env,
     0,
-    MEMBER_TO_FPTR(Perl_magic_clear_all_env),
+    Perl_magic_clear_all_env,
     0,
     0,
     0,
@@ -5103,9 +5136,9 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_envelem,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setenv),
+    Perl_magic_setenv,
     0,
-    MEMBER_TO_FPTR(Perl_magic_clearenv),
+    Perl_magic_clearenv,
     0,
     0,
     0,
@@ -5140,10 +5173,10 @@ MGVTBL_SET(
 #else
 MGVTBL_SET(
     PL_vtbl_sigelem,
-    MEMBER_TO_FPTR(Perl_magic_getsig),
-    MEMBER_TO_FPTR(Perl_magic_setsig),
+    Perl_magic_getsig,
+    Perl_magic_setsig,
     0,
-    MEMBER_TO_FPTR(Perl_magic_clearsig),
+    Perl_magic_clearsig,
     0,
     0,
     0,
@@ -5155,8 +5188,8 @@ MGVTBL_SET(
     PL_vtbl_pack,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_sizepack),
-    MEMBER_TO_FPTR(Perl_magic_wipepack),
+    Perl_magic_sizepack,
+    Perl_magic_wipepack,
     0,
     0,
     0,
@@ -5165,10 +5198,10 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_packelem,
-    MEMBER_TO_FPTR(Perl_magic_getpack),
-    MEMBER_TO_FPTR(Perl_magic_setpack),
+    Perl_magic_getpack,
+    Perl_magic_setpack,
     0,
-    MEMBER_TO_FPTR(Perl_magic_clearpack),
+    Perl_magic_clearpack,
     0,
     0,
     0,
@@ -5178,7 +5211,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_dbline,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setdbline),
+    Perl_magic_setdbline,
     0,
     0,
     0,
@@ -5190,9 +5223,9 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_isa,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setisa),
+    Perl_magic_setisa,
     0,
-    MEMBER_TO_FPTR(Perl_magic_clearisa),
+    Perl_magic_clearisa,
     0,
     0,
     0,
@@ -5202,7 +5235,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_isaelem,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setisa),
+    Perl_magic_setisa,
     0,
     0,
     0,
@@ -5213,8 +5246,8 @@ MGVTBL_SET(
 
 MGVTBL_SET_CONST_MAGIC_GET(
     PL_vtbl_arylen,
-    MEMBER_TO_FPTR(Perl_magic_getarylen),
-    MEMBER_TO_FPTR(Perl_magic_setarylen),
+    Perl_magic_getarylen,
+    Perl_magic_setarylen,
     0,
     0,
     0,
@@ -5229,7 +5262,7 @@ MGVTBL_SET(
     0,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_freearylen_p),
+    Perl_magic_freearylen_p,
     0,
     0,
     0
@@ -5238,7 +5271,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_mglob,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setmglob),
+    Perl_magic_setmglob,
     0,
     0,
     0,
@@ -5249,8 +5282,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_nkeys,
-    MEMBER_TO_FPTR(Perl_magic_getnkeys),
-    MEMBER_TO_FPTR(Perl_magic_setnkeys),
+    Perl_magic_getnkeys,
+    Perl_magic_setnkeys,
     0,
     0,
     0,
@@ -5261,8 +5294,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_taint,
-    MEMBER_TO_FPTR(Perl_magic_gettaint),
-    MEMBER_TO_FPTR(Perl_magic_settaint),
+    Perl_magic_gettaint,
+    Perl_magic_settaint,
     0,
     0,
     0,
@@ -5273,8 +5306,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_substr,
-    MEMBER_TO_FPTR(Perl_magic_getsubstr),
-    MEMBER_TO_FPTR(Perl_magic_setsubstr),
+    Perl_magic_getsubstr,
+    Perl_magic_setsubstr,
     0,
     0,
     0,
@@ -5285,8 +5318,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_vec,
-    MEMBER_TO_FPTR(Perl_magic_getvec),
-    MEMBER_TO_FPTR(Perl_magic_setvec),
+    Perl_magic_getvec,
+    Perl_magic_setvec,
     0,
     0,
     0,
@@ -5297,8 +5330,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_pos,
-    MEMBER_TO_FPTR(Perl_magic_getpos),
-    MEMBER_TO_FPTR(Perl_magic_setpos),
+    Perl_magic_getpos,
+    Perl_magic_setpos,
     0,
     0,
     0,
@@ -5310,7 +5343,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_bm,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setregexp),
+    Perl_magic_setregexp,
     0,
     0,
     0,
@@ -5322,7 +5355,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_fm,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setregexp),
+    Perl_magic_setregexp,
     0,
     0,
     0,
@@ -5333,8 +5366,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_uvar,
-    MEMBER_TO_FPTR(Perl_magic_getuvar),
-    MEMBER_TO_FPTR(Perl_magic_setuvar),
+    Perl_magic_getuvar,
+    Perl_magic_setuvar,
     0,
     0,
     0,
@@ -5345,8 +5378,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_defelem,
-    MEMBER_TO_FPTR(Perl_magic_getdefelem),
-    MEMBER_TO_FPTR(Perl_magic_setdefelem),
+    Perl_magic_getdefelem,
+    Perl_magic_setdefelem,
     0,
     0,
     0,
@@ -5358,7 +5391,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_regexp,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setregexp),
+    Perl_magic_setregexp,
     0,
     0,
     0,
@@ -5371,7 +5404,7 @@ MGVTBL_SET(
     PL_vtbl_regdata,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_regdata_cnt),
+    Perl_magic_regdata_cnt,
     0,
     0,
     0,
@@ -5381,8 +5414,8 @@ MGVTBL_SET(
 
 MGVTBL_SET(
     PL_vtbl_regdatum,
-    MEMBER_TO_FPTR(Perl_magic_regdatum_get),
-    MEMBER_TO_FPTR(Perl_magic_regdatum_set),
+    Perl_magic_regdatum_get,
+    Perl_magic_regdatum_set,
     0,
     0,
     0,
@@ -5394,10 +5427,10 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_amagic,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setamagic),
+    Perl_magic_setamagic,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setamagic),
+    Perl_magic_setamagic,
     0,
     0,
     0
@@ -5406,10 +5439,10 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_amagicelem,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setamagic),
+    Perl_magic_setamagic,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setamagic),
+    Perl_magic_setamagic,
     0,
     0,
     0
@@ -5421,7 +5454,7 @@ MGVTBL_SET(
     0,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_killbackrefs),
+    Perl_magic_killbackrefs,
     0,
     0,
     0
@@ -5433,7 +5466,7 @@ MGVTBL_SET(
     0,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_freeovrld),
+    Perl_magic_freeovrld,
     0,
     0,
     0
@@ -5442,7 +5475,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_utf8,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setutf8),
+    Perl_magic_setutf8,
     0,
     0,
     0,
@@ -5454,7 +5487,7 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_collxfrm,
     0,
-    MEMBER_TO_FPTR(Perl_magic_setcollxfrm),
+    Perl_magic_setcollxfrm,
     0,
     0,
     0,
@@ -5467,9 +5500,9 @@ MGVTBL_SET(
 MGVTBL_SET(
     PL_vtbl_hintselem,
     0,
-    MEMBER_TO_FPTR(Perl_magic_sethint),
+    Perl_magic_sethint,
     0,
-    MEMBER_TO_FPTR(Perl_magic_clearhint),
+    Perl_magic_clearhint,
     0,
     0,
     0,
@@ -5481,7 +5514,7 @@ MGVTBL_SET(
     0,
     0,
     0,
-    MEMBER_TO_FPTR(Perl_magic_clearhints),
+    Perl_magic_clearhints,
     0,
     0,
     0,
@@ -5805,35 +5838,35 @@ typedef struct am_table_short AMTS;
 /* START_MY_CXT must appear in all extensions that define a my_cxt_t structure,
  * right after the definition (i.e. at file scope).  The non-threads
  * case below uses it to declare the data as static. */
-#ifdef PERL_GLOBAL_STRUCT_PRIVATE
-#define START_MY_CXT
-#define MY_CXT_INDEX Perl_my_cxt_index(aTHX_ MY_CXT_KEY)
-#define MY_CXT_INIT_ARG MY_CXT_KEY
-#else
-#define START_MY_CXT static int my_cxt_index = -1;
-#define MY_CXT_INDEX my_cxt_index
-#define MY_CXT_INIT_ARG &my_cxt_index
-#endif /* #ifdef PERL_GLOBAL_STRUCT_PRIVATE */
+#  ifdef PERL_GLOBAL_STRUCT_PRIVATE
+#    define START_MY_CXT
+#    define MY_CXT_INDEX Perl_my_cxt_index(aTHX_ MY_CXT_KEY)
+#    define MY_CXT_INIT_ARG MY_CXT_KEY
+#  else
+#    define START_MY_CXT static int my_cxt_index = -1;
+#    define MY_CXT_INDEX my_cxt_index
+#    define MY_CXT_INIT_ARG &my_cxt_index
+#  endif /* #ifdef PERL_GLOBAL_STRUCT_PRIVATE */
 
 /* Creates and zeroes the per-interpreter data.
  * (We allocate my_cxtp in a Perl SV so that it will be released when
  * the interpreter goes away.) */
-#define MY_CXT_INIT \
+#  define MY_CXT_INIT \
        my_cxt_t *my_cxtp = \
            (my_cxt_t*)Perl_my_cxt_init(aTHX_ MY_CXT_INIT_ARG, sizeof(my_cxt_t))
-#define MY_CXT_INIT_INTERP(my_perl) \
+#  define MY_CXT_INIT_INTERP(my_perl) \
        my_cxt_t *my_cxtp = \
            (my_cxt_t*)Perl_my_cxt_init(my_perl, MY_CXT_INIT_ARG, sizeof(my_cxt_t))
 
 /* This declaration should be used within all functions that use the
  * interpreter-local data. */
-#define dMY_CXT        \
+#  define dMY_CXT      \
        my_cxt_t *my_cxtp = (my_cxt_t *)PL_my_cxt_list[MY_CXT_INDEX]
-#define dMY_CXT_INTERP(my_perl)        \
+#  define dMY_CXT_INTERP(my_perl)      \
        my_cxt_t *my_cxtp = (my_cxt_t *)(my_perl)->Imy_cxt_list[MY_CXT_INDEX]
 
 /* Clones the per-interpreter data. */
-#define MY_CXT_CLONE \
+#  define MY_CXT_CLONE \
        my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
        Copy(PL_my_cxt_list[MY_CXT_INDEX], my_cxtp, 1, my_cxt_t);\
        PL_my_cxt_list[MY_CXT_INDEX] = my_cxtp                          \
@@ -5841,33 +5874,33 @@ typedef struct am_table_short AMTS;
 
 /* This macro must be used to access members of the my_cxt_t structure.
  * e.g. MYCXT.some_data */
-#define MY_CXT         (*my_cxtp)
+#  define MY_CXT               (*my_cxtp)
 
 /* Judicious use of these macros can reduce the number of times dMY_CXT
  * is used.  Use is similar to pTHX, aTHX etc. */
-#define pMY_CXT                my_cxt_t *my_cxtp
-#define pMY_CXT_       pMY_CXT,
-#define _pMY_CXT       ,pMY_CXT
-#define aMY_CXT                my_cxtp
-#define aMY_CXT_       aMY_CXT,
-#define _aMY_CXT       ,aMY_CXT
+#  define pMY_CXT      my_cxt_t *my_cxtp
+#  define pMY_CXT_     pMY_CXT,
+#  define _pMY_CXT     ,pMY_CXT
+#  define aMY_CXT      my_cxtp
+#  define aMY_CXT_     aMY_CXT,
+#  define _aMY_CXT     ,aMY_CXT
 
 #else /* PERL_IMPLICIT_CONTEXT */
 
-#define START_MY_CXT   static my_cxt_t my_cxt;
-#define dMY_CXT_SV     dNOOP
-#define dMY_CXT                dNOOP
-#define dMY_CXT_INTERP(my_perl)        dNOOP
-#define MY_CXT_INIT    NOOP
-#define MY_CXT_CLONE   NOOP
-#define MY_CXT         my_cxt
-
-#define pMY_CXT                void
-#define pMY_CXT_
-#define _pMY_CXT
-#define aMY_CXT
-#define aMY_CXT_
-#define _aMY_CXT
+#  define START_MY_CXT         static my_cxt_t my_cxt;
+#  define dMY_CXT_SV           dNOOP
+#  define dMY_CXT              dNOOP
+#  define dMY_CXT_INTERP(my_perl) dNOOP
+#  define MY_CXT_INIT          NOOP
+#  define MY_CXT_CLONE         NOOP
+#  define MY_CXT               my_cxt
+
+#  define pMY_CXT              void
+#  define pMY_CXT_
+#  define _pMY_CXT
+#  define aMY_CXT
+#  define aMY_CXT_
+#  define _aMY_CXT
 
 #endif /* !defined(PERL_IMPLICIT_CONTEXT) */