Skip to content

Commit 108f83d

Browse files
committed
Remove min/max macros from NativeAOT and fix other build failures on non-Windows.
1 parent 309e330 commit 108f83d

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed

src/coreclr/gc/gc.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ class gc_rand
5151

5252
uint64_t gc_rand::x = 0;
5353

54-
// NativeAOT defines max/min as macros.
55-
// CoreCLR does not.
56-
// Define them if they aren't already available.
54+
// Define min/max as macros
5755
#ifndef min
5856
#define min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
5957
#endif

src/coreclr/nativeaot/Runtime/CommonMacros.h

-10
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ inline bool IS_ALIGNED(T* val, uintptr_t alignment);
8989
#define ZeroMemory(_dst, _size) memset((_dst), 0, (_size))
9090
#endif
9191

92-
//-------------------------------------------------------------------------------------------------
93-
// min/max
94-
95-
#ifndef min
96-
#define min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
97-
#endif
98-
#ifndef max
99-
#define max(_a, _b) ((_a) < (_b) ? (_b) : (_a))
100-
#endif
101-
10292
#endif // !DACCESS_COMPILE
10393

10494
//-------------------------------------------------------------------------------------------------

src/coreclr/vm/methodtable.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9229,7 +9229,7 @@ int MethodTable::GetFieldAlignmentRequirement()
92299229
{
92309230
return GetClass()->GetOverriddenFieldAlignmentRequirement();
92319231
}
9232-
return min(GetNumInstanceFieldBytes(), TARGET_POINTER_SIZE);
9232+
return min((int)GetNumInstanceFieldBytes(), TARGET_POINTER_SIZE);
92339233
}
92349234

92359235
UINT32 MethodTable::GetNativeSize()

src/coreclr/vm/methodtablebuilder.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8356,7 +8356,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach
83568356
// this field type has GC pointers in it, which need to be pointer-size aligned
83578357
// so do this if it has not been done already
83588358
dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, TARGET_POINTER_SIZE);
8359-
largestAlignmentRequirement = max(largestAlignmentRequirement, TARGET_POINTER_SIZE);
8359+
largestAlignmentRequirement = max(largestAlignmentRequirement, (unsigned int)TARGET_POINTER_SIZE);
83608360
containsGCPointers = true;
83618361
}
83628362
else
@@ -8385,7 +8385,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach
83858385
// non-value-type fields always require pointer alignment
83868386
// This does not account for types that are marked IsAlign8Candidate due to 8-byte fields
83878387
// but that is explicitly handled when we calculate the final alignment for the type.
8388-
largestAlignmentRequirement = max(largestAlignmentRequirement, TARGET_POINTER_SIZE);
8388+
largestAlignmentRequirement = max(largestAlignmentRequirement, (unsigned int)TARGET_POINTER_SIZE);
83898389

83908390
if (!pFieldDescList[i].IsObjRef())
83918391
{
@@ -8427,7 +8427,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach
84278427
minAlign *= 2;
84288428
}
84298429

8430-
if (minAlign != min(dwNumInstanceFieldBytes, TARGET_POINTER_SIZE))
8430+
if (minAlign != min(dwNumInstanceFieldBytes, (unsigned int)TARGET_POINTER_SIZE))
84318431
{
84328432
EnsureOptionalFieldsAreAllocated(GetHalfBakedClass(), m_pAllocMemTracker, GetLoaderAllocator()->GetLowFrequencyHeap());
84338433
GetHalfBakedClass()->GetOptionalFields()->m_requiredFieldAlignment = (BYTE)minAlign;

0 commit comments

Comments
 (0)