source: rtems/cpukit/posix/src/seminit.c @ c38f5f16

4.104.114.84.95
Last change on this file since c38f5f16 was c38f5f16, checked in by Jennifer Averett <Jennifer.Averett@…>, on Nov 18, 1999 at 7:55:28 PM

Added EINVAL for passing a NULL pointer in.

  • Property mode set to 100644
File size: 801 bytes
Line 
1/*
2 *  $Id$
3 */
4
5#include <stdarg.h>
6
7#include <errno.h>
8#include <fcntl.h>
9#include <pthread.h>
10#include <semaphore.h>
11#include <limits.h>
12
13#include <rtems/system.h>
14#include <rtems/score/object.h>
15#include <rtems/posix/semaphore.h>
16#include <rtems/posix/time.h>
17#include <rtems/posix/seterr.h>
18
19/*PAGE
20 *
21 *  11.2.1 Initialize an Unnamed Semaphore, P1003.1b-1993, p.219
22 */
23
24int sem_init(
25  sem_t         *sem,
26  int            pshared,
27  unsigned int   value
28)
29{
30  int                        status;
31  POSIX_Semaphore_Control   *the_semaphore;
32
33  if ( !*sem )
34    set_errno_and_return_minus_one( EINVAL );
35   
36
37  status = _POSIX_Semaphore_Create_support(
38    NULL,
39    pshared,
40    value,
41    &the_semaphore
42  );
43   
44  if ( status != -1 )
45    *sem = the_semaphore->Object.id;
46
47  return status;
48}
Note: See TracBrowser for help on using the repository browser.