Back to index

glibc  2.9
Functions
sem_post.c File Reference
#include <errno.h>
#include <sysdep.h>
#include <lowlevellock.h>
#include <internaltypes.h>
#include <semaphore.h>
#include <shlib-compat.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int __new_sem_post (sem_t *sem)
 versioned_symbol (libpthread, __new_sem_post, sem_post, GLIBC_2_1)

Function Documentation

int __new_sem_post ( sem_t sem)

Definition at line 30 of file sem_post.c.

{
  struct new_sem *isem = (struct new_sem *) sem;

  __typeof (isem->value) cur;
  do
    {
      cur = isem->value;
      if (isem->value == SEM_VALUE_MAX)
       {
         __set_errno (EOVERFLOW);
         return -1;
       }
    }
  while (atomic_compare_and_exchange_bool_acq (&isem->value, cur + 1, cur));

  atomic_full_barrier ();
  if (isem->nwaiters > 0)
    {
      int err = lll_futex_wake (&isem->value, 1,
                            isem->private ^ FUTEX_PRIVATE_FLAG);
      if (__builtin_expect (err, 0) < 0)
       {
         __set_errno (-err);
         return -1;
       }
    }
  return 0;
}

Here is the call graph for this function:

versioned_symbol ( libpthread  ,
__new_sem_post  ,
sem_post  ,
GLIBC_2_1   
)