From c0e9b1beec7bd9222032585fbabd239707f22095 Mon Sep 17 00:00:00 2001 From: Jingyun Hua Date: Mon, 14 Nov 2022 09:14:28 +0000 Subject: [PATCH] Add support loongarch Signed-off-by: Jingyun Hua (cherry picked from commit b54ea5a085aa10a1f19bcdab8195e3e000add0d5) --- add-loongarch.patch | 157 ++++++++++++++++++++++++++++++++++++++++++++ userspace-rcu.spec | 8 ++- 2 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 add-loongarch.patch diff --git a/add-loongarch.patch b/add-loongarch.patch new file mode 100644 index 0000000..c7fa269 --- /dev/null +++ b/add-loongarch.patch @@ -0,0 +1,157 @@ +diff --git a/include/Makefile.am b/include/Makefile.am +index 3f92cc3..5c042fd 100644 +--- a/include/Makefile.am ++++ b/include/Makefile.am +@@ -16,6 +16,7 @@ nobase_include_HEADERS = \ + urcu/arch/sparc64.h \ + urcu/arch/tile.h \ + urcu/arch/x86.h \ ++ urcu/arch/loongarch.h \ + urcu/call-rcu.h \ + urcu/cds.h \ + urcu/compiler.h \ +@@ -76,6 +77,7 @@ nobase_include_HEADERS = \ + urcu/uatomic/sparc64.h \ + urcu/uatomic/tile.h \ + urcu/uatomic/x86.h \ ++ urcu/uatomic/loongarch.h \ + urcu/urcu-bp.h \ + urcu/urcu-futex.h \ + urcu/urcu.h \ +diff --git a/include/urcu/arch.h b/include/urcu/arch.h +index 620743c..e42267a 100644 +--- a/include/urcu/arch.h ++++ b/include/urcu/arch.h +@@ -157,6 +157,11 @@ + #define URCU_ARCH_RISCV 1 + #include + ++#elif defined(__loongarch__) || (_loongarch64) ++ ++#define URCU_ARCH_LOONGARCH 1 ++#include ++ + #else + #error "Cannot build: unrecognized architecture, see ." + #endif +diff --git a/include/urcu/arch/loongarch.h b/include/urcu/arch/loongarch.h +new file mode 100644 +index 0000000..865bbb5 +--- /dev/null ++++ b/include/urcu/arch/loongarch.h +@@ -0,0 +1,50 @@ ++#ifndef _URCU_ARCH_LOONGARCH_H ++#define _URCU_ARCH_LOONGARCH_H ++ ++/* ++ * arch/loongarch.h: definitions for the LOONGARCH architecture ++ * ++ * Copyright (c) 2022 Loongson Technology Corporation Limited ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#include ++#include ++#include ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++ ++/* ++ * On Linux, define the membarrier system call number if not yet available in ++ * the system headers. loongarch64 implements asm-generic/unistd.h system call ++ * numbers. ++ */ ++#if (defined(__linux__) && !defined(__NR_membarrier)) ++#define __NR_membarrier 283 ++#endif ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#include ++ ++#endif /* _URCU_ARCH_LOONGARCH_H */ +diff --git a/include/urcu/uatomic.h b/include/urcu/uatomic.h +index 2fb5fd4..e1ff44d 100644 +--- a/include/urcu/uatomic.h ++++ b/include/urcu/uatomic.h +@@ -51,6 +51,8 @@ + #include + #elif defined(URCU_ARCH_RISCV) + #include ++#elif defined(URCU_ARCH_LOONGARCH) ++#include + #else + #error "Cannot build: unrecognized architecture, see ." + #endif +diff --git a/include/urcu/uatomic/loongarch.h b/include/urcu/uatomic/loongarch.h +new file mode 100644 +index 0000000..e0fb2a6 +--- /dev/null ++++ b/include/urcu/uatomic/loongarch.h +@@ -0,0 +1,44 @@ ++/* ++ * Atomic exchange operations for the LOONGARCH architecture. Let GCC do it. ++ * ++ * Copyright (c) 2022 Loongson Technology Corporation Limited ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to ++ * deal in the Software without restriction, including without limitation the ++ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or ++ * sell copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS ++ * IN THE SOFTWARE. ++ */ ++ ++#ifndef _URCU_ARCH_UATOMIC_LOONGARCH_H ++#define _URCU_ARCH_UATOMIC_LOONGARCH_H ++ ++#include ++#include ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#define UATOMIC_HAS_ATOMIC_BYTE ++#define UATOMIC_HAS_ATOMIC_SHORT ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#include ++ ++#endif /* _URCU_ARCH_UATOMIC_LOONGARCH_H */ +-- +2.27.0 diff --git a/userspace-rcu.spec b/userspace-rcu.spec index 4a4ef57..90afa9c 100644 --- a/userspace-rcu.spec +++ b/userspace-rcu.spec @@ -1,12 +1,15 @@ Name: userspace-rcu Version: 0.13.0 -Release: 4 +Release: 5 Summary: Userspace read-copy-update library License: LGPLv2+ URL: http://liburcu.org Source0: http://lttng.org/files/urcu/%{name}-%{version}.tar.bz2 Patch1: userspace-rcu-0.13.0-sw.patch +%ifarch loongarch64 +Patch0000: add-loongarch.patch +%endif BuildRequires: pkgconfig perl-Test-Harness autoconf automake libtool %description @@ -66,6 +69,9 @@ make check %changelog +* Mon Nov 14 2022 huajingyun - 0.13.0-5 +- Add support loongarch + * Thu Aug 11 2022 wuzx - 0.13.0-4 - add sw64 patch -- Gitee