ucontext.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  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. #ifndef _SYS_UCONTEXT_H
  15. #define _SYS_UCONTEXT_H 1
  16. #include <features.h>
  17. #include <signal.h>
  18. /*
  19. * Location of the users' stored registers relative to R0.
  20. * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
  21. */
  22. #define REG_PSR (0)
  23. #define REG_PC (1)
  24. #define REG_SPARE (2)
  25. #define REG_WVALID (3)
  26. #define REG_G1 (4)
  27. #define REG_G2 (5)
  28. #define REG_G3 (6)
  29. #define REG_G4 (7)
  30. #define REG_G5 (8)
  31. #define REG_G6 (9)
  32. #define REG_G7 (10)
  33. #define REG_O0 (11)
  34. #define REG_O1 (12)
  35. #define REG_O2 (13)
  36. #define REG_O3 (14)
  37. #define REG_O4 (15)
  38. #define REG_O5 (16)
  39. #define REG_O6 (17)
  40. #define REG_O7 (18)
  41. #define REG_GLOBALS (19)
  42. /*
  43. * A gregset_t is defined as an array type for compatibility with the reference
  44. * source. This is important due to differences in the way the C language
  45. * treats arrays and structures as parameters.
  46. *
  47. * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
  48. * but that the ABI defines it absolutely to be 21 (resp. 19).
  49. */
  50. #define NGREG 20
  51. typedef int greg_t;
  52. typedef greg_t gregset_t[NGREG];
  53. /*
  54. * The following structures define how a register window can appear on the
  55. * stack. This structure is available (when required) through the `gwins'
  56. * field of an mcontext (nested within ucontext). NIOS_MAXWINDOW is the
  57. * maximum number of outstanding register windows defined in the NIOS
  58. * architecture (*not* implementation).
  59. */
  60. #define NIOS_MAXREGWINDOW 31 /* max windows in NIOS arch. */
  61. struct rwindow
  62. {
  63. greg_t rw_local[8]; /* locals */
  64. greg_t rw_in[8]; /* ins */
  65. };
  66. #define rw_fp rw_in[6] /* frame pointer */
  67. #define rw_rtn rw_in[7] /* return address */
  68. typedef struct gwindows
  69. {
  70. int wbcnt;
  71. int *spbuf[NIOS_MAXREGWINDOW];
  72. struct rwindow wbuf[NIOS_MAXREGWINDOW];
  73. } gwindows_t;
  74. typedef struct
  75. {
  76. gregset_t gregs; /* general register set */
  77. gwindows_t *gwins; /* POSSIBLE pointer to register windows */
  78. } mcontext_t;
  79. /* Userlevel context. */
  80. typedef struct ucontext
  81. {
  82. unsigned long uc_flags;
  83. struct ucontext *uc_link;
  84. __sigset_t uc_sigmask;
  85. stack_t uc_stack;
  86. mcontext_t uc_mcontext;
  87. } ucontext_t;
  88. #endif /* sys/ucontext.h */