提交 ab3eb89a 编写于 作者: R Rich Felker

fix riscv64 signal.h namespace violations and ucontext API mismatches

the top-level mcontext_t member names were namespace-violating in
standards profiles before, and nested-level member names (some of them
single-letter) were egregiously bad namespace impositions even in
non-strict profiles. moreover, they mismatched those used in the
public API first defined in glibc, breaking any code making use of
them.

unlike most archs, the public API used in glibc for riscv mcontext_t
members was designed to be namespace-safe, so we can and should expose
the members regardless of feature test macros. only the typedefs for
greg_t, gregset_t, and fpregset_t need to be protected behind FTMs.

the struct tags for mcontext_t and ucontext_t are also changed. for
mcontext_t this is necessary to make the common definition across
profiles namespace-safe. for ucontext_t, it's just a matter of
matching the tag from the glibc-defined API.

these changes are split off and expanded from a patch by Khem Raj.
上级 33bc7f05
...@@ -6,47 +6,40 @@ ...@@ -6,47 +6,40 @@
# define SIGSTKSZ 8192 # define SIGSTKSZ 8192
#endif #endif
/* gregs[0] holds the program counter. */
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
typedef unsigned long greg_t; typedef unsigned long greg_t;
typedef unsigned long gregset_t[32]; typedef unsigned long gregset_t[32];
typedef union __riscv_mc_fp_state fpregset_t;
#endif
typedef unsigned long __riscv_mc_gp_state[32];
struct __riscv_mc_f_ext_state { struct __riscv_mc_f_ext_state {
unsigned int f[32]; unsigned int __f[32];
unsigned int fcsr; unsigned int __fcsr;
}; };
struct __riscv_mc_d_ext_state { struct __riscv_mc_d_ext_state {
unsigned long long f[32]; unsigned long long __f[32];
unsigned int fcsr; unsigned int __fcsr;
}; };
struct __riscv_mc_q_ext_state { struct __riscv_mc_q_ext_state {
unsigned long long f[64] __attribute__((aligned(16))); unsigned long long __f[64] __attribute__((aligned(16)));
unsigned int fcsr; unsigned int __fcsr;
unsigned int reserved[3]; unsigned int __reserved[3];
}; };
union __riscv_mc_fp_state { union __riscv_mc_fp_state {
struct __riscv_mc_f_ext_state f; struct __riscv_mc_f_ext_state __f;
struct __riscv_mc_d_ext_state d; struct __riscv_mc_d_ext_state __d;
struct __riscv_mc_q_ext_state q; struct __riscv_mc_q_ext_state __q;
}; };
typedef union __riscv_mc_fp_state fpregset_t; typedef struct mcontext_t {
__riscv_mc_gp_state __gregs;
typedef struct sigcontext { union __riscv_mc_fp_state __fpregs;
gregset_t gregs;
fpregset_t fpregs;
} mcontext_t;
#else
typedef struct {
unsigned long gregs[32];
unsigned long long fpregs[66];
} mcontext_t; } mcontext_t;
#endif
struct sigaltstack { struct sigaltstack {
void *ss_sp; void *ss_sp;
...@@ -54,10 +47,10 @@ struct sigaltstack { ...@@ -54,10 +47,10 @@ struct sigaltstack {
size_t ss_size; size_t ss_size;
}; };
typedef struct __ucontext typedef struct ucontext_t
{ {
unsigned long uc_flags; unsigned long uc_flags;
struct __ucontext *uc_link; struct ucontext_t *uc_link;
stack_t uc_stack; stack_t uc_stack;
sigset_t uc_sigmask; sigset_t uc_sigmask;
mcontext_t uc_mcontext; mcontext_t uc_mcontext;
......
...@@ -11,4 +11,4 @@ static inline struct pthread *__pthread_self() ...@@ -11,4 +11,4 @@ static inline struct pthread *__pthread_self()
#define DTP_OFFSET 0x800 #define DTP_OFFSET 0x800
#define MC_PC gregs[0] #define MC_PC __gregs[0]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册