ucontext.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* struct ucontext definition, RISC-V version.
  2. Copyright (C) 1997-2018 Free Software Foundation, Inc.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library. If not, see
  13. <http://www.gnu.org/licenses/>. */
  14. /* Don't rely on this, the interface is currently messed up and may need to
  15. be broken to be fixed. */
  16. #ifndef _SYS_UCONTEXT_H
  17. #define _SYS_UCONTEXT_H 1
  18. #include <features.h>
  19. #include <signal.h>
  20. #include <bits/sigcontext.h>
  21. typedef unsigned long int __riscv_mc_gp_state[32];
  22. #ifdef __USE_MISC
  23. # define NGREG 32
  24. # define REG_PC 0
  25. # define REG_RA 1
  26. # define REG_SP 2
  27. # define REG_TP 4
  28. # define REG_S0 8
  29. # define REG_S1 9
  30. # define REG_A0 10
  31. # define REG_S2 18
  32. # define REG_NARGS 8
  33. typedef unsigned long int greg_t;
  34. /* Container for all general registers. */
  35. typedef __riscv_mc_gp_state gregset_t;
  36. /* Container for floating-point state. */
  37. typedef union __riscv_mc_fp_state fpregset_t;
  38. #endif
  39. struct __riscv_mc_f_ext_state
  40. {
  41. unsigned int __f[32];
  42. unsigned int __fcsr;
  43. };
  44. struct __riscv_mc_d_ext_state
  45. {
  46. unsigned long long int __f[32];
  47. unsigned int __fcsr;
  48. };
  49. struct __riscv_mc_q_ext_state
  50. {
  51. unsigned long long int __f[64] __attribute__ ((__aligned__ (16)));
  52. unsigned int __fcsr;
  53. /* Reserved for expansion of sigcontext structure. Currently zeroed
  54. upon signal, and must be zero upon sigreturn. */
  55. unsigned int __glibc_reserved[3];
  56. };
  57. union __riscv_mc_fp_state
  58. {
  59. struct __riscv_mc_f_ext_state __f;
  60. struct __riscv_mc_d_ext_state __d;
  61. struct __riscv_mc_q_ext_state __q;
  62. };
  63. typedef struct mcontext_t
  64. {
  65. __riscv_mc_gp_state __gregs;
  66. union __riscv_mc_fp_state __fpregs;
  67. } mcontext_t;
  68. /* Userlevel context. */
  69. typedef struct ucontext
  70. {
  71. unsigned long int __uc_flags;
  72. struct ucontext *uc_link;
  73. stack_t uc_stack;
  74. sigset_t uc_sigmask;
  75. /* There's some padding here to allow sigset_t to be expanded in the
  76. future. Though this is unlikely, other architectures put uc_sigmask
  77. at the end of this structure and explicitly state it can be
  78. expanded, so we didn't want to box ourselves in here. */
  79. char __glibc_reserved[1024 / 8 - sizeof (sigset_t)];
  80. /* We can't put uc_sigmask at the end of this structure because we need
  81. to be able to expand sigcontext in the future. For example, the
  82. vector ISA extension will almost certainly add ISA state. We want
  83. to ensure all user-visible ISA state can be saved and restored via a
  84. ucontext, so we're putting this at the end in order to allow for
  85. infinite extensibility. Since we know this will be extended and we
  86. assume sigset_t won't be extended an extreme amount, we're
  87. prioritizing this. */
  88. mcontext_t uc_mcontext;
  89. } ucontext_t;
  90. #endif /* sys/ucontext.h */