In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ea3ffa52d4da2260b940cb269b4e4f51ecd6bc7b?hp=b0b342d4b3fa61880a96b645a3dab648f7c4c682>

- Log -----------------------------------------------------------------
commit ea3ffa52d4da2260b940cb269b4e4f51ecd6bc7b
Author: Tony Cook <[email protected]>
Date:   Thu Nov 3 11:12:57 2016 +1100

    Revert "hv.h: rework HEK_FLAGS to a proper member in struct hek"
    
    This reverts commit d3148f758506efd28325dfd8e1b698385133f0cd.
    
    SV keys are stored as pointers in the key_key, on platforms with
    alignment requirements (such as PA-RISC) this resulted in bus errors
    early in the build.
-----------------------------------------------------------------------

Summary of changes:
 hv.c   |  3 ++-
 hv.h   |  5 +++--
 perl.c | 12 ------------
 3 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/hv.c b/hv.c
index de06148..7659a6d 100644
--- a/hv.c
+++ b/hv.c
@@ -80,7 +80,8 @@ S_save_hek_flags(const char *str, I32 len, U32 hash, int 
flags)
     HEK *hek;
 
     PERL_ARGS_ASSERT_SAVE_HEK_FLAGS;
-    Newx(k, HEK_BASESIZE + len + 1, char);
+
+    Newx(k, HEK_BASESIZE + len + 2, char);
     hek = (HEK*)k;
     Copy(str, HEK_KEY(hek), len, char);
     HEK_KEY(hek)[len] = 0;
diff --git a/hv.h b/hv.h
index 16634b7..ee536f0 100644
--- a/hv.h
+++ b/hv.h
@@ -45,9 +45,10 @@ struct he {
 struct hek {
     U32                hek_hash;       /* hash of key */
     I32                hek_len;        /* length of hash key */
-    char        hek_flags;      /* The flags associated with this key */
     char       hek_key[1];     /* variable-length hash key */
     /* the hash-key is \0-terminated */
+    /* after the \0 there is a byte for flags, such as whether the key
+       is UTF-8 */
 };
 
 struct shared_he {
@@ -396,7 +397,7 @@ C<SV*>.
 #define HEK_HASH(hek)          (hek)->hek_hash
 #define HEK_LEN(hek)           (hek)->hek_len
 #define HEK_KEY(hek)           (hek)->hek_key
-#define HEK_FLAGS(hek)                (hek)->hek_flags
+#define HEK_FLAGS(hek) (*((unsigned char *)(HEK_KEY(hek))+HEK_LEN(hek)+1))
 
 #define HVhek_UTF8     0x01 /* Key is utf8 encoded. */
 #define HVhek_WASUTF8  0x02 /* Key is bytes here, but was supplied as utf8. */
diff --git a/perl.c b/perl.c
index 8fca566..aa7d8b6 100644
--- a/perl.c
+++ b/perl.c
@@ -322,18 +322,6 @@ perl_construct(pTHXx)
     }
 #endif /* #if defined(USE_HASH_SEED) || defined(USE_HASH_SEED_EXPLICIT) */
 
-    /* Afaik, this is good as anywhere else to assert
-     * that our HEK structure is properly sized.
-     * We expect that the char used for the flags is
-     * not padded and the bytes for the key continue right
-     * after. (For now, perhaps we should just make the flags
-     * a U32, and leave the beginning of key buffer aligned)
-     * - Yves
-     */
-    STATIC_ASSERT_STMT(  sizeof(((struct hek *)0)->hek_flags) ==
-                         (offsetof(struct hek, hek_key)
-                          - offsetof(struct hek, hek_flags)));
-
     /* Note that strtab is a rather special HV.  Assumptions are made
        about not iterating on it, and not adding tie magic to it.
        It is properly deallocated in perl_destruct() */

--
Perl5 Master Repository

Reply via email to