ucontext.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Copyright (C) 1998, 1999, 2002, 2004, 2005 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. /* We need the signal context definitions even if they are not used
  19. included in <signal.h>. */
  20. #include <bits/sigcontext.h>
  21. /* Number of general registers. */
  22. # define NGREG 48
  23. /* Container for all general registers. */
  24. typedef unsigned long gregset_t[NGREG];
  25. /* Container for floating-point registers and status */
  26. typedef struct _libc_fpstate
  27. {
  28. double fpregs[32];
  29. double fpscr;
  30. unsigned int _pad[2];
  31. } fpregset_t;
  32. /* Container for Altivec/VMX registers and status.
  33. Needs to be aligned on a 16-byte boundary. */
  34. typedef struct _libc_vrstate
  35. {
  36. unsigned int vrregs[32][4];
  37. unsigned int vrsave;
  38. unsigned int _pad[2];
  39. unsigned int vscr;
  40. } vrregset_t;
  41. /* Context to describe whole processor state. */
  42. typedef struct
  43. {
  44. gregset_t gregs;
  45. fpregset_t fpregs;
  46. vrregset_t vrregs __attribute__((__aligned__(16)));
  47. } mcontext_t;
  48. /* Userlevel context. */
  49. typedef struct ucontext
  50. {
  51. unsigned long int uc_flags;
  52. struct ucontext *uc_link;
  53. stack_t uc_stack;
  54. /*
  55. * These fields are set up this way to maximize source and
  56. * binary compatibility with code written for the old
  57. * ucontext_t definition, which didn't include space for the
  58. * registers.
  59. *
  60. * Different versions of the kernel have stored the registers on
  61. * signal delivery at different offsets from the ucontext struct.
  62. * Programs should thus use the uc_mcontext.uc_regs pointer to
  63. * find where the registers are actually stored. The registers
  64. * will be stored within the ucontext_t struct but not necessarily
  65. * at a fixed address. As a side-effect, this lets us achieve
  66. * 16-byte alignment for the register storage space if the
  67. * Altivec registers are to be saved, without requiring 16-byte
  68. * alignment on the whole ucontext_t.
  69. *
  70. * The uc_mcontext.regs field is included for source compatibility
  71. * with programs written against the older ucontext_t definition,
  72. * and its name should therefore not change. The uc_pad field
  73. * is for binary compatibility with programs compiled against the
  74. * old ucontext_t; it ensures that uc_mcontext.regs and uc_sigmask
  75. * are at the same offset as previously.
  76. */
  77. int uc_pad[7];
  78. union uc_regs_ptr {
  79. struct pt_regs *regs;
  80. mcontext_t *uc_regs;
  81. } uc_mcontext;
  82. sigset_t uc_sigmask;
  83. char uc_reg_space[sizeof(mcontext_t) + 12]; /* last for extensibility */
  84. } ucontext_t;
  85. #endif /* sys/ucontext.h */