]> git.vpit.fr Git - perl/modules/Variable-Magic.git/commitdiff
Wrap MUTEX_{LOCK,UNLOCK} in macros so can we don't have to #ifdef them
authorVincent Pit <vince@profvince.com>
Wed, 26 Oct 2011 10:02:11 +0000 (12:02 +0200)
committerVincent Pit <vince@profvince.com>
Wed, 26 Oct 2011 10:02:16 +0000 (12:02 +0200)
Magic.xs

index 334a0a84025d518b046383b0b2682d603422f6ea..4ac45e73ec12e7de3d11e359d26b38742c2fc2a9 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
 # 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;