ucontext.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (C) 1998-2021 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. <https://www.gnu.org/licenses/>. */
  14. /* System V/AArch64 ABI compliant context switching support. */
  15. #ifndef _SYS_UCONTEXT_H
  16. #define _SYS_UCONTEXT_H 1
  17. #include <features.h>
  18. #include <bits/types/sigset_t.h>
  19. #include <bits/types/stack_t.h>
  20. #ifdef __USE_MISC
  21. # define __ctx(fld) fld
  22. #else
  23. # define __ctx(fld) __ ## fld
  24. #endif
  25. #ifdef __USE_MISC
  26. # include <sys/procfs.h>
  27. typedef elf_greg_t greg_t;
  28. /* Container for all general registers. */
  29. typedef elf_gregset_t gregset_t;
  30. /* Structure to describe FPU registers. */
  31. typedef elf_fpregset_t fpregset_t;
  32. #endif
  33. /* Context to describe whole processor state. This only describes
  34. the core registers; coprocessor registers get saved elsewhere
  35. (e.g. in uc_regspace, or somewhere unspecified on the stack
  36. during non-RT signal handlers). */
  37. typedef struct
  38. {
  39. unsigned long long int __ctx(fault_address);
  40. unsigned long long int __ctx(regs)[31];
  41. unsigned long long int __ctx(sp);
  42. unsigned long long int __ctx(pc);
  43. unsigned long long int __ctx(pstate);
  44. /* This field contains extension records for additional processor
  45. state such as the FP/SIMD state. It has to match the definition
  46. of the corresponding field in the sigcontext struct, see the
  47. arch/arm64/include/uapi/asm/sigcontext.h linux header for details. */
  48. unsigned char __reserved[4096] __attribute__ ((__aligned__ (16)));
  49. } mcontext_t;
  50. /* Userlevel context. */
  51. typedef struct ucontext_t
  52. {
  53. unsigned long __ctx(uc_flags);
  54. struct ucontext_t *uc_link;
  55. stack_t uc_stack;
  56. sigset_t uc_sigmask;
  57. mcontext_t uc_mcontext;
  58. } ucontext_t;
  59. #undef __ctx
  60. #endif /* sys/ucontext.h */