From: Vincent Pit Date: Wed, 26 Oct 2011 10:02:11 +0000 (+0200) Subject: Wrap MUTEX_{LOCK,UNLOCK} in macros so can we don't have to #ifdef them X-Git-Tag: v0.47~15 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=65768c73d8cbf0c086f7032b384de17479aef9fe;p=perl%2Fmodules%2FVariable-Magic.git Wrap MUTEX_{LOCK,UNLOCK} in macros so can we don't have to #ifdef them --- diff --git a/Magic.xs b/Magic.xs index 334a0a8..4ac45e7 100644 --- a/Magic.xs +++ b/Magic.xs @@ -82,6 +82,14 @@ # define MY_CXT_CLONE NOOP #endif +#if VMG_THREADSAFE +# define VMG_LOCK(M) MUTEX_LOCK(M) +# define VMG_UNLOCK(M) MUTEX_UNLOCK(M) +#else +# define VMG_LOCK(M) +# define VMG_UNLOCK(M) +#endif + #if VMG_THREADSAFE STATIC SV *vmg_clone(pTHX_ SV *sv, tTHX owner) { @@ -968,18 +976,14 @@ STATIC void vmg_op_info_init(pTHX_ unsigned int opinfo) { #define vmg_op_info_init(W) vmg_op_info_init(aTHX_ (W)) switch (opinfo) { case VMG_OP_INFO_NAME: -#if VMG_THREADSAFE - MUTEX_LOCK(&vmg_op_name_init_mutex); -#endif + VMG_LOCK(&vmg_op_name_init_mutex); if (!vmg_op_name_init) { OPCODE t; for (t = 0; t < OP_max; ++t) vmg_op_name_len[t] = strlen(PL_op_name[t]); vmg_op_name_init = 1; } -#if VMG_THREADSAFE - MUTEX_UNLOCK(&vmg_op_name_init_mutex); -#endif + VMG_UNLOCK(&vmg_op_name_init_mutex); break; case VMG_OP_INFO_OBJECT: { dMY_CXT;