diff options
author | Raymond Wong <infiwang@pm.me> | 2022-05-10 23:46:31 +0800 |
---|---|---|
committer | Jakov Smolić <jsmolic@gentoo.org> | 2022-05-10 19:20:15 +0200 |
commit | 72ac7a65fce9351185111a2b42573aa4636efe8c (patch) | |
tree | 6baa9a776b0abc20ded5b1a05928294b5179a7db /app-misc/reptyr | |
parent | net-mail/cyrus-imapd: drop back to ~ppc64 (diff) | |
download | gentoo-72ac7a65fce9351185111a2b42573aa4636efe8c.tar.gz gentoo-72ac7a65fce9351185111a2b42573aa4636efe8c.tar.bz2 gentoo-72ac7a65fce9351185111a2b42573aa4636efe8c.zip |
app-misc/reptyr: add riscv64 support
Patch is already done upstream, drop on next version bump.
Signed-off-by: Raymond Wong <infiwang@pm.me>
Signed-off-by: Jakov Smolić <jsmolic@gentoo.org>
Diffstat (limited to 'app-misc/reptyr')
-rw-r--r-- | app-misc/reptyr/files/reptyr-0.8.0-riscv64-support.patch | 115 | ||||
-rw-r--r-- | app-misc/reptyr/reptyr-0.8.0.ebuild | 5 |
2 files changed, 120 insertions, 0 deletions
diff --git a/app-misc/reptyr/files/reptyr-0.8.0-riscv64-support.patch b/app-misc/reptyr/files/reptyr-0.8.0-riscv64-support.patch new file mode 100644 index 000000000000..6cedd3a55c5d --- /dev/null +++ b/app-misc/reptyr/files/reptyr-0.8.0-riscv64-support.patch @@ -0,0 +1,115 @@ +Taken from https://github.com/nelhage/reptyr/commit/e26724cc1ae5fe7af0c9fb6369f6cf09d1d12900 + +From ae0b4ec014c1a01b1c3409e5404cf0fa0102c349 Mon Sep 17 00:00:00 2001 +From: Ast-x64 <Ast-x64@protonmail.com> +Date: Wed, 10 Nov 2021 09:39:45 +0800 +Subject: [PATCH] Support riscv64 on Linux. + +--- + platform/linux/arch/riscv64.h | 68 +++++++++++++++++++++++++++++++++++ + platform/linux/linux_ptrace.c | 2 ++ + ptrace.h | 3 ++ + 3 files changed, 73 insertions(+) + create mode 100644 platform/linux/arch/riscv64.h + +diff --git a/platform/linux/arch/riscv64.h b/platform/linux/arch/riscv64.h +new file mode 100644 +index 0000000..96221c3 +--- /dev/null ++++ b/platform/linux/arch/riscv64.h +@@ -0,0 +1,68 @@ ++/* ++ * Copyright (C) 2021 by Ast-x64 ++ * ++ * 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. ++ */ ++static struct ptrace_personality arch_personality[1] = { ++ { ++ offsetof(struct user_regs_struct, a0), ++ offsetof(struct user_regs_struct, a0), ++ offsetof(struct user_regs_struct, a1), ++ offsetof(struct user_regs_struct, a2), ++ offsetof(struct user_regs_struct, a3), ++ offsetof(struct user_regs_struct, a4), ++ offsetof(struct user_regs_struct, a5), ++ offsetof(struct user_regs_struct, pc), ++ } ++}; ++ ++static inline void arch_fixup_regs(struct ptrace_child *child) { ++ child->regs.pc -= 4; ++} ++ ++static inline int arch_set_syscall(struct ptrace_child *child, ++ unsigned long sysno) { ++ unsigned long x_reg[18]; ++ struct iovec reg_iovec = { ++ .iov_base = x_reg, ++ .iov_len = sizeof(x_reg) ++ }; ++ if (ptrace_command(child, PTRACE_GETREGSET, NT_PRSTATUS, ®_iovec) < 0) ++ return -1; ++ ++ x_reg[17] = sysno; ++ return ptrace_command(child, PTRACE_SETREGSET, NT_PRSTATUS, ®_iovec); ++} ++ ++static inline int arch_save_syscall(struct ptrace_child *child) { ++ unsigned long x_reg[18]; ++ struct iovec reg_iovec = { ++ .iov_base = x_reg, ++ .iov_len = sizeof(x_reg) ++ }; ++ if (ptrace_command(child, PTRACE_GETREGSET, NT_PRSTATUS, ®_iovec) < 0) ++ return -1; ++ ++ child->saved_syscall = x_reg[17]; ++ return 0; ++} ++ ++static inline int arch_restore_syscall(struct ptrace_child *child) { ++ return arch_set_syscall(child, child->saved_syscall); ++} +diff --git a/platform/linux/linux_ptrace.c b/platform/linux/linux_ptrace.c +index d065199..bcbe600 100644 +--- a/platform/linux/linux_ptrace.c ++++ b/platform/linux/linux_ptrace.c +@@ -84,6 +84,8 @@ static struct ptrace_personality *personality(struct ptrace_child *child); + #include "arch/aarch64.h" + #elif defined(__powerpc__) + #include "arch/powerpc.h" ++#elif defined(__riscv) && __riscv_xlen == 64 ++#include "arch/riscv64.h" + #else + #error Unsupported architecture. + #endif +diff --git a/ptrace.h b/ptrace.h +index ee05bd7..8e3a7f4 100644 +--- a/ptrace.h ++++ b/ptrace.h +@@ -25,6 +25,9 @@ + #ifdef __powerpc__ + #include <asm/ptrace.h> + #endif ++#ifdef __riscv ++#include <asm/ptrace.h> ++#endif + #include <sys/ptrace.h> + #include <sys/types.h> + #include <sys/user.h> diff --git a/app-misc/reptyr/reptyr-0.8.0.ebuild b/app-misc/reptyr/reptyr-0.8.0.ebuild index 960ac099ad2a..012379e3b3ed 100644 --- a/app-misc/reptyr/reptyr-0.8.0.ebuild +++ b/app-misc/reptyr/reptyr-0.8.0.ebuild @@ -15,6 +15,11 @@ KEYWORDS="amd64 ~arm ~arm64 ~ppc64 x86 ~amd64-linux ~x86-linux" RESTRICT="test" +PATCHES=( + # drop on next version bump + "${FILESDIR}"/${PN}-0.8.0-riscv64-support.patch +) + src_prepare() { default # respect CFLAGS |