1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Private Inlined Routines for POSIX Semaphores |
---|
5 | * |
---|
6 | * This include file contains the static inline implementation of the private |
---|
7 | * inlined routines for POSIX Semaphores. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2013. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_POSIX_SEMAPHOREIMPL_H |
---|
20 | #define _RTEMS_POSIX_SEMAPHOREIMPL_H |
---|
21 | |
---|
22 | #include <rtems/posix/semaphore.h> |
---|
23 | #include <rtems/posix/posixapi.h> |
---|
24 | #include <rtems/score/coresemimpl.h> |
---|
25 | #include <rtems/seterr.h> |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif |
---|
30 | |
---|
31 | /** |
---|
32 | * This defines the information control block used to manage |
---|
33 | * this class of objects. |
---|
34 | */ |
---|
35 | extern Objects_Information _POSIX_Semaphore_Information; |
---|
36 | |
---|
37 | RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * |
---|
38 | _POSIX_Semaphore_Allocate_unprotected( void ) |
---|
39 | { |
---|
40 | return (POSIX_Semaphore_Control *) |
---|
41 | _Objects_Allocate_unprotected( &_POSIX_Semaphore_Information ); |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * @brief POSIX Semaphore Free |
---|
46 | * |
---|
47 | * This routine frees a semaphore control block to the |
---|
48 | * inactive chain of free semaphore control blocks. |
---|
49 | */ |
---|
50 | RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( |
---|
51 | POSIX_Semaphore_Control *the_semaphore |
---|
52 | ) |
---|
53 | { |
---|
54 | _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object ); |
---|
55 | } |
---|
56 | |
---|
57 | RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get( |
---|
58 | const sem_t *id, |
---|
59 | Thread_queue_Context *queue_context |
---|
60 | ) |
---|
61 | { |
---|
62 | _Thread_queue_Context_initialize( queue_context, NULL ); |
---|
63 | return (POSIX_Semaphore_Control *) _Objects_Get( |
---|
64 | (Objects_Id) *id, |
---|
65 | &queue_context->Lock_context, |
---|
66 | &_POSIX_Semaphore_Information |
---|
67 | ); |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * @brief POSIX Semaphore Create Support |
---|
72 | * |
---|
73 | * This routine supports the sem_init and sem_open routines. |
---|
74 | */ |
---|
75 | |
---|
76 | int _POSIX_Semaphore_Create_support( |
---|
77 | const char *name, |
---|
78 | size_t name_len, |
---|
79 | int pshared, |
---|
80 | unsigned int value, |
---|
81 | POSIX_Semaphore_Control **the_sem |
---|
82 | ); |
---|
83 | |
---|
84 | /** |
---|
85 | * @brief POSIX Semaphore Delete |
---|
86 | * |
---|
87 | * This routine supports the sem_close and sem_unlink routines. |
---|
88 | */ |
---|
89 | void _POSIX_Semaphore_Delete( |
---|
90 | POSIX_Semaphore_Control *the_semaphore, |
---|
91 | Thread_queue_Context *queue_context |
---|
92 | ); |
---|
93 | |
---|
94 | /** |
---|
95 | * @brief POSIX semaphore wait support. |
---|
96 | * |
---|
97 | * This routine supports the sem_wait, sem_trywait, and sem_timedwait |
---|
98 | * services. |
---|
99 | */ |
---|
100 | int _POSIX_Semaphore_Wait_support( |
---|
101 | sem_t *sem, |
---|
102 | bool blocking, |
---|
103 | Watchdog_Interval timeout |
---|
104 | ); |
---|
105 | |
---|
106 | /** |
---|
107 | * @brief POSIX Semaphore Namespace Remove |
---|
108 | */ |
---|
109 | RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove ( |
---|
110 | POSIX_Semaphore_Control *the_semaphore |
---|
111 | ) |
---|
112 | { |
---|
113 | _Objects_Namespace_remove( |
---|
114 | &_POSIX_Semaphore_Information, &the_semaphore->Object ); |
---|
115 | } |
---|
116 | |
---|
117 | RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name( |
---|
118 | const char *name, |
---|
119 | size_t *name_length_p, |
---|
120 | Objects_Get_by_name_error *error |
---|
121 | ) |
---|
122 | { |
---|
123 | return (POSIX_Semaphore_Control *) _Objects_Get_by_name( |
---|
124 | &_POSIX_Semaphore_Information, |
---|
125 | name, |
---|
126 | name_length_p, |
---|
127 | error |
---|
128 | ); |
---|
129 | } |
---|
130 | |
---|
131 | #ifdef __cplusplus |
---|
132 | } |
---|
133 | #endif |
---|
134 | |
---|
135 | #endif |
---|
136 | /* end of include file */ |
---|