|
RTEMS CPU Kit with SuperCore
4.10.99.0
|
00001 00010 /* 00011 * COPYRIGHT (c) 1989-2011. 00012 * On-Line Applications Research Corporation (OAR). 00013 * 00014 * The license and distribution terms for this file may be 00015 * found in the file LICENSE in this distribution or at 00016 * http://www.rtems.com/license/LICENSE. 00017 */ 00018 00019 #ifndef _RTEMS_POSIX_SEMAPHORE_H 00020 #define _RTEMS_POSIX_SEMAPHORE_H 00021 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 #include <semaphore.h> 00036 #include <rtems/score/coresem.h> 00037 #include <rtems/posix/posixapi.h> 00038 00039 /* 00040 * Data Structure used to manage a POSIX semaphore 00041 */ 00042 00043 typedef struct { 00044 Objects_Control Object; 00045 int process_shared; 00046 bool named; 00047 bool linked; 00048 uint32_t open_count; 00049 CORE_semaphore_Control Semaphore; 00050 /* 00051 * sem_t is 32-bit. If Object_Id is 16-bit, then they are not 00052 * interchangeable. We have to be able to return a pointer to 00053 * a 32-bit form of the 16-bit Id. 00054 */ 00055 #if defined(RTEMS_USE_16_BIT_OBJECT) 00056 sem_t Semaphore_id; 00057 #endif 00058 } POSIX_Semaphore_Control; 00059 00060 /* 00061 * The following defines the information control block used to manage 00062 * this class of objects. 00063 */ 00064 00065 POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information; 00066 00067 /* 00068 * _POSIX_Semaphore_Manager_initialization 00069 * 00070 * DESCRIPTION: 00071 * 00072 * This routine performs the initialization necessary for this manager. 00073 */ 00074 00075 void _POSIX_Semaphore_Manager_initialization(void); 00076 00077 /* 00078 * _POSIX_Semaphore_Allocate 00079 * 00080 * DESCRIPTION: 00081 * 00082 * This function allocates a semaphore control block from 00083 * the inactive chain of free semaphore control blocks. 00084 */ 00085 00086 RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void ); 00087 00088 /* 00089 * _POSIX_Semaphore_Free 00090 * 00091 * DESCRIPTION: 00092 * 00093 * This routine frees a semaphore control block to the 00094 * inactive chain of free semaphore control blocks. 00095 */ 00096 00097 RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( 00098 POSIX_Semaphore_Control *the_semaphore 00099 ); 00100 00101 /* 00102 * _POSIX_Semaphore_Get 00103 * 00104 * DESCRIPTION: 00105 * 00106 * This function maps semaphore IDs to semaphore control blocks. 00107 * If ID corresponds to a local semaphore, then it returns 00108 * the_semaphore control pointer which maps to ID and location 00109 * is set to OBJECTS_LOCAL. if the semaphore ID is global and 00110 * resides on a remote node, then location is set to OBJECTS_REMOTE, 00111 * and the_semaphore is undefined. Otherwise, location is set 00112 * to OBJECTS_ERROR and the_semaphore is undefined. 00113 */ 00114 00115 RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get ( 00116 sem_t *id, 00117 Objects_Locations *location 00118 ); 00119 00120 /* 00121 * _POSIX_Semaphore_Is_null 00122 * 00123 * DESCRIPTION: 00124 * 00125 * This function returns TRUE if the_semaphore is NULL and FALSE otherwise. 00126 */ 00127 00128 RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_null ( 00129 POSIX_Semaphore_Control *the_semaphore 00130 ); 00131 00132 /* 00133 * _POSIX_Semaphore_Create_support 00134 * 00135 * DESCRIPTION: 00136 * 00137 * This routine supports the sem_init and sem_open routines. 00138 */ 00139 00140 int _POSIX_Semaphore_Create_support( 00141 const char *name, 00142 size_t name_len, 00143 int pshared, 00144 unsigned int value, 00145 POSIX_Semaphore_Control **the_sem 00146 ); 00147 00155 void _POSIX_Semaphore_Delete( 00156 POSIX_Semaphore_Control *the_semaphore 00157 ); 00158 00167 int _POSIX_Semaphore_Wait_support( 00168 sem_t *sem, 00169 bool blocking, 00170 Watchdog_Interval timeout 00171 ); 00172 00173 /* 00174 * _POSIX_Semaphore_Translate_core_semaphore_return_code 00175 * 00176 * DESCRIPTION: 00177 * 00178 * A support routine which converts core semaphore status codes into the 00179 * appropriate POSIX status values. 00180 */ 00181 00182 int _POSIX_Semaphore_Translate_core_semaphore_return_code( 00183 CORE_semaphore_Status the_semaphore_status 00184 ); 00185 00186 #include <rtems/posix/semaphore.inl> 00187 00188 #ifdef __cplusplus 00189 } 00190 #endif 00191 00194 #endif 00195 /* end of include file */
1.7.5