From d34ff01130ab4b9bcd1765bdd6ec24c61454d297 Mon Sep 17 00:00:00 2001 From: lichenggang Date: Tue, 17 Mar 2026 21:43:10 +0800 Subject: [PATCH] feat: Add sw64 architecture support --- debian/changelog | 10 +++++ .../Add-sw64-architecture-support.patch | 12 +++++ .../Fix-sigset-operations-for-sw64.patch | 44 +++++++++++++++++++ debian/patches/series | 2 + 4 files changed, 68 insertions(+) create mode 100644 debian/patches/Add-sw64-architecture-support.patch create mode 100644 debian/patches/Fix-sigset-operations-for-sw64.patch diff --git a/debian/changelog b/debian/changelog index de8ee0f..a07f94b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +libcap2 (1:2.75-10deepin1) unstable; urgency=medium + + * Add sw64 architecture support + - Add __sw64__ to psx/psx_calls.c architecture detection + - Fixes compilation error on sw64 systems: + "invalid operands to binary | (have 'sigset_t' and 'long unsigned int')" + - The sw64 (Sunway) architecture requires explicit handling of sigset_t + + -- lichenggang Tue, 17 Mar 2026 15:51:00 +0800 + libcap2 (1:2.75-10) unstable; urgency=medium * d/rules: Fix typo in override_dh_auto_clean diff --git a/debian/patches/Add-sw64-architecture-support.patch b/debian/patches/Add-sw64-architecture-support.patch new file mode 100644 index 0000000..97b191a --- /dev/null +++ b/debian/patches/Add-sw64-architecture-support.patch @@ -0,0 +1,12 @@ +--- libcap2-2.75.orig/psx/psx_calls.c ++++ libcap2-2.75/psx/psx_calls.c +@@ -48,7 +48,8 @@ + || defined(__mips__) || defined(__loongarch__) \ + || defined(__powerpc__) || defined(__s390__) || defined(__riscv) \ + || defined(__alpha__) || defined(__hppa__) || defined(__sh__) \ +- || defined(__m68k__) || defined(__sparc__) ++ || defined(__m68k__) || defined(__sparc__) \ ++ || defined(__sw64__) + + #undef _NSIG + #undef _NSIG_BPW diff --git a/debian/patches/Fix-sigset-operations-for-sw64.patch b/debian/patches/Fix-sigset-operations-for-sw64.patch new file mode 100644 index 0000000..096a9b2 --- /dev/null +++ b/debian/patches/Fix-sigset-operations-for-sw64.patch @@ -0,0 +1,44 @@ +Description: Fix sigset operations for sw64 architecture + On sw64 architecture, sigset_t is not a simple integer type and cannot + be manipulated using bitwise operations directly. Replace custom macros + with standard POSIX sigemptyset() and sigaddset() functions which are + portable across all architectures. +Author: Deepin Packages Builder +Forwarded: no +Last-Update: 2026-03-17 + +--- libcap2-2.75.orig/psx/psx_calls.c ++++ libcap2-2.75/psx/psx_calls.c +@@ -112,21 +112,6 @@ + #define _psx_rt_sigaction(sig, act, oact) \ + syscall(SYS_rt_sigaction, sig, act, oact, sizeof(sigset_t)) + +-#define _psx_sigemptyset(pmask) \ +- memset(pmask, 0, sizeof(*(pmask))) +- +-#ifdef _NSIG_WORDS +- +-#define _psx_sigaddset(pmask, signo) \ +- (pmask)->sig[(signo-1)/_NSIG_BPW] |= 1UL << (((signo-1)%_NSIG_BPW)) +- +-#else /* ndef _NSIG_WORDS */ +- +-#define _psx_sigaddset(pmask, signo) \ +- *(pmask) |= 1UL << (signo-1) +- +-#endif /* def _NSIG_WORDS */ +- + #ifdef SA_RESTORER + /* + * Actual assembly code for this "function" is embedded in +@@ -246,8 +231,8 @@ + /* + * Block interrupts while potentially rewriting the handler. + */ +- _psx_sigemptyset(&mask); +- _psx_sigaddset(&mask, psx_tracker.psx_sig); ++ sigemptyset(&mask); ++ sigaddset(&mask, psx_tracker.psx_sig); + _psx_rt_sigprocmask(SIG_BLOCK, &mask, &orig); + _psx_rt_sigaction(psx_tracker.psx_sig, NULL, &existing_sa); + if (existing_sa.sa_handler != (void *) &psx_posix_syscall_actor) { diff --git a/debian/patches/series b/debian/patches/series index 3ccf067..0fa869e 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -5,3 +5,5 @@ Glibc-needs-a-constant-to-be-defined-for-puts-to-work.patch Add-support-for-some-less-mainstream-architectures.patch Extend-support-further-to-__m68k__-and-possibly-__sparc__.patch Be-more-systematic-using-the-kernel-signal-handler-APIs.patch +Add-sw64-architecture-support.patch +Fix-sigset-operations-for-sw64.patch