OLD | NEW |
(Empty) | |
| 1 #ifndef WTF_SizeAssertions_h |
| 2 #define WTF_SizeAssertions_h |
| 3 |
| 4 #include "wtf/CPU.h" |
| 5 |
| 6 namespace WTF { |
| 7 |
| 8 template<class T, int Expected32BitSize, int Expected64BitSize> struct assert_si
ze { |
| 9 template<int ActualSize, int ExpectedSize> class assert_equal { |
| 10 static_assert(ActualSize == ExpectedSize, |
| 11 "Object size doesn't match expected value, think before making them
bigger :-)"); |
| 12 }; |
| 13 #if CPU(32BIT) |
| 14 assert_equal<sizeof(T), Expected32BitSize> tmp; |
| 15 #else |
| 16 assert_equal<sizeof(T), Expected64BitSize> tmp; |
| 17 #endif |
| 18 enum { Dummy = 1 }; |
| 19 }; |
| 20 |
| 21 } // namespace WTF |
| 22 |
| 23 // Some objects have additional members when asserts are enabled, so only check |
| 24 // sizes when they are disabled. |
| 25 #if ENABLE(ASSERT) |
| 26 #define ASSERT_SIZE(className, expected32BitSize, expected64BitSize) |
| 27 #else |
| 28 #define ASSERT_SIZE(className, expected32BitSize, expected64BitSize) \ |
| 29 static_assert(WTF::assert_size<className, expected32BitSize, expected64BitSi
ze>::Dummy, ""); |
| 30 #endif |
| 31 |
| 32 #endif /* WTF_SizeAssertions_h */ |
OLD | NEW |