riscv64: more <sys/ucontext.h>.

Actually, we don't want to reuse the kernel struct ucontext because its
uc_mcontext has the wrong type, which means the fields within that end
up with the wrong names. Add the call site that made that evident, and
update <sys/ucontext.h> appropriately.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: If1d079afef0d5953aa22d9b0e049cfb0119c7718
diff --git a/libc/include/sys/ucontext.h b/libc/include/sys/ucontext.h
index b000914..68b218e 100644
--- a/libc/include/sys/ucontext.h
+++ b/libc/include/sys/ucontext.h
@@ -320,6 +320,7 @@
 #define REG_RA 1
 #define REG_SP 2
 #define REG_TP 4
+#define REG_A0 10
 
 typedef unsigned long __riscv_mc_gp_state[NGREG];
 
@@ -358,8 +359,17 @@
   union __riscv_mc_fp_state __fpregs;
 } mcontext_t;
 
-#include <asm/ucontext.h>
-typedef struct ucontext ucontext_t;
+/* This matches the kernel <asm/ucontext.h> but using mcontext_t. */
+
+typedef struct ucontext_t {
+  unsigned long uc_flags;
+  struct ucontext_t* uc_link;
+  stack_t uc_stack;
+  sigset_t uc_sigmask;
+  /* The kernel adds extra padding here to allow sigset_t to grow. */
+  char __padding[128 - sizeof(sigset_t)];
+  mcontext_t uc_mcontext;
+} ucontext_t;
 
 #endif