Export of internal Abseil changes.
-- 60bc1e62580e0ff352a92c785f29550c2000447d by Xiaoyi Zhang <zhangxy@google.com>: Import Github PR https://github.com/abseil/abseil-cpp/pull/143. absl/synchronization/internal/kernel_timeout.h uses INFINITE macro that comes from windows.h that is included by winsock2.h that is included by absl/time/time.h. This internal header will be included by public header. It should not depend on windows.h. PiperOrigin-RevId: 205109009 -- 1617f0a333a8030e4e4c0bc1eef71f4a5fe9874d by Abseil Team <absl-team@google.com>: Internal change PiperOrigin-RevId: 205101804 -- 8dce298b8c96c12c423943a366a4d92a554366c4 by Chris Kennelly <ckennelly@google.com>: Define UNALIGNED_LOAD/STORE macros for UNDEFINED_BEHAVIOR_SANITIZER. When using UBSan in trap mode (that is, without the ubsan runtime library), the x86 macros can cause alignment errors as they assume unaligned loads/stores are permitted. The macros defined in the presence of {ADDRESS,THREAD,MEMORY}_SANITIZER require the runtime library. PiperOrigin-RevId: 205096794 GitOrigin-RevId: 60bc1e62580e0ff352a92c785f29550c2000447d Change-Id: I65a6cc86a711796c9d3a605310d67795b9f76ce9
This commit is contained in:
parent
44aa275286
commit
2c5af55ed3
3 changed files with 43 additions and 1 deletions
|
@ -96,6 +96,47 @@ inline void UnalignedStore64(void *p, uint64_t v) {
|
||||||
#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) (absl::UnalignedLoad32(_p))
|
#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) (absl::UnalignedLoad32(_p))
|
||||||
#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) (absl::UnalignedLoad64(_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(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) \
|
#define ABSL_INTERNAL_UNALIGNED_STORE16(_p, _val) \
|
||||||
(absl::UnalignedStore16(_p, _val))
|
(absl::UnalignedStore16(_p, _val))
|
||||||
#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
|
#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "absl/base/config.h"
|
#include "absl/base/config.h"
|
||||||
#include "absl/base/macros.h"
|
#include "absl/base/macros.h"
|
||||||
|
|
|
@ -117,7 +117,7 @@ class KernelTimeout {
|
||||||
// This header file may be included transitively by public header files,
|
// This header file may be included transitively by public header files,
|
||||||
// so we define our own DWORD and INFINITE instead of getting them from
|
// so we define our own DWORD and INFINITE instead of getting them from
|
||||||
// <intsafe.h> and <WinBase.h>.
|
// <intsafe.h> and <WinBase.h>.
|
||||||
typedef unsigned long DWord;
|
typedef unsigned long DWord; // NOLINT
|
||||||
DWord InMillisecondsFromNow() const {
|
DWord InMillisecondsFromNow() const {
|
||||||
constexpr DWord kInfinite = std::numeric_limits<DWord>::max();
|
constexpr DWord kInfinite = std::numeric_limits<DWord>::max();
|
||||||
if (!has_timeout()) {
|
if (!has_timeout()) {
|
||||||
|
|
Loading…
Reference in a new issue