Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f959821
Use HOST_64BIT
huoyaoyuan Aug 30, 2025
a93479d
Cleanup __int64 definition
huoyaoyuan Aug 31, 2025
41c3a60
_tfopen
huoyaoyuan Sep 1, 2025
14ba0d9
Consolidate NOINLINE definitions
huoyaoyuan Sep 1, 2025
bf4caa7
FORCEINLINE
huoyaoyuan Sep 1, 2025
210d0ee
Cleanup __forceinline usages
huoyaoyuan Sep 2, 2025
34cb67c
__UNREACHABLE
huoyaoyuan Sep 2, 2025
72d12b0
Unused defines
huoyaoyuan Sep 3, 2025
fcd8af9
Number literal helpers
huoyaoyuan Sep 3, 2025
d12d0e2
DECLSPEC_ALIGN
huoyaoyuan Sep 4, 2025
9ed376a
Unused
huoyaoyuan Sep 6, 2025
0187c45
Use offsetof from stddef
huoyaoyuan Sep 6, 2025
163dbb3
Macros from palrt
huoyaoyuan Sep 6, 2025
74eac86
HWND
huoyaoyuan Sep 6, 2025
d363579
MsgBox
huoyaoyuan Sep 6, 2025
b6c703b
Misc unused
huoyaoyuan Sep 6, 2025
ad03c60
Fix build
huoyaoyuan Sep 6, 2025
ebcd657
Use standard alignas
huoyaoyuan Sep 6, 2025
eb9c8af
Revert "Use standard alignas"
huoyaoyuan Sep 6, 2025
a418cd6
Unify LL numeric suffix
huoyaoyuan Sep 7, 2025
cc8a0ae
More unused mstypes
huoyaoyuan Sep 7, 2025
c49d420
Merge branch 'main' into pal/macros
huoyaoyuan Sep 22, 2025
bdace49
Title-case OffsetOf is unused
huoyaoyuan Sep 22, 2025
92e2f6e
Cleanup raw __UNREACHABLE
huoyaoyuan Sep 23, 2025
63b9410
Unify unreachable with assert
huoyaoyuan Sep 24, 2025
a4d05b3
Merge branch 'main' into pal/macros
huoyaoyuan Sep 24, 2025
abc3362
Apply suggestion from code review
huoyaoyuan Sep 25, 2025
32785f2
Remove duplicated definition
huoyaoyuan Sep 26, 2025
4784833
Update assert redefining
huoyaoyuan Sep 26, 2025
06b2fbc
Merge branch 'main' into pal/macros
jkotas Sep 26, 2025
27109ea
Handle assert conflict
huoyaoyuan Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/rsmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ HRESULT Cordb::CreateProcessCommon(ICorDebugRemoteTarget * pRemoteTarget,
break;

default:
__assume(0);
UNREACHABLE();
}

#endif // FEATURE_INTEROP_DEBUGGING
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8643,12 +8643,16 @@ int Debugger::NotifyUserOfFault(bool userBreakpoint, DebuggerLaunchSetting dls)
if (userBreakpoint)
{
msg = "Application has encountered a user-defined breakpoint.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\nClick ABORT to terminate the application.\nClick RETRY to debug the application.\nClick IGNORE to ignore the breakpoint.";
#ifdef HOST_WINDOWS
flags |= MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION;
#endif
}
else
{
msg = "Application has generated an exception that could not be handled.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\nClick OK to terminate the application.\nClick CANCEL to debug the application.";
#ifdef HOST_WINDOWS
flags |= MB_OKCANCEL | MB_ICONEXCLAMATION;
#endif
}

// Format message string using optional parameters
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/debug/ee/debuggermessagebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ static void DbgPrintf(const LPCSTR szFormat, ...)
}
}

#ifndef HOST_UNIX
typedef int (*MessageBoxWFnPtr)(HWND hWnd,
LPCWSTR lpText,
LPCWSTR lpCaption,
UINT uType);
#endif // !HOST_UNIX

