ucontext.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _SYS_UCONTEXT_H
  16. #define _SYS_UCONTEXT_H 1
  17. #include <features.h>
  18. #include <signal.h>
  19. #include <bits/sigcontext.h>
  20. /*
  21. * These are here mostly for backwards compatibility with older Unices.
  22. * IA-64 Linux does not distinguish between "struct sigcontext" and
  23. * "ucontext_t" as all the necessary info is inside the former.
  24. */
  25. typedef struct sigcontext mcontext_t;
  26. #if defined __cplusplus && __GNUC_PREREQ (3, 5)
  27. # define _SC_GR0_OFFSET \
  28. __builtin_offsetof (struct sigcontext, sc_gr[0])
  29. #elif defined __GNUC__
  30. # define _SC_GR0_OFFSET \
  31. (((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)
  32. #else
  33. # define _SC_GR0_OFFSET 0xc8 /* pray that this is correct... */
  34. #endif
  35. typedef struct ucontext
  36. {
  37. union
  38. {
  39. mcontext_t _mc;
  40. struct
  41. {
  42. unsigned long _pad[_SC_GR0_OFFSET/8];
  43. struct ucontext *_link; /* this should overlay sc_gr[0] */
  44. }
  45. _uc;
  46. }
  47. _u;
  48. }
  49. ucontext_t;
  50. #define uc_mcontext _u._mc
  51. #define uc_sigmask _u._mc.sc_mask
  52. #define uc_stack _u._mc.sc_stack
  53. #define uc_link _u._uc._link
  54. #endif /* sys/ucontext.h */