]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Fix test failures on big-endian architectures
authorAnders Kaseorg <andersk@mit.edu>
Fri, 16 Dec 2016 07:40:47 +0000 (02:40 -0500)
committerAnders Kaseorg <andersk@mit.edu>
Thu, 22 Dec 2016 01:00:45 +0000 (20:00 -0500)
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
debian/changelog
debian/patches/opr-Make-opr_jhash_opaque-consistent-with-opr_jhash.patch [new file with mode: 0644]
debian/patches/opr-Make-opr_jhash_opaque-endian-independent.patch [new file with mode: 0644]
debian/patches/opr-Make-opr_uuid_hash-endian-independent.patch [new file with mode: 0644]
debian/patches/series

index 3183c38ac5a75ee8cce19fbd2f79fdba3e5d5749..9e6e5cf15d6b3dbcbf4782502a3f6fa4f4a41430 100644 (file)
@@ -1,3 +1,12 @@
+openafs (1.8.0~pre1-5) UNRELEASED; urgency=medium
+
+  * debian/patches/opr-Make-opr_jhash_opaque-endian-independent.patch,
+    debian/patches/opr-Make-opr_jhash_opaque-consistent-with-opr_jhash.patch,
+    debian/patches/opr-Make-opr_uuid_hash-endian-independent.patch: Fix
+    test failures on big-endian architectures.
+
+ -- Anders Kaseorg <andersk@mit.edu>  Wed, 21 Dec 2016 19:58:22 -0500
+
 openafs (1.8.0~pre1-4) experimental; urgency=medium
 
   * debian/patches/0006-softsig-helper-fix-signame-loop.patch
diff --git a/debian/patches/opr-Make-opr_jhash_opaque-consistent-with-opr_jhash.patch b/debian/patches/opr-Make-opr_jhash_opaque-consistent-with-opr_jhash.patch
new file mode 100644 (file)
index 0000000..2795fa5
--- /dev/null
@@ -0,0 +1,40 @@
+From: Anders Kaseorg <andersk@mit.edu>
+Date: Fri, 16 Dec 2016 03:04:18 -0500
+Subject: opr: Make opr_jhash_opaque consistent with opr_jhash
+
+Change-Id: I42e1030f8c841dcb974476012a774b91c87d3fb0
+---
+ src/opr/jhash.h     | 2 +-
+ tests/opr/jhash-t.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/opr/jhash.h b/src/opr/jhash.h
+index e7b7d5d53..9c82f9c98 100644
+--- a/src/opr/jhash.h
++++ b/src/opr/jhash.h
+@@ -125,7 +125,7 @@ opr_jhash_opaque(const void *val, size_t length, afs_uint32 initval)
+     afs_uint32 a,b,c;
+     /* Set up the internal state */
+-    a = b = c = 0xdeadbeef + (((afs_uint32)length)<<2) + initval;
++    a = b = c = 0xdeadbeef + ((afs_uint32)length) + initval;
+     while (length > 12) {
+       a += (afs_uint32) str[3]<<24 |
+diff --git a/tests/opr/jhash-t.c b/tests/opr/jhash-t.c
+index 92661c27e..bde5a2e40 100644
+--- a/tests/opr/jhash-t.c
++++ b/tests/opr/jhash-t.c
+@@ -65,10 +65,10 @@ main(int argc, char **argv)
+    is_int(0xdeadbeef, opr_jhash_opaque("", 0, 0),
+         "Hashing an empty string works");
+-   is_int(2748273291UL,
++   is_int(393676113,
+         opr_jhash_opaque("Four score and seven years ago", 30, 0),
+         "Hashing a string with a 0 initval works");
+-   is_int(1389900913,
++   is_int(3445784929UL,
+         opr_jhash_opaque("Four score and seven years ago", 30, 1),
+         "Hashing a string with a 1 initval works");
+   return 0;
diff --git a/debian/patches/opr-Make-opr_jhash_opaque-endian-independent.patch b/debian/patches/opr-Make-opr_jhash_opaque-endian-independent.patch
new file mode 100644 (file)
index 0000000..9afe986
--- /dev/null
@@ -0,0 +1,49 @@
+From: Anders Kaseorg <andersk@mit.edu>
+Date: Fri, 16 Dec 2016 02:16:20 -0500
+Subject: opr: Make opr_jhash_opaque endian-independent
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+gcc -O2 produces exactly the same code for this on little-endian
+systems, but now big-endian systems have a chance of passing ‘make
+check’.
+
+Change-Id: Ifc6350648355a0a9f79184439e3f9522cd6f2ffa
+---
+ src/opr/jhash.h | 17 ++++++++++++-----
+ 1 file changed, 12 insertions(+), 5 deletions(-)
+
+diff --git a/src/opr/jhash.h b/src/opr/jhash.h
+index 5c6e3ad6c..e7b7d5d53 100644
+--- a/src/opr/jhash.h
++++ b/src/opr/jhash.h
+@@ -123,16 +123,23 @@ opr_jhash_opaque(const void *val, size_t length, afs_uint32 initval)
+ {
+     const unsigned char *str = (const unsigned char *) val;
+     afs_uint32 a,b,c;
+-    afs_uint32 k[3];
+     /* Set up the internal state */
+     a = b = c = 0xdeadbeef + (((afs_uint32)length)<<2) + initval;
+     while (length > 12) {
+-      memcpy(&k, str, 12);
+-      a += k[0];
+-      b += k[1];
+-      c += k[2];
++      a += (afs_uint32) str[3]<<24 |
++          (afs_uint32) str[2]<<16 |
++          (afs_uint32) str[1]<<8 |
++          (afs_uint32) str[0];
++      b += (afs_uint32) str[7]<<24 |
++          (afs_uint32) str[6]<<16 |
++          (afs_uint32) str[5]<<8 |
++          (afs_uint32) str[4];
++      c += (afs_uint32) str[11]<<24 |
++          (afs_uint32) str[10]<<16 |
++          (afs_uint32) str[9]<<8 |
++          (afs_uint32) str[8];
+       opr_jhash_mix(a, b, c);
+       length -= 12;
+       str += 12;
diff --git a/debian/patches/opr-Make-opr_uuid_hash-endian-independent.patch b/debian/patches/opr-Make-opr_uuid_hash-endian-independent.patch
new file mode 100644 (file)
index 0000000..bcf3443
--- /dev/null
@@ -0,0 +1,30 @@
+From: Anders Kaseorg <andersk@mit.edu>
+Date: Fri, 16 Dec 2016 02:43:48 -0500
+Subject: opr: Make opr_uuid_hash endian-independent
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+And also make sure it doesn’t use unaligned accesses.  Fixes a ‘make
+check’ failure on big-endian architectures.
+
+Change-Id: I490174f8d1eecb5f20969b4ef12ff16d0dd3806a
+---
+ src/opr/uuid.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/opr/uuid.c b/src/opr/uuid.c
+index 493c660b2..6a22ca3c2 100644
+--- a/src/opr/uuid.c
++++ b/src/opr/uuid.c
+@@ -58,9 +58,7 @@ opr_uuid_equal(const opr_uuid_t *uuid1, const opr_uuid_t *uuid2)
+ unsigned int
+ opr_uuid_hash(const opr_uuid_t *uuid)
+ {
+-   /* uuid->data is a (unsigned char *), so there's every danger that this
+-    * may cause an unaligned access on some platforms */
+-   return opr_jhash((const afs_uint32 *)uuid->data, 4, 0);
++   return opr_jhash_opaque(uuid->data, sizeof(uuid->data), 0);
+ }
+ #if !defined(KERNEL)
index 5042c1166be023995a4c3d36be267b70f795236b..d4bfeffea2e813b9dcb0723c0774e5e7c8e03d8c 100644 (file)
@@ -5,3 +5,6 @@ tests-opr-softsig-t-Avoid-hanging-due-to-intermediat.patch
 opr-ExitHandler-re-raise-the-signal-instead-of-exiti.patch
 0006-softsig-helper-fix-signame-loop.patch
 0007-Run-jhash-t-verbosely.patch
+opr-Make-opr_jhash_opaque-endian-independent.patch
+opr-Make-opr_jhash_opaque-consistent-with-opr_jhash.patch
+opr-Make-opr_uuid_hash-endian-independent.patch