setjmp_i.h revision a369768c279654ae247643f81e0d2f6f7ddd4d15
1<<<<<<< .merge_file_NH3KvZ 2/* libunwind - a platform-independent unwind library 3 Copyright (C) 2003-2005 Hewlett-Packard Co 4 Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 5 6This file is part of libunwind. 7 8Permission is hereby granted, free of charge, to any person obtaining 9a copy of this software and associated documentation files (the 10"Software"), to deal in the Software without restriction, including 11without limitation the rights to use, copy, modify, merge, publish, 12distribute, sublicense, and/or sell copies of the Software, and to 13permit persons to whom the Software is furnished to do so, subject to 14the following conditions: 15 16The above copyright notice and this permission notice shall be 17included in all copies or substantial portions of the Software. 18 19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 26 27#if UNW_TARGET_IA64 28 29#include "libunwind_i.h" 30#include "tdep-ia64/rse.h" 31 32static inline int 33bsp_match (unw_cursor_t *c, unw_word_t *wp) 34{ 35 unw_word_t bsp, pfs, sol; 36 37 if (unw_get_reg (c, UNW_IA64_BSP, &bsp) < 0 38 || unw_get_reg (c, UNW_IA64_AR_PFS, &pfs) < 0) 39 abort (); 40 41 /* simulate the effect of "br.call sigsetjmp" on ar.bsp: */ 42 sol = (pfs >> 7) & 0x7f; 43 bsp = rse_skip_regs (bsp, sol); 44 45 if (bsp != wp[JB_BSP]) 46 return 0; 47 48 if (unlikely (sol == 0)) 49 { 50 unw_word_t sp, prev_sp; 51 unw_cursor_t tmp = *c; 52 53 /* The caller of {sig,}setjmp() cannot have a NULL-frame. If we 54 see a NULL-frame, we haven't reached the right target yet. 55 To have a NULL-frame, the number of locals must be zero and 56 the stack-frame must also be empty. */ 57 58 if (unw_step (&tmp) < 0) 59 abort (); 60 61 if (unw_get_reg (&tmp, UNW_REG_SP, &sp) < 0 62 || unw_get_reg (&tmp, UNW_REG_SP, &prev_sp) < 0) 63 abort (); 64 65 if (sp == prev_sp) 66 /* got a NULL-frame; keep looking... */ 67 return 0; 68 } 69 return 1; 70} 71 72/* On ia64 we cannot always call sigprocmask() at 73 _UI_siglongjmp_cont() because the signal may have switched stacks 74 and the old stack's register-backing store may have overflown, 75 leaving us no space to allocate the stacked registers needed to 76 call sigprocmask(). Fortunately, we can just let unw_resume() (via 77 sigreturn) take care of restoring the signal-mask. That's faster 78 anyhow. */ 79static inline int 80resume_restores_sigmask (unw_cursor_t *c, unw_word_t *wp) 81{ 82 unw_word_t sc_addr = ((struct cursor *) c)->sigcontext_addr; 83 struct sigcontext *sc = (struct sigcontext *) sc_addr; 84 sigset_t current_mask; 85 void *mp; 86 87 if (!sc_addr) 88 return 0; 89 90 /* let unw_resume() install the desired signal mask */ 91 92 if (wp[JB_MASK_SAVED]) 93 mp = &wp[JB_MASK]; 94 else 95 { 96 if (sigprocmask (SIG_BLOCK, NULL, ¤t_mask) < 0) 97 abort (); 98 mp = ¤t_mask; 99 } 100 memcpy (&sc->sc_mask, mp, sizeof (sc->sc_mask)); 101 return 1; 102} 103 104#else /* !UNW_TARGET_IA64 */ 105 106static inline int 107bsp_match (unw_cursor_t *c, unw_word_t *wp) 108{ 109 return 1; 110} 111 112static inline int 113resume_restores_sigmask (unw_cursor_t *c, unw_word_t *wp) 114{ 115 /* We may want to do this analogously as for ia64... */ 116 return 0; 117} 118 119#endif /* !UNW_TARGET_IA64 */ 120======= 121/* libunwind - a platform-independent unwind library 122 Copyright (C) 2003-2005 Hewlett-Packard Co 123 Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 124 125This file is part of libunwind. 126 127Permission is hereby granted, free of charge, to any person obtaining 128a copy of this software and associated documentation files (the 129"Software"), to deal in the Software without restriction, including 130without limitation the rights to use, copy, modify, merge, publish, 131distribute, sublicense, and/or sell copies of the Software, and to 132permit persons to whom the Software is furnished to do so, subject to 133the following conditions: 134 135The above copyright notice and this permission notice shall be 136included in all copies or substantial portions of the Software. 137 138THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 139EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 140MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 141NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 142LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 143OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 144WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 145 146#if UNW_TARGET_IA64 147 148#include "tdep.h" 149#include "ia64/rse.h" 150 151static inline int 152bsp_match (unw_cursor_t *c, unw_word_t *wp) 153{ 154 unw_word_t bsp, pfs, sol; 155 156 if (unw_get_reg (c, UNW_IA64_BSP, &bsp) < 0 157 || unw_get_reg (c, UNW_IA64_AR_PFS, &pfs) < 0) 158 abort (); 159 160 /* simulate the effect of "br.call sigsetjmp" on ar.bsp: */ 161 sol = (pfs >> 7) & 0x7f; 162 bsp = rse_skip_regs (bsp, sol); 163 164 if (bsp != wp[JB_BSP]) 165 return 0; 166 167 if (unlikely (sol == 0)) 168 { 169 unw_word_t sp, prev_sp; 170 unw_cursor_t tmp = *c; 171 172 /* The caller of {sig,}setjmp() cannot have a NULL-frame. If we 173 see a NULL-frame, we haven't reached the right target yet. 174 To have a NULL-frame, the number of locals must be zero and 175 the stack-frame must also be empty. */ 176 177 if (unw_step (&tmp) < 0) 178 abort (); 179 180 if (unw_get_reg (&tmp, UNW_REG_SP, &sp) < 0 181 || unw_get_reg (&tmp, UNW_REG_SP, &prev_sp) < 0) 182 abort (); 183 184 if (sp == prev_sp) 185 /* got a NULL-frame; keep looking... */ 186 return 0; 187 } 188 return 1; 189} 190 191/* On ia64 we cannot always call sigprocmask() at 192 _UI_siglongjmp_cont() because the signal may have switched stacks 193 and the old stack's register-backing store may have overflown, 194 leaving us no space to allocate the stacked registers needed to 195 call sigprocmask(). Fortunately, we can just let unw_resume() (via 196 sigreturn) take care of restoring the signal-mask. That's faster 197 anyhow. */ 198static inline int 199resume_restores_sigmask (unw_cursor_t *c, unw_word_t *wp) 200{ 201 unw_word_t sc_addr = ((struct cursor *) c)->sigcontext_addr; 202 struct sigcontext *sc = (struct sigcontext *) sc_addr; 203 sigset_t current_mask; 204 void *mp; 205 206 if (!sc_addr) 207 return 0; 208 209 /* let unw_resume() install the desired signal mask */ 210 211 if (wp[JB_MASK_SAVED]) 212 mp = &wp[JB_MASK]; 213 else 214 { 215 if (sigprocmask (SIG_BLOCK, NULL, ¤t_mask) < 0) 216 abort (); 217 mp = ¤t_mask; 218 } 219 memcpy (&sc->sc_mask, mp, sizeof (sc->sc_mask)); 220 return 1; 221} 222 223#else /* !UNW_TARGET_IA64 */ 224 225static inline int 226bsp_match (unw_cursor_t *c, unw_word_t *wp) 227{ 228 return 1; 229} 230 231static inline int 232resume_restores_sigmask (unw_cursor_t *c, unw_word_t *wp) 233{ 234 /* We may want to do this analogously as for ia64... */ 235 return 0; 236} 237 238#endif /* !UNW_TARGET_IA64 */ 239>>>>>>> .merge_file_F6t3ZY 240