| 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | #ifndef SkMacros_DEFINED |
| 8 | #define SkMacros_DEFINED |
| 9 | |
| 10 | /* |
| 11 | * Usage: SK_MACRO_CONCAT(a, b) to construct the symbol ab |
| 12 | * |
| 13 | * SK_MACRO_CONCAT_IMPL_PRIV just exists to make this work. Do not use directly |
| 14 | * |
| 15 | */ |
| 16 | #define SK_MACRO_CONCAT(X, Y) SK_MACRO_CONCAT_IMPL_PRIV(X, Y) |
| 17 | #define SK_MACRO_CONCAT_IMPL_PRIV(X, Y) X ## Y |
| 18 | |
| 19 | /* |
| 20 | * Usage: SK_MACRO_APPEND_LINE(foo) to make foo123, where 123 is the current |
| 21 | * line number. Easy way to construct |
| 22 | * unique names for local functions or |
| 23 | * variables. |
| 24 | */ |
| 25 | #define SK_MACRO_APPEND_LINE(name) SK_MACRO_CONCAT(name, __LINE__) |
| 26 | |
| 27 | //////////////////////////////////////////////////////////////////////////////// |
| 28 | |
| 29 | // Can be used to bracket data types that must be dense, e.g. hash keys. |
| 30 | #if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop didn't seem to work! |
| 31 | #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \ |
| 32 | _Pragma("GCC diagnostic error \"-Wpadded\"") |
| 33 | #define SK_END_REQUIRE_DENSE _Pragma("GCC diagnostic pop") |
| 34 | #else |
| 35 | #define SK_BEGIN_REQUIRE_DENSE |
| 36 | #define SK_END_REQUIRE_DENSE |
| 37 | #endif |
| 38 | |
| 39 | #define SK_INIT_TO_AVOID_WARNING = 0 |
| 40 | |
| 41 | #endif // SkMacros_DEFINED |
| 42 | |