summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-08-11 14:46:55 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-08-12 01:53:26 -0700
commit4ea34344d710c5231aae2bde41acf5fda78eb175 (patch)
tree31d8f4c6a708e94a4ef92ea00e2dfb4b564c215b /dist
parente0060e30a691e43bb2fb3e566faa3878a95f8af4 (diff)
downloadperl-4ea34344d710c5231aae2bde41acf5fda78eb175.tar.gz
Make Storable support read-only COWs
Unfortunately, the historical double meaning of SvREADONLY makes it hard to do the correct thing under all perl versions. If this proves too problematic for other XS modules, we might need to forbid read-only COWs, which would be unfortunate, since they speed things up. However, a CPAN search reveals nothing outside core for READONLY.*?(IsCOW|FAKE).
Diffstat (limited to 'dist')
-rw-r--r--dist/Storable/Storable.xs10
1 files changed, 8 insertions, 2 deletions
diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs
index b89ef6f85d..439009a789 100644
--- a/dist/Storable/Storable.xs
+++ b/dist/Storable/Storable.xs
@@ -81,6 +81,12 @@
# define HvTOTALKEYS(hv) HvKEYS(hv)
#endif
+#ifdef SVf_IsCOW
+# define SvTRULYREADONLY(sv) SvREADONLY(sv)
+#else
+# define SvTRULYREADONLY(sv) (SvREADONLY(sv) && !SvIsCOW(sv))
+#endif
+
#ifdef DEBUGME
#ifndef DASSERT
@@ -2452,7 +2458,7 @@ static int store_hash(pTHX_ stcxt_t *cxt, HV *hv)
/* Implementation of restricted hashes isn't nicely
abstracted: */
if ((hash_flags & SHV_RESTRICTED)
- && SvREADONLY(val) && !SvIsCOW(val)) {
+ && SvTRULYREADONLY(val)) {
flags |= SHV_K_LOCKED;
}
@@ -2544,7 +2550,7 @@ static int store_hash(pTHX_ stcxt_t *cxt, HV *hv)
abstracted: */
flags
= (((hash_flags & SHV_RESTRICTED)
- && SvREADONLY(val) && !SvIsCOW(val))
+ && SvTRULYREADONLY(val))
? SHV_K_LOCKED : 0);
if (val == &PL_sv_placeholder) {