4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Unlock a Semaphore |
---|
5 | * @ingroup POSIX_SEMAPHORE |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
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.org/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/posix/semaphoreimpl.h> |
---|
31 | #include <rtems/posix/time.h> |
---|
32 | #include <rtems/seterr.h> |
---|
33 | |
---|
34 | int sem_post( |
---|
35 | sem_t *sem |
---|
36 | ) |
---|
37 | { |
---|
38 | POSIX_Semaphore_Control *the_semaphore; |
---|
39 | Objects_Locations location; |
---|
40 | ISR_lock_Context lock_context; |
---|
41 | |
---|
42 | the_semaphore = _POSIX_Semaphore_Get_interrupt_disable( |
---|
43 | sem, |
---|
44 | &location, |
---|
45 | &lock_context |
---|
46 | ); |
---|
47 | switch ( location ) { |
---|
48 | |
---|
49 | case OBJECTS_LOCAL: |
---|
50 | _CORE_semaphore_Surrender( |
---|
51 | &the_semaphore->Semaphore, |
---|
52 | the_semaphore->Object.id, |
---|
53 | #if defined(RTEMS_MULTIPROCESSING) |
---|
54 | NULL, /* POSIX Semaphores are local only */ |
---|
55 | #else |
---|
56 | NULL, |
---|
57 | #endif |
---|
58 | &lock_context |
---|
59 | ); |
---|
60 | return 0; |
---|
61 | |
---|
62 | #if defined(RTEMS_MULTIPROCESSING) |
---|
63 | case OBJECTS_REMOTE: |
---|
64 | #endif |
---|
65 | case OBJECTS_ERROR: |
---|
66 | break; |
---|
67 | } |
---|
68 | |
---|
69 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
70 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.