зеркало из https://github.com/mozilla/pjs.git
Bug 660335 - Force nsID to align to 64-bit boundary. r=bsmedberg
This commit is contained in:
Родитель
596d1885e8
Коммит
8b130cbdea
|
@ -163,6 +163,34 @@
|
|||
#define NS_CONSTRUCTOR_FASTCALL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* NS_DEFINE_ALIGNED lets you define a variable aligned to a given number of
|
||||
* bytes.
|
||||
*
|
||||
* For instance,
|
||||
*
|
||||
* NS_DEFINE_ALIGNED(PRUint32, foo, 16);
|
||||
*
|
||||
* defines a variable |foo| of type PRUint32 which lives on a 16-byte (128-bit)
|
||||
* boundary.
|
||||
*
|
||||
* This currently only works on GCC and MSVC. On other compilers, we simply
|
||||
* don't align.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
#define NS_DEFINE_ALIGNED(type, name, alignment) \
|
||||
type name __attribute__((aligned (alignment)))
|
||||
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
#define NS_DEFINE_ALIGNED(type, name, alignment) \
|
||||
__declspec(align(alignment)) type name
|
||||
|
||||
#else
|
||||
#define NS_DEFINE_ALIGNED(type, name, alignment) \
|
||||
type name
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NS_DEFCALL undoes the effect of a global regparm/stdcall setting
|
||||
* so that xptcall works correctly.
|
||||
|
|
|
@ -52,11 +52,12 @@
|
|||
|
||||
struct nsID {
|
||||
/**
|
||||
* @name Identifier values
|
||||
* @name Identifier values. Align these to start at an 8-byte (64-bit)
|
||||
* boundary so we can use 64-bit loads in nsID::Equals.
|
||||
*/
|
||||
|
||||
//@{
|
||||
PRUint32 m0;
|
||||
NS_DEFINE_ALIGNED(PRUint32, m0, 8);
|
||||
PRUint16 m1;
|
||||
PRUint16 m2;
|
||||
PRUint8 m3[8];
|
||||
|
@ -73,6 +74,8 @@ struct nsID {
|
|||
*/
|
||||
|
||||
inline PRBool Equals(const nsID& other) const {
|
||||
PR_STATIC_ASSERT(sizeof(nsID) == 64);
|
||||
|
||||
// First cast to void* in order to silence the alignment warnings.
|
||||
return
|
||||
((PRUint64*)(void*) &m0)[0] == ((PRUint64*)(void*) &other.m0)[0] &&
|
||||
|
|
Загрузка…
Ссылка в новой задаче