Skip to content

Commit 8bb5647

Browse files
committed
More precise ifdef
1 parent 4581a71 commit 8bb5647

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -834,10 +834,7 @@ REDHAWK_PALEXPORT UInt32_BOOL REDHAWK_PALAPI PalVirtualProtect(_In_ void* pAddre
834834

835835
REDHAWK_PALEXPORT void PalFlushInstructionCache(_In_ void* pAddress, size_t size)
836836
{
837-
#ifndef HOST_ARM
838-
// Intrinsic should do the right thing across all platforms (except Linux arm)
839-
__builtin___clear_cache((char *)pAddress, (char *)pAddress + size);
840-
#else // HOST_ARM
837+
#if defined(__linux__) && defined(HOST_ARM)
841838
// On Linux/arm (at least on 3.10) we found that there is a problem with __do_cache_op (arch/arm/kernel/traps.c)
842839
// implementing cacheflush syscall. cacheflush flushes only the first page in range [pAddress, pAddress + size)
843840
// and leaves other pages in undefined state which causes random tests failures (often due to SIGSEGV) with no particular pattern.
@@ -857,7 +854,9 @@ REDHAWK_PALEXPORT void PalFlushInstructionCache(_In_ void* pAddress, size_t size
857854
__builtin___clear_cache((char *)begin, (char *)endOrNextPageBegin);
858855
begin = endOrNextPageBegin;
859856
}
860-
#endif // HOST_ARM
857+
#else
858+
__builtin___clear_cache((char *)pAddress, (char *)pAddress + size);
859+
#endif
861860
}
862861

863862
REDHAWK_PALEXPORT _Ret_maybenull_ void* REDHAWK_PALAPI PalSetWerDataBuffer(_In_ void* pNewBuffer)

src/coreclr/pal/src/thread/context.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,10 +1668,7 @@ DBG_FlushInstructionCache(
16681668
IN LPCVOID lpBaseAddress,
16691669
IN SIZE_T dwSize)
16701670
{
1671-
#ifndef HOST_ARM
1672-
// Intrinsic should do the right thing across all platforms (except Linux arm)
1673-
__builtin___clear_cache((char *)lpBaseAddress, (char *)((INT_PTR)lpBaseAddress + dwSize));
1674-
#else // HOST_ARM
1671+
#if defined(__linux__) && defined(HOST_ARM)
16751672
// On Linux/arm (at least on 3.10) we found that there is a problem with __do_cache_op (arch/arm/kernel/traps.c)
16761673
// implementing cacheflush syscall. cacheflush flushes only the first page in range [lpBaseAddress, lpBaseAddress + dwSize)
16771674
// and leaves other pages in undefined state which causes random tests failures (often due to SIGSEGV) with no particular pattern.
@@ -1691,6 +1688,8 @@ DBG_FlushInstructionCache(
16911688
__builtin___clear_cache((char *)begin, (char *)endOrNextPageBegin);
16921689
begin = endOrNextPageBegin;
16931690
}
1694-
#endif // HOST_ARM
1691+
#else
1692+
__builtin___clear_cache((char *)lpBaseAddress, (char *)((INT_PTR)lpBaseAddress + dwSize));
1693+
#endif
16951694
return TRUE;
16961695
}

0 commit comments

Comments
 (0)