Back to index

glibc  2.9
Functions
cancellation.c File Reference
#include <setjmp.h>
#include <stdlib.h>
#include "pthreadP.h"

Go to the source code of this file.

Functions

int attribute_hidden __pthread_enable_asynccancel (void)
void internal_function
attribute_hidden 
__pthread_disable_asynccancel (int oldtype)

Function Documentation

Definition at line 65 of file cancellation.c.

{
  /* If asynchronous cancellation was enabled before we do not have
     anything to do.  */
  if (oldtype & CANCELTYPE_BITMASK)
    return;

  struct pthread *self = THREAD_SELF;
  int oldval = THREAD_GETMEM (self, cancelhandling);

  while (1)
    {
      int newval = oldval & ~CANCELTYPE_BITMASK;

      if (newval == oldval)
       break;

      int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
                                         oldval);
      if (__builtin_expect (curval == oldval, 1))
       break;

      /* Prepare the next round.  */
      oldval = curval;
    }
}

Definition at line 30 of file cancellation.c.

{
  struct pthread *self = THREAD_SELF;
  int oldval = THREAD_GETMEM (self, cancelhandling);

  while (1)
    {
      int newval = oldval | CANCELTYPE_BITMASK;

      if (newval == oldval)
       break;

      int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
                                         oldval);
      if (__builtin_expect (curval == oldval, 1))
       {
         if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
           {
             THREAD_SETMEM (self, result, PTHREAD_CANCELED);
             __do_cancel ();
           }

         break;
       }

      /* Prepare the next round.  */
      oldval = curval;
    }

  return oldval;
}

Here is the call graph for this function: