@@ -26,34 +26,34 @@ template <typename T> struct removeConst<const T> {
26
26
27
27
namespace scudo {
28
28
29
- #define OPTIONAL_TEMPLATE (TYPE, NAME, DEFAULT ) \
29
+ #define OPTIONAL_TEMPLATE (TYPE, NAME, DEFAULT, MEMBER ) \
30
30
template <typename Config, typename = TYPE> struct NAME ##State { \
31
31
static constexpr removeConst<TYPE>::type getValue () { return DEFAULT; } \
32
32
}; \
33
33
template <typename Config> \
34
- struct NAME ##State<Config, decltype (Config::NAME )> { \
34
+ struct NAME ##State<Config, decltype (Config::MEMBER )> { \
35
35
static constexpr removeConst<TYPE>::type getValue () { \
36
- return Config::NAME; \
36
+ return Config::MEMBER; \
37
37
} \
38
38
};
39
39
40
- #define OPTIONAL_TYPE_TEMPLATE (NAME, DEFAULT ) \
40
+ #define OPTIONAL_TYPE_TEMPLATE (NAME, DEFAULT, MEMBER ) \
41
41
template <typename Config, typename Void = Config> struct NAME ##Type { \
42
42
static constexpr bool enabled () { return false ; } \
43
43
using NAME = DEFAULT; \
44
44
}; \
45
45
template <typename Config> \
46
- struct NAME ##Type<Config, typename Config::NAME > { \
46
+ struct NAME ##Type<Config, typename Config::MEMBER > { \
47
47
static constexpr bool enabled () { return true ; } \
48
- using NAME = typename Config::NAME; \
48
+ using NAME = typename Config::MEMBER; \
49
49
};
50
50
51
51
template <typename AllocatorConfig> struct BaseConfig {
52
52
#define BASE_REQUIRED_TEMPLATE_TYPE (NAME ) \
53
53
template <typename T> using NAME = typename AllocatorConfig::template NAME<T>;
54
54
55
55
#define BASE_OPTIONAL (TYPE, NAME, DEFAULT ) \
56
- OPTIONAL_TEMPLATE (TYPE, NAME, DEFAULT) \
56
+ OPTIONAL_TEMPLATE (TYPE, NAME, DEFAULT, NAME) \
57
57
static constexpr removeConst<TYPE>::type get##NAME() { \
58
58
return NAME##State<AllocatorConfig>::getValue (); \
59
59
}
@@ -77,13 +77,13 @@ template <typename AllocatorConfig> struct PrimaryConfig {
77
77
}
78
78
79
79
#define PRIMARY_OPTIONAL (TYPE, NAME, DEFAULT ) \
80
- OPTIONAL_TEMPLATE (TYPE, NAME, DEFAULT) \
80
+ OPTIONAL_TEMPLATE (TYPE, NAME, DEFAULT, NAME) \
81
81
static constexpr removeConst<TYPE>::type get##NAME() { \
82
82
return NAME##State<typename AllocatorConfig::Primary>::getValue (); \
83
83
}
84
84
85
85
#define PRIMARY_OPTIONAL_TYPE (NAME, DEFAULT ) \
86
- OPTIONAL_TYPE_TEMPLATE (NAME, DEFAULT) \
86
+ OPTIONAL_TYPE_TEMPLATE (NAME, DEFAULT, NAME) \
87
87
static constexpr bool has##NAME() { \
88
88
return NAME##Type<typename AllocatorConfig::Primary>::enabled (); \
89
89
} \
@@ -113,22 +113,17 @@ template <typename AllocatorConfig> struct SecondaryConfig {
113
113
}
114
114
115
115
#define SECONDARY_CACHE_OPTIONAL (TYPE, NAME, DEFAULT ) \
116
- template <typename Config, typename = TYPE> struct NAME ##State { \
117
- static constexpr removeConst<TYPE>::type getValue () { return DEFAULT; } \
118
- }; \
119
- template <typename Config> \
120
- struct NAME ##State<Config, decltype (Config::Cache)> { \
121
- static constexpr removeConst<TYPE>::type getValue () { \
122
- return Config::Cache::NAME; \
123
- } \
124
- }; \
116
+ OPTIONAL_TEMPLATE (TYPE, NAME, DEFAULT, Cache::NAME) \
125
117
static constexpr removeConst<TYPE>::type get##NAME() { \
126
118
return NAME##State<typename AllocatorConfig::Secondary>::getValue (); \
127
119
}
128
120
#include " allocator_config.def"
129
- };
121
+ }; // CacheConfig
130
122
}; // SecondaryConfig
131
123
124
+ #undef OPTIONAL_TEMPLATE
125
+ #undef OPTIONAL_TEMPLATE_TYPE
126
+
132
127
} // namespace scudo
133
128
134
129
#endif // SCUDO_ALLOCATOR_CONFIG_WRAPPER_H_
0 commit comments