From cecbc6d2c087febb5850029122c8e27082b5bdcc Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Wed, 4 Nov 2015 22:23:46 +0100 Subject: Fix few issues in PAL to fix the HelloWorld With my latest changes, the HelloWorld stopped working. I had two problems there. One was few simple bugs in the CPU cache details extraction. The other was the fact that InterlockedXXX operations are implemented like this in PalRedhawk.h: ```C EXTERN_C long __cdecl _InterlockedIncrement(long volatile *); Int32 PalInterlockedIncrement(_Inout_ _Interlocked_operand_ Int32 volatile *pDst) { return _InterlockedIncrement((long volatile *)pDst); } ``` The code is using long, which is 64 bits on 64 bit Unix. So it is casting 32 bit pointer to 64 bit one and performing 64 bit ops. It both corrupts 32 bits after the location where the pointer points and makes some InterlockedCompareExchange ops incorrect. So instead of relying in the _InterlockedXXX intrinsics that can only accept int or long, I have moved the inline implementations into separate file, one for windows and one for Unix and implemented all of the PalInterlockedXXX using __sync_xxxxx functions. --- src/Native/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Native/CMakeLists.txt') diff --git a/src/Native/CMakeLists.txt b/src/Native/CMakeLists.txt index 5dcb305f5..b5fed91a1 100644 --- a/src/Native/CMakeLists.txt +++ b/src/Native/CMakeLists.txt @@ -19,7 +19,7 @@ function(clr_unknown_arch) endfunction() if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) - add_definitions(-DBIT64=1) + set(IS_64BIT_BUILD 1) elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l) add_definitions(-DBIT32=1) # Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang @@ -91,6 +91,10 @@ elseif(WIN32) endif() endif() +if(IS_64BIT_BUILD) + add_definitions(-DBIT64=1) +endif(IS_64BIT_BUILD) + if(WIN32) enable_language(ASM_MASM) else() -- cgit v1.2.3