1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#include "common.h"
6#include "gcenv.h"
7#include "gc.h"
8
9#define BOOL_CONFIG(name, key, default, unused_doc) \
10 bool GCConfig::Get##name() { return s_##name; } \
11 bool GCConfig::s_##name = default;
12
13#define INT_CONFIG(name, key, default, unused_doc) \
14 int64_t GCConfig::Get##name() { return s_##name; } \
15 int64_t GCConfig::s_##name = default;
16
17// String configs are not cached because 1) they are rare and
18// not on hot paths and 2) they involve transfers of ownership
19// of EE-allocated strings, which is potentially complicated.
20#define STRING_CONFIG(name, key, unused_doc) \
21 GCConfigStringHolder GCConfig::Get##name() \
22 { \
23 const char* resultStr = nullptr; \
24 GCToEEInterface::GetStringConfigValue(key, &resultStr); \
25 return GCConfigStringHolder(resultStr); \
26 }
27
28GC_CONFIGURATION_KEYS
29
30#undef BOOL_CONFIG
31#undef INT_CONFIG
32#undef STRING_CONFIG
33
34void GCConfig::Initialize()
35{
36#define BOOL_CONFIG(name, key, default, unused_doc) \
37 GCToEEInterface::GetBooleanConfigValue(key, &s_##name);
38
39#define INT_CONFIG(name, key, default, unused_doc) \
40 GCToEEInterface::GetIntConfigValue(key, &s_##name);
41
42#define STRING_CONFIG(unused_name, unused_key, unused_doc)
43
44GC_CONFIGURATION_KEYS
45
46#undef BOOL_CONFIG
47#undef INT_CONFIG
48}
49