12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include <setjmp.h>
- #include "pthread.h"
- #include "internals.h"
- extern void __libc_siglongjmp (sigjmp_buf env, int val)
- __attribute__ ((noreturn));
- extern void __libc_longjmp (sigjmp_buf env, int val)
- __attribute__ ((noreturn));
- static void pthread_cleanup_upto(__jmp_buf target)
- {
- pthread_descr self = thread_self();
- struct _pthread_cleanup_buffer * c;
- for (c = THREAD_GETMEM(self, p_cleanup);
- c != NULL && _JMPBUF_UNWINDS(target, c);
- c = c->__prev)
- 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)))
- THREAD_SETMEM(self, p_in_sighandler, NULL);
- }
- void siglongjmp(sigjmp_buf env, int val)
- {
- pthread_cleanup_upto(env->__jmpbuf);
- __libc_siglongjmp(env, val);
- }
- void longjmp(jmp_buf env, int val)
- {
- pthread_cleanup_upto(env->__jmpbuf);
- __libc_siglongjmp(env, val);
- }
|