From: Vincent Pit Date: Fri, 1 May 2009 23:23:17 +0000 (+0200) Subject: Don't let [ap]PTBL_? values propagate outside ptable.h X-Git-Tag: v0.07~7 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLexical-Types.git;a=commitdiff_plain;h=802bedc36b8f65e33ea579641fe0dc70b4e59e9d Don't let [ap]PTBL_? values propagate outside ptable.h As they can't be kept anyway if we include the file several times. --- diff --git a/Types.xs b/Types.xs index 0644b00..3382014 100644 --- a/Types.xs +++ b/Types.xs @@ -77,6 +77,9 @@ #include "ptable.h" +#define ptable_hints_store(T, K, V) ptable_hints_store(aTHX_ (T), (K), (V)) +#define ptable_hints_free(T) ptable_hints_free(aTHX_ (T)) + #define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION typedef struct { @@ -103,7 +106,7 @@ STATIC void lt_ptable_hints_clone(pTHX_ ptable_ent *ent, void *ud_) { } } - ptable_hints_store(aPTBL_ ud->tbl, ent->key, val); + ptable_hints_store(ud->tbl, ent->key, val); SvREFCNT_inc(val); } @@ -121,19 +124,19 @@ STATIC void lt_thread_cleanup(pTHX_ void *ud) { } else { dMY_CXT; PerlMemShared_free(level); - ptable_hints_free(aPTBL_ MY_CXT.tbl); + ptable_hints_free(MY_CXT.tbl); } } -STATIC SV *lt_tag(pPTBL_ SV *value) { -#define lt_tag(V) lt_tag(aPTBL_ (V)) +STATIC SV *lt_tag(pTHX_ SV *value) { +#define lt_tag(V) lt_tag(aTHX_ (V)) dMY_CXT; value = SvOK(value) && SvROK(value) ? SvRV(value) : NULL; /* We only need for the key to be an unique tag for looking up the value later. * Allocated memory provides convenient unique identifiers, so that's why we * use the value pointer as the key itself. */ - ptable_hints_store(aPTBL_ MY_CXT.tbl, value, value); + ptable_hints_store(MY_CXT.tbl, value, value); SvREFCNT_inc(value); return newSVuv(PTR2UV(value)); @@ -197,10 +200,14 @@ STATIC SV *lt_hint(pTHX) { /* ... op => info map ...................................................... */ +#define PTABLE_NAME ptable_map #define PTABLE_VAL_FREE(V) PerlMemShared_free(V) #include "ptable.h" +/* PerlMemShared_free() needs the [ap]PTBLMS_? default values */ +#define ptable_map_store(T, K, V) ptable_map_store(aPTBLMS_ (T), (K), (V)) + STATIC ptable *lt_op_map = NULL; #ifdef USE_ITHREADS @@ -214,8 +221,8 @@ typedef struct { OP *(*pp_padsv)(pTHX); } lt_op_info; -STATIC void lt_map_store(pPTBL_ const OP *o, SV *orig_pkg, SV *type_pkg, SV *type_meth, OP *(*pp_padsv)(pTHX)) { -#define lt_map_store(O, OP, TP, TM, PP) lt_map_store(aPTBL_ (O), (OP), (TP), (TM), (PP)) +STATIC void lt_map_store(pPTBLMS_ const OP *o, SV *orig_pkg, SV *type_pkg, SV *type_meth, OP *(*pp_padsv)(pTHX)) { +#define lt_map_store(O, OP, TP, TM, PP) lt_map_store(aPTBLMS_ (O), (OP), (TP), (TM), (PP)) lt_op_info *oi; #ifdef USE_ITHREADS @@ -224,7 +231,7 @@ STATIC void lt_map_store(pPTBL_ const OP *o, SV *orig_pkg, SV *type_pkg, SV *typ if (!(oi = ptable_fetch(lt_op_map, o))) { oi = PerlMemShared_malloc(sizeof *oi); - ptable_store(aPTBL_ lt_op_map, o, oi); + ptable_map_store(lt_op_map, o, oi); } oi->orig_pkg = orig_pkg; diff --git a/ptable.h b/ptable.h index fc50652..07a7551 100644 --- a/ptable.h +++ b/ptable.h @@ -212,5 +212,10 @@ STATIC void PTABLE_PREFIX(_free)(pPTBL_ ptable * const t) { PerlMemShared_free(t); } +#undef pPTBL +#undef pPTBL_ +#undef aPTBL +#undef aPTBL_ + #undef PTABLE_NAME #undef PTABLE_VAL_FREE