mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Bug 1325771 - mfbt: Reorder parameters for MOZ_ALIGNED_DECL r=jwalden
Currently, MOZ_ALIGNED_DECL uses the order (_type, _align) for its parameters. However, this order makes the code less readable when _type is a larger object like a struct because the value for _align would be at the end of the struct definition. By swapping the order of _type and _align, the alignment value will always be next to the type name, regardless how far the definition of _type extends. Differential Revision: https://phabricator.services.mozilla.com/D77288
This commit is contained in:
parent
0d3f9839aa
commit
319d3205ce
@ -85,8 +85,8 @@ END_TEST(testAtomicFence)
|
||||
// Memory for testing atomics. This must be aligned to the natural alignment of
|
||||
// the type we're testing; for now, use 8-byte alignment for all.
|
||||
|
||||
MOZ_ALIGNED_DECL(static uint8_t atomicMem[8], 8);
|
||||
MOZ_ALIGNED_DECL(static uint8_t atomicMem2[8], 8);
|
||||
MOZ_ALIGNED_DECL(8, static uint8_t atomicMem[8]);
|
||||
MOZ_ALIGNED_DECL(8, static uint8_t atomicMem2[8]);
|
||||
|
||||
// T is the primitive type we're testing, and A and B are references to constant
|
||||
// bindings holding values of that type.
|
||||
|
@ -2874,7 +2874,7 @@ struct TlsData {
|
||||
// The globalArea must be the last field. Globals for the module start here
|
||||
// and are inline in this structure. 16-byte alignment is required for SIMD
|
||||
// data.
|
||||
MOZ_ALIGNED_DECL(char globalArea, 16);
|
||||
MOZ_ALIGNED_DECL(16, char globalArea);
|
||||
};
|
||||
|
||||
static const size_t TlsDataAlign = 16; // = Simd128DataSize
|
||||
|
@ -62,18 +62,18 @@ struct AlignasHelper {
|
||||
*
|
||||
* For instance,
|
||||
*
|
||||
* MOZ_ALIGNED_DECL(char arr[2], 8);
|
||||
* MOZ_ALIGNED_DECL(8, char arr[2]);
|
||||
*
|
||||
* will declare a two-character array |arr| aligned to 8 bytes.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define MOZ_ALIGNED_DECL(_type, _align) _type __attribute__((aligned(_align)))
|
||||
# define MOZ_ALIGNED_DECL(_align, _type) _type __attribute__((aligned(_align)))
|
||||
#elif defined(_MSC_VER)
|
||||
# define MOZ_ALIGNED_DECL(_type, _align) __declspec(align(_align)) _type
|
||||
# define MOZ_ALIGNED_DECL(_align, _type) __declspec(align(_align)) _type
|
||||
#else
|
||||
# warning "We don't know how to align variables on this compiler."
|
||||
# define MOZ_ALIGNED_DECL(_type, _align) _type
|
||||
# define MOZ_ALIGNED_DECL(_align, _type) _type
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -92,27 +92,27 @@ struct AlignedElem;
|
||||
|
||||
template <>
|
||||
struct AlignedElem<1> {
|
||||
MOZ_ALIGNED_DECL(uint8_t elem, 1);
|
||||
MOZ_ALIGNED_DECL(1, uint8_t elem);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct AlignedElem<2> {
|
||||
MOZ_ALIGNED_DECL(uint8_t elem, 2);
|
||||
MOZ_ALIGNED_DECL(2, uint8_t elem);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct AlignedElem<4> {
|
||||
MOZ_ALIGNED_DECL(uint8_t elem, 4);
|
||||
MOZ_ALIGNED_DECL(4, uint8_t elem);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct AlignedElem<8> {
|
||||
MOZ_ALIGNED_DECL(uint8_t elem, 8);
|
||||
MOZ_ALIGNED_DECL(8, uint8_t elem);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct AlignedElem<16> {
|
||||
MOZ_ALIGNED_DECL(uint8_t elem, 16);
|
||||
MOZ_ALIGNED_DECL(16, uint8_t elem);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user