diff --git a/.gitignore b/.gitignore index cfdb130f7..23b04b41b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ [Bb]in/ [Oo]bj/ ipch/ +*.VC.db !/tools/bin/ diff --git a/CLR/Core/CLR_RT_StackFrame.cpp b/CLR/Core/CLR_RT_StackFrame.cpp index 893c16ae3..5ed193c52 100644 --- a/CLR/Core/CLR_RT_StackFrame.cpp +++ b/CLR/Core/CLR_RT_StackFrame.cpp @@ -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(); @@ -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); @@ -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); @@ -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(); @@ -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(); diff --git a/CLR/Core/CLR_RT_UnicodeHelper.cpp b/CLR/Core/CLR_RT_UnicodeHelper.cpp index 0e9fc7e5b..523428e5e 100644 --- a/CLR/Core/CLR_RT_UnicodeHelper.cpp +++ b/CLR/Core/CLR_RT_UnicodeHelper.cpp @@ -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 ) diff --git a/CLR/Core/Cache.cpp b/CLR/Core/Cache.cpp index c62d06ae2..860d085b0 100644 --- a/CLR/Core/Cache.cpp +++ b/CLR/Core/Cache.cpp @@ -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; { @@ -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 ); @@ -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 ); diff --git a/CLR/Core/Execution.cpp b/CLR/Core/Execution.cpp index c6d75e716..55d2c932c 100644 --- a/CLR/Core/Execution.cpp +++ b/CLR/Core/Execution.cpp @@ -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 @@ -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); @@ -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(); @@ -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); @@ -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 )); @@ -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) @@ -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 )) { @@ -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); diff --git a/CLR/Core/GarbageCollector.cpp b/CLR/Core/GarbageCollector.cpp index e637456d9..900e76563 100644 --- a/CLR/Core/GarbageCollector.cpp +++ b/CLR/Core/GarbageCollector.cpp @@ -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 diff --git a/CLR/Core/Interpreter.cpp b/CLR/Core/Interpreter.cpp index 265ef3461..ff9ca9063 100644 --- a/CLR/Core/Interpreter.cpp +++ b/CLR/Core/Interpreter.cpp @@ -6,7 +6,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(TINYCLR_TRACE_EXCEPTIONS) && defined(PLATFORM_WINDOWS) +#if defined(TINYCLR_TRACE_EXCEPTIONS) && defined(_WIN32) struct BackTrackExecution { @@ -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) ]; @@ -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(); @@ -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(); diff --git a/CLR/Core/Jitter_Execution.cpp b/CLR/Core/Jitter_Execution.cpp index f554cb363..42cadc2f4 100644 --- a/CLR/Core/Jitter_Execution.cpp +++ b/CLR/Core/Jitter_Execution.cpp @@ -10,7 +10,7 @@ #define TINYCLR_JITTER_CODECOVERAGE -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) #undef TINYCLR_JITTER_CODECOVERAGE #endif @@ -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 @@ -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); @@ -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); diff --git a/CLR/Core/StringTable.cpp b/CLR/Core/StringTable.cpp index 9b5bfeabe..99c021b9a 100644 --- a/CLR/Core/StringTable.cpp +++ b/CLR/Core/StringTable.cpp @@ -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& map ) { diff --git a/CLR/Core/TypeSystem.cpp b/CLR/Core/TypeSystem.cpp index 8ec6dd2e6..b247ef499 100644 --- a/CLR/Core/TypeSystem.cpp +++ b/CLR/Core/TypeSystem.cpp @@ -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) @@ -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 @@ -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; @@ -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() { @@ -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(); @@ -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; @@ -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)(); @@ -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 ) diff --git a/CLR/Core/TypeSystemLookup.cpp b/CLR/Core/TypeSystemLookup.cpp index da86eb986..fe2673d1c 100644 --- a/CLR/Core/TypeSystemLookup.cpp +++ b/CLR/Core/TypeSystemLookup.cpp @@ -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) diff --git a/CLR/Debugger/Debugger.cpp b/CLR/Debugger/Debugger.cpp index 2cdada787..53a377760 100644 --- a/CLR/Debugger/Debugger.cpp +++ b/CLR/Debugger/Debugger.cpp @@ -6,10 +6,6 @@ #include #include -#if defined(PLATFORM_WINDOWS) -#pragma comment(lib,"crypto") -#endif - #include #if 0 @@ -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; @@ -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) { diff --git a/CLR/Diagnostics/Diagnostics_stub.cpp b/CLR/Diagnostics/Diagnostics_stub.cpp index 1ec91a460..8bea34e01 100644 --- a/CLR/Diagnostics/Diagnostics_stub.cpp +++ b/CLR/Diagnostics/Diagnostics_stub.cpp @@ -7,7 +7,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) void CLR_Debug::RedirectToString( std::string* str ) { diff --git a/CLR/Diagnostics/Info.cpp b/CLR/Diagnostics/Info.cpp index 0bc115eb3..050e1808f 100644 --- a/CLR/Diagnostics/Info.cpp +++ b/CLR/Diagnostics/Info.cpp @@ -7,7 +7,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) static std::string* s_redirectedString = NULL; @@ -17,10 +17,6 @@ void CLR_Debug::RedirectToString( std::string* str ) s_redirectedString = str; } -#endif - -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) - HRESULT TINYCLR_DEBUG_PROCESS_EXCEPTION( HRESULT hr, LPCSTR szFunc, LPCSTR szFile, int line ) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); @@ -118,7 +114,7 @@ void CLR_Debug::Emit( const char *text, int len ) if(len == -1) len = (int)hal_strlen_s( text ); -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) if(s_redirectedString) { s_redirectedString->append( text, len ); @@ -196,7 +192,7 @@ void CLR_Debug::Emit( const char *text, int len ) { ::Watchdog_ResetCounter(); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(PLATFORM_WINDOWS_EMULATOR) HAL_Windows_Debug_Print( s_buffer ); #endif @@ -207,7 +203,19 @@ void CLR_Debug::Emit( const char *text, int len ) if(!CLR_EE_DBG_IS( Enabled ) || HalSystemConfig.DebugTextPort != HalSystemConfig.DebuggerPorts[ 0 ]) { -#if !defined(PLATFORM_WINDOWS) && !defined(PLATFORM_WINCE) +//#if !defined(PLATFORM_TOOLS) +// TODO: Fix the build so that PLATFORM_TOOLS can work here +// (or eliminate the use of native code from the CLR in the tools by converting them all to managed) +// This entire function could be moved to info_win32.cpp to help. +// The problem is that the build doesn't distinguish between building the diagnostics lib for +// desktop tools, X86, WIN32 or the emulator platforms. And this code was written to assume +// an equivalence for all - as the idea of a non-win32 emulator port to an x86 device wasn't +// considered a reality. However, for testing and development purposes a pure non-emulator x86 +// build is useful, not to mention the potential of Quark and Edison x86 family of chip sets +// targeting IoT. Thus, this needs some re-thinking as DebuggerPort_Write etc... aren't available +// when building the desktop tools, but should be available when building a WIN32 based test +// platform +#if !defined(_WIN32) DebuggerPort_Write( HalSystemConfig.DebugTextPort, s_buffer, s_chars, 0 ); // skip null terminator and don't bother retrying DebuggerPort_Flush( HalSystemConfig.DebugTextPort ); // skip null terminator #endif @@ -255,7 +263,7 @@ int CLR_Debug::Printf( const char *format, ... ) //////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) const CLR_UINT8 c_CLR_opParamSize[] = { @@ -368,7 +376,7 @@ const CLR_UINT8* CLR_SkipBodyOfOpcodeCompressed( const CLR_UINT8* ip, CLR_OPCODE return ip; } -#endif // defined(PLATFORM_WINDOWS) +#endif //////////////////////////////////////////////////////////////////////////////////////////////////// #define LOOKUP_ELEMENT(idx,tblName,tblNameUC) \ diff --git a/CLR/Diagnostics/Profile.cpp b/CLR/Diagnostics/Profile.cpp index 4e8290df5..1ce664401 100644 --- a/CLR/Diagnostics/Profile.cpp +++ b/CLR/Diagnostics/Profile.cpp @@ -76,10 +76,16 @@ volatile CLR_UINT64 CLR_PROF_Handler::s_time_adjusted; //--// + +// TODO: roll this entire function into the HAL so that +// hardware with a HighRes counter can be used, this +// implementation is easy enough to move to the HAL as +// a support function for systems with only a lowres +// counter static CLR_UINT64 GetPerformanceCounter() { NATIVE_PROFILE_CLR_DIAGNOSTICS(); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) return HAL_Windows_GetPerformanceTicks(); #else static CLR_UINT32 rollover = 0; diff --git a/CLR/Graphics/Bmp/Bmp.h b/CLR/Graphics/Bmp/Bmp.h index e845bc926..922cdeed7 100644 --- a/CLR/Graphics/Bmp/Bmp.h +++ b/CLR/Graphics/Bmp/Bmp.h @@ -26,7 +26,7 @@ #define __gnu_packed #endif -#if !defined(PLATFORM_WINDOWS) && !defined(PLATFORM_WINCE) +#if !defined(_WIN32) // For non-windows build, we need to define the Bitmap header structures. // (These are defined in wingdi.h which is indirectly linked in windows build.) @@ -61,7 +61,7 @@ __packed struct __gnu_packed BITMAPINFOHEADER { typedef UINT32 COLORREF; -#endif //#if !defined(PLATFORM_WINDOWS) +#endif //#if !defined(PLATFORM_WINDOWS_EMULATOR) enum BmpEncodingType { diff --git a/CLR/Graphics/Gif/giffile.h b/CLR/Graphics/Gif/giffile.h index 7682c4b28..b9cc13527 100644 --- a/CLR/Graphics/Gif/giffile.h +++ b/CLR/Graphics/Gif/giffile.h @@ -26,7 +26,7 @@ #define GIFPLAINTEXTEXTENSIONSIZE 13 #define GIFAPPEXTENSIONHEADERSIZE 11 -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) || defined(PLATFORM_BLACKFIN) +#if defined(_MSC_VER) || defined(PLATFORM_BLACKFIN) #pragma pack(1) // __packed is an ARM compiler-only keyword (equivalent of #pragma pack(1)) #define __packed @@ -101,7 +101,7 @@ struct __gnu_packed GifGraphicControlExtension //6 bytes BYTE transparentcolorindex; }; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) || defined(PLATFORM_BLACKFIN) +#if defined(_MSC_VER) || defined(PLATFORM_BLACKFIN) #pragma pack() #endif diff --git a/CLR/Include/TinyCLR_Application.h b/CLR/Include/TinyCLR_Application.h index d4871ea62..f7f75db9d 100644 --- a/CLR/Include/TinyCLR_Application.h +++ b/CLR/Include/TinyCLR_Application.h @@ -5,10 +5,6 @@ #ifndef _TINYCLR_APPLICATION_H_ #define _TINYCLR_APPLICATION_H_ -#if defined(_WIN32) || defined(WIN32) -#define PLATFORM_WINDOWS -#endif - extern void InitCRuntime(); struct CLR_SETTINGS @@ -17,7 +13,7 @@ struct CLR_SETTINGS bool WaitForDebugger; bool EnterDebuggerLoopAfterExit; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) bool PerformGarbageCollection; bool PerformHeapCompaction; WCHAR EmulatorArgs[1024]; @@ -27,7 +23,7 @@ struct CLR_SETTINGS struct CLR_RT_EmulatorHooks { -#if defined(PLATFORM_WINDOWS) +#if defined(PLATFORM_WINDOWS_EMULATOR) static void Notify_ExecutionStateChanged(); #else static void Notify_ExecutionStateChanged() {} @@ -36,16 +32,17 @@ struct CLR_RT_EmulatorHooks extern void ClrStartup( CLR_SETTINGS params ); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) extern HRESULT ClrLoadPE( LPCWSTR szPeFilePath ); extern HRESULT ClrLoadDAT( LPCWSTR szDatFilePath ); -void ClrSetLcdDimensions( INT32 width, INT32 height, INT32 bitsPerPixel ); -bool ClrIsDebuggerStopped(); #endif extern void ClrExit(); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(PLATFORM_WINDOWS_EMULATOR) + +void ClrSetLcdDimensions( INT32 width, INT32 height, INT32 bitsPerPixel ); +bool ClrIsDebuggerStopped(); struct HAL_Configuration_Windows { @@ -79,6 +76,6 @@ struct HAL_Configuration_Windows extern HAL_Configuration_Windows g_HAL_Configuration_Windows; -#endif //defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#endif -#endif //_TINYCLR_APPLICATION_H_ +#endif diff --git a/CLR/Include/TinyCLR_Graphics.h b/CLR/Include/TinyCLR_Graphics.h index f61aa1c35..9acff7bee 100644 --- a/CLR/Include/TinyCLR_Graphics.h +++ b/CLR/Include/TinyCLR_Graphics.h @@ -247,7 +247,7 @@ struct CLR_GFX_Bitmap //--// -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) #include #include @@ -443,7 +443,7 @@ struct CLR_GFX_Font //--// -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) HRESULT SaveToBuffer( CLR_RT_Buffer& buffer ); @@ -456,7 +456,7 @@ struct CLR_GFX_Font //--// -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) struct CLR_GFX_Resources { diff --git a/CLR/Include/TinyCLR_Hardware.h b/CLR/Include/TinyCLR_Hardware.h index 5b87328ea..6a61d2fd7 100644 --- a/CLR/Include/TinyCLR_Hardware.h +++ b/CLR/Include/TinyCLR_Hardware.h @@ -37,7 +37,7 @@ static const int c_CLR_HW_Button_Raw_B9 = 19; static const int c_CLR_HW_Button_MAX = 32; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) #include #endif diff --git a/CLR/Include/TinyCLR_Interop.h b/CLR/Include/TinyCLR_Interop.h index 0566a157c..dbd24973c 100644 --- a/CLR/Include/TinyCLR_Interop.h +++ b/CLR/Include/TinyCLR_Interop.h @@ -15,7 +15,7 @@ extern HRESULT TINYCLR_DEBUG_PROCESS_EXCEPTION( HRESULT hr, LPCSTR szFunc, LPCSTR szFile, int line ); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) #define TINYCLR_LEAVE() { if(FAILED(hr)) TINYCLR_DEBUG_PROCESS_EXCEPTION( hr, NULL, NULL, 0 ); goto TinyCLR_Cleanup; } #define TINYCLR_RETURN() return hr diff --git a/CLR/Include/TinyCLR_ParseOptions.h b/CLR/Include/TinyCLR_ParseOptions.h index 82a6fb049..3d52516b8 100644 --- a/CLR/Include/TinyCLR_ParseOptions.h +++ b/CLR/Include/TinyCLR_ParseOptions.h @@ -9,7 +9,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) struct CLR_RT_ParseOptions { diff --git a/CLR/Include/TinyCLR_PlatformDef.h b/CLR/Include/TinyCLR_PlatformDef.h index 47eea4c9a..32c68a435 100644 --- a/CLR/Include/TinyCLR_PlatformDef.h +++ b/CLR/Include/TinyCLR_PlatformDef.h @@ -7,13 +7,16 @@ #include +#ifdef _WIN32 +#define LITTLE_ENDIAN +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////// // PLATFORMS GENERAL DEFINITIONS #if defined(_WIN32_WCE) #define PLATFORM_WINCE #define TINYCLR_STOP() ::DebugBreak() -#elif defined(_WIN32) || defined(WIN32) -#define PLATFORM_WINDOWS +#elif defined(_WIN32) #define TINYCLR_STOP() ::DebugBreak() #pragma warning( error : 4706 ) // error C4706: assignment within conditional expression #elif defined(arm) || defined(__arm) || defined(__GNUC__) @@ -28,9 +31,9 @@ #define PLATFORM_SH #endif -#if !defined(PLATFORM_WINDOWS) && !defined(PLATFORM_WINCE) +#if !defined(PLATFORM_WINDOWS_EMULATOR) && !defined(PLATFORM_WINCE) #if !defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN) -!ERROR ENDIANNESS NOT DEFINED +#error ENDIANNESS NOT DEFINED #endif #endif @@ -89,7 +92,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// // WINDOWS -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) #define TINYCLR_GC_VERBOSE #define TINYCLR_TRACE_MEMORY_STATS #define TINYCLR_PROFILE_NEW @@ -144,7 +147,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// // TRACE DEPENDENCIES -#if defined(TINYCLR_JITTER) || defined(PLATFORM_WINDOWS) +#if defined(TINYCLR_JITTER) || defined(_WIN32) #define TINYCLR_OPCODE_NAMES #define TINYCLR_OPCODE_PARSER #define TINYCLR_OPCODE_STACKCHANGES @@ -166,7 +169,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// // LANGUAGE -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) #define PROHIBIT_ALL_CONSTRUCTORS(cls) \ private: \ cls(); \ @@ -216,7 +219,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) #if !defined(PLATFORM_WINCE) #define _WIN32_WINNT 0x0501 @@ -280,7 +283,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(PLATFORM_WINCE) +#if defined(_WIN32_WCE) #if (_WIN32_WCE == 0x420) #define ENUMLOGFONTEXW ENUMLOGFONT diff --git a/CLR/Include/TinyCLR_Runtime.h b/CLR/Include/TinyCLR_Runtime.h index 3024eb624..086541977 100644 --- a/CLR/Include/TinyCLR_Runtime.h +++ b/CLR/Include/TinyCLR_Runtime.h @@ -26,7 +26,7 @@ extern const CLR_RADIAN c_CLR_radians[]; //--// -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) #include #include @@ -50,9 +50,13 @@ typedef CLR_RT_SymbolToAddressMap::iterator CLR_RT_SymbolToAddressMapIter; typedef std::map< CLR_UINT32, std::wstring > CLR_RT_AddressToSymbolMap; typedef CLR_RT_AddressToSymbolMap::iterator CLR_RT_AddressToSymbolMapIter; +#endif +#if defined(_MSC_VER) #pragma pack(push, TINYCLR_RUNTIME_H, 4) +#endif +#if defined(_WIN32) //--// #define _COM_SMRT_PTR(i) typedef _com_ptr_t<_com_IIID> i ## Ptr @@ -420,7 +424,7 @@ extern int s_CLR_RT_fJitter_Trace_Compile; extern int s_CLR_RT_fJitter_Trace_Invoke; extern int s_CLR_RT_fJitter_Trace_Execution; -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) extern int s_CLR_RT_fTrace_ARM_Execution; extern int s_CLR_RT_fTrace_RedirectLinesPerFile; @@ -676,7 +680,7 @@ struct CLR_RT_MethodDef_DebuggingInfo #include //TODO: Change this to an extern method that is defined in the HAL -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(PLATFORM_WINDOWS_EMULATOR) #define SYSTEM_CLOCK_HZ g_HAL_Configuration_Windows.SystemClock #define SLOW_CLOCKS_PER_SECOND g_HAL_Configuration_Windows.SlowClockPerSecond #endif @@ -723,7 +727,7 @@ struct CLR_RT_UnicodeHelper bool ConvertFromUTF8( int iMaxChars, bool fJustMove, int iMaxBytes = -1 ); bool ConvertToUTF8 ( int iMaxChars, bool fJustMove ); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) static void ConvertToUTF8 ( const std::wstring& src, std:: string& dst ); static void ConvertFromUTF8( const std:: string& src, std::wstring& dst ); #endif @@ -941,13 +945,13 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT CLR_RT_MethodDef_DebuggingInfo * m_pDebuggingInfo_MethodDef ; //EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) #endif //#if defined(TINYCLR_ENABLE_SOURCELEVELDEBUGGING) -#if defined(TINYCLR_TRACE_STACK_HEAVY) && defined(PLATFORM_WINDOWS) +#if defined(TINYCLR_TRACE_STACK_HEAVY) && defined(_WIN32) int m_maxOpcodes; int* m_stackDepth; #endif -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) std::string* m_strPath; #endif @@ -957,7 +961,7 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT bool IsSameAssembly( const CLR_RT_Assembly& assm ) const; -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) static void InitString( std::map& map ); static HRESULT CreateInstance ( const CLR_RECORD_ASSEMBLY* data, CLR_RT_Assembly*& assm, LPCWSTR szName ); @@ -1048,7 +1052,7 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT //--// -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) static FILE* s_output; static FILE* s_toclose; @@ -1088,7 +1092,7 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT #endif private: -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) void Dump_Token ( CLR_UINT32 tk ); void Dump_FieldOwner ( CLR_UINT32 idx ); void Dump_MethodOwner ( CLR_UINT32 idx ); @@ -1352,7 +1356,7 @@ struct CLR_RT_DataTypeLookup CLR_RT_TypeDef_Index* m_cls; CLR_RT_HeapBlockRelocate m_relocate; -#if defined(PLATFORM_WINDOWS) || defined(TINYCLR_TRACE_MEMORY_STATS) +#if defined(_WIN32) || defined(TINYCLR_TRACE_MEMORY_STATS) LPCSTR m_name; #endif }; @@ -1523,7 +1527,7 @@ struct CLR_RT_TypeSystem // EVENT HEAP - NO RELOCATION - static CLR_DataType MapElementTypeToDataType( CLR_UINT32 et ); static CLR_UINT32 MapDataTypeToElementType( CLR_DataType dt ); -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) void Dump( LPCWSTR szFileName, bool fNoByteCode ); #endif @@ -2144,7 +2148,7 @@ struct CLR_RT_GarbageCollector bool m_fOutOfStackSpaceForGC; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) CLR_UINT32 m_events; #endif @@ -2655,7 +2659,7 @@ struct CLR_RT_EventCache //--// -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) void DumpTree ( ); bool ConsistencyCheck( ); bool ConsistencyCheck( LookupEntry* node, int& depth ); @@ -2879,7 +2883,7 @@ struct CLR_RT_ExecutionEngine size_t m_breakpointsActiveNum; #endif //#if defined(TINYCLR_ENABLE_SOURCELEVELDEBUGGING) -#if !defined(BUILD_RTM) || defined(PLATFORM_WINDOWS) +#if !defined(BUILD_RTM) || defined(_WIN32) bool m_fPerformGarbageCollection; //Should the EE do a GC every context switch bool m_fPerformHeapCompaction; //Should the EE do a Compaction following every GC #endif @@ -3221,7 +3225,7 @@ struct CLR_RT_ExecutionEngine CLR_UINT32 WaitSystemEvents( CLR_UINT32 powerLevel, CLR_UINT32 events, CLR_INT64 timeExpire ); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) HRESULT CreateEntryPointArgs( CLR_RT_HeapBlock& args, LPWSTR szCommandLineArgs ); #endif @@ -3275,7 +3279,7 @@ CT_ASSERT( sizeof(CLR_RT_HeapBlock_Raw) == sizeof(CLR_RT_HeapBlock) ) #elif defined(PLATFORM_SH) // SH.compiler uses 12 bytes for a function pointer CT_ASSERT( sizeof(CLR_RT_DataTypeLookup) == 24 + TINYCLR_TRACE_MEMORY_STATS_EXTRA_SIZE ) -#elif defined(PLATFORM_WINDOWS) || defined(TINYCLR_TRACE_MEMORY_STATS) +#elif defined(PLATFORM_WINDOWS_EMULATOR) || defined(TINYCLR_TRACE_MEMORY_STATS) CT_ASSERT( sizeof(CLR_RT_DataTypeLookup) == 16 + 4 ) #elif defined(PLATFORM_WINCE) @@ -3290,7 +3294,7 @@ CT_ASSERT( sizeof(CLR_RT_HeapBlock_Raw) == sizeof(CLR_RT_HeapBlock) ) //--// -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_MSC_VER) #pragma pack(pop, TINYCLR_RUNTIME_H) #endif diff --git a/CLR/Include/TinyCLR_Types.h b/CLR/Include/TinyCLR_Types.h index 01b0dcdc8..c2a21eea3 100644 --- a/CLR/Include/TinyCLR_Types.h +++ b/CLR/Include/TinyCLR_Types.h @@ -73,7 +73,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_MSC_VER) #pragma pack(push, TINYCLR_TYPES_H, 4) #endif @@ -475,7 +475,7 @@ inline CLR_UINT32 CLR_UncompressMethodToken( CLR_UINT32 tk ) return CLR_TkFromType( c_lookup[ (tk >> 15) & 1 ], 0x7fff & tk ); } -#if defined(TINYCLR_JITTER) || defined(PLATFORM_WINDOWS) +#if defined(TINYCLR_JITTER) || defined(_WIN32) CLR_UINT32 CLR_ReadTokenCompressed( CLR_PMETADATA& ip, CLR_OPCODE opcode ); @@ -606,7 +606,7 @@ inline CLR_UINT32 CLR_TkFromStream( const CLR_UINT8*& p ) //--//--//--// -#if defined(PLATFORM_WINCE) || defined(PLATFORM_BLACKFIN) || defined(__GNUC__) || defined(__RENESAS__) // unfortunately WINCE doesn't support 1 byte alignment (even with _declspec unless the entire project is built with 1 byte alignment). +#if defined(PLATFORM_BLACKFIN) || defined(__GNUC__) || defined(__RENESAS__) #define TINYCLR_READ_UNALIGNED_UINT8(arg,ip) arg = *(const CLR_UINT8 *)ip; ip += sizeof(CLR_UINT8 ) template __inline void TINYCLR_READ_UNALIGNED_UINT16(T& arg, CLR_PMETADATA& ip) @@ -708,7 +708,7 @@ template __inline void TINYCLR_READ_UNALIGNED_INT64(T& arg, CLR_PMET } -#elif defined(PLATFORM_WINDOWS) +#elif defined(_MSC_VER) #define TINYCLR_READ_UNALIGNED_UINT8(arg,ip) arg = *(__declspec(align(1)) const CLR_UINT8 *)ip; ip += sizeof(CLR_UINT8 ) #define TINYCLR_READ_UNALIGNED_UINT16(arg,ip) arg = *(__declspec(align(1)) const CLR_UINT16*)ip; ip += sizeof(CLR_UINT16) @@ -732,7 +732,7 @@ template __inline void TINYCLR_READ_UNALIGNED_INT64(T& arg, CLR_PMET #define TINYCLR_WRITE_UNALIGNED_INT32(ip,arg) *(__declspec(align(1)) CLR_INT32* )ip = arg; ip += sizeof(CLR_INT32 ) #define TINYCLR_WRITE_UNALIGNED_INT64(ip,arg) *(__declspec(align(1)) CLR_INT64* )ip = arg; ip += sizeof(CLR_INT64 ) -#else +#else // TODO: __packed is compiler specific... Which compiler is this for? #define TINYCLR_READ_UNALIGNED_UINT8(arg,ip) arg = *(__packed CLR_UINT8 *)ip; ip += sizeof(CLR_UINT8 ) #define TINYCLR_READ_UNALIGNED_UINT16(arg,ip) arg = *(__packed CLR_UINT16*)ip; ip += sizeof(CLR_UINT16) @@ -818,7 +818,7 @@ inline CLR_OPCODE CLR_ReadNextOpcodeCompressed( CLR_PMETADATA& ip ) //--// -#if defined(TINYCLR_JITTER) || defined(PLATFORM_WINDOWS) +#if defined(TINYCLR_JITTER) || defined(_WIN32) CLR_PMETADATA CLR_SkipBodyOfOpcode ( CLR_PMETADATA ip, CLR_OPCODE opcode ); CLR_PMETADATA CLR_SkipBodyOfOpcodeCompressed( CLR_PMETADATA ip, CLR_OPCODE opcode ); @@ -853,7 +853,7 @@ struct CLR_Debug typedef int (*OutputHandler)( const char *format, ... ); -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) static void RedirectToString( std::string* str ); #endif }; @@ -904,7 +904,7 @@ struct CLR_RECORD_ASSEMBLY bool GoodHeader () const; bool GoodAssembly() const; -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) void ComputeCRC(); #endif @@ -1181,7 +1181,7 @@ struct CLR_RECORD_RESOURCE }; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_MSC_VER) #pragma pack(pop, TINYCLR_TYPES_H) #endif diff --git a/CLR/Jitter/Jitter_Execution.cpp b/CLR/Jitter/Jitter_Execution.cpp index a35266828..39c56620b 100644 --- a/CLR/Jitter/Jitter_Execution.cpp +++ b/CLR/Jitter/Jitter_Execution.cpp @@ -10,7 +10,7 @@ #define TINYCLR_JITTER_CODECOVERAGE -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) #undef TINYCLR_JITTER_CODECOVERAGE #endif @@ -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 @@ -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); @@ -280,7 +280,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); diff --git a/CLR/Libraries/CorLib/corlib_native_System_Number.cpp b/CLR/Libraries/CorLib/corlib_native_System_Number.cpp index 155e0c57e..b867b73bc 100644 --- a/CLR/Libraries/CorLib/corlib_native_System_Number.cpp +++ b/CLR/Libraries/CorLib/corlib_native_System_Number.cpp @@ -48,7 +48,7 @@ HRESULT Library_corlib_native_System_Number::FormatNative___STATIC__STRING__OBJE case DATATYPE_U4: hal_snprintf( result, ARRAYSIZE(result), "%.*X", precision, (CLR_UINT32)value->NumericByRef().u4 ); break; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) case DATATYPE_I8: hal_snprintf( result, ARRAYSIZE(result), "%I64X",(CLR_INT64_TEMP_CAST)value->NumericByRef().s8 ); break; @@ -96,7 +96,7 @@ HRESULT Library_corlib_native_System_Number::FormatNative___STATIC__STRING__OBJE case DATATYPE_U4: hal_snprintf( result, ARRAYSIZE(result), "%.*u", precision, value->NumericByRef().u4 ); break; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) case DATATYPE_I8: hal_snprintf( result, ARRAYSIZE(result), "%I64d",(CLR_INT64_TEMP_CAST)value->NumericByRef().s8 ); break; diff --git a/CLR/Messaging/Messaging.cpp b/CLR/Messaging/Messaging.cpp index 32e6500d1..b7225718a 100644 --- a/CLR/Messaging/Messaging.cpp +++ b/CLR/Messaging/Messaging.cpp @@ -6,10 +6,6 @@ #include #include -#if defined(PLATFORM_WINDOWS) -#pragma comment(lib,"crypto") -#endif - #include //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CLR/StartupLib/CLRStartup.cpp b/CLR/StartupLib/CLRStartup.cpp index 6fc430dba..f3270e511 100644 --- a/CLR/StartupLib/CLRStartup.cpp +++ b/CLR/StartupLib/CLRStartup.cpp @@ -4,7 +4,7 @@ #include "CLRStartup.h" -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) #include @@ -13,12 +13,12 @@ //////////////////////////////////////////////////////////////////////////////// struct Settings -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) : CLR_RT_ParseOptions #endif { CLR_SETTINGS m_clrOptions; -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) CLR_RT_ParseOptions::BufferMap m_assemblies; #endif bool m_fInitialized; @@ -31,7 +31,7 @@ struct Settings m_clrOptions = params; -#if defined(PLATFORM_WINDOWS) +#if defined(PLATFORM_WINDOWS_EMULATOR) g_CLR_RT_ExecutionEngine.m_fPerformGarbageCollection = params.PerformGarbageCollection; g_CLR_RT_ExecutionEngine.m_fPerformHeapCompaction = params.PerformHeapCompaction; @@ -59,7 +59,7 @@ struct Settings #if !defined(BUILD_RTM) if(params.WaitForDebugger) { -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) CLR_EE_DBG_SET( Enabled ); #endif CLR_EE_DBG_SET( Stopped ); @@ -125,7 +125,7 @@ struct Settings { TINYCLR_HEADER(); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) CLR_RT_StringVector vec; WCHAR* pContext = NULL; @@ -158,7 +158,7 @@ struct Settings TINYCLR_CHECK_HRESULT(LoadKnownAssemblies( TinyClr_Dat_Start, TinyClr_Dat_End )); -#endif // defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#endif // defined(PLATFORM_WINDOWS_EMULATOR) || defined(PLATFORM_WINCE) #if !defined(BUILD_RTM) CLR_Debug::Printf( "Loading Deployment Assemblies.\r\n" ); @@ -362,7 +362,7 @@ struct Settings CLR_RT_ExecutionEngine::DeleteInstance(); -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) memset( &g_CLR_RT_Persistence_Manager, 0, sizeof(g_CLR_RT_Persistence_Manager) ); memset( &g_CLR_RT_ExecutionEngine, 0, sizeof(g_CLR_RT_ExecutionEngine)); memset( &g_CLR_RT_WellKnownTypes, 0, sizeof(g_CLR_RT_WellKnownTypes)); @@ -380,12 +380,12 @@ struct Settings Settings() { m_fInitialized = false; -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) BuildOptions(); #endif } -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) ~Settings() { for(CLR_RT_ParseOptions::BufferMapIter it = m_assemblies.begin(); it != m_assemblies.end(); it++) @@ -403,7 +403,8 @@ struct Settings Settings& m_parent; FPN m_call; - Command_Call( Settings& parent, FPN call, LPCWSTR szName, LPCWSTR szDescription ) : CLR_RT_ParseOptions::Command( szName, szDescription ), m_parent(parent), m_call(call) + Command_Call( Settings& parent, FPN call, LPCWSTR szName, LPCWSTR szDescription ) + : CLR_RT_ParseOptions::Command( szName, szDescription ), m_parent(parent), m_call(call) { } @@ -570,7 +571,7 @@ struct Settings TINYCLR_NOCLEANUP(); } -#endif //#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#endif //#if defined(_WIN32) }; @@ -592,7 +593,7 @@ void ClrReboot() } -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#if defined(_WIN32) HRESULT ClrLoadPE( LPCWSTR szPeFilePath ) { CLR_RT_StringVector vec; @@ -614,19 +615,6 @@ HRESULT ClrLoadDAT( LPCWSTR szDatFilePath ) return s_ClrSettings.ProcessOptions(vec); } - -void ClrSetLcdDimensions( INT32 width, INT32 height, INT32 bitsPerPixel ) -{ - g_HAL_Configuration_Windows.LCD_Width = width; - g_HAL_Configuration_Windows.LCD_Height = height; - g_HAL_Configuration_Windows.LCD_BitsPerPixel = bitsPerPixel; -} - -bool ClrIsDebuggerStopped() -{ - return CLR_EE_DBG_IS( Stopped ); -} - #endif @@ -660,7 +648,7 @@ void ClrStartup( CLR_SETTINGS params ) CLR_Debug::Printf( "Ready.\r\n" ); #endif -#if defined(PLATFORM_WINDOWS) +#if defined(_WIN32) (void)g_CLR_RT_ExecutionEngine.Execute( params.EmulatorArgs, params.MaxContextSwitches ); #else (void)g_CLR_RT_ExecutionEngine.Execute( NULL, params.MaxContextSwitches ); diff --git a/CLR/Tools/BuildHelper/dotNetMF.proj b/CLR/Tools/BuildHelper/dotNetMF.proj index 49b5af43e..223fa6b79 100644 --- a/CLR/Tools/BuildHelper/dotNetMF.proj +++ b/CLR/Tools/BuildHelper/dotNetMF.proj @@ -4,6 +4,10 @@ CLR\Tools\BuildHelper $(SPOCLIENT)\Solutions\Windows2\Windows2.settings Server + + 4199 + + /wd4091 @@ -12,10 +16,7 @@ BuildHelper E0D29432-F26B-44E7-A0FB-6FA21DF258E1 CONSOLE - - 4199 - - /wd4091 + diff --git a/CLR/Tools/Parser/Linker.cpp b/CLR/Tools/Parser/Linker.cpp index 240e6d9f9..bf175138b 100644 --- a/CLR/Tools/Parser/Linker.cpp +++ b/CLR/Tools/Parser/Linker.cpp @@ -5,10 +5,6 @@ #include "stdafx.h" #include -#if defined(PLATFORM_WINDOWS) -#pragma comment(lib,"crypto") -#endif - #include //--// diff --git a/CLR/Tools/StubWinHal/StubWinHal.cpp b/CLR/Tools/StubWinHal/StubWinHal.cpp index 66eccd49f..20b05863f 100644 --- a/CLR/Tools/StubWinHal/StubWinHal.cpp +++ b/CLR/Tools/StubWinHal/StubWinHal.cpp @@ -24,7 +24,9 @@ void CPU_Reset() {} unsigned int Events_MaskedRead( unsigned int ) { return 0; } +#if defined(PLATFORM_WINDOWS_EMULATOR) void CLR_RT_EmulatorHooks::Notify_ExecutionStateChanged( void ) {} +#endif unsigned int Events_WaitForEvents( unsigned int powerLevel, unsigned int,unsigned int ) { return 0; } diff --git a/CLR/Tools/StubWinHal/minheap.cpp b/CLR/Tools/StubWinHal/minheap.cpp index 03df62a86..9c36cf20f 100644 --- a/CLR/Tools/StubWinHal/minheap.cpp +++ b/CLR/Tools/StubWinHal/minheap.cpp @@ -6,7 +6,9 @@ #include "HAL_Windows.h" //////////////////////////////////////////////////////////////////////////////////////////////////// +#if defined(PLATFORM_WINDOWS_EMULATOR) HAL_Configuration_Windows g_HAL_Configuration_Windows; +#endif HAL_SYSTEM_CONFIG HalSystemConfig = { diff --git a/CLR/Tools/TFConvert/dotNetMF.proj b/CLR/Tools/TFConvert/dotNetMF.proj index 195e25ce5..10027d58e 100644 --- a/CLR/Tools/TFConvert/dotNetMF.proj +++ b/CLR/Tools/TFConvert/dotNetMF.proj @@ -6,7 +6,7 @@ Server 4199 - + /wd4091 diff --git a/CLR/Tools/Tools.settings b/CLR/Tools/Tools.settings index eab8f1251..c6627a6f3 100644 --- a/CLR/Tools/Tools.settings +++ b/CLR/Tools/Tools.settings @@ -1,6 +1,9 @@ + + + - + diff --git a/DeviceCode/Targets/OS/Win32/processor_selector.h b/DeviceCode/Targets/OS/Win32/processor_selector.h index bf6547624..220354c0d 100644 --- a/DeviceCode/Targets/OS/Win32/processor_selector.h +++ b/DeviceCode/Targets/OS/Win32/processor_selector.h @@ -11,8 +11,6 @@ ERROR - WE SHOULD NOT INCLUDE THIS HEADER IF NOT BUILDING A WINDOWS PLATFORM #undef FillMemory -#define PLATFORM_WINDOWS_DEFINED - #define PLATFORM_WIN32 1 #endif //_WINDOWS_PROCESSOR_SELECTOR_H_ diff --git a/DeviceCode/Targets/OS/Windows/processor_selector.h b/DeviceCode/Targets/OS/Windows/processor_selector.h index 4201c2124..714130434 100644 --- a/DeviceCode/Targets/OS/Windows/processor_selector.h +++ b/DeviceCode/Targets/OS/Windows/processor_selector.h @@ -11,7 +11,6 @@ ERROR - WE SHOULD NOT INCLUDE THIS HEADER IF NOT BUILDING A WINDOWS PLATFORM #undef FillMemory -#define PLATFORM_WINDOWS_DEFINED -#define PLATFORM_WINDOWS_EMULATOR_OR_TOOLS 1 +#define PLATFORM_WINDOWS 1 #endif //_WINDOWS_PROCESSOR_SELECTOR_H_ diff --git a/DeviceCode/include/Network_decl.h b/DeviceCode/include/Network_decl.h index 188552981..c5357b712 100644 --- a/DeviceCode/include/Network_decl.h +++ b/DeviceCode/include/Network_decl.h @@ -42,7 +42,7 @@ struct SOCK_NetworkConfiguration UINT32 dnsServer2; UINT32 networkInterfaceType; UINT32 macAddressLen; - char macAddressBuffer[64]; + UINT8 macAddressBuffer[64]; }; struct NETWORK_CONFIG diff --git a/DeviceCode/include/Sockets_decl.h b/DeviceCode/include/Sockets_decl.h index dda4a4bd3..b64280d81 100644 --- a/DeviceCode/include/Sockets_decl.h +++ b/DeviceCode/include/Sockets_decl.h @@ -419,7 +419,7 @@ extern const ConfigurationSector g_ConfigurationSector; //--// -#if defined(LITTLE_ENDIAN) || defined(PLATFORM_WINDOWS) +#if defined(LITTLE_ENDIAN) #define SOCK_htons(x) ( (((x) & 0x000000FFUL) << 8) | (((x) & 0x0000FF00UL) >> 8) ) #define SOCK_htonl(x) ( (((x) & 0x000000FFUL) << 24) | (((x) & 0x0000FF00UL) << 8) | (((x) & 0x00FF0000UL) >> 8) | (((x) & 0xFF000000UL) >> 24) ) #define SOCK_ntohs(x) SOCK_htons(x) diff --git a/DeviceCode/include/USB_decl.h b/DeviceCode/include/USB_decl.h index 554ba1996..2e86a81a0 100644 --- a/DeviceCode/include/USB_decl.h +++ b/DeviceCode/include/USB_decl.h @@ -5,7 +5,7 @@ #ifndef _DRIVERS_USB_DECL_H_ #define _DRIVERS_USB_DECL_H_ 1 -#if defined(PLATFORM_WINDOWS) +#if defined(_MSC_VER) #pragma pack(push, USB_DECL_H_, 1) #endif @@ -584,7 +584,7 @@ BOOL CPU_USB_ProtectPins ( int Controller, BOOL On ); //--// -#if defined(PLATFORM_WINDOWS) +#if defined(_MSC_VER) #pragma pack(pop, USB_DECL_H_) #endif diff --git a/DeviceCode/include/tinycrt_decl.h b/DeviceCode/include/tinycrt_decl.h index 02bf59760..3f9abe628 100644 --- a/DeviceCode/include/tinycrt_decl.h +++ b/DeviceCode/include/tinycrt_decl.h @@ -81,7 +81,7 @@ int hal_strncpy_s( char* strDst, size_t sizeInBytes, const char* strSrc, size_t size_t hal_strlen_s (const char * str); int hal_strncmp_s( const char* str1, const char* str2, size_t num ); -#elif defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +#elif defined(_WIN32) #define hal_strcpy_s(strDst, sizeInBytes, strSrc ) strcpy_s(strDst, sizeInBytes, strSrc) #define hal_strncpy_s(strDst, sizeInBytes, strSrc, count ) strncpy_s(strDst, sizeInBytes, strSrc, count) @@ -95,8 +95,6 @@ int hal_strncpy_s( char* strDst, size_t sizeInBytes, const char* strSrc, size_t #define hal_strlen_s( str ) strlen(str) #define hal_strncmp_s( str1, str2, num ) strncmp(str1, str2, num) - - #else !ERROR #endif @@ -105,8 +103,8 @@ int hal_strncpy_s( char* strDst, size_t sizeInBytes, const char* strSrc, size_t // Compares 2 ASCII strings case insensitive. Always defined in our code ( tinycrt.cpp ) int hal_stricmp( const char * dst, const char * src ); -// For Windows we default to c-runtime impelementation. All other platforms come from use tinycrt.cpp -#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_WINCE) +// For Windows we default to c-runtime implementation. All other platforms come from use tinycrt.cpp +#if defined(_WIN32) #define hal_stricmp _stricmp #endif diff --git a/DeviceCode/include/tinyhal.h b/DeviceCode/include/tinyhal.h index 18f2e0522..12df2f1c7 100644 --- a/DeviceCode/include/tinyhal.h +++ b/DeviceCode/include/tinyhal.h @@ -58,9 +58,8 @@ #endif -#if defined(_WIN32_WCE) +#if defined(_MSC_VER) -#define PLATFORM_WINCE #define ADS_PACKED #define GNU_PACKED #define __section(x) @@ -68,18 +67,6 @@ #define FORCEINLINE __forceinline - -#elif defined(_WIN32) || defined(WIN32) - -#define PLATFORM_WINDOWS -#define ADS_PACKED -#define GNU_PACKED -#define __section(x) -#define __irq - -#define FORCEINLINE __forceinline - - #elif defined(__GNUC__) #define PLATFORM_ARM @@ -211,12 +198,12 @@ struct GPIO_FLAG // NULL_PORT => T==0 && p == 0 // // GENERIC_TRANSPORT is any custom port that isn't one of the above, they -// are implemneted for the DebugPort_xxxx apis and the port number is -// and index into a const global table of port interfaces (structure of +// are implemented for the DebugPort_xxxx APIs and the port number is +// an index into a const global table of port interfaces (structure of // function pointers) These allow custom extensions to the normal transports -// without needing to continue defining additional transport types and modifiying +// without needing to continue defining additional transport types and modifying // switch on transport code. To keep compatibility high and code churn low, the -// previous legacy transports remain. +// previous legacy transports remain though they should be considered deprecated. typedef INT32 COM_HANDLE; #define TRANSPORT_SHIFT 8 @@ -226,7 +213,7 @@ typedef INT32 COM_HANDLE; // Macro to extract the transport type from a COM_HANDLE #define ExtractTransport(x) ((UINT32)(x) & TRANSPORT_MASK) -// Macro to extract wellknown system event flag ids from a COM_HANDLE +// Macro to extract well-known system event flag ids from a COM_HANDLE #define ExtractEventFromTransport(x) (ExtractTransport(x) == USART_TRANSPORT ? SYSTEM_EVENT_FLAG_COM_IN: \ ExtractTransport(x) == USB_TRANSPORT ? SYSTEM_EVENT_FLAG_USB_IN: \ ExtractTransport(x) == SOCKET_TRANSPORT ? SYSTEM_EVENT_FLAG_SOCKET: \ @@ -405,7 +392,7 @@ struct HAL_SYSTEM_CONFIG COM_HANDLE DebugTextPort; UINT32 USART_DefaultBaudRate; - // internal HAL/PAL debug/tracing channel, this is seperate + // internal HAL/PAL debug/tracing channel, this is separate // to allow tracing messages in the driver that implements // the transport for the Debugger and DebugTextPort. This // channel is accessed via hal_printf() in the HAL/PAL @@ -719,7 +706,7 @@ void IDelayLoop( int iterations ); void IDelayLoop2( int iterations ); } -// this costs a minimun of 12 cycles when called from 0 wait-state RAM, 34 cycles when +// this costs a minimum of 12 cycles when called from 0 wait-state RAM, 34 cycles when // called from 2 wait-state FLASH #define CYCLE_DELAY_LOOP(d) IDelayLoop(d) @@ -735,7 +722,7 @@ void IDelayLoop2( int iterations ); //--// -#if !defined(PLATFORM_WINDOWS) +#if !defined(_WIN32) extern "C" INT32 InterlockedIncrement( volatile LONG* lpAddend ); extern "C" INT32 InterlockedDecrement( volatile LONG* lpAddend ); extern "C" INT32 InterlockedExchange( volatile LONG* Target, INT32 Value ); @@ -743,7 +730,7 @@ extern "C" INT32 InterlockedCompareExchange( LONG* Destination, LONG Exchange, L extern "C" INT32 InterlockedExchangeAdd( volatile LONG* Addend, LONG Value ); extern "C" INT32 InterlockedOr( volatile LONG* Destination, LONG Flag ); extern "C" INT32 InterlockedAnd( volatile LONG* Destination, LONG Flag ); -#endif // PLATFORM_WINDOWS +#endif struct OpaqueQueueNode { @@ -1452,8 +1439,6 @@ extern const ConfigurationSector g_ConfigurationSector; #endif //--// -#if defined(PLATFORM_ARM) || defined(PLATFORM_BLACKFIN) || defined(PLATFORM_WINDOWS) ||defined(PLATFORM_SH) - #if !defined(BUILD_RTM) #define DEBUG_TRACE0(t, s) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s) ) @@ -1482,8 +1467,6 @@ extern const ConfigurationSector g_ConfigurationSector; #endif // defined(_DEBUG) -#endif - //--// struct CPU_UTILIZATION_TIME diff --git a/DeviceCode/pal/COM/sockets_lwip_os/sockets_lwip.cpp b/DeviceCode/pal/COM/sockets_lwip_os/sockets_lwip.cpp index 2dcd46228..901e795ab 100644 --- a/DeviceCode/pal/COM/sockets_lwip_os/sockets_lwip.cpp +++ b/DeviceCode/pal/COM/sockets_lwip_os/sockets_lwip.cpp @@ -535,7 +535,7 @@ void Sockets_LWIP_Driver::MulticastDiscoveryRespond(void* arg) if(len > 0) { - UINT32 idx = 0; + INT32 idx = 0; BOOL fFound = FALSE; const char* c_Signature = SOCK_DISCOVERY_MULTICAST_TOKEN; INT32 sigLen = hal_strlen_s(c_Signature); diff --git a/DeviceCode/pal/Ink/ink_driver.cpp b/DeviceCode/pal/Ink/ink_driver.cpp index 3550c3869..0208ee944 100644 --- a/DeviceCode/pal/Ink/ink_driver.cpp +++ b/DeviceCode/pal/Ink/ink_driver.cpp @@ -140,7 +140,7 @@ void InkDriver::DrawInk(void *arg) /// bliting to emulator screen does necessarily mean /// it will shown on desktop monitor right away, hence /// this extra step. -#ifdef PLATFORM_WINDOWS +#ifdef PLATFORM_WINDOWS_EMULATOR LCD_BitBltEx( m_InkRegionInfo.X1, m_InkRegionInfo.Y1, diff --git a/DeviceCode/pal/lwip_1_4_1_os/SocketsDriver/lwIP__Sockets.cpp b/DeviceCode/pal/lwip_1_4_1_os/SocketsDriver/lwIP__Sockets.cpp index 80447c854..2f222fc79 100644 --- a/DeviceCode/pal/lwip_1_4_1_os/SocketsDriver/lwIP__Sockets.cpp +++ b/DeviceCode/pal/lwip_1_4_1_os/SocketsDriver/lwIP__Sockets.cpp @@ -20,7 +20,7 @@ extern NETWORK_CONFIG g_NetworkConfig; #if defined(__RENESAS__) volatile int errno; -#else +#elif !( defined(_MSC_VER) && defined(_WIN32) && defined(_DLL) ) int errno; #endif @@ -462,7 +462,7 @@ static int MARSHAL_SOCK_FDSET_TO_FDSET(SOCK_fd_set *sf, fd_set *f) { FD_ZERO(f); - for(int i=0; ifd_count; i++) + for(unsigned int i=0; i < sf->fd_count; i++) { FD_SET(sf->fd_array[i], f); } diff --git a/DeviceCode/pal/time/time_driver.cpp b/DeviceCode/pal/time/time_driver.cpp index c131f918c..df86c107b 100644 --- a/DeviceCode/pal/time/time_driver.cpp +++ b/DeviceCode/pal/time/time_driver.cpp @@ -39,7 +39,7 @@ HRESULT TimeDriver::Initialize() m_timezoneOffset = 0; -#ifdef PLATFORM_WINDOWS +#ifdef PLATFORM_WINDOWS_EMULATOR TIME_ZONE_INFORMATION tzi; SYSTEMTIME st; diff --git a/Solutions/Windows/TinyCLR/DeviceCode/Network/WinPcap_Eth_lwIP/WinPcap_Eth_lwIP_driver_config.cpp b/Solutions/Windows/TinyCLR/DeviceCode/Network/WinPcap_Eth_lwIP/WinPcap_Eth_lwIP_driver_config.cpp index 4948c9d69..073bc3522 100644 --- a/Solutions/Windows/TinyCLR/DeviceCode/Network/WinPcap_Eth_lwIP/WinPcap_Eth_lwIP_driver_config.cpp +++ b/Solutions/Windows/TinyCLR/DeviceCode/Network/WinPcap_Eth_lwIP/WinPcap_Eth_lwIP_driver_config.cpp @@ -15,7 +15,7 @@ WINPCAP_ETH_LWIP_DEVICE_CONFIG g_WINPCAP_ETH_LWIP_Config = { { - // GUID for network adapter that we want to use + // GUID for network adapter that we want to use "{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}" } }; diff --git a/Solutions/Windows/TinyCLR/Lcd.cpp b/Solutions/Windows/TinyCLR/Lcd.cpp index 10f8da677..ee231071c 100644 --- a/Solutions/Windows/TinyCLR/Lcd.cpp +++ b/Solutions/Windows/TinyCLR/Lcd.cpp @@ -18,7 +18,7 @@ static UINT32* g_FrameBuffer = NULL; static UINT32 g_FrameBufferSize = 0; static bool g_LcdInitialized = false; -// required by core only if PLATFORM_WINDOWS is defined +// required by core only if PLATFORM_WINDOWS_EMULATOR is defined // see: CLR_HW_Hardware::Hardware_Initialize() in Hardware.cpp BOOL LCD_Initialize() { diff --git a/Solutions/Windows/TinyCLR/RequiredHalApis.cpp b/Solutions/Windows/TinyCLR/RequiredHalApis.cpp index e3ee544db..bc2da1f2a 100644 --- a/Solutions/Windows/TinyCLR/RequiredHalApis.cpp +++ b/Solutions/Windows/TinyCLR/RequiredHalApis.cpp @@ -77,7 +77,15 @@ void HAL_EnterBooterMode(void) { } -#ifdef PLATFORM_WINDOWS +// TODO: Rename and move this to a PAL level service for an OS +// This is used to indicate an external OS request to shutdown +// (e.g. clicked the close button on the window's title bar etc... +BOOL HAL_Windows_IsShutdownPending() +{ + return FALSE; +} + +#ifdef PLATFORM_WINDOWS_EMULATOR HAL_Configuration_Windows g_HAL_Configuration_Windows; // This thing is in fact intended to slow down the execution of code on the emulator! @@ -112,7 +120,7 @@ void HAL_Windows_FastSleep(INT64 ticks) //} } -// unfortunately the NETMF build system and code assume x86 == PLATFORM_WINDOWS == MSVC +// unfortunately the NETMF build system and code assume x86 == PLATFORM_WINDOWS_EMULATOR == MSVC // so when the tools binaries are built many x86 binary libs are built but the build for // them is not set to go to a platform specific output. Thus, building this project gets // the libraries built when the tools were built, which are based on the windows2 headers @@ -123,33 +131,27 @@ BOOL HAL_Windows_HasGlobalLock() { return !SmartPtr_IRQ::GetState(); } +#endif -// required by profiling APIs in Debugger component when PLATFORM_WINDOWS defined +// required by profiling APIs in Debugger component when WIN32 defined +// longer term this should be moved out to allow any platform with a +// high resolution performance counter to use it. UINT64 HAL_Windows_GetPerformanceTicks() { return 0; } -BOOL HAL_Windows_IsShutdownPending() -{ - return FALSE; -} - +// TODO: remove dependency on this from the CLR - it's a silly dependency void BackLight_Set(BOOL On) { } +// TODO: remove dependency on this from the CLR - it's a silly dependency BOOL Piezo_Tone(UINT32 Frequency_Hertz, UINT32 Duration_Milliseconds) { return TRUE; } -void CLR_RT_EmulatorHooks::Notify_ExecutionStateChanged() -{ -} - -#endif - int hal_vfprintf( COM_HANDLE stream, const char* format, va_list arg ) { NATIVE_PROFILE_PAL_CRT(); diff --git a/Solutions/Windows/TinyCLR/TinyCLR.vcxproj b/Solutions/Windows/TinyCLR/TinyCLR.vcxproj index 966c44f92..c07bd1831 100644 --- a/Solutions/Windows/TinyCLR/TinyCLR.vcxproj +++ b/Solutions/Windows/TinyCLR/TinyCLR.vcxproj @@ -72,7 +72,6 @@ $(SPOCLIENT)\Crypto\lib\x86;$(SPOCLIENT)\BuildOutput\Windows\le\ANY_MEDIA\$(Configuration)\lib;$(SPOCLIENT)\BuildOutput\Windows\le\RAM\$(Configuration)\Win32\lib;$(SPOCLIENT)\DeviceCode\Targets\OS\Win32\DeviceCode\WinPcap_Eth\Dependencies\WpdPack\Lib clrstartup.lib;Core.lib;IOPort.lib;Serialization_stub.lib;SPOT_Serialization_stub.lib;Time_pal.lib;InterruptHandler.lib;SPOT.lib;CorLib.lib;native_double_pal.lib;CRC.lib;Diagnostics.lib;HeapPersistence_stub.lib;RPC_stub.lib;Messaging_stub.lib;SPOT_Messaging.lib;Debugger_stub.lib;Hardware.lib;I2C_stub.lib;watchdog_pal.lib;ssl_pal_stubs.lib;Graphics_stub.lib;InteropAssembliesTable.lib;blockstorage_pal.lib;spot_hardware.lib;spot_net.lib;sockets_pal_lwip_os.lib;SocketsDriver_PAL_LWIP_os.lib;sockets_hal_sockets_lwIP_os.lib;sockets_hal_udp_lwIP_os.lib;sockets_hal_tcp_lwIP_os.lib;sockets_hal_dhcp_lwIP_os.lib;lwip_1_4_1_os_win32.lib;WinPcap_Eth.lib;Packet.lib;wpcap.lib;LargeBuffer_hal_stubs.lib;SimpleHeap_stubs.lib;batterymeasurement_hal_stubs.lib;batterycharger_hal_stubs.lib;batterymodel_hal_stubs.lib;asyncproccall_pal.lib;WinPcap_Eth_lwIP_driver_config.lib;Rpcrt4.lib;config_pal.lib;SPOT_IO.lib;FS_Config_stubs.lib;fs_pal_stubs.lib;Stream.lib;SPOT_Net_Security.lib;Crypto_stub.lib;Events_pal.lib;%(AdditionalDependencies) true - true diff --git a/Solutions/Windows2/TinyCLR/Lcd.cpp b/Solutions/Windows2/TinyCLR/Lcd.cpp index 2ade79912..fe9dc4829 100644 --- a/Solutions/Windows2/TinyCLR/Lcd.cpp +++ b/Solutions/Windows2/TinyCLR/Lcd.cpp @@ -6,6 +6,19 @@ using namespace Microsoft::SPOT::Emulator; +void ClrSetLcdDimensions( INT32 width, INT32 height, INT32 bitsPerPixel ) +{ + g_HAL_Configuration_Windows.LCD_Width = width; + g_HAL_Configuration_Windows.LCD_Height = height; + g_HAL_Configuration_Windows.LCD_BitsPerPixel = bitsPerPixel; +} + +bool ClrIsDebuggerStopped() +{ + return CLR_EE_DBG_IS( Stopped ); +} + + /// NOTE: 06/18/2008-munirula: /// There's no true framebuffer for LCD in emulator. Unfortunately DirectDrawing for perf in Touch based inking /// requires framebuffer access, so it can respond to user activties right away, without requiring round trip into diff --git a/Solutions/Windows2/TinyCLR/stdafx.h b/Solutions/Windows2/TinyCLR/stdafx.h index f75338b09..9777e1772 100644 --- a/Solutions/Windows2/TinyCLR/stdafx.h +++ b/Solutions/Windows2/TinyCLR/stdafx.h @@ -27,11 +27,12 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// - +#include #include #include #include #include +#include #include "EmulatorNative.h" @@ -39,4 +40,3 @@ #define BOOL_TO_INT(f) ((f) ? 1 : 0) #define INT_TO_BOOL(f) ((f) ? true : false) - diff --git a/Solutions/Windows2/platform_selector.h b/Solutions/Windows2/platform_selector.h index 1d900cc04..27b89407f 100644 --- a/Solutions/Windows2/platform_selector.h +++ b/Solutions/Windows2/platform_selector.h @@ -5,6 +5,8 @@ #ifndef _PLATFORM_WINDOWS_SELECTOR_H_ #define _PLATFORM_WINDOWS_SELECTOR_H_ 1 +#define PLATFORM_WINDOWS_EMULATOR 1 + ///////////////////////////////////////////////////////// // // macros diff --git a/Support/Include/WireProtocol.h b/Support/Include/WireProtocol.h index 159370e4d..156be7f0b 100644 --- a/Support/Include/WireProtocol.h +++ b/Support/Include/WireProtocol.h @@ -7,7 +7,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(PLATFORM_WINDOWS) +#if defined(_MSC_VER) #pragma pack(push, SUPPORT_WIREPROTOCOL_H_, 4) #endif @@ -177,7 +177,7 @@ struct WP_CompileCheck //--// -#if defined(PLATFORM_WINDOWS) +#if defined(_MSC_VER) #pragma pack(pop, SUPPORT_WIREPROTOCOL_H_) #endif diff --git a/Update-DeviceSdkAssembly.ps1 b/Update-DeviceSdkAssembly.ps1 new file mode 100644 index 000000000..99c7bcac6 --- /dev/null +++ b/Update-DeviceSdkAssembly.ps1 @@ -0,0 +1,48 @@ +# copy 4 files to Sdk endian specific folder +# .dll +# .pdb +# .pdbx +# .pe +Function Update-SdkEndianBins +{ +Param( [String] $assemblyName, [String] $endian ) + + $BUILD_CLIENT_DLL = Join-Path ${env:BUILD_TREE_CLIENT} "dll" + $BUILD_CLIENT_PE = Join-Path ${env:BUILD_TREE_CLIENT} "pe" + $SdkInstallRoot = Join-Path ${env:ProgramFiles(x86)} "Microsoft .NET Micro Framework\v4.4" + + $endianName = Join-Path $endian $assemblyName + Copy-Item (Join-Path $BUILD_CLIENT_DLL "$assemblyName.dll") (Join-Path $SdkInstallRoot "Assemblies\$endianName.dll") + Copy-Item (Join-Path $BUILD_CLIENT_DLL "$assemblyName.pdb") (Join-Path $SdkInstallRoot "Assemblies\$endianName.pdb") + Copy-Item (Join-Path $BUILD_CLIENT_PE "$endianName.pdbx") (Join-Path $SdkInstallRoot "Assemblies\$endianName.pdbx") + Copy-Item (Join-Path $BUILD_CLIENT_PE "$endianName.pe") (Join-Path $SdkInstallRoot "Assemblies\$endianName.pe") +} + +# copy 2 files into Reference Assemblies location +# .pdb +# .dll +Function Update-SdkRefAssembly +{ +Param( [String] $assemblyName ) + + $RefAssembliesDir = Join-Path ${env:ProgramFiles(x86)} "Reference Assemblies\Microsoft\Framework\.NETMicroFramework\v4.4" + $BUILD_CLIENT_DLL = Join-Path ${env:BUILD_TREE_CLIENT} "dll" + $BUILD_CLIENT_PE = Join-Path ${env:BUILD_TREE_CLIENT} "pe" + Copy-Item (Join-Path $BUILD_CLIENT_DLL "$assemblyName.dll") (Join-Path $RefAssembliesDir "$assemblyName.dll") + Copy-Item (Join-Path $BUILD_CLIENT_DLL "$assemblyName.pdb") (Join-Path $RefAssembliesDir "$assemblyName.pdb") +} + +Function Update-SdkAssembly +{ +Param( [String] $assemblyName ) + + if( [String]::IsNullOrWhiteSpace( ${env:BUILD_TREE_CLIENT} ) ) + { + Write-Error "You must run one of the setenv_xxx scripts to initialize the environment before using this command" + return + } + + Update-SdkRefAssembly $AssemblyName + Update-SdkEndianBins $AssemblyName "le" + Update-SdkEndianBins $AssemblyName "be" +} diff --git a/tools/DisAsmPE/DisAsmPE.sln b/tools/DisAsmPE/DisAsmPE.sln index 42b131a5a..10b4b8497 100644 --- a/tools/DisAsmPE/DisAsmPE.sln +++ b/tools/DisAsmPE/DisAsmPE.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NETMF.PE.Metadata", "NETMF.PE.Metadata\NETMF.PE.Metadata.vcxproj", "{D9366B12-F36F-4263-8B80-FEA1DC9A6AE6}" EndProject @@ -9,10 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DisAsmPE", "DisAsmPE\DisAsm EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C3C6516C-47F7-4675-8934-9264C513CC96}" ProjectSection(SolutionItems) = preProject - AssemblyRefTableEntry.md = AssemblyRefTableEntry.md - PeFileFormat.md = PeFileFormat.md readme.md = readme.md - TypeRefTableEntry.md = TypeRefTableEntry.md EndProjectSection EndProject Global diff --git a/tools/DisAsmPE/DisAsmPE/CommonFormatting.cpp b/tools/DisAsmPE/DisAsmPE/CommonFormatting.cpp index fe9a72cfb..436d482ab 100644 --- a/tools/DisAsmPE/DisAsmPE/CommonFormatting.cpp +++ b/tools/DisAsmPE/DisAsmPE/CommonFormatting.cpp @@ -34,6 +34,8 @@ std::ostream& operator<<( std::ostream& strm, NETMF::Metadata::VersionInfo const } // create an std::string with whitespace control chars replaced as standard C++ char escape style +// That is, a newline, carriage return or tab will appear as a two character sequence (i.e. "\n" ) +// in the resulting string std::string FormatString( const char* peString ) { std::string retVal( peString ); diff --git a/tools/DisAsmPE/DisAsmPE/DisAsmPE.cpp b/tools/DisAsmPE/DisAsmPE/DisAsmPE.cpp index bb970e071..d5ab857ed 100644 --- a/tools/DisAsmPE/DisAsmPE/DisAsmPE.cpp +++ b/tools/DisAsmPE/DisAsmPE/DisAsmPE.cpp @@ -28,6 +28,9 @@ using namespace NETMF; using namespace NETMF::Metadata; using namespace Microsoft::Win32; using namespace Microsoft::Utilities; + +// file namespace not officially included in C++ library yet +// expected to be ratified pretty much 'as-is' into C++17 using namespace std::tr2::sys; int ParseOneAssemblyFile( std::ostream& strm, path peFilePath ); @@ -76,7 +79,7 @@ void DumpTable( std::ostream& strm, AssemblyHeader const& header, std::string ti void OutputAssemblyTableDetails( std::ostream& strm, AssemblyHeader const& header, std::string name, TableKind kind ) { - // "ResourcesFiles" is the longest name (14 chars) so use that for alignment padding + // "ResourcesFiles" is the longest table name (14 chars) so use that for alignment padding strm << std::string( 14 - name.length( ), ' ' ); strm << " [" << name << "] 0x"; strm << std::setw( 8 ) << header.StartOfTables[ ( int )kind ]; diff --git a/tools/DisAsmPE/Include/MetadataTables.h b/tools/DisAsmPE/Include/MetadataTables.h index f0c668f24..ff7d7a732 100644 --- a/tools/DisAsmPE/Include/MetadataTables.h +++ b/tools/DisAsmPE/Include/MetadataTables.h @@ -28,11 +28,17 @@ namespace NETMF { namespace Metadata { + // Simple const expression to form a NETMF LCR opcode value + // from the prefix and code value pair, used in computing the + // value of the Opcode enumeration below. constexpr uint16_t MakeOpcode( uint8_t msb, uint8_t lsb ) { return ( msb << 8 ) + lsb; } + // enumeration of all opcodes with their values in binary IL + // NOTE: This requires a version of OCODE.def that contains + // no duplicate opcode IDs or aliases enum class Opcode : uint16_t { #define OPDEF( id, name, pop, push, params, kind, len, b1, b2, flow )\ @@ -41,20 +47,8 @@ namespace NETMF #undef OPDEF }; - // using a typedef for each of these helps in providing more - // self documenting code. - typedef uint16_t StringTableIndex; - typedef uint16_t TypeDefTableIndex; - typedef uint16_t TypeRefTableIndex; - typedef uint16_t FieldDefTableIndex; - typedef uint16_t MethodDefTableIndex; - typedef uint16_t SigTableIndex; - typedef uint32_t MetadataToken; - typedef uint16_t MetadataOffset; - typedef uint8_t const* MetadataPtr; - - const uint16_t EmptyIndex = 0xFFFF; - + // Enumeration used as an index into the table of tables + // to locate the table data in an assemblies metadata enum class TableKind : uint16_t { AssemblyRef = 0x0000, @@ -76,32 +70,82 @@ namespace NETMF Max = 0x0010, }; + // using a typedef for each of these helps in providing more + // self documenting code as there are a number of tables and + // a simple integer type conveys no useful information on + // which table an index refers to. + typedef uint16_t AssemblyTableRefIndex; + typedef uint16_t TypeRefTableIndex; + typedef uint16_t FieldRefTableIndex; + typedef uint16_t MethodRefTableIndex; + typedef uint16_t TypeDefTableIndex; + typedef uint16_t FieldDefTableIndex; + typedef uint16_t MethodDefTableIndex; + typedef uint16_t AttributesTableIndex; + typedef uint16_t TypeSpecTableIndex; + typedef uint16_t ResourcesTableIndex; + typedef uint32_t ResourcesDataTableIndex; + typedef uint16_t StringTableIndex; + typedef uint16_t SigTableIndex; + typedef uint16_t MetadataOffset; // offset (index) into IL Blob + typedef uint16_t ResourcesFilesTableIndex; + + const uint16_t EmptyIndex = 0xFFFF; // constant value indicating an empty table ( Zero can't be used here as it is a valid index) + typedef uint32_t MetadataToken; // FULL 32 bit token + typedef uint8_t const* MetadataPtr; // pointer into IL Blob + + // constant for the maximum table index + // that is the maximum legal integer index + // is to AssemblyHeader::StartOfTables[] is + // TableMax - 1. static const uint32_t TableMax = static_cast< uint32_t >( TableKind::Max ); - + // Traits style template specialized by DECLARE_TABLEKIND // macro to bind the table type with the enumeration index. // This allows other templates based on the type to determine // the correct index without repetitive and error prone manual // alternatives. + // + // This template is specialized based on the table entry type + // with the DECLARE_TABLEKIND macro to provide the following members: + // value - (TalbeKind) enumeration value for the table associated + // with the type T + // example: + // template + // MetadatToken MakeToken( typename table_kind::type index ) + // { + // return MakeToken( table_kind::value, (uint32_t)index); + // } template< typename T> struct table_kind; - #define DECLARE_TABLEKIND( t, k )\ + // macro to declare the binding between a table entry type and + // TableKind index for that table in the Assembly header + // This also verifies that the table entry type passes the C++ + // POD type traits check. + // Input: + // t - Type of the table entry + // k - TypeKind enum for this table type + // it - index type for index into the table of entries + // (i.e. StringTableIndex, TypeDefTableIndex, etc...) + // + #define DECLARE_TABLEKIND( t, k, it )\ ASSERT_STRUCT_IS_POD( t ) \ template<> \ struct table_kind \ {\ static const TableKind value = k;\ + typedef it IndexType;\ }; - // some token types in the Binary form refer to - // one of two possible tables only, this template + // some token types in the Metadata refer to one + // of two possible tables only, this template // provides support for defining such types and // extracting the table and index values from them // template< TableKind bitSetKind, TableKind bitUnsetKind> - struct BinaryToken + struct BinaryToken final { uint16_t Value; @@ -150,7 +194,7 @@ namespace NETMF return ( ( static_cast( tbl) << 24 ) & 0xFF000000 ) | ( data & 0x00FFFFFF ); } - struct VersionInfo + struct VersionInfo final { uint16_t MajorVersion; uint16_t MinorVersion; @@ -159,15 +203,15 @@ namespace NETMF }; ASSERT_STRUCT_IS_POD( VersionInfo ) - struct AssemblyRefTableEntry + struct AssemblyRefTableEntry final { StringTableIndex Name; uint16_t pad; VersionInfo Version; }; - DECLARE_TABLEKIND( AssemblyRefTableEntry, TableKind::AssemblyRef ) + DECLARE_TABLEKIND( AssemblyRefTableEntry, TableKind::AssemblyRef, AssemblyTableRefIndex ) - struct TypeRefTableEntry + struct TypeRefTableEntry final { StringTableIndex Name; StringTableIndex NameSpace; @@ -175,9 +219,9 @@ namespace NETMF TypeRefOrAssemblyRef Scope; uint16_t Pad; }; - DECLARE_TABLEKIND( TypeRefTableEntry, TableKind::TypeRef ) + DECLARE_TABLEKIND( TypeRefTableEntry, TableKind::TypeRef, TypeRefTableIndex ) - struct FieldRefTableEntry + struct FieldRefTableEntry final { StringTableIndex Name; TypeRefTableIndex Container; @@ -185,16 +229,16 @@ namespace NETMF SigTableIndex Sig; uint16_t Pad; }; - DECLARE_TABLEKIND( FieldRefTableEntry, TableKind::FieldRef ) + DECLARE_TABLEKIND( FieldRefTableEntry, TableKind::FieldRef, FieldRefTableIndex ) - struct MethodRefTableEntry + struct MethodRefTableEntry final { StringTableIndex Name; TypeRefTableIndex Container; SigTableIndex Sig; uint16_t Pad; }; - DECLARE_TABLEKIND( MethodRefTableEntry, TableKind::MethodRef ) + DECLARE_TABLEKIND( MethodRefTableEntry, TableKind::MethodRef, MethodRefTableIndex ) enum class TypeDefFlags : uint16_t { @@ -227,7 +271,7 @@ namespace NETMF }; ENUM_FLAGS( TypeDefFlags ) - struct TypeDefTableEntry + struct TypeDefTableEntry final { StringTableIndex Name; StringTableIndex NameSpace; @@ -260,7 +304,7 @@ namespace NETMF return ( flags & ( TypeDefFlags::Delegate | TypeDefFlags::MulticastDelegate ) ) != TypeDefFlags::None; } }; - DECLARE_TABLEKIND( TypeDefTableEntry, TableKind::TypeDef ) + DECLARE_TABLEKIND( TypeDefTableEntry, TableKind::TypeDef, TypeDefTableIndex ) enum class FieldDefFlags : uint16_t { @@ -285,7 +329,7 @@ namespace NETMF }; ENUM_FLAGS( FieldDefFlags ) - struct FieldDefTableEntry + struct FieldDefTableEntry final { StringTableIndex Name; SigTableIndex sig; @@ -293,7 +337,7 @@ namespace NETMF SigTableIndex DefaultValue; FieldDefFlags Flags; }; - DECLARE_TABLEKIND( FieldDefTableEntry, TableKind::FieldDef ) + DECLARE_TABLEKIND( FieldDefTableEntry, TableKind::FieldDef, FieldDefTableIndex ) enum class MethodDefFlags : uint32_t { @@ -334,7 +378,7 @@ namespace NETMF }; ENUM_FLAGS( MethodDefFlags ) - struct MethodDefTableEntry + struct MethodDefTableEntry final { StringTableIndex Name; MetadataOffset RVA; @@ -349,23 +393,23 @@ namespace NETMF SigTableIndex Locals; SigTableIndex Sig; }; - DECLARE_TABLEKIND( MethodDefTableEntry, TableKind::MethodDef ) + DECLARE_TABLEKIND( MethodDefTableEntry, TableKind::MethodDef, MethodDefTableIndex ) - struct AttributeTableEntry + struct AttributeTableEntry final { TableKind OwnerType; // one of TableKind::TypeDef, TableKind::MethodDef, or TableKind::FieldDef. uint16_t OwnerIdx; // index into the table specified by ownerType MethodRefOrMethodDef Constructor; SigTableIndex Data; }; - DECLARE_TABLEKIND( AttributeTableEntry, TableKind::Attributes ) + DECLARE_TABLEKIND( AttributeTableEntry, TableKind::Attributes, AttributesTableIndex ) - struct TypeSpecTableEntry + struct TypeSpecTableEntry final { SigTableIndex Sig; uint16_t pad; }; - DECLARE_TABLEKIND( TypeSpecTableEntry, TableKind::TypeSpec ) + DECLARE_TABLEKIND( TypeSpecTableEntry, TableKind::TypeSpec, TypeSpecTableIndex ) enum class ExceptionHandlerMode : uint16_t { @@ -393,7 +437,7 @@ namespace NETMF // VERIFY whether MetadataProcessor will align the table entries // or not. (Current NETMF CLR seems to assume it won't and does // a memcpy) - struct ExceptionHandlerTableEntry + struct ExceptionHandlerTableEntry final { ExceptionHandlerMode Mode; union @@ -454,7 +498,7 @@ namespace NETMF static_assert( sizeof( ExceptionHandlerTableEntry ) == 12, "Record size mismatch!" ); - struct ResourcesFilesTableEntry + struct ResourcesFilesTableEntry final { static const uint32_t CurrentVersion = 2; @@ -473,18 +517,20 @@ namespace NETMF uint32_t NumberOfResources; StringTableIndex Name; uint16_t Pad; - uint32_t Offset; // TableKind::Resource + ResourcesDataTableIndex Offset; }; - DECLARE_TABLEKIND( ResourcesFilesTableEntry, TableKind::ResourcesFiles ) + DECLARE_TABLEKIND( ResourcesFilesTableEntry, TableKind::ResourcesFiles, ResourcesFilesTableIndex ) - // in future release of NETMF CLR the + // In future release of NETMF CLR the // bitmap and font enumeration values here // should be removed and treated as binary // blobs. // This requires that the PE generator // (or more specifically the NETMF resource generator) // understands the format and can perform the necessary - // byte order conversions. + // byte order conversions. This helps in keeping the core + // runtime and tooling isolated from the graphics system + // (a goal of the new work on the runtime ) enum class ResourceKind : uint8_t { Invalid = 0x00, @@ -494,7 +540,7 @@ namespace NETMF Binary = 0x04, }; - struct ResourcesTableEntry + struct ResourcesTableEntry final { // The last entry in the Resources table // will have: @@ -521,9 +567,9 @@ namespace NETMF ResourceKind Kind; uint8_t Flags; - // offset into the ResourceData blob table for the + // offset into the ResourcesData blob table for the // start of the resource data - uint32_t Offset; // TableKind::ResourceData + ResourcesDataTableIndex Offset; // Compute size of the resourceData blob for this entry // based on the start of the next entry @@ -542,7 +588,7 @@ namespace NETMF return next.Offset - Offset + ( next.Flags & FlagsPaddingMask ); } }; - DECLARE_TABLEKIND( ResourcesTableEntry, TableKind::Resources ) + DECLARE_TABLEKIND( ResourcesTableEntry, TableKind::Resources, ResourcesTableIndex ) enum class AssemblyHeaderFlags : uint32_t { @@ -572,7 +618,8 @@ namespace NETMF Generic = 0x10, // Generic method sig with explicit number of type arguments (precedes ordinary parameter count) }; - // NOTE: While this NETMF specific enum corresponds to the ECMA ELEMENT_TYPE_xxxx + // NOTE: + // While this NETMF specific enum corresponds to the ECMA ELEMENT_TYPE_xxxx // the actual numeric values are not the same and it is a reduced set of values. enum class DataType : uint8_t { @@ -607,7 +654,7 @@ namespace NETMF // headers are located in the well known memory regions used by the // CLR. The memory regions are scanned for valid headers (e.g. marker // and CRCs are valid ) - struct AssemblyHeader + struct AssemblyHeader final { uint8_t Marker[ 8 ]; @@ -616,7 +663,7 @@ namespace NETMF AssemblyHeaderFlags Flags; uint32_t NativeMethodsChecksum; - // offset into TableKind::ResourceData for native "patch" code exists. + // offset into TableKind::ResourcesData for native "patch" code exists. // At runtime if this is not 0xFFFFFFFF then the CLR will compute // a physical address of the start of the patch code and call the function // located there. The function must be position independent and must have @@ -627,7 +674,7 @@ namespace NETMF // as many micro controllers limit the memory addresses where executable // code can reside. (i.e. internal flash or RAM only ) thus, this is not a // generalized extensibility/ dynamically loaded native code mechanism. - uint32_t PatchEntryOffset; + ResourcesDataTableIndex PatchEntryOffset; VersionInfo Version; @@ -834,7 +881,7 @@ namespace NETMF // use in ranged for loops, and other standard C++ // contexts. template - class AssemblyTable + class AssemblyTable final { static const TableKind Kind = table_kind::value; public: @@ -845,9 +892,9 @@ namespace NETMF T const* begin( ) { return reinterpret_cast( Header.GetTable( Kind ) ); } T const* end( ) { return begin() + Header.TableElementCount( Kind ); } - T const& operator[]( uint16_t index ) + T const& operator[]( typename table_kind::IndexType index ) { - return begin()[ index ]; + return begin()[ static_cast( index ) ]; } size_t length( ) @@ -869,7 +916,6 @@ namespace NETMF MethodDefTableEntry const& p = GetTable( )[ i ]; return FindMethodBoundaries( p, i, start, end ); } - } } #endif \ No newline at end of file diff --git a/tools/DisAsmPE/Include/Utilities.h b/tools/DisAsmPE/Include/Utilities.h index 35f394d3b..cb6fb9e34 100644 --- a/tools/DisAsmPE/Include/Utilities.h +++ b/tools/DisAsmPE/Include/Utilities.h @@ -26,8 +26,9 @@ namespace NETMF // macro to generate a compile time error if the given structure is not a proper C++ POD type // POD types are essential for ensuring binary compatibility with the memory layout generated - // by the NETMF tools. Since this code is intended for use on the desktop and on devices it - // must remain portable so that the raw PE images are accessible directly in memory as-is. + // by the NETMF tools. Since the NETMF CLR code is intended for use on the desktop and on + // devices it must remain portable so that the raw PE images are accessible directly in memory + // as-is. #define ASSERT_STRUCT_IS_POD( t ) \ static_assert( std::is_pod::value \ , "Data structure " #t " MUST always remain a POD structure for portability" \