Skip to content

Commit

Permalink
Merge pull request #945 from no92/riscv-gcc-13
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke authored Nov 14, 2023
2 parents 3b38e03 + f1e550a commit 1826d46
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 39 deletions.
63 changes: 25 additions & 38 deletions abis/linux/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ typedef struct __stack {
#define REG_TRAPNO 20
#define REG_OLDMASK 21
#define REG_CR2 22
#define NGREG 23

struct sigevent {
union sigval sigev_value;
Expand All @@ -244,6 +243,8 @@ struct sigaction {

#if defined(__x86_64__)

#define NGREG 23

struct _fpreg {
unsigned short significand[4];
unsigned short exponent;
Expand Down Expand Up @@ -290,6 +291,23 @@ typedef struct __ucontext {
#elif defined(__riscv) && __riscv_xlen == 64
// Definitions from Linux kernel headers.

#define NGREG 32

enum {
REG_PC = 0,
#define REG_PC REG_PC
REG_RA = 1,
#define REG_RA REG_RA
REG_SP = 2,
#define REG_SP REG_SP
REG_TP = 4,
#define REG_TP REG_TP
REG_S0 = 8,
#define REG_S0 REG_S0
REG_A0 = 10,
#define REG_A0 REG_A0
};

struct __riscv_f_ext_state {
uint32_t f[32];
uint32_t fcsr;
Expand All @@ -312,44 +330,11 @@ union __riscv_fp_state {
struct __riscv_q_ext_state q;
};

struct __user_regs_struct {
unsigned long pc;
unsigned long ra;
unsigned long sp;
unsigned long gp;
unsigned long tp;
unsigned long t0;
unsigned long t1;
unsigned long t2;
unsigned long s0;
unsigned long s1;
unsigned long a0;
unsigned long a1;
unsigned long a2;
unsigned long a3;
unsigned long a4;
unsigned long a5;
unsigned long a6;
unsigned long a7;
unsigned long s2;
unsigned long s3;
unsigned long s4;
unsigned long s5;
unsigned long s6;
unsigned long s7;
unsigned long s8;
unsigned long s9;
unsigned long s10;
unsigned long s11;
unsigned long t3;
unsigned long t4;
unsigned long t5;
unsigned long t6;
};
typedef unsigned long __riscv_mc_gp_state[NGREG];

typedef struct __mcontext {
struct __user_regs_struct sc_regs;
union __riscv_fp_state sc_fpregs;
typedef struct sigcontext {
__riscv_mc_gp_state gregs;
union __riscv_fp_state fpregs;
} mcontext_t;

typedef struct __ucontext {
Expand All @@ -363,6 +348,8 @@ typedef struct __ucontext {

#elif defined (__aarch64__)

#define NGREG 34

typedef struct sigcontext {
uint64_t fault_address;
uint64_t regs[31];
Expand Down
2 changes: 1 addition & 1 deletion sysdeps/linux/generic/sysdeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ int sys_before_cancellable_syscall(ucontext_t *uct) {
#if defined(__x86_64__)
auto pc = reinterpret_cast<void*>(uct->uc_mcontext.gregs[REG_RIP]);
#elif defined(__riscv)
auto pc = reinterpret_cast<void*>(uct->uc_mcontext.sc_regs.pc);
auto pc = reinterpret_cast<void*>(uct->uc_mcontext.gregs[REG_PC]);
#elif defined(__aarch64__)
auto pc = reinterpret_cast<void*>(uct->uc_mcontext.pc);
#else
Expand Down

0 comments on commit 1826d46

Please sign in to comment.