summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/riscv32/sys/ucontext.h
blob: 2893ff3596171a645d9fd3bd8170a2f8f156540f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* struct ucontext definition, RISC-V version.
   Copyright (C) 1997-2018 Free Software Foundation, Inc.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library.  If not, see
   <http://www.gnu.org/licenses/>.  */

/* Don't rely on this, the interface is currently messed up and may need to
   be broken to be fixed.  */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H	1

#include <features.h>
#include <signal.h>
#include <bits/sigcontext.h>

typedef unsigned long int __riscv_mc_gp_state[32];

#ifdef __USE_MISC
# define NGREG	32

# define REG_PC 0
# define REG_RA 1
# define REG_SP 2
# define REG_TP 4
# define REG_S0 8
# define REG_S1 9
# define REG_A0 10
# define REG_S2 18
# define REG_NARGS 8

typedef unsigned long int greg_t;

/* Container for all general registers.  */
typedef __riscv_mc_gp_state gregset_t;

/* Container for floating-point state.  */
typedef union __riscv_mc_fp_state fpregset_t;
#endif

struct __riscv_mc_f_ext_state
  {
    unsigned int __f[32];
    unsigned int __fcsr;
  };

struct __riscv_mc_d_ext_state
  {
    unsigned long long int __f[32];
    unsigned int __fcsr;
  };

struct __riscv_mc_q_ext_state
  {
    unsigned long long int __f[64] __attribute__ ((__aligned__ (16)));
    unsigned int __fcsr;
    /* Reserved for expansion of sigcontext structure.  Currently zeroed
       upon signal, and must be zero upon sigreturn.  */
    unsigned int __glibc_reserved[3];
  };

union __riscv_mc_fp_state
  {
    struct __riscv_mc_f_ext_state __f;
    struct __riscv_mc_d_ext_state __d;
    struct __riscv_mc_q_ext_state __q;
  };

typedef struct mcontext_t
  {
    __riscv_mc_gp_state __gregs;
    union  __riscv_mc_fp_state __fpregs;
  } mcontext_t;

/* Userlevel context.  */
typedef struct ucontext_t
  {
    unsigned long int  __uc_flags;
    struct ucontext_t *uc_link;
    stack_t            uc_stack;
    sigset_t           uc_sigmask;
    /* There's some padding here to allow sigset_t to be expanded in the
       future.  Though this is unlikely, other architectures put uc_sigmask
       at the end of this structure and explicitly state it can be
       expanded, so we didn't want to box ourselves in here.  */
    char               __glibc_reserved[1024 / 8 - sizeof (sigset_t)];
    /* We can't put uc_sigmask at the end of this structure because we need
       to be able to expand sigcontext in the future.  For example, the
       vector ISA extension will almost certainly add ISA state.  We want
       to ensure all user-visible ISA state can be saved and restored via a
       ucontext, so we're putting this at the end in order to allow for
       infinite extensibility.  Since we know this will be extended and we
       assume sigset_t won't be extended an extreme amount, we're
       prioritizing this.  */
    mcontext_t uc_mcontext;
  } ucontext_t;

#endif /* sys/ucontext.h */