00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #if !defined(__critsec_h__)
00029 #define __critsec_h__
00030
00031 #if defined(__cplusplus)
00032 extern "C" {
00033 #endif // __cplusplus
00034
00035 #include <config.h>
00036
00037 #if defined(CONF_TM) && defined(CONF_CRITICAL_SECTIONS)
00038 #include <sys/tm.h>
00039 #include <atomic.h>
00040
00041 #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS
00042
00043
00048 struct critsec {
00049 atomic_t count;
00050 tdata_t* task;
00051 };
00052 #endif // DOXYGEN_SHOULD_SKIP_INTERNALS
00053
00055 typedef struct critsec critsec_t;
00056
00058
00060 #define locked_decrement(counter) atomic_dec(counter)
00061
00063
00069 extern wakeup_t wait_critical_section(wakeup_t data);
00070
00072
00079 #define initialize_critical_section(cs) (cs)->count=0
00080
00082
00090 extern int enter_critical_section(critsec_t* cs);
00091
00093
00101 #define leave_critical_section(cs) atomic_dec(&(cs)->count)
00102
00104
00111 #define destroy_critical_section(cs)
00112
00113 #endif // CONF_TM && CONF_CRITICAL_SECTIONS
00114
00115 #if defined(__cplusplus)
00116 }
00117 #endif // __cplusplus
00118
00119 #endif // __critsec_h__