ucontext.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. typedef unsigned long int __riscv_mc_gp_state[32];
  20. #ifdef __USE_MISC
  21. # define NGREG 32
  22. # define REG_PC 0
  23. # define REG_RA 1
  24. # define REG_SP 2
  25. # define REG_TP 4
  26. # define REG_S0 8
  27. # define REG_S1 9
  28. # define REG_A0 10
  29. # define REG_S2 18
  30. # define REG_NARGS 8
  31. typedef unsigned long int greg_t;
  32. /* Container for all general registers. */
  33. typedef __riscv_mc_gp_state gregset_t;
  34. /* Container for floating-point state. */
  35. typedef union __riscv_mc_fp_state fpregset_t;
  36. #endif
  37. struct __riscv_mc_f_ext_state
  38. {
  39. unsigned int __f[32];
  40. unsigned int __fcsr;
  41. };
  42. struct __riscv_mc_d_ext_state
  43. {
  44. unsigned long long int __f[32];
  45. unsigned int __fcsr;
  46. };
  47. struct __riscv_mc_q_ext_state
  48. {
  49. unsigned long long int __f[64] __attribute__ ((__aligned__ (16)));
  50. unsigned int __fcsr;
  51. /* Reserved for expansion of sigcontext structure. Currently zeroed
  52. upon signal, and must be zero upon sigreturn. */
  53. unsigned int __glibc_reserved[3];
  54. };
  55. union __riscv_mc_fp_state
  56. {
  57. struct __riscv_mc_f_ext_state __f;
  58. struct __riscv_mc_d_ext_state __d;
  59. struct __riscv_mc_q_ext_state __q;
  60. };
  61. typedef struct mcontext_t
  62. {
  63. __riscv_mc_gp_state __gregs;
  64. union __riscv_mc_fp_state __fpregs;
  65. } mcontext_t;
  66. /* Userlevel context. */
  67. typedef struct ucontext_t
  68. {
  69. unsigned long int __uc_flags;
  70. struct ucontext_t *uc_link;
  71. stack_t uc_stack;
  72. sigset_t uc_sigmask;
  73. /* There's some padding here to allow sigset_t to be expanded in the
  74. future. Though this is unlikely, other architectures put uc_sigmask
  75. at the end of this structure and explicitly state it can be
  76. expanded, so we didn't want to box ourselves in here. */
  77. char __glibc_reserved[1024 / 8 - sizeof (sigset_t)];
  78. /* We can't put uc_sigmask at the end of this structure because we need
  79. to be able to expand sigcontext in the future. For example, the
  80. vector ISA extension will almost certainly add ISA state. We want
  81. to ensure all user-visible ISA state can be saved and restored via a
  82. ucontext, so we're putting this at the end in order to allow for
  83. infinite extensibility. Since we know this will be extended and we
  84. assume sigset_t won't be extended an extreme amount, we're
  85. prioritizing this. */
  86. mcontext_t uc_mcontext;
  87. } ucontext_t;
  88. #endif /* sys/ucontext.h */