File: big_endian.patch

package info (click to toggle)
o2 1.1~ds-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,416 kB
  • sloc: ansic: 11,340; python: 145; sh: 119; makefile: 73
file content (47 lines) | stat: -rw-r--r-- 1,660 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Description: Fix BIGendian hash
Author: IOhannes m zmölnig
Origin: Debian
Bug: https://github.com/rbdannenberg/o2/issues/23
Last-Update: 2022-09-30
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- o2.orig/src/o2_search.c
+++ o2/src/o2_search.c
@@ -78,10 +78,18 @@
 
 #if IS_LITTLE_ENDIAN
 // for little endian machines
-#define STRING_EOS_MASK 0xFF000000
+# define INT32_MASK0 0x000000FF
+# define INT32_MASK1 0x0000FF00
+# define INT32_MASK2 0x00FF0000
+# define INT32_MASK3 0xFF000000
 #else
-#define STRING_EOS_MASK 0x000000FF
+# define INT32_MASK0 0xFF000000
+# define INT32_MASK1 0x00FF0000
+# define INT32_MASK2 0x0000FF00
+# define INT32_MASK3 0x000000FF
 #endif
+
+#define STRING_EOS_MASK INT32_MASK3
 #define SCRAMBLE 2686453351680
 
 #define MAX_SERVICE_NUM  1024
@@ -417,11 +425,11 @@
         c = *ikey++;
         // c must be either all non-zero, or each zero must be followed by zero
         // and the last character is zero
-        assert(((c & 0xff) && (c & 0xff00) &&
-                (c & 0xff0000) && (c & 0xff000000)) ||
-               ((((c & 0xff) != 0) || ((c & 0xff00) == 0)) &&
-                (((c & 0xff00) != 0) || ((c & 0xff0000) == 0)) &&
-                ((c & 0xff000000) == 0)));
+        assert(((c & INT32_MASK0) && (c & INT32_MASK1) &&
+                (c & INT32_MASK2) && (c & INT32_MASK3)) ||
+               ((((c & INT32_MASK0) != 0) || ((c & INT32_MASK1) == 0)) &&
+                (((c & INT32_MASK1) != 0) || ((c & INT32_MASK2) == 0)) &&
+                ((c & INT32_MASK3) == 0)));
         hash = ((hash + c) * SCRAMBLE) >> 32;
     } while (c & STRING_EOS_MASK);
     return hash;