File indexing completed on 2025-05-11 08:24:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef _RTEMS_THREAD_H
0038 #define _RTEMS_THREAD_H
0039
0040 #include <sys/lock.h>
0041 #include <errno.h>
0042 #include <stdint.h>
0043
0044 __BEGIN_DECLS
0045
0046
0047 int _Semaphore_Wait_timed_ticks(struct _Semaphore_Control *, __uint32_t);
0048
0049
0050 int _Semaphore_Try_wait(struct _Semaphore_Control *);
0051
0052
0053 void _Semaphore_Post_binary(struct _Semaphore_Control *);
0054
0055 typedef struct _Mutex_Control rtems_mutex;
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 #define RTEMS_MUTEX_INITIALIZER( name ) _MUTEX_NAMED_INITIALIZER( name )
0068
0069 static __inline void rtems_mutex_init( rtems_mutex *mutex, const char *name )
0070 {
0071 _Mutex_Initialize_named( mutex, name );
0072 }
0073
0074 static __inline const char *rtems_mutex_get_name( const rtems_mutex *mutex )
0075 {
0076 return mutex->_Queue._name;
0077 }
0078
0079 static __inline void rtems_mutex_set_name( rtems_mutex *mutex, const char *name )
0080 {
0081 mutex->_Queue._name = name;
0082 }
0083
0084 static __inline void rtems_mutex_lock( rtems_mutex *mutex )
0085 {
0086 _Mutex_Acquire( mutex );
0087 }
0088
0089 static __inline int rtems_mutex_try_lock( rtems_mutex *mutex )
0090 {
0091 return _Mutex_Try_acquire( mutex );
0092 }
0093
0094 static __inline void rtems_mutex_unlock( rtems_mutex *mutex )
0095 {
0096 _Mutex_Release( mutex );
0097 }
0098
0099 static __inline void rtems_mutex_destroy( rtems_mutex *mutex )
0100 {
0101 _Mutex_Destroy( mutex );
0102 }
0103
0104 typedef struct _Mutex_recursive_Control rtems_recursive_mutex;
0105
0106 #define RTEMS_RECURSIVE_MUTEX_INITIALIZER( name ) \
0107 _MUTEX_RECURSIVE_NAMED_INITIALIZER( name )
0108
0109 static __inline void rtems_recursive_mutex_init(
0110 rtems_recursive_mutex *mutex, const char *name
0111 )
0112 {
0113 _Mutex_recursive_Initialize_named( mutex, name );
0114 }
0115
0116 static __inline const char *rtems_recursive_mutex_get_name(
0117 const rtems_recursive_mutex *mutex
0118 )
0119 {
0120 return mutex->_Mutex._Queue._name;
0121 }
0122
0123 static __inline void rtems_recursive_mutex_set_name(
0124 rtems_recursive_mutex *mutex, const char *name
0125 )
0126 {
0127 mutex->_Mutex._Queue._name = name;
0128 }
0129
0130 static __inline void rtems_recursive_mutex_lock(
0131 rtems_recursive_mutex *mutex
0132 )
0133 {
0134 _Mutex_recursive_Acquire( mutex );
0135 }
0136
0137 static __inline int rtems_recursive_mutex_try_lock(
0138 rtems_recursive_mutex *mutex
0139 )
0140 {
0141 return _Mutex_recursive_Try_acquire( mutex );
0142 }
0143
0144 static __inline void rtems_recursive_mutex_unlock(
0145 rtems_recursive_mutex *mutex
0146 )
0147 {
0148 _Mutex_recursive_Release( mutex );
0149 }
0150
0151 static __inline void rtems_recursive_mutex_destroy(
0152 rtems_recursive_mutex *mutex
0153 )
0154 {
0155 _Mutex_recursive_Destroy( mutex );
0156 }
0157
0158 typedef struct _Condition_Control rtems_condition_variable;
0159
0160 #define RTEMS_CONDITION_VARIABLE_INITIALIZER( name ) \
0161 _CONDITION_NAMED_INITIALIZER( name )
0162
0163 static __inline void rtems_condition_variable_init(
0164 rtems_condition_variable *condition_variable,
0165 const char *name
0166 )
0167 {
0168 _Condition_Initialize_named( condition_variable, name );
0169 }
0170
0171 static __inline const char *rtems_condition_variable_get_name(
0172 const rtems_condition_variable *condition_variable
0173 )
0174 {
0175 return condition_variable->_Queue._name;
0176 }
0177
0178 static __inline void rtems_condition_variable_set_name(
0179 rtems_condition_variable *condition_variable,
0180 const char *name
0181 )
0182 {
0183 condition_variable->_Queue._name = name;
0184 }
0185
0186 static __inline void rtems_condition_variable_wait(
0187 rtems_condition_variable *condition_variable,
0188 rtems_mutex *mutex
0189 )
0190 {
0191 _Condition_Wait( condition_variable, mutex );
0192 }
0193
0194 static __inline void rtems_condition_variable_signal(
0195 rtems_condition_variable *condition_variable
0196 )
0197 {
0198 _Condition_Signal( condition_variable );
0199 }
0200
0201 static __inline void rtems_condition_variable_broadcast(
0202 rtems_condition_variable *condition_variable
0203 )
0204 {
0205 _Condition_Broadcast( condition_variable );
0206 }
0207
0208 static __inline void rtems_condition_variable_destroy(
0209 rtems_condition_variable *condition_variable
0210 )
0211 {
0212 _Condition_Destroy( condition_variable );
0213 }
0214
0215 typedef struct _Semaphore_Control rtems_counting_semaphore;
0216
0217 #define RTEMS_COUNTING_SEMAPHORE_INITIALIZER( name, value ) \
0218 _SEMAPHORE_NAMED_INITIALIZER( name, value )
0219
0220 static __inline void rtems_counting_semaphore_init(
0221 rtems_counting_semaphore *counting_semaphore,
0222 const char *name,
0223 unsigned int value
0224 )
0225 {
0226 _Semaphore_Initialize_named( counting_semaphore, name, value );
0227 }
0228
0229 static __inline const char *rtems_counting_semaphore_get_name(
0230 const rtems_counting_semaphore *counting_semaphore
0231 )
0232 {
0233 return counting_semaphore->_Queue._name;
0234 }
0235
0236 static __inline void rtems_counting_semaphore_set_name(
0237 rtems_counting_semaphore *counting_semaphore,
0238 const char *name
0239 )
0240 {
0241 counting_semaphore->_Queue._name = name;
0242 }
0243
0244 static __inline void rtems_counting_semaphore_wait(
0245 rtems_counting_semaphore *counting_semaphore
0246 )
0247 {
0248 _Semaphore_Wait( counting_semaphore );
0249 }
0250
0251 static __inline int rtems_counting_semaphore_wait_timed_ticks(
0252 rtems_counting_semaphore *counting_semaphore,
0253 uint32_t ticks
0254 )
0255 {
0256 return _Semaphore_Wait_timed_ticks( counting_semaphore, ticks );
0257 }
0258
0259 static __inline int rtems_counting_semaphore_try_wait(
0260 rtems_counting_semaphore *counting_semaphore
0261 )
0262 {
0263 return _Semaphore_Try_wait( counting_semaphore );
0264 }
0265
0266 static __inline void rtems_counting_semaphore_post(
0267 rtems_counting_semaphore *counting_semaphore
0268 )
0269 {
0270 _Semaphore_Post( counting_semaphore );
0271 }
0272
0273 static __inline void rtems_counting_semaphore_destroy(
0274 rtems_counting_semaphore *counting_semaphore
0275 )
0276 {
0277 _Semaphore_Destroy( counting_semaphore );
0278 }
0279
0280 typedef struct {
0281 struct _Semaphore_Control Semaphore;
0282 } rtems_binary_semaphore;
0283
0284 #define RTEMS_BINARY_SEMAPHORE_INITIALIZER( name ) \
0285 { _SEMAPHORE_NAMED_INITIALIZER( name, 0 ) }
0286
0287 static __inline void rtems_binary_semaphore_init(
0288 rtems_binary_semaphore *binary_semaphore,
0289 const char *name
0290 )
0291 {
0292 _Semaphore_Initialize_named( &binary_semaphore->Semaphore, name, 0 );
0293 }
0294
0295 static __inline const char *rtems_binary_semaphore_get_name(
0296 const rtems_binary_semaphore *binary_semaphore
0297 )
0298 {
0299 return binary_semaphore->Semaphore._Queue._name;
0300 }
0301
0302 static __inline void rtems_binary_semaphore_set_name(
0303 rtems_binary_semaphore *binary_semaphore,
0304 const char *name
0305 )
0306 {
0307 binary_semaphore->Semaphore._Queue._name = name;
0308 }
0309
0310 static __inline void rtems_binary_semaphore_wait(
0311 rtems_binary_semaphore *binary_semaphore
0312 )
0313 {
0314 _Semaphore_Wait( &binary_semaphore->Semaphore );
0315 }
0316
0317 static __inline int rtems_binary_semaphore_wait_timed_ticks(
0318 rtems_binary_semaphore *binary_semaphore,
0319 uint32_t ticks
0320 )
0321 {
0322 return _Semaphore_Wait_timed_ticks( &binary_semaphore->Semaphore, ticks );
0323 }
0324
0325 static __inline int rtems_binary_semaphore_try_wait(
0326 rtems_binary_semaphore *binary_semaphore
0327 )
0328 {
0329 return _Semaphore_Try_wait( &binary_semaphore->Semaphore );
0330 }
0331
0332 static __inline void rtems_binary_semaphore_post(
0333 rtems_binary_semaphore *binary_semaphore
0334 )
0335 {
0336 _Semaphore_Post_binary( &binary_semaphore->Semaphore );
0337 }
0338
0339 static __inline void rtems_binary_semaphore_destroy(
0340 rtems_binary_semaphore *binary_semaphore
0341 )
0342 {
0343 _Semaphore_Destroy( &binary_semaphore->Semaphore );
0344 }
0345
0346
0347
0348 __END_DECLS
0349
0350 #endif