Skip to content

Commit 73893d9

Browse files
huoyaoyuanjkotas
andauthored
Cleanup some macro definitions in PAL (#119427)
* Use HOST_64BIT * Cleanup __int64 definition * _tfopen * Consolidate NOINLINE definitions * FORCEINLINE * Cleanup __forceinline usages * __UNREACHABLE * Unused defines * Number literal helpers * DECLSPEC_ALIGN * Unused * Use offsetof from stddef * Macros from palrt * HWND * MsgBox * Misc unused * Unify LL numeric suffix * More unused mstypes * Title-case OffsetOf is unused * Cleanup raw __UNREACHABLE * Unify unreachable with assert * Handle assert conflict --------- Co-authored-by: Jan Kotas <[email protected]>
1 parent 0fce5eb commit 73893d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+160
-531
lines changed

src/coreclr/debug/di/rsmain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ HRESULT Cordb::CreateProcessCommon(ICorDebugRemoteTarget * pRemoteTarget,
16461646
break;
16471647

16481648
default:
1649-
__assume(0);
1649+
UNREACHABLE();
16501650
}
16511651

16521652
#endif // FEATURE_INTEROP_DEBUGGING

src/coreclr/debug/ee/debugger.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8643,12 +8643,16 @@ int Debugger::NotifyUserOfFault(bool userBreakpoint, DebuggerLaunchSetting dls)
86438643
if (userBreakpoint)
86448644
{
86458645
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.";
8646+
#ifdef HOST_WINDOWS
86468647
flags |= MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION;
8648+
#endif
86478649
}
86488650
else
86498651
{
86508652
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.";
8653+
#ifdef HOST_WINDOWS
86518654
flags |= MB_OKCANCEL | MB_ICONEXCLAMATION;
8655+
#endif
86528656
}
86538657

86548658
// Format message string using optional parameters

src/coreclr/debug/ee/debuggermessagebox.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ static void DbgPrintf(const LPCSTR szFormat, ...)
3434
}
3535
}
3636

37+
#ifndef HOST_UNIX
3738
typedef int (*MessageBoxWFnPtr)(HWND hWnd,
3839
LPCWSTR lpText,
3940
LPCWSTR lpCaption,
4041
UINT uType);
42+
#endif // !HOST_UNIX
4143

