about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--absl/base/internal/unaligned_access.h41
-rw-r--r--absl/numeric/int128.h1
-rw-r--r--absl/synchronization/internal/kernel_timeout.h2
3 files changed, 43 insertions, 1 deletions
diff --git a/absl/base/internal/unaligned_access.h b/absl/base/internal/unaligned_access.h
index c5724362a4e3..5c7517abd71a 100644
--- a/absl/base/internal/unaligned_access.h
+++ b/absl/base/internal/unaligned_access.h
@@ -103,6 +103,47 @@ inline void UnalignedStore64(void *p, uint64_t v) {
 #define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
   (absl::UnalignedStore64(_p, _val))
 
+#elif defined(UNDEFINED_BEHAVIOR_SANITIZER)
+
+namespace absl {
+
+inline uint16_t UnalignedLoad16(const void *p) {
+  uint16_t t;
+  memcpy(&t, p, sizeof t);
+  return t;
+}
+
+inline uint32_t UnalignedLoad32(const void *p) {
+  uint32_t t;
+  memcpy(&t, p, sizeof t);
+  return t;
+}
+
+inline uint64_t UnalignedLoad64(const void *p) {
+  uint64_t t;
+  memcpy(&t, p, sizeof t);
+  return t;
+}
+
+inline void UnalignedStore16(void *p, uint16_t v) { memcpy(p, &v, sizeof v); }
+
+inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); }
+
+inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
+
+}  // namespace absl
+
+#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) (absl::UnalignedLoad16(_p))
+#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) (absl::UnalignedLoad32(_p))
+#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) (absl::UnalignedLoad64(_p))
+
+#define ABSL_INTERNAL_UNALIGNED_STORE16(_p, _val) \
+  (absl::UnalignedStore16(_p, _val))
+#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
+  (absl::UnalignedStore32(_p, _val))
+#define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
+  (absl::UnalignedStore64(_p, _val))
+
 #elif defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \
     defined(_M_IX86) || defined(__ppc__) || defined(__PPC__) ||    \
     defined(__ppc64__) || defined(__PPC64__)
diff --git a/absl/numeric/int128.h b/absl/numeric/int128.h
index e4f39c305152..2d131b8bda1c 100644
--- a/absl/numeric/int128.h
+++ b/absl/numeric/int128.h
@@ -31,6 +31,7 @@
 #include <cstring>
 #include <iosfwd>
 #include <limits>
+#include <utility>
 
 #include "absl/base/config.h"
 #include "absl/base/macros.h"
diff --git a/absl/synchronization/internal/kernel_timeout.h b/absl/synchronization/internal/kernel_timeout.h
index 92dffb7841eb..bb7080004c72 100644
--- a/absl/synchronization/internal/kernel_timeout.h
+++ b/absl/synchronization/internal/kernel_timeout.h
@@ -117,7 +117,7 @@ class KernelTimeout {
   // This header file may be included transitively by public header files,
   // so we define our own DWORD and INFINITE instead of getting them from
   // <intsafe.h> and <WinBase.h>.
-  typedef unsigned long DWord;
+  typedef unsigned long DWord;  // NOLINT
   DWord InMillisecondsFromNow() const {
     constexpr DWord kInfinite = std::numeric_limits<DWord>::max();
     if (!has_timeout()) {