From: Vincent Pit Date: Sat, 16 Oct 2010 12:34:04 +0000 (+0200) Subject: Explicitely state that C++ compilers aren't supported X-Git-Tag: v0.45~9 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=bdc2a15aa5ca3f57b45d2c6e560f110c91b2ae87;p=perl%2Fmodules%2FVariable-Magic.git Explicitely state that C++ compilers aren't supported --- diff --git a/Magic.xs b/Magic.xs index 9aabb41..2de483f 100644 --- a/Magic.xs +++ b/Magic.xs @@ -12,6 +12,13 @@ #define __PACKAGE__ "Variable::Magic" +#undef VOID2 +#ifdef __cplusplus +# define VOID2(T, P) static_cast(P) +#else +# define VOID2(T, P) (P) +#endif + #ifndef VMG_PERL_PATCHLEVEL # ifdef PERL_PATCHNUM # define VMG_PERL_PATCHLEVEL PERL_PATCHNUM @@ -543,7 +550,7 @@ STATIC MGWIZ *vmg_mgwiz_clone(pTHX_ const MGWIZ *w) { #if VMG_THREADSAFE #define PTABLE_NAME ptable -#define PTABLE_VAL_FREE(V) vmg_mgwiz_free(V) +#define PTABLE_VAL_FREE(V) vmg_mgwiz_free(VOID2(MGWIZ *, (V))) #define pPTBL pTHX #define pPTBL_ pTHX_ @@ -573,13 +580,13 @@ START_MY_CXT #if VMG_THREADSAFE STATIC void vmg_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) { - my_cxt_t *ud = ud_; + my_cxt_t *ud = VOID2(my_cxt_t *, ud_); MGWIZ *w; if (ud->owner == aTHX) return; - w = vmg_mgwiz_clone(ent->val); + w = vmg_mgwiz_clone(VOID2(MGWIZ *, ent->val)); if (w) ptable_store(ud->wizards, ent->key, w); } @@ -672,7 +679,7 @@ STATIC const MGWIZ *vmg_wizard_mgwiz(pTHX_ const SV *wiz) { { dMY_CXT; - return ptable_fetch(MY_CXT.wizards, w); + return VOID2(const MGWIZ *, ptable_fetch(MY_CXT.wizards, w)); } } @@ -966,7 +973,7 @@ STATIC void vmg_op_info_init(pTHX_ unsigned int opinfo) { case VMG_OP_INFO_OBJECT: { dMY_CXT; if (!MY_CXT.b__op_stashes[0]) { - opclass c; + int c; require_pv("B.pm"); for (c = OPc_NULL; c < OPc_MAX; ++c) MY_CXT.b__op_stashes[c] = gv_stashpv(vmg_opclassnames[c], 1); @@ -1087,7 +1094,7 @@ STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) { if (t < SVt_PVAV) { STRLEN l; #if VMG_HAS_PERL(5, 9, 3) - const U8 *s = SvPV_const(sv, l); + const U8 *s = VOID2(const U8 *, VOID2(const void *, SvPV_const(sv, l))); #else U8 *s = SvPV(sv, l); #endif @@ -1390,7 +1397,7 @@ PROTOTYPE: DISABLE PREINIT: ptable *t; U32 had_b__op_stash = 0; - opclass c; + int c; PPCODE: { my_cxt_t ud; diff --git a/lib/Variable/Magic.pm b/lib/Variable/Magic.pm index 4753904..48278de 100644 --- a/lib/Variable/Magic.pm +++ b/lib/Variable/Magic.pm @@ -608,6 +608,9 @@ In order to define magic on hash members, you need at least L 5.10.0 (see L 5.8. +A C compiler. +This module may happen to build with a C++ compiler as well, but don't rely on it, as no guarantee is made about this. + L (standard since perl 5), L (standard since perl 5.006). Copy tests need L (standard since perl 5.005) and L (since 5.002). diff --git a/ptable.h b/ptable.h index fa6434a..b3d19e2 100644 --- a/ptable.h +++ b/ptable.h @@ -9,6 +9,13 @@ /* This header is designed to be included several times with different * definitions for PTABLE_NAME and PTABLE_VAL_FREE(). */ +#undef VOID2 +#ifdef __cplusplus +# define VOID2(T, P) static_cast(P) +#else +# define VOID2(T, P) (P) +#endif + #undef pPTBLMS #undef pPTBLMS_ #undef aPTBLMS @@ -79,10 +86,11 @@ typedef struct ptable { #ifndef ptable_new STATIC ptable *ptable_new(pPTBLMS) { #define ptable_new() ptable_new(aPTBLMS) - ptable *t = PerlMemShared_malloc(sizeof *t); - t->max = 15; - t->items = 0; - t->ary = PerlMemShared_calloc(t->max + 1, sizeof *t->ary); + ptable *t = VOID2(ptable *, PerlMemShared_malloc(sizeof *t)); + t->max = 15; + t->items = 0; + t->ary = VOID2(ptable_ent **, + PerlMemShared_calloc(t->max + 1, sizeof *t->ary)); return t; } #endif /* !ptable_new */ @@ -125,7 +133,7 @@ STATIC void ptable_split(pPTBLMS_ ptable * const t) { size_t newsize = oldsize * 2; size_t i; - ary = PerlMemShared_realloc(ary, newsize * sizeof(*ary)); + ary = VOID2(ptable_ent **, PerlMemShared_realloc(ary, newsize * sizeof(*ary))); Zero(&ary[oldsize], newsize - oldsize, sizeof(*ary)); t->max = --newsize; t->ary = ary; @@ -157,7 +165,7 @@ STATIC void PTABLE_PREFIX(_store)(pPTBL_ ptable * const t, const void * const ke ent->val = val; } else if (val) { const size_t i = PTABLE_HASH(key) & t->max; - ent = PerlMemShared_malloc(sizeof *ent); + ent = VOID2(ptable_ent *, PerlMemShared_malloc(sizeof *ent)); ent->key = key; ent->val = val; ent->next = t->ary[i];