File:  [DVB] / dietlibc / libpthread / pthread_semaphore_init.c
Revision 1.1: download - view: text, annotated - select for diffs
Wed Sep 17 15:06:10 2003 UTC (20 years, 8 months ago) by sanjiyan
Branches: MAIN
CVS tags: HEAD
add the semaphore support.

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

#include <semaphore.h>
#include "thread_internal.h"

int sem_init(sem_t*sem,int pshared,unsigned int value) {
  pthread_mutexattr_t attr={PTHREAD_MUTEX_RECURSIVE_NP};

  if (value>SEM_VALUE_MAX) { _errno_=EINVAL; return -1; }
  if (pshared) { _errno_=ENOSYS; return -1; }

  pthread_mutex_init(&(sem->lock),&attr);
  pthread_cond_init(&(sem->cond),0);
  sem->value=value;
  sem->magic=SEM_MAGIC;
  return 0;
}


LinuxTV legacy CVS <linuxtv.org/cvs>