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.
9 #define BOOL_CONFIG(name, key, default, unused_doc) \
10 bool GCConfig::Get##name() { return s_##name; } \
11 bool GCConfig::s_##name = default;
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;
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() \
23 const char* resultStr = nullptr; \
24 GCToEEInterface::GetStringConfigValue(key, &resultStr); \
25 return GCConfigStringHolder(resultStr); \
34 void GCConfig::Initialize()
36 #define BOOL_CONFIG(name, key, default, unused_doc) \
37 GCToEEInterface::GetBooleanConfigValue(key, &s_##name);
39 #define INT_CONFIG(name, key, default, unused_doc) \
40 GCToEEInterface::GetIntConfigValue(key, &s_##name);
42 #define STRING_CONFIG(unused_name, unused_key, unused_doc)
50 bool ParseGCHeapAffinitizeRanges(AffinitySet* config_affinity_set)
54 GCConfigStringHolder cpu_index_ranges_holder(GCConfig::GetGCHeapAffinitizeRanges());
55 const char* cpu_index_ranges = cpu_index_ranges_holder.Get();
57 // The cpu index ranges is a comma separated list of indices or ranges of indices (e.g. 1-5).
58 // Example 1,3,5,7-9,12
60 if (cpu_index_ranges != NULL)
66 size_t start_index = strtoul(cpu_index_ranges, &number_end, 10);
68 if (number_end == cpu_index_ranges)
70 // No number found, invalid format
74 size_t end_index = start_index;
76 if (*number_end == '-')
78 char* range_end_start = number_end + 1;
79 end_index = strtoul(range_end_start, &number_end, 10);
80 if (number_end == range_end_start)
82 // No number found, invalid format
87 if ((start_index < MAX_SUPPORTED_CPUS) && end_index < (MAX_SUPPORTED_CPUS))
89 for (size_t i = start_index; i <= end_index; i++)
91 config_affinity_set->Add(i);
95 cpu_index_ranges = number_end + 1;
97 while (*number_end == ',');
99 success = (*number_end == '\0');