Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RISC-V support #5030

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC)
}
" HAVE_HMT_PRIORITY_INSTRUCTION)
ENDIF()

# Check for RISC-V Zihintpause
IF (processor MATCHES "riscv")
CHECK_C_SOURCE_COMPILES("
int main()
{
__asm__ __volatile__ (\"pause\");
return 0;
}
" HAVE_PAUSE_INSTRUCTION)
ENDIF()
ENDIF()

INCLUDE (CheckIncludeFileCXX)
Expand Down
29 changes: 29 additions & 0 deletions storage/ndb/include/portlib/mt-asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,35 @@ xcng(volatile unsigned * addr, int val)

#define cpu_pause() __asm__ __volatile__ ("yield")

#elif defined(__riscv)
#define NDB_HAVE_MB
#define NDB_HAVE_RMB
#define NDB_HAVE_WMB
#define NDB_HAVE_XCNG

#define mb() asm volatile ("fence iorw, iorw" ::: "memory")
#define rmb() asm volatile ("fence ir, ir" ::: "memory")
#define wmb() asm volatile ("fence ow, ow" ::: "memory")

static
inline
int
xcng(volatile unsigned * addr, int val)
{
int prev;
__asm__ __volatile__ (
"amoswap.d.aqrl %0, %2, %1\n"
: "=r" (prev), "+A" (*addr)
: "r" (val)
: "memory");
return prev;
}

#if defined(HAVE_PAUSE_INSTRUCTION)
#define NDB_HAVE_PAUSE
#define cpu_pause() asm volatile ("pause")
#endif

#else
#define NDB_NO_ASM "Unsupported architecture (gcc)"
#endif
Expand Down