Changeset View
Changeset View
Standalone View
Standalone View
libraries/source/spidermonkey/include-win32-debug/mozilla/Alignment.h
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | struct AlignedStorage | ||||
union U | union U | ||||
{ | { | ||||
char mBytes[Nbytes]; | char mBytes[Nbytes]; | ||||
uint64_t mDummy; | uint64_t mDummy; | ||||
} u; | } u; | ||||
const void* addr() const { return u.mBytes; } | const void* addr() const { return u.mBytes; } | ||||
void* addr() { return u.mBytes; } | void* addr() { return u.mBytes; } | ||||
AlignedStorage() = default; | |||||
// AlignedStorage is non-copyable: the default copy constructor violates | |||||
// strict aliasing rules, per bug 1269319. | |||||
AlignedStorage(const AlignedStorage&) = delete; | |||||
void operator=(const AlignedStorage&) = delete; | |||||
}; | }; | ||||
template<typename T> | template<typename T> | ||||
struct MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS AlignedStorage2 | struct MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS AlignedStorage2 | ||||
{ | { | ||||
union U | union U | ||||
{ | { | ||||
char mBytes[sizeof(T)]; | char mBytes[sizeof(T)]; | ||||
uint64_t mDummy; | uint64_t mDummy; | ||||
} u; | } u; | ||||
const T* addr() const { return reinterpret_cast<const T*>(u.mBytes); } | const T* addr() const { return reinterpret_cast<const T*>(u.mBytes); } | ||||
T* addr() { return static_cast<T*>(static_cast<void*>(u.mBytes)); } | T* addr() { return static_cast<T*>(static_cast<void*>(u.mBytes)); } | ||||
AlignedStorage2() = default; | |||||
// AlignedStorage2 is non-copyable: the default copy constructor violates | |||||
// strict aliasing rules, per bug 1269319. | |||||
AlignedStorage2(const AlignedStorage2&) = delete; | |||||
void operator=(const AlignedStorage2&) = delete; | |||||
}; | }; | ||||
} /* namespace mozilla */ | } /* namespace mozilla */ | ||||
#endif /* mozilla_Alignment_h */ | #endif /* mozilla_Alignment_h */ |
Wildfire Games · Phabricator