static int MessageBoxImpl(
LPCWSTR title, // Dialog box title
Expand Down Expand Up @@ -157,10 +159,12 @@ int NotifyUserOfFaultMessageBox(

int result = IDCANCEL;

#ifdef HOST_WINDOWS
// Add the MB_TASKMODAL style to indicate that the dialog should be displayed on top of the windows
// owned by the current thread and should prevent interaction with them until dismissed.
// Include in the MB_DEFAULT_DESKTOP_ONLY style.
uType |= (MB_TASKMODAL | MB_DEFAULT_DESKTOP_ONLY);
#endif

EX_TRY
{
Expand Down
29 changes: 0 additions & 29 deletions src/coreclr/gc/env/gcenv.base.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,8 @@

#ifndef _MSC_VER
#define __stdcall
#ifdef __GNUC__
#define __forceinline __attribute__((always_inline)) inline
#else // __GNUC__
#define __forceinline inline
#endif // __GNUC__
// [LOCALGC TODO] is there a better place for this?
#define NOINLINE __attribute__((noinline))
#else // !_MSC_VER
#define NOINLINE __declspec(noinline)
#endif // _MSC_VER

#ifdef _MSC_VER
#define __UNREACHABLE() __assume(0)
#else
#define __UNREACHABLE() __builtin_unreachable()
#endif

#ifndef SIZE_T_MAX
#define SIZE_T_MAX ((size_t)-1)
#endif
Expand Down Expand Up @@ -88,7 +73,6 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x)
#define FALSE false

#define CALLBACK __stdcall
#define FORCEINLINE __forceinline

#define INFINITE 0xFFFFFFFF

Expand All @@ -103,12 +87,6 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x)
snprintf(string, sizeInBytes, format, ## __VA_ARGS__)
#endif

#ifdef UNICODE
#define _tfopen _wfopen
#else
#define _tfopen fopen
#endif

#define WINAPI __stdcall

typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter);
Expand Down Expand Up @@ -448,19 +426,12 @@ typedef DPTR(uint8_t) PTR_uint8_t;
#define DATA_ALIGNMENT sizeof(uintptr_t)
#define RAW_KEYWORD(x) x

#ifdef _MSC_VER
#define DECLSPEC_ALIGN(x) __declspec(align(x))
#else
#define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
#endif

#ifndef _ASSERTE
#define _ASSERTE(_expr) ASSERT(_expr)
#endif
#define CONSISTENCY_CHECK(_expr) ASSERT(_expr)
#define COMPILER_ASSUME(cond) ASSERT(cond)
#define EEPOLICY_HANDLE_FATAL_ERROR(error) ASSERT(!"EEPOLICY_HANDLE_FATAL_ERROR")
#define UI64(_literal) _literal##ULL

class ObjHeader;
class MethodTable;
Expand Down
30 changes: 15 additions & 15 deletions src/coreclr/gc/env/gcenv.interlocked.inl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// __forceinline implementation of the Interlocked class methods
// FORCEINLINE implementation of the Interlocked class methods
//

#ifndef __GCENV_INTERLOCKED_INL__
Expand All @@ -11,7 +11,7 @@
#endif // _MSC_VER

#ifndef _MSC_VER
__forceinline void Interlocked::InterlockedOperationBarrier()
FORCEINLINE void Interlocked::InterlockedOperationBarrier()
{
#if defined(HOST_ARM64) || defined(HOST_LOONGARCH64) || defined(HOST_RISCV64)
// See PAL_InterlockedOperationBarrier() in the PAL
Expand All @@ -26,7 +26,7 @@ __forceinline void Interlocked::InterlockedOperationBarrier()
// Return:
// The resulting incremented value
template <typename T>
__forceinline T Interlocked::Increment(T volatile *addend)
FORCEINLINE T Interlocked::Increment(T volatile *addend)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
Expand All @@ -44,7 +44,7 @@ __forceinline T Interlocked::Increment(T volatile *addend)
// Return:
// The resulting decremented value
template <typename T>
__forceinline T Interlocked::Decrement(T volatile *addend)
FORCEINLINE T Interlocked::Decrement(T volatile *addend)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
Expand All @@ -63,7 +63,7 @@ __forceinline T Interlocked::Decrement(T volatile *addend)
// Return:
// The previous value of the destination
template <typename T>
__forceinline T Interlocked::Exchange(T volatile *destination, T value)
FORCEINLINE T Interlocked::Exchange(T volatile *destination, T value)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
Expand All @@ -84,7 +84,7 @@ __forceinline T Interlocked::Exchange(T volatile *destination, T value)
// Return:
// The original value of the destination
template <typename T>
__forceinline T Interlocked::CompareExchange(T volatile *destination, T exchange, T comparand)
FORCEINLINE T Interlocked::CompareExchange(T volatile *destination, T exchange, T comparand)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
Expand All @@ -103,7 +103,7 @@ __forceinline T Interlocked::CompareExchange(T volatile *destination, T exchange
// Return:
// The previous value of the addend
template <typename T>
__forceinline T Interlocked::ExchangeAdd(T volatile *addend, T value)
FORCEINLINE T Interlocked::ExchangeAdd(T volatile *addend, T value)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
Expand All @@ -116,7 +116,7 @@ __forceinline T Interlocked::ExchangeAdd(T volatile *addend, T value)
}

template <typename T>
__forceinline T Interlocked::ExchangeAdd64(T volatile* addend, T value)
FORCEINLINE T Interlocked::ExchangeAdd64(T volatile* addend, T value)
{
#ifdef _MSC_VER
static_assert(sizeof(int64_t) == sizeof(T), "Size of LONGLONG must be the same as size of T");
Expand All @@ -129,7 +129,7 @@ __forceinline T Interlocked::ExchangeAdd64(T volatile* addend, T value)
}

template <typename T>
__forceinline T Interlocked::ExchangeAddPtr(T volatile* addend, T value)
FORCEINLINE T Interlocked::ExchangeAddPtr(T volatile* addend, T value)
{
#ifdef _MSC_VER
#ifdef HOST_64BIT
Expand All @@ -151,7 +151,7 @@ __forceinline T Interlocked::ExchangeAddPtr(T volatile* addend, T value)
// destination - the first operand and the destination
// value - second operand
template <typename T>
__forceinline void Interlocked::And(T volatile *destination, T value)
FORCEINLINE void Interlocked::And(T volatile *destination, T value)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
Expand All @@ -167,7 +167,7 @@ __forceinline void Interlocked::And(T volatile *destination, T value)
// destination - the first operand and the destination
// value - second operand
template <typename T>
__forceinline void Interlocked::Or(T volatile *destination, T value)
FORCEINLINE void Interlocked::Or(T volatile *destination, T value)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
Expand All @@ -185,7 +185,7 @@ __forceinline void Interlocked::Or(T volatile *destination, T value)
// Return:
// The previous value of the destination
template <typename T>
__forceinline T Interlocked::ExchangePointer(T volatile * destination, T value)
FORCEINLINE T Interlocked::ExchangePointer(T volatile * destination, T value)
{
#ifdef _MSC_VER
#ifdef HOST_64BIT
Expand All @@ -201,7 +201,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, T value)
}

template <typename T>
__forceinline T Interlocked::ExchangePointer(T volatile * destination, std::nullptr_t value)
FORCEINLINE T Interlocked::ExchangePointer(T volatile * destination, std::nullptr_t value)
{
#ifdef _MSC_VER
#ifdef HOST_64BIT
Expand All @@ -225,7 +225,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, std::null
// Return:
// The original value of the destination
template <typename T>
__forceinline T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, T comparand)
FORCEINLINE T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, T comparand)
{
#ifdef _MSC_VER
#ifdef HOST_64BIT
Expand All @@ -241,7 +241,7 @@ __forceinline T Interlocked::CompareExchangePointer(T volatile *destination, T e
}

template <typename T>
__forceinline T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, std::nullptr_t comparand)
FORCEINLINE T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, std::nullptr_t comparand)
{
#ifdef _MSC_VER
#ifdef HOST_64BIT
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/env/gcenv.unix.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern uint32_t g_pageSizeUnixInl;
#define OS_PAGE_SIZE GCToOSInterface::GetPageSize()

#ifndef DACCESS_COMPILE
__forceinline size_t GCToOSInterface::GetPageSize()
FORCEINLINE size_t GCToOSInterface::GetPageSize()
{
return g_pageSizeUnixInl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/env/gcenv.windows.inl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define OS_PAGE_SIZE GCToOSInterface::GetPageSize()

__forceinline size_t GCToOSInterface::GetPageSize()
FORCEINLINE size_t GCToOSInterface::GetPageSize()
{
return 0x1000;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/gceventstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GCEventStatus
* IsEnabled queries whether or not the given level and keyword are
* enabled on the given provider, returning true if they are.
*/
__forceinline static bool IsEnabled(GCEventProvider provider, GCEventKeyword keyword, GCEventLevel level)
FORCEINLINE static bool IsEnabled(GCEventProvider provider, GCEventKeyword keyword, GCEventLevel level)
{
assert(level >= GCEventLevel_None && level < GCEventLevel_Max);

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/gc/handletablecore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ void SegmentRemoveFreeBlocks(TableSegment *pSegment, uint32_t uType, BOOL *pfSca

#ifdef HANDLE_OPTIMIZE_FOR_64_HANDLE_BLOCKS
// determine whether this block is empty
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == UI64(0xFFFFFFFFFFFFFFFF))
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == 0xFFFFFFFFFFFFFFFFULL)
#else
// assume this block is empty until we know otherwise
BOOL fEmpty = TRUE;
Expand Down Expand Up @@ -1039,7 +1039,7 @@ void SegmentResortChains(TableSegment *pSegment)
{
#ifdef HANDLE_OPTIMIZE_FOR_64_HANDLE_BLOCKS
// determine whether this block is empty
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == UI64(0xFFFFFFFFFFFFFFFF))
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == 0xFFFFFFFFFFFFFFFFULL)
#else
// assume this block is empty until we know otherwise
BOOL fEmpty = TRUE;
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
#undef min
#undef max

#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) (0)
#endif

#include <algorithm>

#if HAVE_SYS_TIME_H
Expand Down
10 changes: 4 additions & 6 deletions src/coreclr/gc/vxsort/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifndef VXSORT_DEFS_H
#define VXSORT_DEFS_H

#include <minipal/utils.h>

#if _MSC_VER
#ifdef _M_X86
#define ARCH_X86
Expand All @@ -29,22 +31,18 @@
#ifdef _MSC_VER
#ifdef __clang__
#define mess_up_cmov()
#define INLINE __attribute__((always_inline))
#define NOINLINE __attribute__((noinline))
#else
// MSVC
#include <intrin.h>
#define mess_up_cmov() _ReadBarrier();
#define INLINE __forceinline
#define NOINLINE __declspec(noinline)
#endif
#else
// GCC + Clang
#define mess_up_cmov()
#define INLINE __attribute__((always_inline))
#define NOINLINE __attribute__((noinline))
#endif

#define INLINE FORCEINLINE

using std::max;
using std::min;
#endif // VXSORT_DEFS_H
2 changes: 1 addition & 1 deletion src/coreclr/gcinfo/gcinfodumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifdef HOST_64BIT
// All stack offsets are INT32's, so this guarantees a disjoint range of
// addresses for each register.
#define ADDRESS_SPACING UI64(0x100000000)
#define ADDRESS_SPACING 0x100000000ULL
#elif defined(TARGET_ARM)
#define ADDRESS_SPACING 0x100000
#else
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/ilasm/grammar_after.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,8 @@ int yylex()
begNum = curPos;
{
uint64_t i64 = str2uint64(begNum, const_cast<const char**>(&curPos), radix);
uint64_t mask64 = neg ? UI64(0xFFFFFFFF80000000) : UI64(0xFFFFFFFF00000000);
uint64_t largestNegVal32 = UI64(0x0000000080000000);
uint64_t mask64 = neg ? 0xFFFFFFFF80000000ULL : 0xFFFFFFFF00000000ULL;
uint64_t largestNegVal32 = 0x0000000080000000ULL;
if ((i64 & mask64) && (i64 != largestNegVal32))
{
yylval.int64 = new int64_t(i64);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/ilasm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct ARG_NAME_LIST
DWORD dwAttr;
CustomDescrList CustDList;
ARG_NAME_LIST *pNext;
__forceinline ARG_NAME_LIST(int i, LPCUTF8 sz, BinStr *pbSig, BinStr *pbMarsh, DWORD attr)
FORCEINLINE ARG_NAME_LIST(int i, LPCUTF8 sz, BinStr *pbSig, BinStr *pbMarsh, DWORD attr)
{
nNum = i;
//dwName = (DWORD)strlen(sz);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/ilasm/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ HRESULT Assembler::CreatePEFile(_In_ __nullterminated WCHAR *pwzOutputFilename)
if(m_dwCeeFileFlags & ICEE_CREATE_FILE_PE64)
{
ULONGLONG *pdw = new ULONGLONG[N];
for(i=0; i<N; i++) pdw[i] = UI64(0xdeadbeefdeadbeef);
for(i=0; i<N; i++) pdw[i] = 0xdeadbeefdeadbeefULL;
EmitData(pdw,sizeof(ULONGLONG)*N);
m_VTFList.PUSH(new VTFEntry((USHORT)N,COR_VTABLE_64BIT|COR_VTABLE_FROM_UNMANAGED,sz));
delete [] pdw;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/ildasm/dasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5857,8 +5857,8 @@ IMetaDataTables *pITables = NULL;
//int size, size2;
int metaSize = 0;
int64_t fTableSeen;
inline void TableSeen(unsigned long n) { fTableSeen |= (I64(1) << n); }
inline int IsTableSeen(unsigned long n) { return (fTableSeen & (I64(1) << n)) ? 1 : 0;}
inline void TableSeen(unsigned long n) { fTableSeen |= (1LL << n); }
inline int IsTableSeen(unsigned long n) { return (fTableSeen & (1LL << n)) ? 1 : 0;}
inline void TableSeenReset() { fTableSeen = 0;}

void DumpTable(unsigned long Table, const char *TableName, void* GUICookie)
Expand Down
Loading
Loading