| Index: Source/wtf/SizeAssertions.h
|
| diff --git a/Source/wtf/SizeAssertions.h b/Source/wtf/SizeAssertions.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e7e90e8a418676e390ea9dbdb1641a577e971db4
|
| --- /dev/null
|
| +++ b/Source/wtf/SizeAssertions.h
|
| @@ -0,0 +1,32 @@
|
| +#ifndef WTF_SizeAssertions_h
|
| +#define WTF_SizeAssertions_h
|
| +
|
| +#include "wtf/CPU.h"
|
| +
|
| +namespace WTF {
|
| +
|
| +template<class T, int Expected32BitSize, int Expected64BitSize> struct assert_size {
|
| + template<int ActualSize, int ExpectedSize> class assert_equal {
|
| + static_assert(ActualSize == ExpectedSize,
|
| + "Object size doesn't match expected value, think before making them bigger :-)");
|
| + };
|
| +#if CPU(32BIT)
|
| + assert_equal<sizeof(T), Expected32BitSize> tmp;
|
| +#else
|
| + assert_equal<sizeof(T), Expected64BitSize> tmp;
|
| +#endif
|
| + enum { Dummy = 1 };
|
| +};
|
| +
|
| +} // namespace WTF
|
| +
|
| +// Some objects have additional members when asserts are enabled, so only check
|
| +// sizes when they are disabled.
|
| +#if ENABLE(ASSERT)
|
| +#define ASSERT_SIZE(className, expected32BitSize, expected64BitSize)
|
| +#else
|
| +#define ASSERT_SIZE(className, expected32BitSize, expected64BitSize) \
|
| + static_assert(WTF::assert_size<className, expected32BitSize, expected64BitSize>::Dummy, "");
|
| +#endif
|
| +
|
| +#endif /* WTF_SizeAssertions_h */
|
|
|