diff options
author | Aaron Robinson <arobins@microsoft.com> | 2021-03-29 23:58:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 23:58:50 +0300 |
commit | d2613848efd92dfaad21499a8de81916346a3b60 (patch) | |
tree | 60895eee4feafa1a63c57a7bb3a846282b5f7bf7 /src/coreclr/utilcode | |
parent | 98ace7d4837fcd81c1f040b1f67e63e9e1973e13 (diff) |
Clean up REGUTIL/CLRConfig system (#50314)
* Convert all configuration options from REGUTIL to CLRConfig.
* Remove uses of REGUTIL outside of CLRConfig impl.
Diffstat (limited to 'src/coreclr/utilcode')
-rw-r--r-- | src/coreclr/utilcode/clrconfig.cpp | 72 | ||||
-rw-r--r-- | src/coreclr/utilcode/configuration.cpp | 4 | ||||
-rw-r--r-- | src/coreclr/utilcode/log.cpp | 20 | ||||
-rw-r--r-- | src/coreclr/utilcode/stresslog.cpp | 2 | ||||
-rw-r--r-- | src/coreclr/utilcode/util.cpp | 16 |
5 files changed, 38 insertions, 76 deletions
diff --git a/src/coreclr/utilcode/clrconfig.cpp b/src/coreclr/utilcode/clrconfig.cpp index 5142e395ac0..6c0f6eca654 100644 --- a/src/coreclr/utilcode/clrconfig.cpp +++ b/src/coreclr/utilcode/clrconfig.cpp @@ -32,14 +32,6 @@ const CLRConfig::ConfigStringInfo CLRConfig::symbol = {name, CLRConfig::EEConfig_default}; #define RETAIL_CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) \ const CLRConfig::ConfigStringInfo CLRConfig::symbol = {name, lookupOptions}; - -// TEMPORARY macros that intialize strings for config value accesses that haven't been moved over to -// CLRConfig yet. Once all accesses have been moved, these macros (and corresponding instantiations in -// file:../utilcode/CLRConfig.h) should be removed. -#define RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(symbol, name, description) \ - const LPCWSTR CLRConfig::symbol = name; -#define RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(symbol, name, description) \ - const LPCWSTR CLRConfig::symbol = name; // // Debug versions of the macros // @@ -52,17 +44,11 @@ const CLRConfig::ConfigStringInfo CLRConfig::symbol = {name, CLRConfig::EEConfig_default}; #define CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) \ const CLRConfig::ConfigStringInfo CLRConfig::symbol = {name, lookupOptions}; - #define CONFIG_DWORD_INFO_DIRECT_ACCESS(symbol, name, description) \ - const LPCWSTR CLRConfig::symbol = name; - #define CONFIG_STRING_INFO_DIRECT_ACCESS(symbol, name, description) \ - const LPCWSTR CLRConfig::symbol = name; #else #define CONFIG_DWORD_INFO(symbol, name, defaultValue, description) #define CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions) #define CONFIG_STRING_INFO(symbol, name, description) #define CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) - #define CONFIG_DWORD_INFO_DIRECT_ACCESS(symbol, name, description) - #define CONFIG_STRING_INFO_DIRECT_ACCESS(symbol, name, description) #endif // _DEBUG // Now that we have defined what what the macros in file:../inc/CLRConfigValues.h mean, include it to generate the code. @@ -72,14 +58,10 @@ #undef RETAIL_CONFIG_STRING_INFO #undef RETAIL_CONFIG_DWORD_INFO_EX #undef RETAIL_CONFIG_STRING_INFO_EX -#undef RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS -#undef RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS #undef CONFIG_DWORD_INFO #undef CONFIG_STRING_INFO #undef CONFIG_DWORD_INFO_EX #undef CONFIG_STRING_INFO_EX -#undef CONFIG_DWORD_INFO_DIRECT_ACCESS -#undef CONFIG_STRING_INFO_DIRECT_ACCESS // @@ -88,19 +70,13 @@ // Arguments: // * info - see file:../inc/CLRConfig.h for details. // -// * useDefaultIfNotSet - if true, fall back to the default value if the value is not set. -// -// * acceptExplicitDefaultFromRegutil - if false, only accept a value returned by REGUTIL if it is -// different from the default value. This parameter is useful as a way to preserve existing -// behavior. -// // * result - the result. // // Return value: // * true for success, false otherwise. // // static -DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info, bool acceptExplicitDefaultFromRegutil, /* [Out] */ bool *isDefault) +DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info, /* [Out] */ bool *isDefault) { CONTRACTL { @@ -112,7 +88,6 @@ DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info, bool acceptExplici _ASSERTE (isDefault != nullptr); - // // Set up REGUTIL options. // @@ -122,25 +97,11 @@ DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info, bool acceptExplici DWORD resultMaybe; HRESULT hr = REGUTIL::GetConfigDWORD_DontUse_(info.name, info.defaultValue, &resultMaybe, level, prependCOMPlus); - if (!acceptExplicitDefaultFromRegutil) + // Ignore the default value even if it's set explicitly. + if (resultMaybe != info.defaultValue) { - // Ignore the default value even if it's set explicitly. - if (resultMaybe != info.defaultValue) - { - *isDefault = false; - return resultMaybe; - } - } - else - { - // If we are willing to accept the default value when it's set explicitly, - // checking the HRESULT here is sufficient. E_FAIL is returned when the - // default is used. - if (SUCCEEDED(hr)) - { - *isDefault = false; - return resultMaybe; - } + *isDefault = false; + return resultMaybe; } *isDefault = true; @@ -154,12 +115,29 @@ DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info, bool acceptExplici // * info - see file:../inc/CLRConfig.h for details // // static +DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info, DWORD defaultValue) +{ + bool isDefault = false; + DWORD valueMaybe = GetConfigValue(info, &isDefault); + + // If the default value was returned, defer to the user supplied version. + if (isDefault) + return defaultValue; + + return valueMaybe; +} + +// +// Look up a DWORD config value. +// +// Arguments: +// * info - see file:../inc/CLRConfig.h for details +// +// static DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info) { - // We pass false for 'acceptExplicitDefaultFromRegutil' to maintain the existing behavior of this function. - // Callers who don't need that behavior should switch to the other version of this function and pass true. bool unused; - return GetConfigValue(info, false /* acceptExplicitDefaultFromRegutil */, &unused); + return GetConfigValue(info, &unused); } // diff --git a/src/coreclr/utilcode/configuration.cpp b/src/coreclr/utilcode/configuration.cpp index e67507d5bae..50a5e335a74 100644 --- a/src/coreclr/utilcode/configuration.cpp +++ b/src/coreclr/utilcode/configuration.cpp @@ -52,7 +52,7 @@ static LPCWSTR GetConfigurationValue(LPCWSTR name) DWORD Configuration::GetKnobDWORDValue(LPCWSTR name, const CLRConfig::ConfigDWORDInfo& dwordInfo) { bool returnedDefaultValue; - DWORD legacyValue = CLRConfig::GetConfigValue(dwordInfo, true /* acceptExplicitDefaultFromRegutil */, &returnedDefaultValue); + DWORD legacyValue = CLRConfig::GetConfigValue(dwordInfo, &returnedDefaultValue); if (!returnedDefaultValue) { return legacyValue; @@ -108,7 +108,7 @@ LPCWSTR Configuration::GetKnobStringValue(LPCWSTR name) bool Configuration::GetKnobBooleanValue(LPCWSTR name, const CLRConfig::ConfigDWORDInfo& dwordInfo) { bool returnedDefaultValue; - DWORD legacyValue = CLRConfig::GetConfigValue(dwordInfo, true /* acceptExplicitDefaultFromRegutil */, &returnedDefaultValue); + DWORD legacyValue = CLRConfig::GetConfigValue(dwordInfo, &returnedDefaultValue); if (!returnedDefaultValue) { return (legacyValue != 0); diff --git a/src/coreclr/utilcode/log.cpp b/src/coreclr/utilcode/log.cpp index 37edc05b5cd..b4a73f2cb6b 100644 --- a/src/coreclr/utilcode/log.cpp +++ b/src/coreclr/utilcode/log.cpp @@ -47,16 +47,16 @@ VOID InitLogging() // <TODO>FIX bit of a workaround for now, check for the log file in the // registry and if there, turn on file logging VPM</TODO> - LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogEnable, LOG_ENABLE); - LogFacilityMask = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_LogFacility, LogFacilityMask) | LF_ALWAYS; - LogVMLevel = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::EXTERNAL_LogLevel, LogVMLevel); - LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogFileAppend, LOG_ENABLE_APPEND_FILE); - LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogFlushFile, LOG_ENABLE_FLUSH_FILE); - LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogToDebugger, LOG_ENABLE_DEBUGGER_LOGGING); - LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogToFile, LOG_ENABLE_FILE_LOGGING); - LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogToConsole, LOG_ENABLE_CONSOLE_LOGGING); + LogFlags |= (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogEnable) != 0) ? LOG_ENABLE : 0; + LogFacilityMask = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogFacility, LogFacilityMask) | LF_ALWAYS; + LogVMLevel = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_LogLevel, LogVMLevel); + LogFlags |= (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogFileAppend) != 0) ? LOG_ENABLE_APPEND_FILE : 0; + LogFlags |= (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogFlushFile) != 0) ? LOG_ENABLE_FLUSH_FILE : 0; + LogFlags |= (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogToDebugger) != 0) ? LOG_ENABLE_DEBUGGER_LOGGING : 0; + LogFlags |= (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogToFile) != 0) ? LOG_ENABLE_FILE_LOGGING : 0; + LogFlags |= (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogToConsole) != 0) ? LOG_ENABLE_CONSOLE_LOGGING : 0; - LogFacilityMask2 = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_LogFacility2, LogFacilityMask2) | LF_ALWAYS; + LogFacilityMask2 = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogFacility2, LogFacilityMask2) | LF_ALWAYS; if (SUCCEEDED(szLogFileName.ReSizeNoThrow(MAX_LONGPATH))) { @@ -73,7 +73,7 @@ VOID InitLogging() delete fileName; } - if (REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_LogWithPid, FALSE)) + if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogWithPid)) { WCHAR szPid[20]; swprintf_s(szPid, COUNTOF(szPid), W(".%d"), GetCurrentProcessId()); diff --git a/src/coreclr/utilcode/stresslog.cpp b/src/coreclr/utilcode/stresslog.cpp index 2b81551eb38..6203d572701 100644 --- a/src/coreclr/utilcode/stresslog.cpp +++ b/src/coreclr/utilcode/stresslog.cpp @@ -142,7 +142,7 @@ void StressLog::Leave(CRITSEC_COOKIE) { /*********************************************************************************/ void StressLog::Initialize(unsigned facilities, unsigned level, unsigned maxBytesPerThread, - ULONGLONG maxBytesTotal, void* moduleBase, LPWSTR logFilename) + unsigned maxBytesTotal, void* moduleBase, LPWSTR logFilename) { STATIC_CONTRACT_LEAF; diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp index 018ea351c53..1be42772b6e 100644 --- a/src/coreclr/utilcode/util.cpp +++ b/src/coreclr/utilcode/util.cpp @@ -1406,22 +1406,6 @@ bool ConfigMethodSet::contains(LPCUTF8 methodName, LPCUTF8 className, CORINFO_SI } /**************************************************************************/ -void ConfigDWORD::init_DontUse_(__in_z LPCWSTR keyName, DWORD defaultVal) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - m_value = REGUTIL::GetConfigDWORD_DontUse_(keyName, defaultVal); - m_inited = 1; -} - -/**************************************************************************/ void ConfigString::init(const CLRConfig::ConfigStringInfo & info) { CONTRACTL |