1 Star 0 Fork 17

kiritake kumi/userspace-rcu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
add-loongarch.patch 4.80 KB
一键复制 编辑 原始数据 按行查看 历史
huajingyun 提交于 2022-11-14 09:14 . Add support loongarch
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 <urcu/arch/riscv.h>
+#elif defined(__loongarch__) || (_loongarch64)
+
+#define URCU_ARCH_LOONGARCH 1
+#include <urcu/arch/loongarch.h>
+
#else
#error "Cannot build: unrecognized architecture, see <urcu/arch.h>."
#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 <urcu/compiler.h>
+#include <urcu/config.h>
+#include <urcu/syscall-compat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <sys/time.h>
+
+/*
+ * 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 <urcu/arch/generic.h>
+
+#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 <urcu/uatomic/m68k.h>
#elif defined(URCU_ARCH_RISCV)
#include <urcu/uatomic/riscv.h>
+#elif defined(URCU_ARCH_LOONGARCH)
+#include <urcu/uatomic/loongarch.h>
#else
#error "Cannot build: unrecognized architecture, see <urcu/arch.h>."
#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 <urcu/compiler.h>
+#include <urcu/system.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UATOMIC_HAS_ATOMIC_BYTE
+#define UATOMIC_HAS_ATOMIC_SHORT
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <urcu/uatomic/generic.h>
+
+#endif /* _URCU_ARCH_UATOMIC_LOONGARCH_H */
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kiritake-kumi/userspace-rcu.git
git@gitee.com:kiritake-kumi/userspace-rcu.git
kiritake-kumi
userspace-rcu
userspace-rcu
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385