4244
static int MessageBoxImpl(
4345
LPCWSTR title, // Dialog box title
@@ -157,10 +159,12 @@ int NotifyUserOfFaultMessageBox(
157159

158160
int result = IDCANCEL;
159161

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

165169
EX_TRY
166170
{

src/coreclr/gc/env/gcenv.base.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,8 @@
2121

2222
#ifndef _MSC_VER
2323
#define __stdcall
24-
#ifdef __GNUC__
25-
#define __forceinline __attribute__((always_inline)) inline
26-
#else // __GNUC__
27-
#define __forceinline inline
28-
#endif // __GNUC__
29-
// [LOCALGC TODO] is there a better place for this?
30-
#define NOINLINE __attribute__((noinline))
31-
#else // !_MSC_VER
32-
#define NOINLINE __declspec(noinline)
3324
#endif // _MSC_VER
3425

35-
#ifdef _MSC_VER
36-
#define __UNREACHABLE() __assume(0)
37-
#else
38-
#define __UNREACHABLE() __builtin_unreachable()
39-
#endif
40-
4126
#ifndef SIZE_T_MAX
4227
#define SIZE_T_MAX ((size_t)-1)
4328
#endif
@@ -88,7 +73,6 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x)
8873
#define FALSE false
8974

9075
#define CALLBACK __stdcall
91-
#define FORCEINLINE __forceinline
9276

9377
#define INFINITE 0xFFFFFFFF
9478

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

106-
#ifdef UNICODE
107-
#define _tfopen _wfopen
108-
#else
109-
#define _tfopen fopen
110-
#endif
111-
11290
#define WINAPI __stdcall
11391

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

451-
#ifdef _MSC_VER
452-
#define DECLSPEC_ALIGN(x) __declspec(align(x))
453-
#else
454-
#define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
455-
#endif
456-
457429
#ifndef _ASSERTE
458430
#define _ASSERTE(_expr) ASSERT(_expr)
459431
#endif
460432
#define CONSISTENCY_CHECK(_expr) ASSERT(_expr)
461433
#define COMPILER_ASSUME(cond) ASSERT(cond)
462434
#define EEPOLICY_HANDLE_FATAL_ERROR(error) ASSERT(!"EEPOLICY_HANDLE_FATAL_ERROR")
463-
#define UI64(_literal) _literal##ULL
464435

465436
class ObjHeader;
466437
class MethodTable;

src/coreclr/gc/env/gcenv.interlocked.inl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
3-
// __forceinline implementation of the Interlocked class methods
3+
// FORCEINLINE implementation of the Interlocked class methods
44
//
55

66
#ifndef __GCENV_INTERLOCKED_INL__
@@ -11,7 +11,7 @@
1111
#endif // _MSC_VER
1212

1313
#ifndef _MSC_VER
14-
__forceinline void Interlocked::InterlockedOperationBarrier()
14+
FORCEINLINE void Interlocked::InterlockedOperationBarrier()
1515
{
1616
#if defined(HOST_ARM64) || defined(HOST_LOONGARCH64) || defined(HOST_RISCV64)
1717
// See PAL_InterlockedOperationBarrier() in the PAL
@@ -26,7 +26,7 @@ __forceinline void Interlocked::InterlockedOperationBarrier()
2626
// Return:
2727
// The resulting incremented value
2828
template <typename T>
29-
__forceinline T Interlocked::Increment(T volatile *addend)
29+
FORCEINLINE T Interlocked::Increment(T volatile *addend)
3030
{
3131
#ifdef _MSC_VER
3232
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
@@ -44,7 +44,7 @@ __forceinline T Interlocked::Increment(T volatile *addend)
4444
// Return:
4545
// The resulting decremented value
4646
template <typename T>
47-
__forceinline T Interlocked::Decrement(T volatile *addend)
47+
FORCEINLINE T Interlocked::Decrement(T volatile *addend)
4848
{
4949
#ifdef _MSC_VER
5050
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
@@ -63,7 +63,7 @@ __forceinline T Interlocked::Decrement(T volatile *addend)
6363
// Return:
6464
// The previous value of the destination
6565
template <typename T>
66-
__forceinline T Interlocked::Exchange(T volatile *destination, T value)
66+
FORCEINLINE T Interlocked::Exchange(T volatile *destination, T value)
6767
{
6868
#ifdef _MSC_VER
6969
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
@@ -84,7 +84,7 @@ __forceinline T Interlocked::Exchange(T volatile *destination, T value)
8484
// Return:
8585
// The original value of the destination
8686
template <typename T>
87-
__forceinline T Interlocked::CompareExchange(T volatile *destination, T exchange, T comparand)
87+
FORCEINLINE T Interlocked::CompareExchange(T volatile *destination, T exchange, T comparand)
8888
{
8989
#ifdef _MSC_VER
9090
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
@@ -103,7 +103,7 @@ __forceinline T Interlocked::CompareExchange(T volatile *destination, T exchange
103103
// Return:
104104
// The previous value of the addend
105105
template <typename T>
106-
__forceinline T Interlocked::ExchangeAdd(T volatile *addend, T value)
106+
FORCEINLINE T Interlocked::ExchangeAdd(T volatile *addend, T value)
107107
{
108108
#ifdef _MSC_VER
109109
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
@@ -116,7 +116,7 @@ __forceinline T Interlocked::ExchangeAdd(T volatile *addend, T value)
116116
}
117117

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

131131
template <typename T>
132-
__forceinline T Interlocked::ExchangeAddPtr(T volatile* addend, T value)
132+
FORCEINLINE T Interlocked::ExchangeAddPtr(T volatile* addend, T value)
133133
{
134134
#ifdef _MSC_VER
135135
#ifdef HOST_64BIT
@@ -151,7 +151,7 @@ __forceinline T Interlocked::ExchangeAddPtr(T volatile* addend, T value)
151151
// destination - the first operand and the destination
152152
// value - second operand
153153
template <typename T>
154-
__forceinline void Interlocked::And(T volatile *destination, T value)
154+
FORCEINLINE void Interlocked::And(T volatile *destination, T value)
155155
{
156156
#ifdef _MSC_VER
157157
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
@@ -167,7 +167,7 @@ __forceinline void Interlocked::And(T volatile *destination, T value)
167167
// destination - the first operand and the destination
168168
// value - second operand
169169
template <typename T>
170-
__forceinline void Interlocked::Or(T volatile *destination, T value)
170+
FORCEINLINE void Interlocked::Or(T volatile *destination, T value)
171171
{
172172
#ifdef _MSC_VER
173173
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
@@ -185,7 +185,7 @@ __forceinline void Interlocked::Or(T volatile *destination, T value)
185185
// Return:
186186
// The previous value of the destination
187187
template <typename T>
188-
__forceinline T Interlocked::ExchangePointer(T volatile * destination, T value)
188+
FORCEINLINE T Interlocked::ExchangePointer(T volatile * destination, T value)
189189
{
190190
#ifdef _MSC_VER
191191
#ifdef HOST_64BIT
@@ -201,7 +201,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, T value)
201201
}
202202

203203
template <typename T>
204-
__forceinline T Interlocked::ExchangePointer(T volatile * destination, std::nullptr_t value)
204+
FORCEINLINE T Interlocked::ExchangePointer(T volatile * destination, std::nullptr_t value)
205205
{
206206
#ifdef _MSC_VER
207207
#ifdef HOST_64BIT
@@ -225,7 +225,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, std::null
225225
// Return:
226226
// The original value of the destination
227227
template <typename T>
228-
__forceinline T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, T comparand)
228+
FORCEINLINE T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, T comparand)
229229
{
230230
#ifdef _MSC_VER
231231
#ifdef HOST_64BIT
@@ -241,7 +241,7 @@ __forceinline T Interlocked::CompareExchangePointer(T volatile *destination, T e
241241
}
242242

243243
template <typename T>
244-
__forceinline T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, std::nullptr_t comparand)
244+
FORCEINLINE T Interlocked::CompareExchangePointer(T volatile *destination, T exchange, std::nullptr_t comparand)
245245
{
246246
#ifdef _MSC_VER
247247
#ifdef HOST_64BIT

src/coreclr/gc/env/gcenv.unix.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern uint32_t g_pageSizeUnixInl;
1111
#define OS_PAGE_SIZE GCToOSInterface::GetPageSize()
1212

1313
#ifndef DACCESS_COMPILE
14-
__forceinline size_t GCToOSInterface::GetPageSize()
14+
FORCEINLINE size_t GCToOSInterface::GetPageSize()
1515
{
1616
return g_pageSizeUnixInl;
1717
}

src/coreclr/gc/env/gcenv.windows.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#define OS_PAGE_SIZE GCToOSInterface::GetPageSize()
1111

12-
__forceinline size_t GCToOSInterface::GetPageSize()
12+
FORCEINLINE size_t GCToOSInterface::GetPageSize()
1313
{
1414
return 0x1000;
1515
}

src/coreclr/gc/gc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5304,7 +5304,7 @@ struct initial_memory_details
53045304
case 0: return block_size_normal;
53055305
case 1: return block_size_large;
53065306
case 2: return block_size_pinned;
5307-
default: __UNREACHABLE();
5307+
default: UNREACHABLE();
53085308
}
53095309
};
53105310

@@ -5317,7 +5317,7 @@ struct initial_memory_details
53175317
case soh_gen2: return initial_normal_heap[h_number].memory_base;
53185318
case loh_generation: return initial_large_heap[h_number].memory_base;
53195319
case poh_generation: return initial_pinned_heap[h_number].memory_base;
5320-
default: __UNREACHABLE();
5320+
default: UNREACHABLE();
53215321
}
53225322
};
53235323

@@ -5330,7 +5330,7 @@ struct initial_memory_details
53305330
case soh_gen2: return block_size_normal;
53315331
case loh_generation: return block_size_large;
53325332
case poh_generation: return block_size_pinned;
5333-
default: __UNREACHABLE();
5333+
default: UNREACHABLE();
53345334
}
53355335
};
53365336

src/coreclr/gc/gceventstatus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class GCEventStatus
6060
* IsEnabled queries whether or not the given level and keyword are
6161
* enabled on the given provider, returning true if they are.
6262
*/
63-
__forceinline static bool IsEnabled(GCEventProvider provider, GCEventKeyword keyword, GCEventLevel level)
63+
FORCEINLINE static bool IsEnabled(GCEventProvider provider, GCEventKeyword keyword, GCEventLevel level)
6464
{
6565
assert(level >= GCEventLevel_None && level < GCEventLevel_Max);
6666

src/coreclr/gc/handletablecore.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ void SegmentRemoveFreeBlocks(TableSegment *pSegment, uint32_t uType, BOOL *pfSca
685685

686686
#ifdef HANDLE_OPTIMIZE_FOR_64_HANDLE_BLOCKS
687687
// determine whether this block is empty
688-
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == UI64(0xFFFFFFFFFFFFFFFF))
688+
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == 0xFFFFFFFFFFFFFFFFULL)
689689
#else
690690
// assume this block is empty until we know otherwise
691691
BOOL fEmpty = TRUE;
@@ -1039,7 +1039,7 @@ void SegmentResortChains(TableSegment *pSegment)
10391039
{
10401040
#ifdef HANDLE_OPTIMIZE_FOR_64_HANDLE_BLOCKS
10411041
// determine whether this block is empty
1042-
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == UI64(0xFFFFFFFFFFFFFFFF))
1042+
if (((uint64_t*)pSegment->rgFreeMask)[uBlock] == 0xFFFFFFFFFFFFFFFFULL)
10431043
#else
10441044
// assume this block is empty until we know otherwise
10451045
BOOL fEmpty = TRUE;

0 commit comments

Comments
 (0)