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 #define SK_MACRO_APPEND_COUNTER(name) SK_MACRO_CONCAT(name, __COUNTER__)
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 
31 // Can be used to bracket data types that must be dense, e.g. hash keys.
32 #if defined(__clang__)  // This should work on GCC too, but GCC diagnostic pop didn't seem to work!
33     #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \
34                                    _Pragma("GCC diagnostic error \"-Wpadded\"")
35     #define SK_END_REQUIRE_DENSE   _Pragma("GCC diagnostic pop")
36 #else
37     #define SK_BEGIN_REQUIRE_DENSE
38     #define SK_END_REQUIRE_DENSE
39 #endif
40 
41 #define SK_INIT_TO_AVOID_WARNING    = 0
42 
43 #endif  // SkMacros_DEFINED
44