Back to index

glibc  2.9
novmxsetjmp.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991-1999, 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 /* Copied from setjmp/setjmp.h, powerpc/bits/setjmp.h and modified
00020    appropriately to keep backward compatible with setjmp without
00021    AltiVec/VMX support.
00022 
00023    This file is not exported and the interfaces are private to libc.  */
00024 
00025 #ifndef       __NOVMX_SETJMP_H
00026 #define       __NOVMX_SETJMP_H     1
00027 
00028 #include <bits/wordsize.h>
00029 
00030 /* The following definitions are needed by ASM implementations of the old
00031    (novmx) __longjmp/__setjmp functions.  */
00032 
00033 # define JB_GPR1   0  /* Also known as the stack pointer */
00034 # define JB_GPR2   1
00035 # define JB_LR     2  /* The address we will return to */
00036 # if __WORDSIZE == 64
00037 #  define JB_GPRS   3  /* GPRs 14 through 31 are saved, 18*2 words total.  */
00038 #  define JB_CR     21 /* Condition code registers. */
00039 #  define JB_FPRS   22 /* FPRs 14 through 31 are saved, 18*2 words total.  */
00040 #  define JB_SIZE   (40 * 8)
00041 # else
00042 #  define JB_GPRS   3  /* GPRs 14 through 31 are saved, 18 in total.  */
00043 #  define JB_CR     21 /* Condition code registers.  */
00044 #  define JB_FPRS   22 /* FPRs 14 through 31 are saved, 18*2 words total.  */
00045 #  define JB_SIZE   (58 * 4)
00046 # endif
00047 
00048 #ifndef       _ASM
00049 /* The following definitions are needed by the novmx* implementations of
00050    setjmp/longjmp/sigsetjmp/etc that wrapper __setjmp/__longjmp.  */
00051 
00052 # if __WORDSIZE == 64
00053 typedef long int __jmp_buf[40];
00054 # else
00055 typedef long int __jmp_buf[58];
00056 # endif
00057 
00058 # include <bits/sigset.h>          /* Get `__sigset_t'.  */
00059 
00060 /* Calling environment, plus possibly a saved signal mask.  */
00061 typedef struct __novmx__jmp_buf_tag
00062   {
00063     /* NOTE: The machine-dependent definitions of `__sigsetjmp'
00064        assume that a `jmp_buf' begins with a `__jmp_buf' and that
00065        `__mask_was_saved' follows it.  Do not move these members
00066        or add others before it.  */
00067     __jmp_buf __jmpbuf;            /* Calling environment.  */
00068     int __mask_was_saved;   /* Saved the signal mask?  */
00069     __sigset_t __saved_mask;       /* Saved signal mask.  */
00070   } __novmx__jmp_buf[1];
00071 
00072 
00073 /* Store the calling environment in ENV, also saving the signal mask.
00074    Return 0.  */
00075 extern int __novmxsetjmp (__novmx__jmp_buf __env);
00076 
00077 /* Store the calling environment in ENV, also saving the
00078    signal mask if SAVEMASK is nonzero.  Return 0.
00079    This is the internal name for `sigsetjmp'.  */
00080 extern int __novmx__sigsetjmp (struct __novmx__jmp_buf_tag __env[1],
00081                             int __savemask);
00082 
00083 /* Store the calling environment in ENV, not saving the signal mask.
00084    Return 0.  */
00085 extern int __novmx_setjmp (struct __novmx__jmp_buf_tag __env[1]);
00086 
00087 /* Jump to the environment saved in ENV, making the
00088    `setjmp' call there return VAL, or 1 if VAL is 0.  */
00089 extern void __novmxlongjmp (struct __novmx__jmp_buf_tag __env[1], int __val)
00090      __attribute__ ((__noreturn__));
00091 
00092 /* Same.  Usually `_longjmp' is used with `_setjmp', which does not save
00093    the signal mask.  But it is how ENV was saved that determines whether
00094    `longjmp' restores the mask; `_longjmp' is just an alias.  */
00095 extern void __novmx_longjmp (struct __novmx__jmp_buf_tag __env[1], int __val)
00096      __attribute__ ((__noreturn__));
00097 
00098 /* Use the same type for `jmp_buf' and `sigjmp_buf'.
00099    The `__mask_was_saved' flag determines whether
00100    or not `longjmp' will restore the signal mask.  */
00101 typedef struct __novmx__jmp_buf_tag __novmx__sigjmp_buf[1];
00102 
00103 /* Jump to the environment saved in ENV, making the
00104    sigsetjmp call there return VAL, or 1 if VAL is 0.
00105    Restore the signal mask if that sigsetjmp call saved it.
00106    This is just an alias `longjmp'.  */
00107 extern void __novmxsiglongjmp (__novmx__sigjmp_buf __env, int __val)
00108      __attribute__ ((__noreturn__));
00109 
00110 /* Internal machine-dependent function to restore context sans signal mask.  */
00111 extern void __novmx__longjmp (__jmp_buf __env, int __val)
00112      __attribute__ ((__noreturn__));
00113 
00114 /* Internal function to possibly save the current mask of blocked signals
00115    in ENV, and always set the flag saying whether or not it was saved.
00116    This is used by the machine-dependent definition of `__sigsetjmp'.
00117    Always returns zero, for convenience.  */
00118 extern int __novmx__sigjmp_save (__novmx__jmp_buf __env, int __savemask);
00119 
00120 extern void _longjmp_unwind (__novmx__jmp_buf env, int val);
00121 
00122 extern void __novmx__libc_siglongjmp (__novmx__sigjmp_buf env, int val)
00123           __attribute__ ((noreturn));
00124 
00125 extern void __novmx__libc_longjmp (__novmx__sigjmp_buf env, int val)
00126      __attribute__ ((noreturn));
00127 
00128 libc_hidden_proto (__novmx__libc_longjmp)
00129 libc_hidden_proto (__novmx_setjmp)
00130 libc_hidden_proto (__novmx__sigsetjmp)
00131 #endif /* !_ASM */
00132 
00133 #endif