RTEMS CPU Kit with SuperCore  4.11.3
semaphoreimpl.h
Go to the documentation of this file.
1 
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>
25 
26 #include <errno.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
37 
41 extern const int
42  _POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1];
43 
50 
52  _POSIX_Semaphore_Allocate_unprotected( void )
53 {
54  return (POSIX_Semaphore_Control *)
55  _Objects_Allocate_unprotected( &_POSIX_Semaphore_Information );
56 }
57 
65  POSIX_Semaphore_Control *the_semaphore
66 )
67 {
68  _CORE_semaphore_Destroy( &the_semaphore->Semaphore );
69  _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object );
70 }
71 
84  sem_t *id,
85  Objects_Locations *location
86 )
87 {
88  return (POSIX_Semaphore_Control *)
89  _Objects_Get( &_POSIX_Semaphore_Information, (Objects_Id)*id, location );
90 }
91 
93 _POSIX_Semaphore_Get_interrupt_disable(
94  sem_t *id,
95  Objects_Locations *location,
96  ISR_lock_Context *lock_context
97 )
98 {
100  &_POSIX_Semaphore_Information,
101  (Objects_Id)*id,
102  location,
103  lock_context
104  );
105 }
106 
114  const char *name,
115  size_t name_len,
116  int pshared,
117  unsigned int value,
118  POSIX_Semaphore_Control **the_sem
119 );
120 
127  POSIX_Semaphore_Control *the_semaphore
128 );
129 
137  sem_t *sem,
138  bool blocking,
139  Watchdog_Interval timeout
140 );
141 
150  CORE_semaphore_Status the_semaphore_status
151 )
152 {
153  /*
154  * Internal consistency check for bad status from SuperCore
155  */
156  #if defined(RTEMS_DEBUG)
157  if ( the_semaphore_status > CORE_SEMAPHORE_STATUS_LAST )
158  return EINVAL;
159  #endif
160  return _POSIX_Semaphore_Return_codes[the_semaphore_status];
161 }
162 
167  POSIX_Semaphore_Control *the_semaphore
168 )
169 {
171  &_POSIX_Semaphore_Information, &the_semaphore->Object );
172 }
173 
178  const char *name,
179  Objects_Id *id,
180  size_t *len
181 )
182 {
183  return _POSIX_Name_to_id( &_POSIX_Semaphore_Information, name, id, len );
184 }
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif
191 /* end of include file */
int _POSIX_Semaphore_Wait_support(sem_t *sem, bool blocking, Watchdog_Interval timeout)
POSIX semaphore wait support.
Definition: semaphorewaitsupp.c:34
void _POSIX_Semaphore_Manager_initialization(void)
POSIX Semaphore Manager Initialization.
Definition: semaphore.c:45
void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectfree.c:25
Objects_Control * _Objects_Allocate_unprotected(Objects_Information *information)
Allocates an object without locking the allocator mutex.
Definition: objectallocate.c:39
RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * _POSIX_Semaphore_Get(sem_t *id, Objects_Locations *location)
POSIX Semaphore Get.
Definition: semaphoreimpl.h:83
POSIX API Implementation.
RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free(POSIX_Semaphore_Control *the_semaphore)
POSIX Semaphore Free.
Definition: semaphoreimpl.h:64
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
Definition: semaphore.h:43
#define CORE_SEMAPHORE_STATUS_LAST
Core semaphore last status value.
Definition: coresemimpl.h:68
CORE_semaphore_Status
Core Semaphore handler return statuses.
Definition: coresemimpl.h:40
Objects_Control * _Objects_Get(Objects_Information *information, Objects_Id id, Objects_Locations *location)
Maps object ids to object control blocks.
Definition: objectget.c:23
void _POSIX_Semaphore_Delete(POSIX_Semaphore_Control *the_semaphore)
POSIX Semaphore Delete.
Definition: semaphoredeletesupp.c:34
int _POSIX_Semaphore_Create_support(const char *name, size_t name_len, int pshared, unsigned int value, POSIX_Semaphore_Control **the_sem)
POSIX Semaphore Create Support.
Definition: semaphorecreatesupp.c:43
int _POSIX_Name_to_id(Objects_Information *information, const char *name, Objects_Id *id, size_t *len)
Queries the object identifier id for a name.
Definition: psxnametoid.c:30
The following defines the structure for the information used to manage each class of objects...
Definition: objectimpl.h:136
RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Name_to_id(const char *name, Objects_Id *id, size_t *len)
Definition: semaphoreimpl.h:177
Private Support Information for POSIX Semaphores.
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdog.h:47
RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove(POSIX_Semaphore_Control *the_semaphore)
POSIX Semaphore Namespace Remove.
Definition: semaphoreimpl.h:166
POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information
This defines the information control block used to manage this class of objects.
Definition: semaphoreimpl.h:36
Objects_Locations
This enumerated type lists the locations which may be returned by _Objects_Get.
Definition: objectimpl.h:117
RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Translate_core_semaphore_return_code(CORE_semaphore_Status the_semaphore_status)
POSIX Semaphore Translate Score to POSIX Return Codes.
Definition: semaphoreimpl.h:149
Inlined Routines Associated with the SuperCore Semaphore.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
uint32_t Objects_Id
The following type defines the control block used to manage object IDs.
Definition: object.h:122
Objects_Control * _Objects_Get_isr_disable(Objects_Information *information, Objects_Id id, Objects_Locations *location, ISR_lock_Context *lock_context)
Maps object ids to object control blocks.
Definition: objectgetisr.c:23
#define POSIX_EXTERN
The following ensures that all data is declared in the space of the initialization routine for either...
Definition: basedefs.h:123
void _Objects_Namespace_remove(Objects_Information *information, Objects_Control *the_object)
Removes object from namespace.
Definition: objectnamespaceremove.c:25