hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
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
From 6224d20a6af0216c12bf269a7b9daeaac333decb Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 27 Mar 2020 17:48:20 +0800
Subject: [PATCH 08/12] cld3: Avoid unaligned accesses
 
Although the unaligned memory accesses are enabled, somehow i still hit
the SIGBUS:
[23496.643138] Unhandled fault: alignment fault (0x92000021) at 0x00000000b182e636
Received signal 7 BUS_ADRALN 0000b182e636
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 .../third_party/cld_3/src/src/script_span/port.h     | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 
diff --git a/src/3rdparty/chromium/third_party/cld_3/src/src/script_span/port.h b/src/3rdparty/chromium/third_party/cld_3/src/src/script_span/port.h
index 2b3bc515ae..1d437babf7 100644
--- a/src/3rdparty/chromium/third_party/cld_3/src/src/script_span/port.h
+++ b/src/3rdparty/chromium/third_party/cld_3/src/src/script_span/port.h
@@ -78,11 +78,23 @@ namespace CLD2 {
 //
 // This is a mess, but there's not much we can do about it.
 
+#if 0
 #define UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))
 #define UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))
 
 #define UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16 *>(_p) = (_val))
 #define UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val))
+#else
+inline uint32 UNALIGNED_LOAD32(const void *p) {
+  uint32 t;
+  memcpy(&t, p, sizeof t);
+  return t;
+}
+
+inline void UNALIGNED_STORE32(void *p, uint32 v) {
+  memcpy(p, &v, sizeof v);
+}
+#endif
 
 // TODO(sesse): NEON supports unaligned 64-bit loads and stores.
 // See if that would be more efficient on platforms supporting it,
-- 
2.20.1