From 8bc1a92d8f9275bf608ebf7b4b49cf64484f2d45 Mon Sep 17 00:00:00 2001 From: herengui Date: Mon, 22 May 2023 11:31:12 +0800 Subject: [PATCH] add loongarch64 support Signed-off-by: herengui --- CMakeLists.txt | 2 ++ src/common/cm_concurrency/cm_spinlock.h | 3 +++ src/common/cm_concurrency/cm_thread.c | 2 +- src/common/cm_utils/cm_checksum.h | 2 +- src/common/cm_utils/cm_memory.h | 3 +++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81d310b..54ffffe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,8 @@ if (UNIX) endif (USE_H1620) add_compile_options(-mtune=cortex-a72 -fsigned-char -g -ggdb3 -march=armv8-a+crc -funwind-tables) + elseif (OS_ARCH STREQUAL "loongarch64") + add_compile_options(-march=loongarch64 ) else () add_compile_options(-msse4.2 ) endif () diff --git a/src/common/cm_concurrency/cm_spinlock.h b/src/common/cm_concurrency/cm_spinlock.h index 7965853..ef4755d 100644 --- a/src/common/cm_concurrency/cm_spinlock.h +++ b/src/common/cm_concurrency/cm_spinlock.h @@ -68,6 +68,9 @@ typedef struct st_spin_statis { { \ __asm__ volatile("nop"); \ } +#elif defined(__loongarch__) +#define fas_cpu_pause() \ + {} #else #define fas_cpu_pause() \ { \ diff --git a/src/common/cm_concurrency/cm_thread.c b/src/common/cm_concurrency/cm_thread.c index 2d0aa2a..266abba 100644 --- a/src/common/cm_concurrency/cm_thread.c +++ b/src/common/cm_concurrency/cm_thread.c @@ -294,7 +294,7 @@ uint32 cm_get_current_thread_id() { #if (defined __x86_64__) #define __SYS_GET_SPID 186 -#elif (defined __aarch64__) +#elif defined(__aarch64__) || defined(__loongarch__) #define __SYS_GET_SPID 178 #endif #define gettid() syscall(__SYS_GET_SPID) diff --git a/src/common/cm_utils/cm_checksum.h b/src/common/cm_utils/cm_checksum.h index 85bb9fa..8e05e5a 100644 --- a/src/common/cm_utils/cm_checksum.h +++ b/src/common/cm_utils/cm_checksum.h @@ -26,7 +26,7 @@ #include "cm_defs.h" -#if defined(__arm__) || defined(__aarch64__) +#if defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) #ifdef __has_include #if __has_include() #include diff --git a/src/common/cm_utils/cm_memory.h b/src/common/cm_utils/cm_memory.h index 988b78e..d6494fb 100644 --- a/src/common/cm_utils/cm_memory.h +++ b/src/common/cm_utils/cm_memory.h @@ -56,6 +56,9 @@ extern "C" { __asm__ volatile("dmb ish" :: \ : "memory"); \ } +#elif defined(__loongarch__) +#define CM_MFENCE \ + {} #else #define CM_MFENCE \ { \ -- 2.40.1