1 /*
2  * This file is subject to the terms and conditions of the LGPL V2.1
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2019 Kalray Inc.
7  */
8 
9 #include <setjmp.h>
10 #include <jmpbuf-offsets.h>
11 
12 /* Test if longjmp to JMPBUF would unwind the frame
13    containing a local variable at ADDRESS.  */
14 #if __WORDSIZE == 64
15 # define _JMPBUF_UNWINDS(jmpbuf, address) \
16   ((void *) (address) < (void *) (jmpbuf)[JB_R12])
17 #else
18 #error 32-bit unsupported
19 #endif
20 
21 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
22 #include <stdint.h>
23 #include <unwind.h>
24 
25 #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
26   _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
27 
28 #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
29   ((uintptr_t) (_address) - (_adj) < (uintptr_t) _jmpbuf_sp(_jmpbuf) - (_adj))
30 #endif
31