Back to index

glibc  2.9
Functions
sem_init.c File Reference
#include <errno.h>
#include <semaphore.h>
#include <lowlevellock.h>
#include <shlib-compat.h>
#include "semaphoreP.h"
#include <kernel-features.h>

Go to the source code of this file.

Functions

int __new_sem_init (sem_t *sem, int pshared, unsigned int value)
 versioned_symbol (libpthread, __new_sem_init, sem_init, GLIBC_2_1)

Function Documentation

int __new_sem_init ( sem_t sem,
int  pshared,
unsigned int  value 
)

Definition at line 29 of file sem_init.c.

{
  /* Parameter sanity check.  */
  if (__builtin_expect (value > SEM_VALUE_MAX, 0))
    {
      __set_errno (EINVAL);
      return -1;
    }

  /* Map to the internal type.  */
  struct new_sem *isem = (struct new_sem *) sem;

  /* Use the values the user provided.  */
  isem->value = value;
#ifdef __ASSUME_PRIVATE_FUTEX
  isem->private = pshared ? 0 : FUTEX_PRIVATE_FLAG;
#else
  isem->private = pshared ? 0 : THREAD_GETMEM (THREAD_SELF,
                                          header.private_futex);
#endif

  isem->nwaiters = 0;

  return 0;
}
versioned_symbol ( libpthread  ,
__new_sem_init  ,
sem_init  ,
GLIBC_2_1   
)