catchup 4/16

This commit is contained in:
greg
2019-04-20 19:56:20 -04:00
parent 2b2adf07c8
commit 54d4634290
2 changed files with 0 additions and 162 deletions
-136
View File
@@ -109,144 +109,8 @@ inline void UnalignedStore64(void *p, uint64_t v) {
#define PHMAP_INTERNAL_UNALIGNED_STORE32(_p, _val) (phmap::bits::UnalignedStore32(_p, _val))
#define PHMAP_INTERNAL_UNALIGNED_STORE64(_p, _val) (phmap::bits::UnalignedStore64(_p, _val))
#elif defined(UNDEFINED_BEHAVIOR_SANITIZER)
namespace phmap {
namespace bits {
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 bits
} // namespace phmap
#define PHMAP_INTERNAL_UNALIGNED_LOAD16(_p) \
(phmap::bits::UnalignedLoad16(_p))
#define PHMAP_INTERNAL_UNALIGNED_LOAD32(_p) \
(phmap::bits::UnalignedLoad32(_p))
#define PHMAP_INTERNAL_UNALIGNED_LOAD64(_p) \
(phmap::bits::UnalignedLoad64(_p))
#define PHMAP_INTERNAL_UNALIGNED_STORE16(_p, _val) \
(phmap::bits::UnalignedStore16(_p, _val))
#define PHMAP_INTERNAL_UNALIGNED_STORE32(_p, _val) \
(phmap::bits::UnalignedStore32(_p, _val))
#define PHMAP_INTERNAL_UNALIGNED_STORE64(_p, _val) \
(phmap::bits::UnalignedStore64(_p, _val))
#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \
defined(_M_IX86) || defined(__ppc__) || defined(__PPC__) || \
defined(__ppc64__) || defined(__PPC64__)
// x86 and x86-64 can perform unaligned loads/stores directly;
// modern PowerPC hardware can also do unaligned integer loads and stores;
// but note: the FPU still sends unaligned loads and stores to a trap handler!
#define PHMAP_INTERNAL_UNALIGNED_LOAD16(_p) \
(*reinterpret_cast<const uint16_t *>(_p))
#define PHMAP_INTERNAL_UNALIGNED_LOAD32(_p) \
(*reinterpret_cast<const uint32_t *>(_p))
#define PHMAP_INTERNAL_UNALIGNED_LOAD64(_p) \
(*reinterpret_cast<const uint64_t *>(_p))
#define PHMAP_INTERNAL_UNALIGNED_STORE16(_p, _val) \
(*reinterpret_cast<uint16_t *>(_p) = (_val))
#define PHMAP_INTERNAL_UNALIGNED_STORE32(_p, _val) \
(*reinterpret_cast<uint32_t *>(_p) = (_val))
#define PHMAP_INTERNAL_UNALIGNED_STORE64(_p, _val) \
(*reinterpret_cast<uint64_t *>(_p) = (_val))
#elif defined(__arm__) && \
!defined(__ARM_ARCH_5__) && \
!defined(__ARM_ARCH_5T__) && \
!defined(__ARM_ARCH_5TE__) && \
!defined(__ARM_ARCH_5TEJ__) && \
!defined(__ARM_ARCH_6__) && \
!defined(__ARM_ARCH_6J__) && \
!defined(__ARM_ARCH_6K__) && \
!defined(__ARM_ARCH_6Z__) && \
!defined(__ARM_ARCH_6ZK__) && \
!defined(__ARM_ARCH_6T2__)
namespace phmap {
namespace bits {
struct Unaligned16Struct
{
uint16_t value;
uint8_t dummy; // To make the size non-power-of-two.
} PHMAP_ATTRIBUTE_PACKED;
struct Unaligned32Struct
{
uint32_t value;
uint8_t dummy; // To make the size non-power-of-two.
} PHMAP_ATTRIBUTE_PACKED;
} // namespace bits
} // namespace phmap
#define PHMAP_INTERNAL_UNALIGNED_LOAD16(_p) \
((reinterpret_cast<const ::phmap::bits::Unaligned16Struct *>(_p))->value)
#define PHMAP_INTERNAL_UNALIGNED_LOAD32(_p) \
((reinterpret_cast<const ::phmap::bits::Unaligned32Struct *>(_p))->value)
#define PHMAP_INTERNAL_UNALIGNED_STORE16(_p, _val) \
((reinterpret_cast< ::phmap::bits::Unaligned16Struct *>(_p))->value = (_val))
#define PHMAP_INTERNAL_UNALIGNED_STORE32(_p, _val) \
((reinterpret_cast< ::phmap::bits::Unaligned32Struct *>(_p))->value = (_val))
namespace phmap {
namespace bits {
inline uint64_t UnalignedLoad64(const void *p)
{
uint64_t t;
memcpy(&t, p, sizeof t);
return t;
}
inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
} // namespace bits
} // namespace phmap
#define PHMAP_INTERNAL_UNALIGNED_LOAD64(_p) \
(phmap::bits::UnalignedLoad64(_p))
#define PHMAP_INTERNAL_UNALIGNED_STORE64(_p, _val) \
(phmap::bits::UnalignedStore64(_p, _val))
#else
// PHMAP_INTERNAL_NEED_ALIGNED_LOADS is defined when the underlying platform
// doesn't support unaligned access.
#define PHMAP_INTERNAL_NEED_ALIGNED_LOADS
// These functions are provided for architectures that don't support
// unaligned loads and stores.
namespace phmap {
namespace bits {