Signed-off-by: yangchenguang <yangchenguang@kylinsec.com.cn> (cherry picked from commit 6119b0e0db6b0edb77bbfc4fa2050e6e314d1a1e)
110 lines
3.6 KiB
Diff
110 lines
3.6 KiB
Diff
From 5152ebe60d70f212df8619313463ae08185cfc55 Mon Sep 17 00:00:00 2001
|
|
From: panchenbo <panchenbo@kylinsec.com.cn>
|
|
Date: Tue, 16 May 2023 20:03:44 +0800
|
|
Subject: [PATCH] add sw_64 support
|
|
|
|
---
|
|
src/components/appio/tests/iozone/iozone.c | 2 +-
|
|
src/configure | 2 +-
|
|
src/configure.in | 2 +-
|
|
src/linux-context.h | 2 ++
|
|
src/linux-timer.c | 15 +++++++++++++++
|
|
src/mb.h | 3 +++
|
|
6 files changed, 23 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/components/appio/tests/iozone/iozone.c b/src/components/appio/tests/iozone/iozone.c
|
|
index 7708cd7..0fb29e3 100644
|
|
--- a/src/components/appio/tests/iozone/iozone.c
|
|
+++ b/src/components/appio/tests/iozone/iozone.c
|
|
@@ -81,7 +81,7 @@ extern int h_errno; /* imported for errors */
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
-#if defined (__LP64__) || defined(OSF_64) || defined(__alpha__) || defined(__arch64__) || defined(_LP64) || defined(__s390x__) || defined(__AMD64__)
|
|
+#if defined (__LP64__) || defined(OSF_64) || defined(__alpha__) || defined(__sw_64__) || defined(__arch64__) || defined(_LP64) || defined(__s390x__) || defined(__AMD64__)
|
|
#define MODE "\tCompiled for 64 bit mode."
|
|
#define _64BIT_ARCH_
|
|
#else
|
|
diff --git a/src/configure b/src/configure
|
|
index 02db3ac..2f83166 100755
|
|
--- a/src/configure
|
|
+++ b/src/configure
|
|
@@ -4628,7 +4628,7 @@ _ACEOF
|
|
|
|
# First set pthread-mutexes based on arch
|
|
case $arch in
|
|
- aarch64|arm*|parisc*|riscv*)
|
|
+ aarch64|arm*|parisc*|riscv*|sw_64)
|
|
pthread_mutexes=yes
|
|
CFLAGS="$CFLAGS -DUSE_PTHREAD_MUTEXES"
|
|
echo "forcing use of pthread mutexes... " >&6
|
|
diff --git a/src/configure.in b/src/configure.in
|
|
index 2c219ad..964f0e6 100644
|
|
--- a/src/configure.in
|
|
+++ b/src/configure.in
|
|
@@ -378,7 +378,7 @@ AC_DEFINE_UNQUOTED(CPU,$CPU,[cpu type])
|
|
|
|
# First set pthread-mutexes based on arch
|
|
case $arch in
|
|
- aarch64|arm*|parisc*|riscv*)
|
|
+ aarch64|arm*|parisc*|riscv*|sw_64)
|
|
pthread_mutexes=yes
|
|
CFLAGS="$CFLAGS -DUSE_PTHREAD_MUTEXES"
|
|
echo "forcing use of pthread mutexes... " >&6
|
|
diff --git a/src/linux-context.h b/src/linux-context.h
|
|
index fc07338..a55127c 100644
|
|
--- a/src/linux-context.h
|
|
+++ b/src/linux-context.h
|
|
@@ -33,6 +33,8 @@ typedef ucontext_t hwd_ucontext_t;
|
|
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.arm_pc
|
|
#elif defined(__aarch64__)
|
|
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.pc
|
|
+#elif defined(__sw_64__)
|
|
+#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.sc_pc
|
|
#elif defined(__loongarch__)
|
|
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.__pc
|
|
#elif defined(__mips__)
|
|
diff --git a/src/linux-timer.c b/src/linux-timer.c
|
|
index 1d6b7a8..43de746 100644
|
|
--- a/src/linux-timer.c
|
|
+++ b/src/linux-timer.c
|
|
@@ -230,6 +230,21 @@ get_cycles( void )
|
|
return ret;
|
|
}
|
|
|
|
+/************************/
|
|
+/* sw_64 get_cycles() */
|
|
+/************************/
|
|
+
|
|
+#elif defined(__sw_64__)
|
|
+static inline long long
|
|
+get_cycles( void )
|
|
+{
|
|
+ register unsigned long ret;
|
|
+
|
|
+ __asm__ __volatile__ ("rtc %0" : "=r" (ret));
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
/************************/
|
|
/* aarch64 get_cycles() */
|
|
/************************/
|
|
diff --git a/src/mb.h b/src/mb.h
|
|
index e98b574..b14bf5e 100644
|
|
--- a/src/mb.h
|
|
+++ b/src/mb.h
|
|
@@ -26,6 +26,9 @@
|
|
#elif defined (__alpha__)
|
|
#define rmb() asm volatile("mb" ::: "memory")
|
|
|
|
+#elif defined (__sw_64__)
|
|
+#define rmb() asm volatile("memb" ::: "memory")
|
|
+
|
|
#elif defined(__ia64__)
|
|
#define rmb() asm volatile ("mf" ::: "memory")
|
|
|
|
--
|
|
2.27.0
|
|
|