Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Refactored conditional compilation for PLATFORM_WINDOWS and WIN32 #468

Merged
merged 5 commits into from
Jun 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
[Bb]in/
[Oo]bj/
ipch/
*.VC.db

!/tools/bin/

Expand Down
11 changes: 6 additions & 5 deletions CLR/Core/CLR_RT_StackFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ HRESULT CLR_RT_StackFrame::Push( CLR_RT_Thread* th, const CLR_RT_MethodDef_Insta
CLR_UINT32 sizeLocals;
CLR_UINT32 sizeEvalStack;

#if defined(PLATFORM_WINDOWS)
#if defined(PLATFORM_WINDOWS_EMULATOR)
if(s_CLR_RT_fTrace_SimulateSpeed > c_CLR_RT_Trace_None)
{
CLR_PROF_Handler::SuspendTime();
Expand Down Expand Up @@ -264,7 +264,7 @@ HRESULT CLR_RT_StackFrame::Push( CLR_RT_Thread* th, const CLR_RT_MethodDef_Insta
//
if(extraBlocks < 0)
{
#if defined(PLATFORM_WINDOWS) || (defined(PLATFORM_WINCE) && defined(_DEBUG))
#if defined(_WIN32) || (defined(PLATFORM_WINCE) && defined(_DEBUG))
if(caller->m_evalStackPos > caller->m_evalStackEnd)
{
TINYCLR_SET_AND_LEAVE(CLR_E_STACK_OVERFLOW);
Expand All @@ -278,7 +278,7 @@ HRESULT CLR_RT_StackFrame::Push( CLR_RT_Thread* th, const CLR_RT_MethodDef_Insta

caller->m_evalStackPos = stack->m_arguments;

#if defined(PLATFORM_WINDOWS) || (defined(PLATFORM_WINCE) && defined(_DEBUG))
#if defined(_WIN32) || (defined(PLATFORM_WINCE) && defined(_DEBUG))
if(stack->m_arguments < caller->m_evalStack)
{
TINYCLR_SET_AND_LEAVE(CLR_E_STACK_UNDERFLOW);
Expand Down Expand Up @@ -315,7 +315,7 @@ bool CLR_RT_StackFrame::PushInline( CLR_PMETADATA& ip, CLR_RT_Assembly*& assm, C

CLR_PMETADATA ipTmp = calleeInst.m_assm->GetByteCode( md->RVA );

#if defined(PLATFORM_WINDOWS)
#if defined(PLATFORM_WINDOWS_EMULATOR)
if(s_CLR_RT_fTrace_SimulateSpeed > c_CLR_RT_Trace_None)
{
CLR_PROF_Handler::SuspendTime();
Expand Down Expand Up @@ -382,7 +382,8 @@ bool CLR_RT_StackFrame::PushInline( CLR_PMETADATA& ip, CLR_RT_Assembly*& assm, C
}

void CLR_RT_StackFrame::PopInline()
{
{

CLR_RT_HeapBlock& src = m_evalStackPos[0];

RestoreFromInlineStack();
Expand Down
2 changes: 1 addition & 1 deletion CLR/Core/CLR_RT_UnicodeHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ bool CLR_RT_UnicodeHelper::ConvertToUTF8( int iMaxChars, bool fJustMove )

////////////////////////////////////////////////////////////////////////////////////////////////////

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(_WIN32)

void CLR_RT_UnicodeHelper::ConvertToUTF8( const std::wstring& src ,
std::string& dst )
Expand Down
6 changes: 3 additions & 3 deletions CLR/Core/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( const CLR_RT_Type
CLR_UINT32 clsData = cls .m_data;
CLR_UINT32 mdVirtualData = mdVirtual.m_data;

#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
bool fVerify = false;

{
Expand Down Expand Up @@ -251,7 +251,7 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( const CLR_RT_Type

if(cls.Type() == owner)
{
#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
if(fVerify != true)
{
CLR_Debug::Printf( "INTERNAL ERROR: Shortcut for terminal virtual methods failed: CLS:%08x:%08x => %08x\r\n", cls.m_data, mdVirtual.m_data, md.m_data );
Expand All @@ -265,7 +265,7 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( const CLR_RT_Type
}
}

#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
if(fVerify != false)
{
CLR_Debug::Printf( "INTERNAL ERROR: Shortcut for terminal virtual methods failed: CLS:%08x:%08x\r\n", cls.m_data, mdVirtual.m_data );
Expand Down
19 changes: 10 additions & 9 deletions CLR/Core/Execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ CLR_UINT32 CLR_RT_ExecutionEngine::PerformGarbageCollection()

m_lastHcUsed = NULL;

#if !defined(BUILD_RTM) || defined(PLATFORM_WINDOWS)
#if !defined(BUILD_RTM) || defined(_WIN32)
if(m_fPerformHeapCompaction) CLR_EE_SET( Compaction_Pending );
#endif

Expand Down Expand Up @@ -583,7 +583,8 @@ HRESULT CLR_RT_ExecutionEngine::WaitForDebugger()

while(CLR_EE_DBG_IS(Stopped) && !CLR_EE_DBG_IS(RebootPending) && !CLR_EE_DBG_IS(ExitPending))
{
#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
// TODO: Generalize this as a standard HAL API
#if defined(WIN32)
if(HAL_Windows_IsShutdownPending())
{
TINYCLR_SET_AND_LEAVE(CLR_E_SHUTTING_DOWN);
Expand All @@ -593,14 +594,14 @@ HRESULT CLR_RT_ExecutionEngine::WaitForDebugger()
DebuggerLoop();
}

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(WIN32)
TINYCLR_NOCLEANUP();
#else
TINYCLR_NOCLEANUP_NOLABEL();
#endif
}

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(WIN32)
HRESULT CLR_RT_ExecutionEngine::CreateEntryPointArgs( CLR_RT_HeapBlock& argsBlk, WCHAR* szCommandLineArgs )
{
NATIVE_PROFILE_CLR_CORE();
Expand Down Expand Up @@ -654,7 +655,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute( LPWSTR entryPointArgs, int maxContextSw

if(TINYCLR_INDEX_IS_INVALID(g_CLR_RT_TypeSystem.m_entryPoint))
{
#if !defined(BUILD_RTM) || defined(PLATFORM_WINDOWS)
#if !defined(BUILD_RTM) || defined(WIN32)
CLR_Debug::Printf( "Cannot find any entrypoint!\r\n" );
#endif
TINYCLR_SET_AND_LEAVE(CLR_E_ENTRYPOINT_NOT_FOUND);
Expand Down Expand Up @@ -682,7 +683,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute( LPWSTR entryPointArgs, int maxContextSw
//Main entrypoint takes an optional String[] parameter.
//Set the arg to NULL, if that's the case.

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(WIN32)
if(entryPointArgs != NULL)
{
TINYCLR_CHECK_HRESULT(CreateEntryPointArgs( stack->m_arguments[ 0 ], entryPointArgs ));
Expand Down Expand Up @@ -734,7 +735,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute( LPWSTR entryPointArgs, int maxContextSw
}
else if(hr2 == CLR_S_QUANTUM_EXPIRED)
{
#if !defined(BUILD_RTM) || defined(PLATFORM_WINDOWS)
#if !defined(BUILD_RTM) || defined(WIN32)
if(m_fPerformGarbageCollection)
{
#if defined(TINYCLR_GC_VERBOSE)
Expand Down Expand Up @@ -773,7 +774,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute( LPWSTR entryPointArgs, int maxContextSw

g_CLR_RT_Persistence_Manager.Flush();

#if defined(PLATFORM_WINDOWS)
#if defined(WIN32)
#if defined(TINYCLR_PROFILE_NEW)
if(CLR_EE_PRF_IS( Enabled ))
{
Expand Down Expand Up @@ -1172,7 +1173,7 @@ HRESULT CLR_RT_ExecutionEngine::ScheduleThreads( int maxContextSwitch )
while(maxContextSwitch-- > 0)
{

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(WIN32)
if(HAL_Windows_IsShutdownPending())
{
TINYCLR_SET_AND_LEAVE(CLR_S_NO_THREADS);
Expand Down
2 changes: 1 addition & 1 deletion CLR/Core/GarbageCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void CLR_RT_AssertEarlyCollection::CheckAll( CLR_RT_HeapBlock* ptr )
{
CLR_Debug::Printf( "INTERNAL ERROR: %08x retired early!!!\r\n", ptr );

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(_WIN32)
::Sleep( 1000 );
::DebugBreak();
#endif
Expand Down
8 changes: 4 additions & 4 deletions CLR/Core/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

////////////////////////////////////////////////////////////////////////////////////////////////////

#if defined(TINYCLR_TRACE_EXCEPTIONS) && defined(PLATFORM_WINDOWS)
#if defined(TINYCLR_TRACE_EXCEPTIONS) && defined(_WIN32)

struct BackTrackExecution
{
Expand Down Expand Up @@ -562,7 +562,7 @@ HRESULT CLR_RT_Thread::Execute()
stack = CurrentFrame();
if(stack->Prev() != NULL)
{
#if defined(TINYCLR_TRACE_INSTRUCTIONS) && defined(PLATFORM_WINDOWS)
#if defined(TINYCLR_TRACE_INSTRUCTIONS) && defined(PLATFORM_WINDOWS_EMULATOR)
for(int i = 0; i < ARRAYSIZE(s_track); i++)
{
BackTrackExecution& track = s_track[ (s_trackPos+i) % ARRAYSIZE(s_track) ];
Expand Down Expand Up @@ -899,7 +899,7 @@ HRESULT CLR_RT_Thread::Execute_IL( CLR_RT_StackFrame* stack )
}
#endif //#if defined(TINYCLR_ENABLE_SOURCELEVELDEBUGGING)

#if defined(TINYCLR_TRACE_EXCEPTIONS) && defined(PLATFORM_WINDOWS)
#if defined(TINYCLR_TRACE_EXCEPTIONS) && defined(_WIN32)
if(s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Annoying)
{
CLR_PROF_HANDLER_SUSPEND_TIME();
Expand Down Expand Up @@ -941,7 +941,7 @@ HRESULT CLR_RT_Thread::Execute_IL( CLR_RT_StackFrame* stack )
////////////////////////
//
//
#if defined(PLATFORM_WINDOWS)
#if defined(PLATFORM_WINDOWS_EMULATOR)
if(s_CLR_RT_fTrace_SimulateSpeed > c_CLR_RT_Trace_None)
{
CLR_PROF_Handler::SuspendTime();
Expand Down
8 changes: 4 additions & 4 deletions CLR/Core/Jitter_Execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#define TINYCLR_JITTER_CODECOVERAGE

#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
#undef TINYCLR_JITTER_CODECOVERAGE
#endif

Expand Down Expand Up @@ -73,7 +73,7 @@ HRESULT CLR_RT_ExecutionEngine::Compile( const CLR_RT_MethodDef_Index& md, CLR_U
CLR_UINT64 stats_start;
#endif

#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
g_CLR_RT_ArmEmulator.InitializeExternalCalls();
#endif

Expand Down Expand Up @@ -172,7 +172,7 @@ HRESULT CLR_RT_ExecutionEngine::Compile( const CLR_RT_MethodDef_Index& md, CLR_U
CLR_Debug::Printf( "Jitter: no space for thunk table!\r\n" );
}
}
#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
else
{
size_t len = mc.m_Arm_Opcodes.Size() * sizeof(CLR_UINT32);
Expand Down Expand Up @@ -282,7 +282,7 @@ HRESULT CLR_RT_ExecutionEngine::Compile( const CLR_RT_MethodDef_Index& md, CLR_U
CLR_Debug::Printf( "Jitter: cannot allocate method table!\r\n" );
}
}
#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
else
{
size_t len = mc.m_Arm_Opcodes.Size() * sizeof(CLR_UINT32);
Expand Down
2 changes: 1 addition & 1 deletion CLR/Core/StringTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LPCSTR CLR_RT_Assembly::GetString( CLR_STRING i )
return &(((LPCSTR)GetTable( TBL_Strings ))[ i ]);
}

#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)

void CLR_RT_Assembly::InitString( std::map<std::string,CLR_OFFSET>& map )
{
Expand Down
18 changes: 9 additions & 9 deletions CLR/Core/TypeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

////////////////////////////////////////////////////////////////////////////////////////////////////

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(_WIN32)
#define TINYCLR_TRACE_DEFAULT(win,arm) (win)
#else
#define TINYCLR_TRACE_DEFAULT(win,arm) (arm)
Expand Down Expand Up @@ -48,7 +48,7 @@ int s_CLR_RT_fTrace_MemoryStats = TINYCLR_TRACE_DEFAULT(c_CLR_RT_
int s_CLR_RT_fTrace_GC = TINYCLR_TRACE_DEFAULT(c_CLR_RT_Trace_None,c_CLR_RT_Trace_None);
#endif

#if defined(PLATFORM_WINDOWS)
#if defined(WIN32)
int s_CLR_RT_fTrace_SimulateSpeed = TINYCLR_TRACE_DEFAULT(c_CLR_RT_Trace_Info,c_CLR_RT_Trace_None);
#endif

Expand All @@ -64,11 +64,11 @@ int s_CLR_RT_fJitter_Trace_Invoke = TINYCLR_TRACE_DEFAULT(c_CLR_RT_
int s_CLR_RT_fJitter_Trace_Execution = TINYCLR_TRACE_DEFAULT(c_CLR_RT_Trace_None,c_CLR_RT_Trace_None);
#endif

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(WIN32)
int s_CLR_RT_fTrace_StopOnFAILED = TINYCLR_TRACE_DEFAULT(c_CLR_RT_Trace_None,c_CLR_RT_Trace_None);
#endif

#if defined(PLATFORM_WINDOWS)
#if defined(WIN32)
int s_CLR_RT_fTrace_ARM_Execution = 0;

int s_CLR_RT_fTrace_RedirectLinesPerFile;
Expand Down Expand Up @@ -1366,7 +1366,7 @@ bool CLR_RECORD_ASSEMBLY::GoodAssembly() const
return SUPPORT_ComputeCRC( &this[ 1 ], this->TotalSize() - sizeof(*this), 0 ) == this->assemblyCRC;
}

#if defined(PLATFORM_WINDOWS)
#if defined(WIN32)

void CLR_RECORD_ASSEMBLY::ComputeCRC()
{
Expand Down Expand Up @@ -1697,7 +1697,7 @@ HRESULT CLR_RT_Assembly::CreateInstance( const CLR_RECORD_ASSEMBLY* header, CLR_
}


#if defined(PLATFORM_WINDOWS)
#if defined(WIN32)
HRESULT CLR_RT_Assembly::CreateInstance( const CLR_RECORD_ASSEMBLY* header, CLR_RT_Assembly*& assm, LPCWSTR szName )
{
NATIVE_PROFILE_CLR_CORE();
Expand Down Expand Up @@ -1776,7 +1776,7 @@ void CLR_RT_Assembly::DestroyInstance()
g_CLR_RT_TypeSystem.m_assemblies[ m_idx-1 ] = NULL;
}

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(WIN32)
if(this->m_strPath != NULL)
{
delete this->m_strPath;
Expand Down Expand Up @@ -2881,7 +2881,7 @@ HRESULT CLR_RT_Assembly::PrepareForExecution()
{
CLR_PMETADATA ptr = GetResourceData( m_header->patchEntryOffset );

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(WIN32)
CLR_Debug::Printf( "Simulating jump into patch code...\r\n" );
#else
((void (*)())ptr)();
Expand Down Expand Up @@ -3616,7 +3616,7 @@ bool CLR_RT_TypeSystem::FindTypeDef( LPCSTR szClass, CLR_RT_Assembly* assm, CLR_
//--//

int
#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE)
#if defined(_MSC_VER)
__cdecl
#endif
CompareResource( const void* p1, const void* p2 )
Expand Down
2 changes: 1 addition & 1 deletion CLR/Core/TypeSystemLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define DT_NOREL(x) NULL
#define DT_REL(x) (CLR_RT_HeapBlockRelocate)&x

#if defined(PLATFORM_WINDOWS) || defined(TINYCLR_TRACE_MEMORY_STATS)
#if defined(WIN32) || defined(TINYCLR_TRACE_MEMORY_STATS)
#define DT_OPT_NAME(x) , #x
#else
#define DT_OPT_NAME(x)
Expand Down
8 changes: 2 additions & 6 deletions CLR/Debugger/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#include <TinyCLR_Debugging.h>
#include <MFUpdate_decl.h>

#if defined(PLATFORM_WINDOWS)
#pragma comment(lib,"crypto")
#endif

#include <crypto.h>

#if 0
Expand Down Expand Up @@ -696,7 +692,7 @@ bool CLR_DBG_Debugger::AccessMemory( CLR_UINT32 location, UINT32 lengthInBytes,
//--// RAM write
ByteAddress sectAddr = location;

#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)

bool proceed = false;
void * temp;
Expand Down Expand Up @@ -2950,7 +2946,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Assembly( WP_Message* msg, void* owner

if(assm)
{
#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)
//append path
if(assm->m_strPath != NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion CLR/Diagnostics/Diagnostics_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

////////////////////////////////////////////////////////////////////////////////////////////////////

#if defined(PLATFORM_WINDOWS)
#if defined(_WIN32)

void CLR_Debug::RedirectToString( std::string* str )
{
Expand Down
Loading