summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Ellis <matell@microsoft.com>2015-02-07 16:00:27 -0800
committerMatt Ellis <matell@microsoft.com>2015-02-07 16:00:27 -0800
commit114eb57cabec658011e09a8ed3638275bfb46902 (patch)
tree61e349d74700ce5ccecafc7ee33ecbcd667c3123 /src
parent0b58e4ea50b657e7c204ffa3f5f82cfe30426ba6 (diff)
parent61469b29a796087b9d3ce22b430ff2bd81665d16 (diff)
downloadcoreclr-114eb57cabec658011e09a8ed3638275bfb46902.tar.gz
coreclr-114eb57cabec658011e09a8ed3638275bfb46902.tar.bz2
coreclr-114eb57cabec658011e09a8ed3638275bfb46902.zip
Merge pull request #140 from dotnet-bot/from-tfs
Merge changes from TFS
Diffstat (limited to 'src')
-rw-r--r--src/pal/src/include/pal/cs.hpp2
-rw-r--r--src/pal/src/init/pal.cpp26
-rw-r--r--src/pal/src/sync/cs.cpp21
3 files changed, 24 insertions, 25 deletions
diff --git a/src/pal/src/include/pal/cs.hpp b/src/pal/src/include/pal/cs.hpp
index 4bc2e40264..ce120ff419 100644
--- a/src/pal/src/include/pal/cs.hpp
+++ b/src/pal/src/include/pal/cs.hpp
@@ -25,7 +25,7 @@
namespace CorUnix
{
- bool CriticalSectionSubSysInitialize(void);
+ void CriticalSectionSubSysInitialize(void);
void InternalInitializeCriticalSectionAndSpinCount(
PCRITICAL_SECTION pCriticalSection,
diff --git a/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp
index ae1fa50b60..7433cf81ec 100644
--- a/src/pal/src/init/pal.cpp
+++ b/src/pal/src/init/pal.cpp
@@ -137,7 +137,7 @@ PAL_Initialize(
int argc,
const char *argv[])
{
- PAL_ERROR palError = NO_ERROR;
+ PAL_ERROR palError = ERROR_GEN_FAILURE;
CPalThread *pThread = NULL;
CSharedMemoryObjectManager *pshmom = NULL;
LPWSTR command_line = NULL;
@@ -150,7 +150,7 @@ PAL_Initialize(
ENTRY will be called after the DBG channels initialization */
ENTRY_EXTERNAL("PAL_Initialize(argc = %d argv = %p)\n", argc, argv);
/*Firstly initiate a temporary lastError storage */
- StartupLastError = 0;
+ StartupLastError = ERROR_GEN_FAILURE;
#ifdef __APPLE__
if (!RunningNatively())
@@ -160,11 +160,7 @@ PAL_Initialize(
}
#endif // __APPLE__
- if (!CriticalSectionSubSysInitialize())
- {
- // Too early to log a message
- goto exit;
- }
+ CriticalSectionSubSysInitialize();
if(NULL == init_critsec)
{
@@ -293,6 +289,7 @@ PAL_Initialize(
if (!SEHInitializeMachExceptions())
{
ERROR("SEHInitializeMachExceptions failed!\n");
+ palError = ERROR_GEN_FAILURE;
goto CLEANUP1;
}
#endif // HAVE_MACH_EXCEPTIONS
@@ -367,6 +364,8 @@ PAL_Initialize(
g_pSynchronizationManager =
CPalSynchMgrController::CreatePalSynchronizationManager(pThread);
+ palError = ERROR_GEN_FAILURE;
+
if (NULL == g_pSynchronizationManager)
{
ERROR("Failure creating synchronization manager\n");
@@ -440,6 +439,8 @@ PAL_Initialize(
goto CLEANUP5;
}
+ palError = ERROR_GEN_FAILURE;
+
/* initialize structured exception handling stuff (signals, etc) */
if (FALSE == SEHInitialize(pThread))
{
@@ -511,6 +512,8 @@ PAL_Initialize(
(void)PAL_Enter(PAL_BoundaryTop);
TRACE("Initialization count increases to %d\n", init_count.Load());
+
+ SetLastError(NO_ERROR);
retval = 0;
}
goto done;
@@ -575,7 +578,14 @@ done:
_ASSERTE(pThread->suspensionInfo.IsSuspensionStateSafe());
}
-exit:
+ if (retval != 0 && GetLastError() == ERROR_SUCCESS)
+ {
+ ASSERT("returning failure, but last error not set\n");
+ }
+
+#ifdef __APPLE__
+exit :
+#endif // __APPLE__
LOGEXIT("PAL_Initialize returns int %d\n", retval);
return retval;
}
diff --git a/src/pal/src/sync/cs.cpp b/src/pal/src/sync/cs.cpp
index a63d09cf0e..7ad1ae4262 100644
--- a/src/pal/src/sync/cs.cpp
+++ b/src/pal/src/sync/cs.cpp
@@ -529,8 +529,12 @@ namespace CorUnix
Initializes CS subsystem
--*/
- bool CriticalSectionSubSysInitialize()
+ void CriticalSectionSubSysInitialize()
{
+ static_assert(sizeof(CRITICAL_SECTION) >= sizeof(PAL_CRITICAL_SECTION),
+ "PAL fatal internal error: sizeof(CRITICAL_SECTION) is "
+ "smaller than sizeof(PAL_CRITICAL_SECTION)");
+
#ifdef _DEBUG
LONG lRet = InterlockedCompareExchange((LONG *)&csssInitState,
(LONG)CSSubSysInitializing,
@@ -553,21 +557,6 @@ namespace CorUnix
}
}
#endif // _DEBUG
-
- // In non-error conditions the optimizer should remove the following
- // 'if' block, since the tested expression is verifiable at compile time
- if (sizeof(CRITICAL_SECTION) < sizeof(PAL_CRITICAL_SECTION))
- {
- // Too early to log, writing directly to stderr
- fprintf(stderr,
- "PAL fatal internal error: sizeof(CRITICAL_SECTION)=%lu is "
- "smaller than sizeof(PAL_CRITICAL_SECTION)=%lu\n",
- sizeof(CRITICAL_SECTION),
- sizeof(PAL_CRITICAL_SECTION));
-
- return false;
- }
- return true;
}
/*++