Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2015-10-17 11:18:37 +0300
committerJan Vorlicek <janvorli@microsoft.com>2015-10-24 18:38:19 +0300
commitb8ee1855645d427fd9a1ad17f9270340a42f96a0 (patch)
tree5d66f0d662b5c7f8441e356f2e157796cf5656e7 /src/Native/Runtime/RhConfig.cpp
parent86b0cc9a82ae0655eb334ca4aacf9a384a05b89b (diff)
Enable compilation of the runtime on Linux
This change enables compilation of the runtime excluding the PAL layer on Linux. Most of the changes are just to make it build with clang that's more strict w.r.t. the C++11 standard. In addition to that, I have removed our implementation of the new / delete operators and replaced all calls to new in the runtime by new (nothrow).
Diffstat (limited to 'src/Native/Runtime/RhConfig.cpp')
-rw-r--r--src/Native/Runtime/RhConfig.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/Native/Runtime/RhConfig.cpp b/src/Native/Runtime/RhConfig.cpp
index 4cfbd3cdd..b3ee82fc4 100644
--- a/src/Native/Runtime/RhConfig.cpp
+++ b/src/Native/Runtime/RhConfig.cpp
@@ -26,7 +26,7 @@
#include "RhConfig.h"
-UInt32 RhConfig::ReadConfigValue(_In_z_ WCHAR *wszName)
+UInt32 RhConfig::ReadConfigValue(_In_z_ const WCHAR *wszName)
{
WCHAR wszBuffer[CONFIG_VAL_MAXLEN + 1]; // 8 hex digits plus a nul terminator.
const UInt32 cchBuffer = sizeof(wszBuffer) / sizeof(wszBuffer[0]);
@@ -69,7 +69,7 @@ UInt32 RhConfig::ReadConfigValue(_In_z_ WCHAR *wszName)
//if the file is not avaliable, or unreadable zero will always be returned
//cchOuputBuffer is the maximum number of characters to write to outputBuffer
//cchOutputBuffer must be a size >= CONFIG_VAL_MAXLEN + 1
-UInt32 RhConfig::GetIniVariable(_In_z_ WCHAR* configName, _Out_writes_all_(cchBuff) WCHAR* outputBuffer, _In_ UInt32 cchOuputBuffer)
+UInt32 RhConfig::GetIniVariable(_In_z_ const WCHAR* configName, _Out_writes_all_(cchBuff) WCHAR* outputBuffer, _In_ UInt32 cchOuputBuffer)
{
//the buffer needs to be big enough to read the value buffer + null terminator
if (cchOuputBuffer < CONFIG_VAL_MAXLEN + 1)
@@ -158,7 +158,14 @@ void RhConfig::ReadConfigIni()
return;
}
- ConfigPair* iniBuff = new ConfigPair[RCV_Count];
+ ConfigPair* iniBuff = new (nothrow) ConfigPair[RCV_Count];
+ if (iniBuff == NULL)
+ {
+ //only set if another thread hasn't initialized the buffer yet, otherwise ignore and let the first setter win
+ PalInterlockedCompareExchangePointer(&g_iniSettings, CONFIG_INI_NOT_AVAIL, NULL);
+
+ return;
+ }
UInt32 iBuff = 0;
UInt32 iIniBuff = 0;
@@ -241,17 +248,19 @@ _Ret_maybenull_z_ WCHAR* RhConfig::GetConfigPath()
return NULL;
}
- WCHAR* configPath = new WCHAR[iLastBackslash + 1 + wcslen(CONFIG_INI_FILENAME) + 1];
-
- //copy the path base and file name
- for (UInt32 i = 0; i <= iLastBackslash; i++)
+ WCHAR* configPath = new (nothrow) WCHAR[iLastBackslash + 1 + wcslen(CONFIG_INI_FILENAME) + 1];
+ if (configPath != NULL)
{
- configPath[i] = exePathBuff[i];
- }
+ //copy the path base and file name
+ for (UInt32 i = 0; i <= iLastBackslash; i++)
+ {
+ configPath[i] = exePathBuff[i];
+ }
- for (UInt32 i = 0; i <= wcslen(CONFIG_INI_FILENAME); i++)
- {
- configPath[i + iLastBackslash + 1] = CONFIG_INI_FILENAME[i];
+ for (UInt32 i = 0; i <= wcslen(CONFIG_INI_FILENAME); i++)
+ {
+ configPath[i + iLastBackslash + 1] = CONFIG_INI_FILENAME[i];
+ }
}
return configPath;