4.115
Last change
on this file since be1b8a7 was
9c743e8e,
checked in by Sebastian Huber <sebastian.huber@…>, on 07/18/13 at 11:50:25
|
posix: Create semaphore implementation header
Move implementation specific parts of semaphore.h and semaphore.inl into
new header file semaphoreimpl.h. The semaphore.h contains now only the
application visible API.
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Initializing of an Unnamed Semaphore |
---|
5 | * @ingroup POSIXAPI |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <stdarg.h> |
---|
22 | |
---|
23 | #include <errno.h> |
---|
24 | #include <fcntl.h> |
---|
25 | #include <pthread.h> |
---|
26 | #include <semaphore.h> |
---|
27 | #include <limits.h> |
---|
28 | |
---|
29 | #include <rtems/system.h> |
---|
30 | #include <rtems/score/object.h> |
---|
31 | #include <rtems/posix/semaphoreimpl.h> |
---|
32 | #include <rtems/posix/time.h> |
---|
33 | #include <rtems/seterr.h> |
---|
34 | |
---|
35 | /* |
---|
36 | * 11.2.1 Initialize an Unnamed Semaphore, P1003.1b-1993, p.219 |
---|
37 | */ |
---|
38 | |
---|
39 | int sem_init( |
---|
40 | sem_t *sem, |
---|
41 | int pshared, |
---|
42 | unsigned int value |
---|
43 | ) |
---|
44 | { |
---|
45 | int status; |
---|
46 | POSIX_Semaphore_Control *the_semaphore; |
---|
47 | |
---|
48 | if ( !sem ) |
---|
49 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
50 | |
---|
51 | status = _POSIX_Semaphore_Create_support( |
---|
52 | NULL, |
---|
53 | 0, |
---|
54 | pshared, |
---|
55 | value, |
---|
56 | &the_semaphore |
---|
57 | ); |
---|
58 | |
---|
59 | if ( status != -1 ) |
---|
60 | *sem = the_semaphore->Object.id; |
---|
61 | |
---|
62 | return status; |
---|
63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.