]> git.vpit.fr Git - perl/modules/autovivification.git/blobdiff - autovivification.xs
Introduce A_THREADSAFE and A_FORKSAFE
[perl/modules/autovivification.git] / autovivification.xs
index f50afa1c9f3d175151741cf3e6de8f7ef213b864..b4c76a1cb02c5ee8961394aaf027d290499a2029 100644 (file)
 
 /* ... Thread safety and multiplicity ...................................... */
 
+/* Always safe when the workaround isn't needed */
+#if !A_WORKAROUND_REQUIRE_PROPAGATION
+# undef A_FORKSAFE
+# define A_FORKSAFE 1
+/* Otherwise, safe unless Makefile.PL says it's Win32 */
+#elif !defined(A_FORKSAFE)
+# define A_FORKSAFE 1
+#endif
+
 #ifndef A_MULTIPLICITY
 # if defined(MULTIPLICITY) || defined(PERL_IMPLICIT_CONTEXT)
 #  define A_MULTIPLICITY 1
@@ -86,8 +95,6 @@ typedef struct {
  IV  require_tag;
 } a_hint_t;
 
-#define A_HINT_BITS(H) ((H)->bits)
-
 #define A_HINT_FREE(H) PerlMemShared_free(H)
 
 #if A_THREADSAFE
@@ -146,6 +153,7 @@ STATIC void a_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) {
   return;
 
  h2              = PerlMemShared_malloc(sizeof *h2);
+ h2->bits        = h1->bits;
  h2->require_tag = PTR2IV(a_clone(INT2PTR(SV *, h1->require_tag), ud->owner));
 
  ptable_hints_store(ud->tbl, ent->key, h2);
@@ -249,7 +257,7 @@ STATIC UV a_detag(pTHX_ const SV *hint) {
  if (a_require_tag() != h->require_tag)
   return 0;
 
- return A_HINT_BITS(h);
+ return h->bits;
 }
 
 #else /* A_WORKAROUND_REQUIRE_PROPAGATION */
@@ -1027,6 +1035,8 @@ BOOT:
   newCONSTSUB(stash, "A_HINT_EXISTS", newSVuv(A_HINT_EXISTS));
   newCONSTSUB(stash, "A_HINT_DELETE", newSVuv(A_HINT_DELETE));
   newCONSTSUB(stash, "A_HINT_MASK",   newSVuv(A_HINT_MASK));
+  newCONSTSUB(stash, "A_THREADSAFE",  newSVuv(A_THREADSAFE));
+  newCONSTSUB(stash, "A_FORKSAFE",    newSVuv(A_FORKSAFE));
  }
 }