Bug#1057761: papi: add support for loongarch64
Source: papi
Version: 7.0.1-1
Severity: wishlist
Tags: patch
User: debian-loongarch@lists.debian.org
Usertags: loong64
Dear maintainers,
Compiling the papi failed for loong64 in the Debian Package
Auto-Building environment.
The full compilation log can be found at
https://buildd.debian.org/status/logs.php?pkg=papi&ver=7.0.1-1&arch=loong64
Please consider the patch I have attached.
And the papi source package was compiled successfully on my local
loong64 rootfs environment.
If you have any questions, you can contact me at any time.
thanks,
Dandan Zhang
Description: Add support for loongarch64
Author: Dandan Zhang <zhangdandan@loongson.cn>
Last-Update: 2023-12-06
--- papi-7.0.1.orig/src/linux-context.h
+++ papi-7.0.1/src/linux-context.h
@@ -35,6 +35,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(__loongarch64)
+#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.__pc
#elif defined(__mips__)
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.pc
#elif defined(__hppa__)
--- papi-7.0.1.orig/src/linux-timer.c
+++ papi-7.0.1/src/linux-timer.c
@@ -246,6 +246,22 @@ get_cycles( void )
}
/************************/
+/* loongarch64 get_cycles() */
+/************************/
+
+#elif defined(__loongarch64)
+static inline long long
+get_cycles( void )
+{
+ int rid = 0;
+ unsigned long ret;
+
+ __asm__ __volatile__ ( "rdtime.d %0, %1" : "=r" (ret), "=r" (rid) );
+
+ return ret;
+}
+
+/************************/
/* POWER get_cycles() */
/************************/
--- papi-7.0.1.orig/src/mb.h
+++ papi-7.0.1/src/mb.h
@@ -39,6 +39,9 @@
#elif defined(__aarch64__)
#define rmb() asm volatile("dmb ld" ::: "memory")
+#elif defined(__loongarch64)
+#define rmb() __asm__ __volatile__("dbar 0" : : : "memory")
+
#elif defined(__mips__)
#define rmb() asm volatile( \
".set mips2\n\t" \
Reply to: