aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkTypes.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-11-24 05:35:58 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-24 05:35:58 -0800
commitb68ce74bd197a9ca4becd53cbcfee825b8d08e0e (patch)
treed7b723fe7fc5e92dbb34f635f6d0239f6f429140 /include/core/SkTypes.h
parentd14c39eff209f6eacd322af95a69534fc207cf27 (diff)
Add SK_BEGIN_REQUIRE_DENSE / SK_END_REQUIRE_DENSE.
Use in on a few examples of things we hash. BUG=skia: Review URL: https://codereview.chromium.org/1468483002
Diffstat (limited to 'include/core/SkTypes.h')
-rw-r--r--include/core/SkTypes.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index d9254acf5f..5720c30970 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -287,6 +287,16 @@ static inline bool SkIsU16(long x) {
template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N];
#define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array)))
+// Can be used to bracket data types that must be dense, e.g. hash keys.
+#if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop didn't seem to work!
+ #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic error \"-Wpadded\"")
+ #define SK_END_REQUIRE_DENSE _Pragma("GCC diagnostic pop")
+#else
+ #define SK_BEGIN_REQUIRE_DENSE
+ #define SK_END_REQUIRE_DENSE
+#endif
+
#define SkAlign2(x) (((x) + 1) >> 1 << 1)
#define SkIsAlign2(x) (0 == ((x) & 1))