Back to index

glibc  2.9
ucontext.h
Go to the documentation of this file.
00001 /* Copyright (C) 1998, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef _SYS_UCONTEXT_H
00020 #define _SYS_UCONTEXT_H     1
00021 
00022 #include <features.h>
00023 #include <signal.h>
00024 
00025 #include <bits/sigcontext.h>
00026 
00027 /*
00028  * These are here mostly for backwards compatibility with older Unices.
00029  * IA-64 Linux does not distinguish between "struct sigcontext" and
00030  * "ucontext_t" as all the necessary info is inside the former.
00031  */
00032 
00033 typedef struct sigcontext mcontext_t;
00034 
00035 #if defined __cplusplus && __GNUC_PREREQ (3, 5)
00036 # define _SC_GR0_OFFSET     \
00037        __builtin_offsetof (struct sigcontext, sc_gr[0])
00038 #elif defined __GNUC__
00039 # define _SC_GR0_OFFSET     \
00040        (((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)
00041 #else
00042 # define _SC_GR0_OFFSET     0xc8   /* pray that this is correct... */
00043 #endif
00044 
00045 typedef struct ucontext
00046   {
00047     union
00048       {
00049        mcontext_t _mc;
00050        struct
00051          {
00052            unsigned long _pad[_SC_GR0_OFFSET/8];
00053            struct ucontext *_link; /* this should overlay sc_gr[0] */
00054          }
00055        _uc;
00056       }
00057     _u;
00058   }
00059 ucontext_t;
00060 
00061 #define uc_mcontext  _u._mc
00062 #define uc_sigmask   _u._mc.sc_mask
00063 #define uc_stack     _u._mc.sc_stack
00064 #define uc_link             _u._uc._link
00065 
00066 #endif /* sys/ucontext.h */