Skip to content

Commit

Permalink
[RISC-V] Fix intermittent failures due to unalignment access (#100431)
Browse files Browse the repository at this point in the history
* [RISC-V] Fix intermittent failures due to unalignment access

* [RISC-V] Update for ALIGN_ACCESS

* Apply suggestions from code review

---------

Co-authored-by: Jan Kotas <[email protected]>
  • Loading branch information
clamp03 and jkotas authored Mar 31, 2024
1 parent cc7bf83 commit 1949bd2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/coreclr/gcinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ if (CLR_CMAKE_TARGET_ARCH_RISCV64)
create_gcinfo_lib(TARGET gcinfo_unix_riscv64 OS unix ARCH riscv64)
endif (CLR_CMAKE_TARGET_ARCH_RISCV64)

create_gcinfo_lib(TARGET gcinfo_universal_arm OS universal ARCH arm)
create_gcinfo_lib(TARGET gcinfo_win_x86 OS win ARCH x86)
if (NOT CLR_CMAKE_TARGET_ARCH_RISCV64)
create_gcinfo_lib(TARGET gcinfo_universal_arm OS universal ARCH arm)
create_gcinfo_lib(TARGET gcinfo_win_x86 OS win ARCH x86)
endif (NOT CLR_CMAKE_TARGET_ARCH_RISCV64)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
create_gcinfo_lib(TARGET gcinfo_unix_x86 OS unix ARCH x86)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/inc/stdmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@
#define DBG_ADDR(ptr) (DWORD)((UINT_PTR)(ptr))
#endif // HOST_64BIT

#ifdef TARGET_ARM
#if defined(HOST_ARM) || defined(HOST_RISCV64)
#define ALIGN_ACCESS ((1<<LOG2_PTRSIZE)-1)
#endif
#endif // HOST_ARM || HOST_RISCV64


#ifndef ALLOC_ALIGN_CONSTANT
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/pal/inc/pal_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ inline void SwapGuid(GUID *pGuid)
#define ALIGN_ACCESS ((1<<LOG2_PTRSIZE)-1)
#endif

#ifdef HOST_RISCV64
#define LOG2_PTRSIZE 3
#define ALIGN_ACCESS ((1<<LOG2_PTRSIZE)-1)
#endif

#if defined(ALIGN_ACCESS) && !defined(_MSC_VER)
#ifdef __cplusplus
extern "C++" {
Expand Down

0 comments on commit 1949bd2

Please sign in to comment.