Back to index

glibc  2.9
Functions
pt-cleanup.c File Reference
#include <setjmp.h>
#include <stdlib.h>
#include "pthreadP.h"
#include <jmpbuf-unwind.h>

Go to the source code of this file.

Functions

void __pthread_cleanup_upto (__jmp_buf target, char *targetframe)

Function Documentation

void __pthread_cleanup_upto ( __jmp_buf  target,
char *  targetframe 
)

Definition at line 26 of file pt-cleanup.c.

{
  struct pthread *self = THREAD_SELF;
  struct _pthread_cleanup_buffer *cbuf;

  /* Adjust all pointers used in comparisons, so that top of thread's
     stack is at the top of address space.  Without that, things break
     if stack is allocated above the main stack.  */
  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)
    {
#if _STACK_GROWS_DOWN
      if ((uintptr_t) cbuf - adj <= targetframe_adj)
        {
          cbuf = NULL;
          break;
        }
#elif _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

      /* Call the cleanup code.  */
      cbuf->__routine (cbuf->__arg);
    }

  THREAD_SETMEM (self, cleanup, cbuf);
}

Here is the call graph for this function:

Here is the caller graph for this function: