ucontext.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Copyright (C) 1998, 2000, 2001, 2002, 2004 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. #include <bits/sigcontext.h>
  19. /*
  20. * These are here mostly for backwards compatibility with older Unices.
  21. * IA-64 Linux does not distinguish between "struct sigcontext" and
  22. * "ucontext_t" as all the necessary info is inside the former.
  23. */
  24. typedef struct sigcontext mcontext_t;
  25. #if defined __cplusplus && __GNUC_PREREQ (3, 5)
  26. # define _SC_GR0_OFFSET \
  27. __builtin_offsetof (struct sigcontext, sc_gr[0])
  28. #elif defined __GNUC__
  29. # define _SC_GR0_OFFSET \
  30. (((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)
  31. #else
  32. # define _SC_GR0_OFFSET 0xc8 /* pray that this is correct... */
  33. #endif
  34. typedef struct ucontext
  35. {
  36. union
  37. {
  38. mcontext_t _mc;
  39. struct
  40. {
  41. unsigned long _pad[_SC_GR0_OFFSET/8];
  42. struct ucontext *_link; /* this should overlay sc_gr[0] */
  43. }
  44. _uc;
  45. }
  46. _u;
  47. }
  48. ucontext_t;
  49. #define uc_mcontext _u._mc
  50. #define uc_sigmask _u._mc.sc_mask
  51. #define uc_stack _u._mc.sc_stack
  52. #define uc_link _u._uc._link
  53. #endif /* sys/ucontext.h */