123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include <setjmp.h>
- #include <stdlib.h>
- #include "pthreadP.h"
- #include <jmpbuf-unwind.h>
- void
- __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
- {
- struct pthread *self = THREAD_SELF;
- struct _pthread_cleanup_buffer *cbuf;
-
- uintptr_t adj = (uintptr_t) self->stackblock + self->stackblock_size;
- uintptr_t targetframe_adj = (uintptr_t) targetframe - adj;
- for (cbuf = THREAD_GETMEM (self, cleanup);
- cbuf != NULL && _JMPBUF_UNWINDS_ADJ (target, cbuf, adj);
- cbuf = cbuf->__prev)
- {
- #ifdef _STACK_GROWS_DOWN
- if ((uintptr_t) cbuf - adj <= targetframe_adj)
- {
- cbuf = NULL;
- break;
- }
- #elif defined _STACK_GROWS_UP
- if ((uintptr_t) cbuf - adj >= targetframe_adj)
- {
- cbuf = NULL;
- break;
- }
- #else
- # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
- #endif
-
- cbuf->__routine (cbuf->__arg);
- }
- THREAD_SETMEM (self, cleanup, cbuf);
- }
- hidden_def (__pthread_cleanup_upto)
|