From b823cfd30a4113b9bda15cd0e3a31b29c913d053 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 14 Oct 2022 15:44:16 +0200 Subject: [PATCH 1/6] Modify __int64 definition in PAL to match the OS definition This change modifies the definition of __int64 and thus of many other types defined on the basis of it to match the OS definitions. This ensures that we can use these types in interfaces between code in coreclr and various PALs that are compiled against OS headers. The key issue was that we were defining __int64 for 64 bit OSes as long while Unix defines it as long long. The size of those types is the same on Unix, but they are different and result in different mangling of C++ names. --- .../debug/createdump/crashinfounix.cpp | 2 +- src/coreclr/debug/inc/dacdbistructures.inl | 2 - src/coreclr/inc/check.inl | 8 + src/coreclr/inc/clrtypes.h | 26 +++ src/coreclr/inc/daccess.h | 6 + src/coreclr/inc/regdisp.h | 2 +- src/coreclr/jit/compiler.hpp | 9 + src/coreclr/jit/gentree.h | 2 +- src/coreclr/jit/jit.h | 11 +- src/coreclr/jit/register.h | 4 +- src/coreclr/jit/utils.h | 1 + src/coreclr/pal/inc/pal.h | 6 + src/coreclr/pal/inc/pal_mstypes.h | 19 +- .../pal/src/exception/remote-unwind.cpp | 114 +++++------ src/coreclr/pal/src/exception/seh-unwind.cpp | 186 +++++++++--------- src/coreclr/pal/src/misc/sysinfo.cpp | 2 +- .../tools/StressLogAnalyzer/StressLogDump.cpp | 8 +- .../StressLogAnalyzer/StressLogPlugin.cpp | 8 +- src/coreclr/tools/StressLogAnalyzer/strike.h | 4 +- src/coreclr/vm/gcenv.os.cpp | 2 +- 20 files changed, 236 insertions(+), 186 deletions(-) diff --git a/src/coreclr/debug/createdump/crashinfounix.cpp b/src/coreclr/debug/createdump/crashinfounix.cpp index d7e93bdc7a2eae..f26f1c8867bb07 100644 --- a/src/coreclr/debug/createdump/crashinfounix.cpp +++ b/src/coreclr/debug/createdump/crashinfounix.cpp @@ -378,7 +378,7 @@ CrashInfo::VisitProgramHeader(uint64_t loadbias, uint64_t baseAddress, Phdr* phd uint64_t ehFrameStart; uint64_t ehFrameSize; - if (PAL_GetUnwindInfoSize(baseAddress, ehFrameHdrStart, ReadMemoryAdapter, &ehFrameStart, &ehFrameSize)) + if (PAL_GetUnwindInfoSize(baseAddress, ehFrameHdrStart, ReadMemoryAdapter, (ULONG64*)&ehFrameStart, (ULONG64*)&ehFrameSize)) { TRACE("VisitProgramHeader: ehFrameStart %016llx ehFrameSize %08llx\n", ehFrameStart, ehFrameSize); if (ehFrameStart != 0 && ehFrameSize != 0) 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/inc/check.inl b/src/coreclr/inc/check.inl index f234e988faf0d8..070278af8f9be6 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; } +#if defined(HOST_UNIX) && defined(HOST_64BIT) +inline CHECK CheckOverflow(const void *address, SIZE_T offset) +{ + CHECK((UINT64) address + offset >= (UINT64) address); + + CHECK_OK; +} +#endif // HOST_UNIX && HOST_BIT64 inline CHECK CheckUnderflow(UINT value1, UINT value2) { diff --git a/src/coreclr/inc/clrtypes.h b/src/coreclr/inc/clrtypes.h index 5e83573e7aa943..6ab68eb03581fc 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); } +#if defined(HOST_UNIX) && defined(HOST_64BIT) +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 // HOST_UNIX && HOST_BIT64 + 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); } +#if defined(HOST_UNIX) && defined(HOST_64BIT) +inline UINT AlignmentPad(SIZE_T value, UINT alignment) +{ + STATIC_CONTRACT_WRAPPER; + return (UINT) (AlignUp(value, alignment) - value); +} +#endif // HOST_UNIX && HOST_BIT64 + 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); } +#if defined(HOST_UNIX) && defined(HOST_64BIT) +inline UINT AlignmentTrim(SIZE_T value, UINT alignment) +{ + STATIC_CONTRACT_LEAF; + STATIC_CONTRACT_SUPPORTS_DAC; + return ((UINT)value)&(alignment-1); +} +#endif // HOST_UNIX && HOST_BIT64 + #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 dbead03655efd1..781f4bdbe8274a 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -233,6 +233,13 @@ inline unsigned genLog2(unsigned __int64 value) #endif } +#if defined(HOST_UNIX) && defined(HOST_64BIT) +inline unsigned genLog2(size_t value) +{ + return genLog2((unsigned __int64) value); +} +#endif // HOST_UNIX && HOST_BIT64 + /***************************************************************************** * * Return the lowest bit that is set in the given register mask. @@ -1536,7 +1543,9 @@ 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)); + 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 70abd0a98ebb19..e8894e6033703d 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -3287,7 +3287,7 @@ 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 8fcc451aa627c6..d4a4f2a2aa8237 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; @@ -630,9 +630,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 HOST_UNIX +inline size_t unsigned_abs(__int64 x) { return ((size_t)abs(x)); } +#endif HOST_UNIX #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 9dbce41679cc6b..0e129f1ed0340c 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -821,6 +821,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 ecc72fc9df6ad6..3947e569494330 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4323,6 +4323,12 @@ inline __int64 abs(__int64 _X) { return llabs(_X); } +#ifdef HOST_64BIT +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..568f293380a201 100644 --- a/src/coreclr/pal/inc/pal_mstypes.h +++ b/src/coreclr/pal/inc/pal_mstypes.h @@ -195,12 +195,7 @@ 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 -#define __int64 long -#else // HOST_64BIT #define __int64 long long -#endif // HOST_64BIT - #define __int32 int #define __int16 short int #define __int8 char // assumes char is signed @@ -543,8 +538,13 @@ 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 #ifndef SIZE_T_MAX #define SIZE_T_MAX ULONG_PTR_MAX @@ -562,6 +562,7 @@ typedef LONG_PTR SSIZE_T, *PSSIZE_T; #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; @@ -596,8 +597,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/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 e26a53b9935757..e94922cea04512 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -518,12 +518,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); @@ -547,101 +547,101 @@ 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); - 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(HOST_UNIX) && defined(HOST_RISCV64)) #error "TODO-RISCV64: review this" // https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d865a2964fe06bfc569ab00c74e152b582ed764/riscv-cc.adoc - GetContextPointer(cursor, unwContext, UNW_RISCV_X1, &contextPointers->Ra); - GetContextPointer(cursor, unwContext, UNW_RISCV_X4, &contextPointers->Tp); - GetContextPointer(cursor, unwContext, UNW_RISCV_X5, &contextPointers->T0); - GetContextPointer(cursor, unwContext, UNW_RISCV_X7, &contextPointers->T1); - GetContextPointer(cursor, unwContext, UNW_RISCV_X8, &contextPointers->S0); - GetContextPointer(cursor, unwContext, UNW_RISCV_X9, &contextPointers->S1); - GetContextPointer(cursor, unwContext, UNW_RISCV_X10, &contextPointers->A0); - GetContextPointer(cursor, unwContext, UNW_RISCV_X11, &contextPointers->A1); - GetContextPointer(cursor, unwContext, UNW_RISCV_X12, &contextPointers->A2); - GetContextPointer(cursor, unwContext, UNW_RISCV_X13, &contextPointers->A3); - GetContextPointer(cursor, unwContext, UNW_RISCV_X14, &contextPointers->A4); - GetContextPointer(cursor, unwContext, UNW_RISCV_X15, &contextPointers->A5); - GetContextPointer(cursor, unwContext, UNW_RISCV_X16, &contextPointers->A6); - GetContextPointer(cursor, unwContext, UNW_RISCV_X17, &contextPointers->A7); - GetContextPointer(cursor, unwContext, UNW_RISCV_X18, &contextPointers->S2); - GetContextPointer(cursor, unwContext, UNW_RISCV_X19, &contextPointers->S3); - GetContextPointer(cursor, unwContext, UNW_RISCV_X20, &contextPointers->S4); - GetContextPointer(cursor, unwContext, UNW_RISCV_X21, &contextPointers->S5); - GetContextPointer(cursor, unwContext, UNW_RISCV_X22, &contextPointers->S6); - GetContextPointer(cursor, unwContext, UNW_RISCV_X23, &contextPointers->S7); - GetContextPointer(cursor, unwContext, UNW_RISCV_X24, &contextPointers->S8); - GetContextPointer(cursor, unwContext, UNW_RISCV_X25, &contextPointers->S9); - GetContextPointer(cursor, unwContext, UNW_RISCV_X26, &contextPointers->S10); - GetContextPointer(cursor, unwContext, UNW_RISCV_X27, &contextPointers->S11); - GetContextPointer(cursor, unwContext, UNW_RISCV_X28, &contextPointers->T3); - GetContextPointer(cursor, unwContext, UNW_RISCV_X29, &contextPointers->T4); - GetContextPointer(cursor, unwContext, UNW_RISCV_X30, &contextPointers->T5); - GetContextPointer(cursor, unwContext, UNW_RISCV_X31, &contextPointers->T6); + GetContextPointer(cursor, unwContext, UNW_RISCV_X1, (SIZE_T **)&contextPointers->Ra); + GetContextPointer(cursor, unwContext, UNW_RISCV_X4, (SIZE_T **)&contextPointers->Tp); + GetContextPointer(cursor, unwContext, UNW_RISCV_X5, (SIZE_T **)&contextPointers->T0); + GetContextPointer(cursor, unwContext, UNW_RISCV_X7, (SIZE_T **)&contextPointers->T1); + GetContextPointer(cursor, unwContext, UNW_RISCV_X8, (SIZE_T **)&contextPointers->S0); + GetContextPointer(cursor, unwContext, UNW_RISCV_X9, (SIZE_T **)&contextPointers->S1); + GetContextPointer(cursor, unwContext, UNW_RISCV_X10, (SIZE_T **)&contextPointers->A0); + GetContextPointer(cursor, unwContext, UNW_RISCV_X11, (SIZE_T **)&contextPointers->A1); + GetContextPointer(cursor, unwContext, UNW_RISCV_X12, (SIZE_T **)&contextPointers->A2); + GetContextPointer(cursor, unwContext, UNW_RISCV_X13, (SIZE_T **)&contextPointers->A3); + GetContextPointer(cursor, unwContext, UNW_RISCV_X14, (SIZE_T **)&contextPointers->A4); + GetContextPointer(cursor, unwContext, UNW_RISCV_X15, (SIZE_T **)&contextPointers->A5); + GetContextPointer(cursor, unwContext, UNW_RISCV_X16, (SIZE_T **)&contextPointers->A6); + GetContextPointer(cursor, unwContext, UNW_RISCV_X17, (SIZE_T **)&contextPointers->A7); + GetContextPointer(cursor, unwContext, UNW_RISCV_X18, (SIZE_T **)&contextPointers->S2); + GetContextPointer(cursor, unwContext, UNW_RISCV_X19, (SIZE_T **)&contextPointers->S3); + GetContextPointer(cursor, unwContext, UNW_RISCV_X20, (SIZE_T **)&contextPointers->S4); + GetContextPointer(cursor, unwContext, UNW_RISCV_X21, (SIZE_T **)&contextPointers->S5); + GetContextPointer(cursor, unwContext, UNW_RISCV_X22, (SIZE_T **)&contextPointers->S6); + GetContextPointer(cursor, unwContext, UNW_RISCV_X23, (SIZE_T **)&contextPointers->S7); + GetContextPointer(cursor, unwContext, UNW_RISCV_X24, (SIZE_T **)&contextPointers->S8); + GetContextPointer(cursor, unwContext, UNW_RISCV_X25, (SIZE_T **)&contextPointers->S9); + GetContextPointer(cursor, unwContext, UNW_RISCV_X26, (SIZE_T **)&contextPointers->S10); + GetContextPointer(cursor, unwContext, UNW_RISCV_X27, (SIZE_T **)&contextPointers->S11); + GetContextPointer(cursor, unwContext, UNW_RISCV_X28, (SIZE_T **)&contextPointers->T3); + GetContextPointer(cursor, unwContext, UNW_RISCV_X29, (SIZE_T **)&contextPointers->T4); + GetContextPointer(cursor, unwContext, UNW_RISCV_X30, (SIZE_T **)&contextPointers->T5); + GetContextPointer(cursor, unwContext, UNW_RISCV_X31, (SIZE_T **)&contextPointers->T6); #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/misc/sysinfo.cpp b/src/coreclr/pal/src/misc/sysinfo.cpp index d9ddb02f521666..102a012f76af31 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) 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 88ca8528ef9c2a..4a4141490e6be9 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/vm/gcenv.os.cpp b/src/coreclr/vm/gcenv.os.cpp index fe6dfceffc37fa..4f0868d4f6d692 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()); } From 92d27877093862ef5b7afef3f28c025f0f108638 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 14 Oct 2022 13:30:20 -0700 Subject: [PATCH 2/6] Fix coreclr tests build --- .../getappdomainstaticaddress.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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); } From 4bada8768849ff79aa6e7aa4244c07a4b066743d Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 14 Oct 2022 13:49:02 -0700 Subject: [PATCH 3/6] Fix comment on #endif in jit.h --- src/coreclr/jit/jit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/jit.h b/src/coreclr/jit/jit.h index d4a4f2a2aa8237..8d8eedd914bcf3 100644 --- a/src/coreclr/jit/jit.h +++ b/src/coreclr/jit/jit.h @@ -639,7 +639,7 @@ inline size_t unsigned_abs(__int64 x) { return ((size_t)abs(x)); } -#endif HOST_UNIX +#endif // HOST_UNIX #endif // TARGET_64BIT /*****************************************************************************/ From ddafbc2f525dd90fe407c96a971666e788bd2741 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 14 Oct 2022 15:01:00 -0700 Subject: [PATCH 4/6] Reflect PR feedback --- src/coreclr/debug/createdump/crashinfounix.cpp | 6 +++--- src/coreclr/pal/inc/pal_mstypes.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/coreclr/debug/createdump/crashinfounix.cpp b/src/coreclr/debug/createdump/crashinfounix.cpp index f26f1c8867bb07..77a5439629206d 100644 --- a/src/coreclr/debug/createdump/crashinfounix.cpp +++ b/src/coreclr/debug/createdump/crashinfounix.cpp @@ -376,9 +376,9 @@ 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; - if (PAL_GetUnwindInfoSize(baseAddress, ehFrameHdrStart, ReadMemoryAdapter, (ULONG64*)&ehFrameStart, (ULONG64*)&ehFrameSize)) + ULONG64 ehFrameStart; + ULONG64 ehFrameSize; + if (PAL_GetUnwindInfoSize(baseAddress, ehFrameHdrStart, ReadMemoryAdapter, &ehFrameStart, &ehFrameSize)) { TRACE("VisitProgramHeader: ehFrameStart %016llx ehFrameSize %08llx\n", ehFrameStart, ehFrameSize); if (ehFrameStart != 0 && ehFrameSize != 0) diff --git a/src/coreclr/pal/inc/pal_mstypes.h b/src/coreclr/pal/inc/pal_mstypes.h index 568f293380a201..7f4360b6f91668 100644 --- a/src/coreclr/pal/inc/pal_mstypes.h +++ b/src/coreclr/pal/inc/pal_mstypes.h @@ -546,6 +546,9 @@ 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 #endif // SIZE_T_MAX From 6d136290c24fa3c5f44c9c19ddb9339f2532f680 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 14 Oct 2022 16:46:49 -0700 Subject: [PATCH 5/6] Fix jit source formatting --- src/coreclr/jit/compiler.hpp | 5 ++--- src/coreclr/jit/gentree.h | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index 781f4bdbe8274a..e9b118f001e88b 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -236,7 +236,7 @@ inline unsigned genLog2(unsigned __int64 value) #if defined(HOST_UNIX) && defined(HOST_64BIT) inline unsigned genLog2(size_t value) { - return genLog2((unsigned __int64) value); + return genLog2((unsigned __int64)value); } #endif // HOST_UNIX && HOST_BIT64 @@ -1543,8 +1543,7 @@ 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 || std::is_same::value)); static_assert_no_msg(sizeof(int64_t) == sizeof(long long)); diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index e8894e6033703d..85e27fe3dce1be 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -3287,7 +3287,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 || std::is_same::value)); + static_assert_no_msg( + (std::is_same::value || std::is_same::value || std::is_same::value)); if (TypeIs(TYP_LONG)) { From cc99180b252b2b254643986109fc24cbce7fa193 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 14 Oct 2022 17:20:30 -0700 Subject: [PATCH 6/6] Fix FreeBSD build --- src/coreclr/pal/inc/pal_mstypes.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/coreclr/pal/inc/pal_mstypes.h b/src/coreclr/pal/inc/pal_mstypes.h index 7f4360b6f91668..ddeb135f2cce10 100644 --- a/src/coreclr/pal/inc/pal_mstypes.h +++ b/src/coreclr/pal/inc/pal_mstypes.h @@ -562,7 +562,6 @@ static_assert(sizeof(SSIZE_T) == sizeof(void*), "SSIZE_T should be pointer sized #endif #ifndef PAL_STDCPP_COMPAT -#if defined(__APPLE_CC__) || defined(__linux__) #ifdef HOST_64BIT typedef unsigned long size_t; typedef long ssize_t; @@ -571,10 +570,6 @@ typedef long ptrdiff_t; 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