1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #define NO_PTR_DEMANGLE
- #include <setjmp.h>
- #include "pthread.h"
- #include "internals.h"
- #ifndef NO_PTR_DEMANGLE
- #include <jmpbuf-unwind.h>
- #define __JMPBUF_UNWINDS(a,b,c) _JMPBUF_UNWINDS(a,b,c)
- #else
- #define __JMPBUF_UNWINDS(a,b,c) _JMPBUF_UNWINDS(a,b)
- #endif
- #ifndef NO_PTR_DEMANGLE
- static __inline__ uintptr_t
- demangle_ptr (uintptr_t x)
- {
- #ifdef PTR_DEMANGLE
- PTR_DEMANGLE (x);
- #endif
- return x;
- }
- #else
- #define demangle_ptr(x) x
- #endif
- void __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
- {
- pthread_descr self = thread_self();
- struct _pthread_cleanup_buffer * c;
- for (c = THREAD_GETMEM(self, p_cleanup);
- c != NULL && __JMPBUF_UNWINDS(target, c, demangle_ptr);
- c = c->__prev)
- {
- #if _STACK_GROWS_DOWN
- if ((char *) c <= targetframe)
- {
- c = NULL;
- break;
- }
- #elif _STACK_GROWS_UP
- if ((char *) c >= targetframe)
- {
- c = NULL;
- break;
- }
- #else
- # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
- #endif
- c->__routine(c->__arg);
- }
- THREAD_SETMEM(self, p_cleanup, c);
- if (THREAD_GETMEM(self, p_in_sighandler)
- && __JMPBUF_UNWINDS(target, THREAD_GETMEM(self, p_in_sighandler),
- demangle_ptr))
- THREAD_SETMEM(self, p_in_sighandler, NULL);
- }
|