diff --git a/src/coreclr/debug/createdump/crashinfounix.cpp b/src/coreclr/debug/createdump/crashinfounix.cpp index d7e93bdc7a2eae..77a5439629206d 100644 --- a/src/coreclr/debug/createdump/crashinfounix.cpp +++ b/src/coreclr/debug/createdump/crashinfounix.cpp @@ -376,8 +376,8 @@ CrashInfo::VisitProgramHeader(uint64_t loadbias, uint64_t baseAddress, Phdr* phd TRACE("VisitProgramHeader: ehFrameHdrStart %016llx ehFrameHdrSize %08llx\n", ehFrameHdrStart, ehFrameHdrSize); InsertMemoryRegion(ehFrameHdrStart, ehFrameHdrSize); - uint64_t ehFrameStart; - uint64_t ehFrameSize; + ULONG64 ehFrameStart; + ULONG64 ehFrameSize; if (PAL_GetUnwindInfoSize(baseAddress, ehFrameHdrStart, ReadMemoryAdapter, &ehFrameStart, &ehFrameSize)) { TRACE("VisitProgramHeader: ehFrameStart %016llx ehFrameSize %08llx\n", ehFrameStart, ehFrameSize); diff --git a/src/coreclr/debug/inc/dacdbistructures.inl b/src/coreclr/debug/inc/dacdbistructures.inl index 9478ce5132c513..e31583faff589b 100644 --- a/src/coreclr/debug/inc/dacdbistructures.inl +++ b/src/coreclr/debug/inc/dacdbistructures.inl @@ -640,8 +640,6 @@ void FieldData::ClearFields() m_pFldStaticAddress = NULL; } -typedef ULONG_PTR SIZE_T; - inline BOOL FieldData::OkToGetOrSetInstanceOffset() { diff --git a/src/coreclr/dlls/mscordac/mscordac_unixexports.src b/src/coreclr/dlls/mscordac/mscordac_unixexports.src index cbdce1b792472c..fbadc7ad4a0c4d 100644 --- a/src/coreclr/dlls/mscordac/mscordac_unixexports.src +++ b/src/coreclr/dlls/mscordac/mscordac_unixexports.src @@ -31,7 +31,6 @@ nativeStringResourceTable_mscorrc #PAL_fwprintf #PAL_GetLogicalCpuCountFromOS #PAL_GetTotalCpuCount -#PAL_GetNumaProcessorNode #PAL_GetUnwindInfoSize #PAL_get_stdout #PAL_get_stderr @@ -126,7 +125,6 @@ nativeStringResourceTable_mscorrc #GetFullPathNameW #GetLastError #GetModuleFileNameW -#GetNumaHighestNodeNumber #GetProcAddress #GetStdHandle #GetSystemInfo @@ -168,7 +166,6 @@ nativeStringResourceTable_mscorrc #SwitchToThread #TerminateProcess #VirtualAlloc -#VirtualAllocExNuma #VirtualFree #VirtualProtect #VirtualQuery diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 688629d178ddcf..6e22bd96f79dc1 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -82,6 +82,7 @@ set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) if (CLR_CMAKE_HOST_UNIX) set(LIB_UNWINDER unwinder_wks) + set(GC_PAL gc_unix) endif (CLR_CMAKE_HOST_UNIX) # IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is @@ -108,6 +109,7 @@ set(CORECLR_LIBRARIES System.Globalization.Native-Static interop coreclrminipal + ${GC_PAL} ) if(CLR_CMAKE_TARGET_WIN32) diff --git a/src/coreclr/gc/CMakeLists.txt b/src/coreclr/gc/CMakeLists.txt index 9052c4a529f7ed..4441c41df36f94 100644 --- a/src/coreclr/gc/CMakeLists.txt +++ b/src/coreclr/gc/CMakeLists.txt @@ -27,12 +27,10 @@ set(GC_SOURCES handletablecache.cpp) if(CLR_CMAKE_HOST_UNIX) + add_subdirectory(unix) include(unix/configure.cmake) set (GC_SOURCES - ${GC_SOURCES} - unix/gcenv.unix.cpp - unix/events.cpp - unix/cgroup.cpp) + ${GC_SOURCES}) else() set (GC_SOURCES ${GC_SOURCES} @@ -101,7 +99,7 @@ if(CLR_CMAKE_HOST_WIN32) kernel32.lib advapi32.lib) else() - set (GC_LINK_LIBRARIES) + set (GC_LINK_LIBRARIES gc_unix) endif(CLR_CMAKE_HOST_WIN32) list(APPEND GC_SOURCES ${GC_HEADERS}) diff --git a/src/coreclr/gc/unix/cgroup.cpp b/src/coreclr/gc/unix/cgroup.cpp index ad2a41284cbbe4..136ff3fb19105d 100644 --- a/src/coreclr/gc/unix/cgroup.cpp +++ b/src/coreclr/gc/unix/cgroup.cpp @@ -54,6 +54,8 @@ Module Name: extern bool ReadMemoryValueFromFile(const char* filename, uint64_t* val); +namespace +{ class CGroup { // the cgroup version number or 0 to indicate cgroups are not found or not enabled @@ -453,6 +455,7 @@ class CGroup return foundInactiveFileValue; } }; +} int CGroup::s_cgroup_version = 0; char *CGroup::s_memory_cgroup_path = nullptr; diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 68e76302031260..645e6da01d86e8 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -633,7 +633,7 @@ void GCToOSInterface::YieldThread(uint32_t switchCount) static void* VirtualReserveInner(size_t size, size_t alignment, uint32_t flags, uint32_t hugePagesFlag = 0) { assert(!(flags & VirtualReserveFlags::WriteWatch) && "WriteWatch not supported on Unix"); - if (alignment == 0) + if (alignment < OS_PAGE_SIZE) { alignment = OS_PAGE_SIZE; } @@ -641,7 +641,7 @@ static void* VirtualReserveInner(size_t size, size_t alignment, uint32_t flags, size_t alignedSize = size + (alignment - OS_PAGE_SIZE); void * pRetVal = mmap(nullptr, alignedSize, PROT_NONE, MAP_ANON | MAP_PRIVATE | hugePagesFlag, -1, 0); - if (pRetVal != NULL) + if (pRetVal != MAP_FAILED) { void * pAlignedRetVal = (void *)(((size_t)pRetVal + (alignment - 1)) & ~(alignment - 1)); size_t startPadding = (size_t)pAlignedRetVal - (size_t)pRetVal; @@ -659,9 +659,14 @@ static void* VirtualReserveInner(size_t size, size_t alignment, uint32_t flags, } pRetVal = pAlignedRetVal; +#ifdef MADV_DONTDUMP + // Do not include reserved memory in coredump. + madvise(pRetVal, size, MADV_DONTDUMP); +#endif + return pRetVal; } - return pRetVal; + return NULL; // return NULL if mmap failed } // Reserve virtual memory range. @@ -724,6 +729,14 @@ bool GCToOSInterface::VirtualCommit(void* address, size_t size, uint16_t node) { bool success = mprotect(address, size, PROT_WRITE | PROT_READ) == 0; +#ifdef MADV_DODUMP + if (success) + { + // Include committed memory in coredump. + madvise(address, size, MADV_DODUMP); + } +#endif + #if HAVE_NUMA_H if (success && g_numaAvailable && (node != NUMA_NODE_UNDEFINED)) { @@ -760,7 +773,17 @@ bool GCToOSInterface::VirtualDecommit(void* address, size_t size) // that much more clear to the operating system that we no // longer need these pages. Also, GC depends on re-committed pages to // be zeroed-out. - return mmap(address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0) != NULL; + bool bRetVal = mmap(address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0) != MAP_FAILED; + +#ifdef MADV_DONTDUMP + if (bRetVal) + { + // Do not include freed memory in coredump. + madvise(address, size, MADV_DONTDUMP); + } +#endif + + return bRetVal; } // Reset virtual memory range. Indicates that data in the memory range specified by address and size is no @@ -791,6 +814,14 @@ bool GCToOSInterface::VirtualReset(void * address, size_t size, bool unlock) #endif } +#ifdef MADV_DONTDUMP + if (st == 0) + { + // Do not include reset memory in coredump. + madvise(address, size, MADV_DONTDUMP); + } +#endif + return (st == 0); } diff --git a/src/coreclr/inc/check.inl b/src/coreclr/inc/check.inl index f234e988faf0d8..9296c48f7a7a3d 100644 --- a/src/coreclr/inc/check.inl +++ b/src/coreclr/inc/check.inl @@ -220,6 +220,14 @@ inline CHECK CheckOverflow(const void *address, UINT64 offset) CHECK_OK; } +#ifdef __APPLE__ +inline CHECK CheckOverflow(const void *address, SIZE_T offset) +{ + CHECK((UINT64) address + offset >= (UINT64) address); + + CHECK_OK; +} +#endif // __APPLE__ inline CHECK CheckUnderflow(UINT value1, UINT value2) { diff --git a/src/coreclr/inc/clrtypes.h b/src/coreclr/inc/clrtypes.h index 5e83573e7aa943..19e9720b34d90b 100644 --- a/src/coreclr/inc/clrtypes.h +++ b/src/coreclr/inc/clrtypes.h @@ -338,6 +338,15 @@ inline UINT64 AlignUp(UINT64 value, UINT alignment) return (value+alignment-1)&~(UINT64)(alignment-1); } +#ifdef __APPLE__ +inline SIZE_T AlignUp(SIZE_T value, UINT alignment) +{ + STATIC_CONTRACT_LEAF; + STATIC_CONTRACT_SUPPORTS_DAC; + return (value+alignment-1)&~(SIZE_T)(alignment-1); +} +#endif // __APPLE__ + inline UINT AlignDown(UINT value, UINT alignment) { STATIC_CONTRACT_LEAF; @@ -381,6 +390,14 @@ inline UINT AlignmentPad(UINT64 value, UINT alignment) return (UINT) (AlignUp(value, alignment) - value); } +#ifdef __APPLE__ +inline UINT AlignmentPad(SIZE_T value, UINT alignment) +{ + STATIC_CONTRACT_WRAPPER; + return (UINT) (AlignUp(value, alignment) - value); +} +#endif // __APPLE__ + inline UINT AlignmentTrim(UINT value, UINT alignment) { STATIC_CONTRACT_LEAF; @@ -406,4 +423,13 @@ inline UINT AlignmentTrim(UINT64 value, UINT alignment) return ((UINT)value)&(alignment-1); } +#ifdef __APPLE__ +inline UINT AlignmentTrim(SIZE_T value, UINT alignment) +{ + STATIC_CONTRACT_LEAF; + STATIC_CONTRACT_SUPPORTS_DAC; + return ((UINT)value)&(alignment-1); +} +#endif // __APPLE__ + #endif // CLRTYPES_H_ diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index a8056a5451561a..df31ac579e52c1 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -1027,6 +1027,12 @@ class __DPtrBase : public __TPtrBase { return DPtrType(DacTAddrOffset(m_addr, val, sizeof(type))); } +#if defined(HOST_UNIX) && defined(HOST_64BIT) + DPtrType operator+(unsigned long long val) + { + return DPtrType(DacTAddrOffset(m_addr, val, sizeof(type))); + } +#endif // HOST_UNIX && HOST_BIT64 DPtrType operator+(short val) { return DPtrType(m_addr + val * sizeof(type)); diff --git a/src/coreclr/inc/regdisp.h b/src/coreclr/inc/regdisp.h index 7a51ec54e2f38c..b6ccc87ff6d876 100644 --- a/src/coreclr/inc/regdisp.h +++ b/src/coreclr/inc/regdisp.h @@ -561,7 +561,7 @@ inline size_t * getRegAddr (unsigned regNum, PTR_CONTEXT regs) return (PTR_size_t)(PTR_BYTE(regs) + OFFSET_OF_REGISTERS[regNum]); #elif defined(TARGET_AMD64) _ASSERTE(regNum < 16); - return ®s->Rax + regNum; + return (size_t *)®s->Rax + regNum; #elif defined(TARGET_ARM) _ASSERTE(regNum < 16); return (size_t *)®s->R0 + regNum; diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index 63b83aa8eb61d1..91941fe49f7a22 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -233,6 +233,13 @@ inline unsigned genLog2(unsigned __int64 value) #endif } +#ifdef __APPLE__ +inline unsigned genLog2(size_t value) +{ + return genLog2((unsigned __int64)value); +} +#endif // __APPLE__ + /***************************************************************************** * * Return the lowest bit that is set in the given register mask. @@ -1557,7 +1564,8 @@ void GenTree::BashToConst(T value, var_types type /* = TYP_UNDEF */) { static_assert_no_msg((std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || - std::is_same::value)); + std::is_same::value || std::is_same::value)); + static_assert_no_msg(sizeof(int64_t) == sizeof(long long)); var_types typeOfValue = TYP_UNDEF; diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 81c0c181bfa3ed..f1f9d503cdc86f 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -3290,7 +3290,8 @@ inline void GenTreeIntConCommon::SetIntegralValue(int64_t value) template inline void GenTreeIntConCommon::SetValueTruncating(T value) { - static_assert_no_msg((std::is_same::value || std::is_same::value)); + static_assert_no_msg( + (std::is_same::value || std::is_same::value || std::is_same::value)); if (TypeIs(TYP_LONG)) { diff --git a/src/coreclr/jit/jit.h b/src/coreclr/jit/jit.h index e15d3ade77ecad..df7368bdff1c8e 100644 --- a/src/coreclr/jit/jit.h +++ b/src/coreclr/jit/jit.h @@ -219,6 +219,8 @@ #error Unsupported or unset target architecture #endif +typedef ptrdiff_t ssize_t; + // Include the AMD64 unwind codes when appropriate. #if defined(TARGET_AMD64) #include "win64unwind.h" @@ -349,8 +351,6 @@ typedef int NATIVE_OFFSET; // this is used for native code sizes. typedef unsigned UNATIVE_OFFSET; -typedef ptrdiff_t ssize_t; - // Type used for weights (e.g. block and edge weights) typedef double weight_t; @@ -631,9 +631,16 @@ inline unsigned int unsigned_abs(int x) #ifdef TARGET_64BIT inline size_t unsigned_abs(ssize_t x) +{ + return ((size_t)abs((__int64)x)); +} + +#ifdef __APPLE__ +inline size_t unsigned_abs(__int64 x) { return ((size_t)abs(x)); } +#endif // __APPLE__ #endif // TARGET_64BIT /*****************************************************************************/ diff --git a/src/coreclr/jit/register.h b/src/coreclr/jit/register.h index 971974722eee81..6f63bc51211d63 100644 --- a/src/coreclr/jit/register.h +++ b/src/coreclr/jit/register.h @@ -68,10 +68,10 @@ REGALIAS(EDI, RDI) #ifdef TARGET_AMD64 #define XMMBASE 16 -#define XMMMASK(x) (__int64(1) << ((x)+XMMBASE)) +#define XMMMASK(x) ((__int64)(1) << ((x)+XMMBASE)) #else // !TARGET_AMD64 #define XMMBASE 8 -#define XMMMASK(x) (__int32(1) << ((x)+XMMBASE)) +#define XMMMASK(x) ((__int32)(1) << ((x)+XMMBASE)) #endif // !TARGET_AMD64 REGDEF(XMM0, 0+XMMBASE, XMMMASK(0), "mm0" ) diff --git a/src/coreclr/jit/utils.h b/src/coreclr/jit/utils.h index 8ae84d0d8858c2..79a0be63bac0d5 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -819,6 +819,7 @@ template bool FitsIn(var_types type, T value) { static_assert_no_msg((std::is_same::value || std::is_same::value || + std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value)); switch (type) diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index cfb764368b576a..21ce98a678f715 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4417,6 +4417,12 @@ inline __int64 abs(__int64 _X) { return llabs(_X); } +#ifdef __APPLE__ +inline __int64 abs(SSIZE_T _X) { + return llabs((__int64)_X); +} +#endif + } #endif diff --git a/src/coreclr/pal/inc/pal_mstypes.h b/src/coreclr/pal/inc/pal_mstypes.h index 90378a81f4acb9..1eee6b2bbbd245 100644 --- a/src/coreclr/pal/inc/pal_mstypes.h +++ b/src/coreclr/pal/inc/pal_mstypes.h @@ -195,12 +195,11 @@ extern "C" { // they must be either signed or unsigned) and we want to be able to use // __int64 as though it were intrinsic -#ifdef HOST_64BIT +#if defined(HOST_64BIT) && !defined(__APPLE__) #define __int64 long -#else // HOST_64BIT +#else // HOST_64BIT && !__APPLE__ #define __int64 long long -#endif // HOST_64BIT - +#endif // HOST_64BIT && !__APPLE__ #define __int32 int #define __int16 short int #define __int8 char // assumes char is signed @@ -543,8 +542,16 @@ typedef _W64 unsigned __int32 DWORD_PTR, *PDWORD_PTR; #define UlongToPtr(ul) ULongToPtr(ul) #define UintToPtr(ui) UIntToPtr(ui) -typedef ULONG_PTR SIZE_T, *PSIZE_T; -typedef LONG_PTR SSIZE_T, *PSSIZE_T; +#ifdef HOST_64BIT +typedef unsigned long SIZE_T; +typedef long SSIZE_T; +#else +typedef unsigned int SIZE_T; +typedef int SSIZE_T; +#endif + +static_assert(sizeof(SIZE_T) == sizeof(void*), "SIZE_T should be pointer sized"); +static_assert(sizeof(SSIZE_T) == sizeof(void*), "SSIZE_T should be pointer sized"); #ifndef SIZE_T_MAX #define SIZE_T_MAX ULONG_PTR_MAX @@ -559,18 +566,14 @@ typedef LONG_PTR SSIZE_T, *PSSIZE_T; #endif #ifndef PAL_STDCPP_COMPAT -#if defined(__APPLE_CC__) || defined(__linux__) #ifdef HOST_64BIT typedef unsigned long size_t; +typedef long ssize_t; typedef long ptrdiff_t; #else // !HOST_64BIT typedef unsigned int size_t; typedef int ptrdiff_t; #endif // !HOST_64BIT -#else -typedef ULONG_PTR size_t; -typedef LONG_PTR ptrdiff_t; -#endif #endif // !PAL_STDCPP_COMPAT #define _SIZE_T_DEFINED @@ -596,8 +599,8 @@ typedef int intptr_t; typedef unsigned int uintptr_t; #endif // !HOST_64BIT #else -typedef INT_PTR intptr_t; -typedef UINT_PTR uintptr_t; +typedef long int intptr_t; +typedef unsigned long int uintptr_t; #endif #endif // PAL_STDCPP_COMPAT diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 1315dac0cb1b94..1088bb1791869e 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -171,7 +171,6 @@ set(SOURCES misc/sysinfo.cpp misc/time.cpp misc/utils.cpp - numa/numa.cpp objmgr/palobjbase.cpp objmgr/shmobject.cpp objmgr/shmobjectmanager.cpp diff --git a/src/coreclr/pal/src/exception/remote-unwind.cpp b/src/coreclr/pal/src/exception/remote-unwind.cpp index 87bb1d42757351..22c72eeb709f08 100644 --- a/src/coreclr/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/pal/src/exception/remote-unwind.cpp @@ -1820,12 +1820,12 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i static void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) { #if defined(TARGET_AMD64) - GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, &contextPointers->Rbp); - GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, &contextPointers->Rbx); - GetContextPointer(cursor, unwContext, UNW_X86_64_R12, &contextPointers->R12); - GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13); - GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14); - GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15); + GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, (SIZE_T**)&contextPointers->Rbp); + GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, (SIZE_T**)&contextPointers->Rbx); + GetContextPointer(cursor, unwContext, UNW_X86_64_R12, (SIZE_T**)&contextPointers->R12); + GetContextPointer(cursor, unwContext, UNW_X86_64_R13, (SIZE_T**)&contextPointers->R13); + GetContextPointer(cursor, unwContext, UNW_X86_64_R14, (SIZE_T**)&contextPointers->R14); + GetContextPointer(cursor, unwContext, UNW_X86_64_R15, (SIZE_T**)&contextPointers->R15); #elif defined(TARGET_X86) GetContextPointer(cursor, unwContext, UNW_X86_EBX, &contextPointers->Ebx); GetContextPointer(cursor, unwContext, UNW_X86_EBP, &contextPointers->Ebp); @@ -1841,60 +1841,60 @@ static void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, GetContextPointer(cursor, unwContext, UNW_ARM_R10, &contextPointers->R10); GetContextPointer(cursor, unwContext, UNW_ARM_R11, &contextPointers->R11); #elif defined(TARGET_ARM64) - GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, &contextPointers->X19); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, &contextPointers->X20); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, &contextPointers->X21); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X22, &contextPointers->X22); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X23, &contextPointers->X23); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X24, &contextPointers->X24); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X25, &contextPointers->X25); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X26, &contextPointers->X26); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X27, &contextPointers->X27); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X28, &contextPointers->X28); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X29, &contextPointers->Fp); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, (SIZE_T**)&contextPointers->X19); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, (SIZE_T**)&contextPointers->X20); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, (SIZE_T**)&contextPointers->X21); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X22, (SIZE_T**)&contextPointers->X22); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X23, (SIZE_T**)&contextPointers->X23); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X24, (SIZE_T**)&contextPointers->X24); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X25, (SIZE_T**)&contextPointers->X25); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X26, (SIZE_T**)&contextPointers->X26); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X27, (SIZE_T**)&contextPointers->X27); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X28, (SIZE_T**)&contextPointers->X28); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X29, (SIZE_T**)&contextPointers->Fp); #elif defined(TARGET_LOONGARCH64) - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R1, &contextPointers->Ra); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R2, &contextPointers->Tp); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R22, &contextPointers->Fp); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R23, &contextPointers->S0); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R24, &contextPointers->S1); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R25, &contextPointers->S2); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R26, &contextPointers->S3); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R27, &contextPointers->S4); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R28, &contextPointers->S5); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R29, &contextPointers->S6); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R30, &contextPointers->S7); - GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R31, &contextPointers->S8); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R1, (SIZE_T **)&contextPointers->Ra); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R2, (SIZE_T **)&contextPointers->Tp); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R22, (SIZE_T **)&contextPointers->Fp); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R23, (SIZE_T **)&contextPointers->S0); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R24, (SIZE_T **)&contextPointers->S1); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R25, (SIZE_T **)&contextPointers->S2); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R26, (SIZE_T **)&contextPointers->S3); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R27, (SIZE_T **)&contextPointers->S4); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R28, (SIZE_T **)&contextPointers->S5); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R29, (SIZE_T **)&contextPointers->S6); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R30, (SIZE_T **)&contextPointers->S7); + GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R31, (SIZE_T **)&contextPointers->S8); #elif defined(TARGET_S390X) - GetContextPointer(cursor, unwContext, UNW_S390X_R6, &contextPointers->R6); - GetContextPointer(cursor, unwContext, UNW_S390X_R7, &contextPointers->R7); - GetContextPointer(cursor, unwContext, UNW_S390X_R8, &contextPointers->R8); - GetContextPointer(cursor, unwContext, UNW_S390X_R9, &contextPointers->R9); - GetContextPointer(cursor, unwContext, UNW_S390X_R10, &contextPointers->R10); - GetContextPointer(cursor, unwContext, UNW_S390X_R11, &contextPointers->R11); - GetContextPointer(cursor, unwContext, UNW_S390X_R12, &contextPointers->R12); - GetContextPointer(cursor, unwContext, UNW_S390X_R13, &contextPointers->R13); - GetContextPointer(cursor, unwContext, UNW_S390X_R14, &contextPointers->R14); - GetContextPointer(cursor, unwContext, UNW_S390X_R15, &contextPointers->R15); + GetContextPointer(cursor, unwContext, UNW_S390X_R6, (SIZE_T **)&contextPointers->R6); + GetContextPointer(cursor, unwContext, UNW_S390X_R7, (SIZE_T **)&contextPointers->R7); + GetContextPointer(cursor, unwContext, UNW_S390X_R8, (SIZE_T **)&contextPointers->R8); + GetContextPointer(cursor, unwContext, UNW_S390X_R9, (SIZE_T **)&contextPointers->R9); + GetContextPointer(cursor, unwContext, UNW_S390X_R10, (SIZE_T **)&contextPointers->R10); + GetContextPointer(cursor, unwContext, UNW_S390X_R11, (SIZE_T **)&contextPointers->R11); + GetContextPointer(cursor, unwContext, UNW_S390X_R12, (SIZE_T **)&contextPointers->R12); + GetContextPointer(cursor, unwContext, UNW_S390X_R13, (SIZE_T **)&contextPointers->R13); + GetContextPointer(cursor, unwContext, UNW_S390X_R14, (SIZE_T **)&contextPointers->R14); + GetContextPointer(cursor, unwContext, UNW_S390X_R15, (SIZE_T **)&contextPointers->R15); #elif defined(TARGET_POWERPC64) - GetContextPointer(cursor, unwContext, UNW_PPC64_R14, &contextPointers->R14); - GetContextPointer(cursor, unwContext, UNW_PPC64_R15, &contextPointers->R15); - GetContextPointer(cursor, unwContext, UNW_PPC64_R16, &contextPointers->R16); - GetContextPointer(cursor, unwContext, UNW_PPC64_R17, &contextPointers->R17); - GetContextPointer(cursor, unwContext, UNW_PPC64_R18, &contextPointers->R18); - GetContextPointer(cursor, unwContext, UNW_PPC64_R19, &contextPointers->R19); - GetContextPointer(cursor, unwContext, UNW_PPC64_R20, &contextPointers->R20); - GetContextPointer(cursor, unwContext, UNW_PPC64_R21, &contextPointers->R21); - GetContextPointer(cursor, unwContext, UNW_PPC64_R22, &contextPointers->R22); - GetContextPointer(cursor, unwContext, UNW_PPC64_R23, &contextPointers->R23); - GetContextPointer(cursor, unwContext, UNW_PPC64_R24, &contextPointers->R24); - GetContextPointer(cursor, unwContext, UNW_PPC64_R25, &contextPointers->R25); - GetContextPointer(cursor, unwContext, UNW_PPC64_R26, &contextPointers->R26); - GetContextPointer(cursor, unwContext, UNW_PPC64_R27, &contextPointers->R27); - GetContextPointer(cursor, unwContext, UNW_PPC64_R28, &contextPointers->R28); - GetContextPointer(cursor, unwContext, UNW_PPC64_R29, &contextPointers->R29); - GetContextPointer(cursor, unwContext, UNW_PPC64_R30, &contextPointers->R30); - GetContextPointer(cursor, unwContext, UNW_PPC64_R31, &contextPointers->R31); + GetContextPointer(cursor, unwContext, UNW_PPC64_R14, (SIZE_T **)&contextPointers->R14); + GetContextPointer(cursor, unwContext, UNW_PPC64_R15, (SIZE_T **)&contextPointers->R15); + GetContextPointer(cursor, unwContext, UNW_PPC64_R16, (SIZE_T **)&contextPointers->R16); + GetContextPointer(cursor, unwContext, UNW_PPC64_R17, (SIZE_T **)&contextPointers->R17); + GetContextPointer(cursor, unwContext, UNW_PPC64_R18, (SIZE_T **)&contextPointers->R18); + GetContextPointer(cursor, unwContext, UNW_PPC64_R19, (SIZE_T **)&contextPointers->R19); + GetContextPointer(cursor, unwContext, UNW_PPC64_R20, (SIZE_T **)&contextPointers->R20); + GetContextPointer(cursor, unwContext, UNW_PPC64_R21, (SIZE_T **)&contextPointers->R21); + GetContextPointer(cursor, unwContext, UNW_PPC64_R22, (SIZE_T **)&contextPointers->R22); + GetContextPointer(cursor, unwContext, UNW_PPC64_R23, (SIZE_T **)&contextPointers->R23); + GetContextPointer(cursor, unwContext, UNW_PPC64_R24, (SIZE_T **)&contextPointers->R24); + GetContextPointer(cursor, unwContext, UNW_PPC64_R25, (SIZE_T **)&contextPointers->R25); + GetContextPointer(cursor, unwContext, UNW_PPC64_R26, (SIZE_T **)&contextPointers->R26); + GetContextPointer(cursor, unwContext, UNW_PPC64_R27, (SIZE_T **)&contextPointers->R27); + GetContextPointer(cursor, unwContext, UNW_PPC64_R28, (SIZE_T **)&contextPointers->R28); + GetContextPointer(cursor, unwContext, UNW_PPC64_R29, (SIZE_T **)&contextPointers->R29); + GetContextPointer(cursor, unwContext, UNW_PPC64_R30, (SIZE_T **)&contextPointers->R30); + GetContextPointer(cursor, unwContext, UNW_PPC64_R31, (SIZE_T **)&contextPointers->R31); #else #error unsupported architecture #endif diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index f718be6af54c27..2987ff705a25fd 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -457,12 +457,12 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) { #if (defined(HOST_UNIX) && defined(HOST_AMD64)) || (defined(HOST_WINDOWS) && defined(TARGET_AMD64)) - GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, &contextPointers->Rbp); - GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, &contextPointers->Rbx); - GetContextPointer(cursor, unwContext, UNW_X86_64_R12, &contextPointers->R12); - GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13); - GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14); - GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15); + GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, (SIZE_T **)&contextPointers->Rbp); + GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, (SIZE_T **)&contextPointers->Rbx); + GetContextPointer(cursor, unwContext, UNW_X86_64_R12, (SIZE_T **)&contextPointers->R12); + GetContextPointer(cursor, unwContext, UNW_X86_64_R13, (SIZE_T **)&contextPointers->R13); + GetContextPointer(cursor, unwContext, UNW_X86_64_R14, (SIZE_T **)&contextPointers->R14); + GetContextPointer(cursor, unwContext, UNW_X86_64_R15, (SIZE_T **)&contextPointers->R15); #elif (defined(HOST_UNIX) && defined(HOST_X86)) || (defined(HOST_WINDOWS) && defined(TARGET_X86)) GetContextPointer(cursor, unwContext, UNW_X86_EBX, &contextPointers->Ebx); GetContextPointer(cursor, unwContext, UNW_X86_EBP, &contextPointers->Ebp); @@ -486,36 +486,36 @@ void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOL GetContextPointer(cursor, unwContext, UNW_ARM_D14, (SIZE_T **)&contextPointers->D14); GetContextPointer(cursor, unwContext, UNW_ARM_D15, (SIZE_T **)&contextPointers->D15); #elif (defined(HOST_UNIX) && defined(HOST_ARM64)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM64)) - GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, &contextPointers->X19); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, &contextPointers->X20); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, &contextPointers->X21); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X22, &contextPointers->X22); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X23, &contextPointers->X23); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X24, &contextPointers->X24); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X25, &contextPointers->X25); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X26, &contextPointers->X26); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X27, &contextPointers->X27); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X28, &contextPointers->X28); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X29, &contextPointers->Fp); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V8, &contextPointers->D8); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V9, &contextPointers->D9); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V10, &contextPointers->D10); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V11, &contextPointers->D11); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V12, &contextPointers->D12); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V13, &contextPointers->D13); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V14, &contextPointers->D14); - GetContextPointer(cursor, unwContext, UNW_AARCH64_V15, &contextPointers->D15); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, (SIZE_T**)&contextPointers->X19); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, (SIZE_T**)&contextPointers->X20); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, (SIZE_T**)&contextPointers->X21); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X22, (SIZE_T**)&contextPointers->X22); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X23, (SIZE_T**)&contextPointers->X23); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X24, (SIZE_T**)&contextPointers->X24); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X25, (SIZE_T**)&contextPointers->X25); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X26, (SIZE_T**)&contextPointers->X26); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X27, (SIZE_T**)&contextPointers->X27); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X28, (SIZE_T**)&contextPointers->X28); + GetContextPointer(cursor, unwContext, UNW_AARCH64_X29, (SIZE_T**)&contextPointers->Fp); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V8, (SIZE_T**)&contextPointers->D8); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V9, (SIZE_T**)&contextPointers->D9); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V10, (SIZE_T**)&contextPointers->D10); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V11, (SIZE_T**)&contextPointers->D11); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V12, (SIZE_T**)&contextPointers->D12); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V13, (SIZE_T**)&contextPointers->D13); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V14, (SIZE_T**)&contextPointers->D14); + GetContextPointer(cursor, unwContext, UNW_AARCH64_V15, (SIZE_T**)&contextPointers->D15); #elif (defined(HOST_UNIX) && defined(HOST_S390X)) - GetContextPointer(cursor, unwContext, UNW_S390X_R6, &contextPointers->R6); - GetContextPointer(cursor, unwContext, UNW_S390X_R7, &contextPointers->R7); - GetContextPointer(cursor, unwContext, UNW_S390X_R8, &contextPointers->R8); - GetContextPointer(cursor, unwContext, UNW_S390X_R9, &contextPointers->R9); - GetContextPointer(cursor, unwContext, UNW_S390X_R10, &contextPointers->R10); - GetContextPointer(cursor, unwContext, UNW_S390X_R11, &contextPointers->R11); - GetContextPointer(cursor, unwContext, UNW_S390X_R12, &contextPointers->R12); - GetContextPointer(cursor, unwContext, UNW_S390X_R13, &contextPointers->R13); - GetContextPointer(cursor, unwContext, UNW_S390X_R14, &contextPointers->R14); - GetContextPointer(cursor, unwContext, UNW_S390X_R15, &contextPointers->R15); + GetContextPointer(cursor, unwContext, UNW_S390X_R6, (SIZE_T **)&contextPointers->R6); + GetContextPointer(cursor, unwContext, UNW_S390X_R7, (SIZE_T **)&contextPointers->R7); + GetContextPointer(cursor, unwContext, UNW_S390X_R8, (SIZE_T **)&contextPointers->R8); + GetContextPointer(cursor, unwContext, UNW_S390X_R9, (SIZE_T **)&contextPointers->R9); + GetContextPointer(cursor, unwContext, UNW_S390X_R10, (SIZE_T **)&contextPointers->R10); + GetContextPointer(cursor, unwContext, UNW_S390X_R11, (SIZE_T **)&contextPointers->R11); + GetContextPointer(cursor, unwContext, UNW_S390X_R12, (SIZE_T **)&contextPointers->R12); + GetContextPointer(cursor, unwContext, UNW_S390X_R13, (SIZE_T **)&contextPointers->R13); + GetContextPointer(cursor, unwContext, UNW_S390X_R14, (SIZE_T **)&contextPointers->R14); + GetContextPointer(cursor, unwContext, UNW_S390X_R15, (SIZE_T **)&contextPointers->R15); #elif (defined(HOST_UNIX) && defined(HOST_LOONGARCH64)) GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R1, &contextPointers->Ra); GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R2, &contextPointers->Tp); @@ -530,24 +530,24 @@ void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOL GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R30, &contextPointers->S7); GetContextPointer(cursor, unwContext, UNW_LOONGARCH64_R31, &contextPointers->S8); #elif (defined(HOST_UNIX) && defined(HOST_POWERPC64)) - GetContextPointer(cursor, unwContext, UNW_PPC64_R14, &contextPointers->R14); - GetContextPointer(cursor, unwContext, UNW_PPC64_R15, &contextPointers->R15); - GetContextPointer(cursor, unwContext, UNW_PPC64_R16, &contextPointers->R16); - GetContextPointer(cursor, unwContext, UNW_PPC64_R17, &contextPointers->R17); - GetContextPointer(cursor, unwContext, UNW_PPC64_R18, &contextPointers->R18); - GetContextPointer(cursor, unwContext, UNW_PPC64_R19, &contextPointers->R19); - GetContextPointer(cursor, unwContext, UNW_PPC64_R20, &contextPointers->R20); - GetContextPointer(cursor, unwContext, UNW_PPC64_R21, &contextPointers->R21); - GetContextPointer(cursor, unwContext, UNW_PPC64_R22, &contextPointers->R22); - GetContextPointer(cursor, unwContext, UNW_PPC64_R23, &contextPointers->R23); - GetContextPointer(cursor, unwContext, UNW_PPC64_R24, &contextPointers->R24); - GetContextPointer(cursor, unwContext, UNW_PPC64_R25, &contextPointers->R25); - GetContextPointer(cursor, unwContext, UNW_PPC64_R26, &contextPointers->R26); - GetContextPointer(cursor, unwContext, UNW_PPC64_R27, &contextPointers->R27); - GetContextPointer(cursor, unwContext, UNW_PPC64_R28, &contextPointers->R28); - GetContextPointer(cursor, unwContext, UNW_PPC64_R29, &contextPointers->R29); - GetContextPointer(cursor, unwContext, UNW_PPC64_R30, &contextPointers->R30); - GetContextPointer(cursor, unwContext, UNW_PPC64_R31, &contextPointers->R31); + GetContextPointer(cursor, unwContext, UNW_PPC64_R14, (SIZE_T **)&contextPointers->R14); + GetContextPointer(cursor, unwContext, UNW_PPC64_R15, (SIZE_T **)&contextPointers->R15); + GetContextPointer(cursor, unwContext, UNW_PPC64_R16, (SIZE_T **)&contextPointers->R16); + GetContextPointer(cursor, unwContext, UNW_PPC64_R17, (SIZE_T **)&contextPointers->R17); + GetContextPointer(cursor, unwContext, UNW_PPC64_R18, (SIZE_T **)&contextPointers->R18); + GetContextPointer(cursor, unwContext, UNW_PPC64_R19, (SIZE_T **)&contextPointers->R19); + GetContextPointer(cursor, unwContext, UNW_PPC64_R20, (SIZE_T **)&contextPointers->R20); + GetContextPointer(cursor, unwContext, UNW_PPC64_R21, (SIZE_T **)&contextPointers->R21); + GetContextPointer(cursor, unwContext, UNW_PPC64_R22, (SIZE_T **)&contextPointers->R22); + GetContextPointer(cursor, unwContext, UNW_PPC64_R23, (SIZE_T **)&contextPointers->R23); + GetContextPointer(cursor, unwContext, UNW_PPC64_R24, (SIZE_T **)&contextPointers->R24); + GetContextPointer(cursor, unwContext, UNW_PPC64_R25, (SIZE_T **)&contextPointers->R25); + GetContextPointer(cursor, unwContext, UNW_PPC64_R26, (SIZE_T **)&contextPointers->R26); + GetContextPointer(cursor, unwContext, UNW_PPC64_R27, (SIZE_T **)&contextPointers->R27); + GetContextPointer(cursor, unwContext, UNW_PPC64_R28, (SIZE_T **)&contextPointers->R28); + GetContextPointer(cursor, unwContext, UNW_PPC64_R29, (SIZE_T **)&contextPointers->R29); + GetContextPointer(cursor, unwContext, UNW_PPC64_R30, (SIZE_T **)&contextPointers->R30); + GetContextPointer(cursor, unwContext, UNW_PPC64_R31, (SIZE_T **)&contextPointers->R31); #else #error unsupported architecture #endif diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index dc39af8f4d41aa..b3b69683b0cc04 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -652,7 +652,7 @@ typedef enum _TimeConversionConstants } bool -ReadMemoryValueFromFile(const char* filename, uint64_t* val); +PAL_ReadMemoryValueFromFile(const char* filename, uint64_t* val); #ifdef __APPLE__ bool diff --git a/src/coreclr/pal/src/init/pal.cpp b/src/coreclr/pal/src/init/pal.cpp index 72c0ffb9fa6e8c..bddda8ceb023bd 100644 --- a/src/coreclr/pal/src/init/pal.cpp +++ b/src/coreclr/pal/src/init/pal.cpp @@ -673,13 +673,6 @@ Initialize( goto CLEANUP15; } - if (FALSE == NUMASupportInitialize()) - { - ERROR("Unable to initialize NUMA support\n"); - palError = ERROR_PALINIT_NUMA; - goto CLEANUP15; - } - TRACE("First-time PAL initialization complete.\n"); init_count++; diff --git a/src/coreclr/pal/src/misc/cgroup.cpp b/src/coreclr/pal/src/misc/cgroup.cpp index 6a100d9389c5f1..0eae4e8db451d6 100644 --- a/src/coreclr/pal/src/misc/cgroup.cpp +++ b/src/coreclr/pal/src/misc/cgroup.cpp @@ -470,7 +470,7 @@ class CGroup static bool ReadMemoryValueFromFile(const char* filename, uint64_t* val) { - return ::ReadMemoryValueFromFile(filename, val); + return ::PAL_ReadMemoryValueFromFile(filename, val); } static bool GetCGroup1CpuLimit(UINT *val) diff --git a/src/coreclr/pal/src/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index d9ddb02f521666..f9731f474586ed 100644 --- a/src/coreclr/pal/src/misc/sysinfo.cpp +++ b/src/coreclr/pal/src/misc/sysinfo.cpp @@ -438,7 +438,7 @@ GlobalMemoryStatusEx( { // Ensure that we don't try to read the /proc/meminfo in successive calls to the GlobalMemoryStatusEx // if we have failed to access the file or the file didn't contain the MemAvailable value. - tryReadMemInfo = ReadMemAvailable(&lpBuffer->ullAvailPhys); + tryReadMemInfo = ReadMemAvailable((uint64_t*)&lpBuffer->ullAvailPhys); } if (!tryReadMemInfo) @@ -504,7 +504,7 @@ PAL_HasGetCurrentProcessorNumber() } bool -ReadMemoryValueFromFile(const char* filename, uint64_t* val) +PAL_ReadMemoryValueFromFile(const char* filename, uint64_t* val) { bool result = false; char *line = nullptr; @@ -585,11 +585,11 @@ PAL_GetLogicalProcessorCacheSizeFromOS() { path_to_size_file[index] = (char)(48 + i); - if (ReadMemoryValueFromFile(path_to_size_file, &size)) + if (PAL_ReadMemoryValueFromFile(path_to_size_file, &size)) { path_to_level_file[index] = (char)(48 + i); - if (ReadMemoryValueFromFile(path_to_level_file, &level)) + if (PAL_ReadMemoryValueFromFile(path_to_level_file, &level)) { UPDATE_CACHE_SIZE_AND_LEVEL(size, level) } diff --git a/src/coreclr/pal/src/numa/numa.cpp b/src/coreclr/pal/src/numa/numa.cpp deleted file mode 100644 index 676775ca637355..00000000000000 --- a/src/coreclr/pal/src/numa/numa.cpp +++ /dev/null @@ -1,292 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - numa.cpp - -Abstract: - - Implementation of NUMA related APIs - ---*/ - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(NUMA); - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/numa.h" -#include "pal/corunix.hpp" -#include "pal/thread.hpp" - -#include -#ifdef __FreeBSD__ -#include -#else -#include -#endif - -#include - -#include "numashim.h" - -using namespace CorUnix; - -// The highest NUMA node available -int g_highestNumaNode = 0; -// Is numa available -bool g_numaAvailable = false; - -void* numaHandle = nullptr; - -#if HAVE_NUMA_H -#include -#include -#include - -#define PER_FUNCTION_BLOCK(fn) decltype(fn)* fn##_ptr; -FOR_ALL_NUMA_FUNCTIONS -#undef PER_FUNCTION_BLOCK - -#if defined(__linux__) -static bool ShouldOpenLibNuma() -{ - // This is a simple heuristic to determine if libnuma.so should be opened. There's - // no point in linking and resolving everything in this library if we're running on - // a system that's not NUMA-capable. - int fd = open("/sys/devices/system/node/possible", O_RDONLY | O_CLOEXEC); - - if (fd == -1) - { - // sysfs might not be mounted, not available, or the interface might have - // changed. Return `true' here so NUMASupportInitialize() can try initializing - // NUMA support with libnuma. - return true; - } - - while (true) - { - char buffer[32]; - ssize_t bytesRead = read(fd, buffer, 32); - - if (bytesRead == -1 && errno == EINTR) - { - continue; - } - - close(fd); - - // If an unknown error happened (bytesRead < 0), or the file was empty - // (bytesRead = 0), let libnuma handle this. Otherwise, if there's just - // one NUMA node, don't bother linking in libnuma. - return (bytesRead <= 0) ? true : strncmp(buffer, "0\n", bytesRead) != 0; - } -} -#else -static bool ShouldOpenLibNuma() -{ - return true; -} -#endif // __linux__ - -#endif // HAVE_NUMA_H - -/*++ -Function: - NUMASupportInitialize - -Initialize data structures for getting and setting thread affinities to processors and -querying NUMA related processor information. -On systems with no NUMA support, it behaves as if there was a single NUMA node with -a single group of processors. ---*/ -BOOL -NUMASupportInitialize() -{ -#if HAVE_NUMA_H - if (!ShouldOpenLibNuma()) - { - g_numaAvailable = false; - g_highestNumaNode = 0; - return TRUE; - } - - numaHandle = dlopen("libnuma.so.1", RTLD_LAZY); - if (numaHandle == 0) - { - numaHandle = dlopen("libnuma.so.1.0.0", RTLD_LAZY); - if (numaHandle == 0) - { - numaHandle = dlopen("libnuma.so", RTLD_LAZY); - } - } - if (numaHandle != 0) - { -#define PER_FUNCTION_BLOCK(fn) \ - fn##_ptr = (decltype(fn)*)dlsym(numaHandle, #fn); \ - if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol " #fn " from libnuma\n"); abort(); } -FOR_ALL_NUMA_FUNCTIONS -#undef PER_FUNCTION_BLOCK - - if (numa_available() == -1) - { - dlclose(numaHandle); - } - else - { - g_numaAvailable = true; - g_highestNumaNode = numa_max_node(); - } - } -#endif // HAVE_NUMA_H - if (!g_numaAvailable) - { - // No NUMA - g_highestNumaNode = 0; - } - - return TRUE; -} - -/*++ -Function: - NUMASupportCleanup - -Cleanup of the NUMA support data structures ---*/ -VOID -NUMASupportCleanup() -{ -#if HAVE_NUMA_H - if (g_numaAvailable) - { - dlclose(numaHandle); - } -#endif // HAVE_NUMA_H -} - -/*++ -Function: - GetNumaHighestNodeNumber - -See MSDN doc. ---*/ -BOOL -PALAPI -GetNumaHighestNodeNumber( - OUT PULONG HighestNodeNumber -) -{ - PERF_ENTRY(GetNumaHighestNodeNumber); - ENTRY("GetNumaHighestNodeNumber(HighestNodeNumber=%p)\n", HighestNodeNumber); - *HighestNodeNumber = (ULONG)g_highestNumaNode; - - BOOL success = TRUE; - - LOGEXIT("GetNumaHighestNodeNumber returns BOOL %d\n", success); - PERF_EXIT(GetNumaHighestNodeNumber); - - return success; -} - -/*++ -Function: - PAL_GetNumaProcessorNode - -Abstract - Get NUMA node of a processor - -Parameters: - procNo - number of the processor to get the NUMA node for - node - the resulting NUMA node - -Return value: - TRUE if the function was able to get the NUMA node, FALSE if it has failed. ---*/ -BOOL -PALAPI -PAL_GetNumaProcessorNode(WORD procNo, WORD* node) -{ -#if HAVE_NUMA_H - if (g_numaAvailable) - { - int result = numa_node_of_cpu(procNo); - if (result >= 0) - { - *node = (WORD)result; - return TRUE; - } - } -#endif // HAVE_NUMA_H - - return FALSE; -} - -/*++ -Function: - VirtualAllocExNuma - -See MSDN doc. ---*/ -LPVOID -PALAPI -VirtualAllocExNuma( - IN HANDLE hProcess, - IN OPTIONAL LPVOID lpAddress, - IN SIZE_T dwSize, - IN DWORD flAllocationType, - IN DWORD flProtect, - IN DWORD nndPreferred -) -{ - PERF_ENTRY(VirtualAllocExNuma); - ENTRY("VirtualAllocExNuma(hProcess=%p, lpAddress=%p, dwSize=%u, flAllocationType=%#x, flProtect=%#x, nndPreferred=%d\n", - hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred); - - LPVOID result = NULL; - - if (hProcess == GetCurrentProcess()) - { - if ((int)nndPreferred <= g_highestNumaNode) - { - result = VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); -#if HAVE_NUMA_H - if (result != NULL && g_numaAvailable) - { - int usedNodeMaskBits = g_highestNumaNode + 1; - int nodeMaskLength = (usedNodeMaskBits + sizeof(unsigned long) - 1) / sizeof(unsigned long); - unsigned long nodeMask[nodeMaskLength]; - memset(nodeMask, 0, sizeof(nodeMask)); - - int index = nndPreferred / sizeof(unsigned long); - nodeMask[index] = ((unsigned long)1) << (nndPreferred & (sizeof(unsigned long) - 1)); - - int st = mbind(result, dwSize, MPOL_PREFERRED, nodeMask, usedNodeMaskBits, 0); - - _ASSERTE(st == 0); - // If the mbind fails, we still return the allocated memory since the nndPreferred is just a hint - } -#endif // HAVE_NUMA_H - } - else - { - // The specified node number is larger than the maximum available one - SetLastError(ERROR_INVALID_PARAMETER); - } - } - else - { - // PAL supports allocating from the current process virtual space only - SetLastError(ERROR_INVALID_PARAMETER); - } - - LOGEXIT("VirtualAllocExNuma returns %p\n", result); - PERF_EXIT(VirtualAllocExNuma); - - return result; -} diff --git a/src/coreclr/pal/src/numa/numashim.h b/src/coreclr/pal/src/numa/numashim.h deleted file mode 100644 index c6594b5d06325b..00000000000000 --- a/src/coreclr/pal/src/numa/numashim.h +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// Enable calling numa functions through shims to make it a soft -// runtime dependency. - -#ifndef __NUMASHIM_H__ -#define __NUMASHIM_H__ - -#if HAVE_NUMA_H - -#include -#include - -// List of all functions from the numa library that are used -#define FOR_ALL_NUMA_FUNCTIONS \ - PER_FUNCTION_BLOCK(numa_available) \ - PER_FUNCTION_BLOCK(mbind) \ - PER_FUNCTION_BLOCK(numa_max_node) \ - PER_FUNCTION_BLOCK(numa_node_of_cpu) - -// Declare pointers to all the used numa functions -#define PER_FUNCTION_BLOCK(fn) extern decltype(fn)* fn##_ptr; -FOR_ALL_NUMA_FUNCTIONS -#undef PER_FUNCTION_BLOCK - -// Redefine all calls to numa functions as calls through pointers that are set -// to the functions of libnuma in the initialization. -#define numa_available() numa_available_ptr() -#define mbind(...) mbind_ptr(__VA_ARGS__) -#define numa_max_node() numa_max_node_ptr() -#define numa_node_of_cpu(...) numa_node_of_cpu_ptr(__VA_ARGS__) - -#endif // HAVE_NUMA_H - -#endif // __NUMASHIM_H__ diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp index f66f05cf6165f1..d5bee6754e1f7f 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp @@ -4,6 +4,7 @@ #include "strike.h" #include "util.h" #include +#include #include #include @@ -15,14 +16,9 @@ class MapViewHolder void* whatever; }; -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -#ifdef HOST_WINDOWS -typedef long long int64_t; -#else +#ifndef HOST_WINDOWS #define FEATURE_PAL #endif -typedef size_t uint64_t; #endif // STRESS_LOG #define STRESS_LOG_READONLY #include "../../../inc/stresslog.h" diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp index 18d4564c7a33d2..06ff844a2d57e0 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #ifndef INFINITY @@ -32,13 +33,6 @@ class MapViewHolder void* whatever; }; -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -#ifdef HOST_WINDOWS -typedef long long int64_t; -#endif -typedef size_t uint64_t; - bool IsInCantAllocStressLogRegion() { return true; diff --git a/src/coreclr/tools/StressLogAnalyzer/strike.h b/src/coreclr/tools/StressLogAnalyzer/strike.h index 5b59ac738f3020..22c6d31a5d2351 100644 --- a/src/coreclr/tools/StressLogAnalyzer/strike.h +++ b/src/coreclr/tools/StressLogAnalyzer/strike.h @@ -2,11 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. #include +#include #include -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -typedef size_t uint64_t; typedef void* TADDR; extern BOOL g_bDacBroken; diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp index 623ef923516ce5..f23b3f3283abd5 100644 --- a/src/coreclr/utilcode/util.cpp +++ b/src/coreclr/utilcode/util.cpp @@ -513,6 +513,8 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, return pResult; } +#ifdef HOST_WINDOWS + //****************************************************************************** // NumaNodeInfo //****************************************************************************** @@ -524,7 +526,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, return ::VirtualAllocExNuma(hProc, lpAddr, dwSize, allocType, prot, node); } -#ifdef HOST_WINDOWS /*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no) { return ::GetNumaProcessorNodeEx(proc_no, node_no); @@ -566,6 +567,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, #endif // HOST_WINDOWS #endif +#ifdef HOST_WINDOWS /*static*/ BOOL NumaNodeInfo::m_enableGCNumaAware = FALSE; /*static*/ uint16_t NumaNodeInfo::m_nNodes = 0; /*static*/ BOOL NumaNodeInfo::InitNumaNodeInfoAPI() @@ -599,7 +601,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, m_enableGCNumaAware = InitNumaNodeInfoAPI(); } -#ifdef HOST_WINDOWS //****************************************************************************** // CPUGroupInfo diff --git a/src/coreclr/vm/CMakeLists.txt b/src/coreclr/vm/CMakeLists.txt index b5b9afb48b40e5..f1fe1a7aced372 100644 --- a/src/coreclr/vm/CMakeLists.txt +++ b/src/coreclr/vm/CMakeLists.txt @@ -329,7 +329,6 @@ set(VM_SOURCES_WKS gccover.cpp gcenv.ee.static.cpp gcenv.ee.common.cpp - gcenv.os.cpp gchelpers.cpp genanalysis.cpp genmeth.cpp @@ -511,6 +510,13 @@ if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32) ) endif (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32) +if (CLR_CMAKE_TARGET_WIN32) + set ( GC_SOURCES_WKS + ${GC_SOURCES_WKS} + gcenv.os.cpp + ) +endif (CLR_CMAKE_TARGET_WIN32) + set(GC_HEADERS_WKS ${GC_HEADERS_DAC_AND_WKS_COMMON} ../gc/gceventstatus.h diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index 4094b4ff28db83..4b5fe275de80f2 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -627,12 +627,13 @@ void EEStartupHelper() #ifdef HOST_WINDOWS InitializeCrashDump(); -#endif // HOST_WINDOWS + // Initialize Numa and CPU group information // Need to do this as early as possible. Used by creating object handle // table inside Ref_Initialization() before GC is initialized. NumaNodeInfo::InitNumaNodeInfo(); +#endif // HOST_WINDOWS #ifndef TARGET_UNIX CPUGroupInfo::EnsureInitialized(); #endif // !TARGET_UNIX diff --git a/src/coreclr/vm/gcenv.os.cpp b/src/coreclr/vm/gcenv.os.cpp index 18413baea25092..a3b69e795ffe75 100644 --- a/src/coreclr/vm/gcenv.os.cpp +++ b/src/coreclr/vm/gcenv.os.cpp @@ -117,7 +117,7 @@ bool GCToOSInterface::Initialize() g_pageSizeUnixInl = GetOsPageSize(); uint32_t currentProcessCpuCount = PAL_GetLogicalCpuCountFromOS(); - if (PAL_GetCurrentThreadAffinitySet(AffinitySet::BitsetDataSize, g_processAffinitySet.GetBitsetData())) + if (PAL_GetCurrentThreadAffinitySet(AffinitySet::BitsetDataSize, (UINT_PTR *)g_processAffinitySet.GetBitsetData())) { _ASSERTE(currentProcessCpuCount == g_processAffinitySet.Count()); } diff --git a/src/tests/profiler/native/getappdomainstaticaddress/getappdomainstaticaddress.cpp b/src/tests/profiler/native/getappdomainstaticaddress/getappdomainstaticaddress.cpp index 6c16e676f54165..c7c00addd194a2 100644 --- a/src/tests/profiler/native/getappdomainstaticaddress/getappdomainstaticaddress.cpp +++ b/src/tests/profiler/native/getappdomainstaticaddress/getappdomainstaticaddress.cpp @@ -194,7 +194,7 @@ HRESULT GetAppDomainStaticAddress::ModuleUnloadStarted(ModuleID moduleId) { if (DEBUG_OUT) { - printf("ClassID 0x%" PRIxPTR " being removed due to parent module unloading\n", classId); + printf("ClassID 0x%" PRIxPTR " being removed due to parent module unloading\n", (uintptr_t)classId); } it = classADMap.erase(it); @@ -211,7 +211,7 @@ HRESULT GetAppDomainStaticAddress::ModuleUnloadStarted(ModuleID moduleId) if (DEBUG_OUT) { - printf("Checking generic argument 0x%" PRIxPTR " of class 0x%" PRIxPTR "\n", typeArg, classId); + printf("Checking generic argument 0x%" PRIxPTR " of class 0x%" PRIxPTR "\n", (uintptr_t)typeArg, (uintptr_t)classId); } hr = pCorProfilerInfo->GetClassIDInfo(typeArg, &typeArgModId, NULL); @@ -285,7 +285,7 @@ HRESULT GetAppDomainStaticAddress::ClassLoadFinished(ClassID classId, HRESULT hr hr = pCorProfilerInfo->GetThreadAppDomain(threadId, &appDomainId); if (FAILED(hr)) { - printf("GetThreadAppDomain returned 0x%x for ThreadID 0x%" PRIxPTR "\n", hr, threadId); + printf("GetThreadAppDomain returned 0x%x for ThreadID 0x%" PRIxPTR "\n", hr, (uintptr_t)threadId); ++failures; return hr; } @@ -303,7 +303,7 @@ HRESULT GetAppDomainStaticAddress::ClassLoadFinished(ClassID classId, HRESULT hr NULL); if (FAILED(hr)) { - printf("GetClassIDInfo2 returned 0x%x for ClassID 0x%" PRIxPTR "\n", hr, classId); + printf("GetClassIDInfo2 returned 0x%x for ClassID 0x%" PRIxPTR "\n", hr, (uintptr_t)classId); ++failures; } @@ -386,7 +386,7 @@ HRESULT GetAppDomainStaticAddress::GarbageCollectionFinished() if (DEBUG_OUT) { - printf("Calling GetClassIDInfo2 on classId 0x%" PRIxPTR "\n", classId); + printf("Calling GetClassIDInfo2 on classId 0x%" PRIxPTR "\n", (uintptr_t)classId); fflush(stdout); } @@ -400,7 +400,7 @@ HRESULT GetAppDomainStaticAddress::GarbageCollectionFinished() NULL); if (FAILED(hr)) { - printf("GetClassIDInfo2 returned 0x%x for ClassID 0x%" PRIxPTR "\n", hr, classId); + printf("GetClassIDInfo2 returned 0x%x for ClassID 0x%" PRIxPTR "\n", hr, (uintptr_t)classId); ++failures; continue; } @@ -418,7 +418,7 @@ HRESULT GetAppDomainStaticAddress::GarbageCollectionFinished() } else if (FAILED(hr)) { - printf("GetModuleMetaData returned 0x%x for ModuleID 0x%" PRIxPTR "\n", hr, classModuleId); + printf("GetModuleMetaData returned 0x%x for ModuleID 0x%" PRIxPTR "\n", hr, (uintptr_t)classModuleId); ++failures; continue; } @@ -430,7 +430,7 @@ HRESULT GetAppDomainStaticAddress::GarbageCollectionFinished() if (DEBUG_OUT) { - printf("Calling GetClassIDInfo2 (again?) on classId 0x%" PRIxPTR "\n", classId); + printf("Calling GetClassIDInfo2 (again?) on classId 0x%" PRIxPTR "\n", (uintptr_t)classId); fflush(stdout); } @@ -513,7 +513,7 @@ HRESULT GetAppDomainStaticAddress::GarbageCollectionFinished() if (DEBUG_OUT) { - printf("Calling GetAppDomainStaticAddress on classId=0x%" PRIxPTR "\n", classId); + printf("Calling GetAppDomainStaticAddress on classId=0x%" PRIxPTR "\n", (uintptr_t)classId); fflush(stdout); }