Xenomai API
2.5.6.1
|
00001 00022 #ifndef _XENO_COND_H 00023 #define _XENO_COND_H 00024 00025 #include <native/mutex.h> 00026 00027 typedef struct rt_cond_info { 00028 00029 int nwaiters; /* !< Number of pending tasks. */ 00030 00031 char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */ 00032 00033 } RT_COND_INFO; 00034 00035 typedef struct rt_cond_placeholder { 00036 00037 xnhandle_t opaque; 00038 00039 } RT_COND_PLACEHOLDER; 00040 00041 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP) 00042 00043 #include <nucleus/synch.h> 00044 #include <native/ppd.h> 00045 00046 #define XENO_COND_MAGIC 0x55550606 00047 00048 typedef struct rt_cond { 00049 00050 unsigned magic; /* !< Magic code - must be first */ 00051 00052 xnsynch_t synch_base; /* !< Base synchronization object. */ 00053 00054 xnhandle_t handle; /* !< Handle in registry -- zero if unregistered. */ 00055 00056 char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */ 00057 00058 #ifdef CONFIG_XENO_OPT_PERVASIVE 00059 pid_t cpid; /* !< Creator's pid. */ 00060 #endif /* CONFIG_XENO_OPT_PERVASIVE */ 00061 00062 xnholder_t rlink; /* !< Link in resource queue. */ 00063 00064 #define rlink2cond(ln) container_of(ln, RT_COND, rlink) 00065 00066 xnqueue_t *rqueue; /* !< Backpointer to resource queue. */ 00067 00068 } RT_COND; 00069 00070 #ifdef __cplusplus 00071 extern "C" { 00072 #endif 00073 00074 #ifdef CONFIG_XENO_OPT_NATIVE_COND 00075 00076 int __native_cond_pkg_init(void); 00077 00078 void __native_cond_pkg_cleanup(void); 00079 00080 static inline void __native_cond_flush_rq(xnqueue_t *rq) 00081 { 00082 xeno_flush_rq(RT_COND, rq, cond); 00083 } 00084 00085 int rt_cond_wait_prologue(RT_COND *cond, RT_MUTEX *mutex, unsigned *plockcnt, 00086 xntmode_t timeout_mode, RTIME timeout); 00087 00088 int rt_cond_wait_epilogue(RT_MUTEX *mutex, unsigned lockcnt); 00089 00090 #else /* !CONFIG_XENO_OPT_NATIVE_COND */ 00091 00092 #define __native_cond_pkg_init() ({ 0; }) 00093 #define __native_cond_pkg_cleanup() do { } while(0) 00094 #define __native_cond_flush_rq(rq) do { } while(0) 00095 00096 #endif /* !CONFIG_XENO_OPT_NATIVE_COND */ 00097 00098 #ifdef __cplusplus 00099 } 00100 #endif 00101 00102 #else /* !(__KERNEL__ || __XENO_SIM__) */ 00103 00104 typedef RT_COND_PLACEHOLDER RT_COND; 00105 00106 #ifdef __cplusplus 00107 extern "C" { 00108 #endif 00109 00110 int rt_cond_bind(RT_COND *cond, 00111 const char *name, 00112 RTIME timeout); 00113 00114 static inline int rt_cond_unbind (RT_COND *cond) 00115 00116 { 00117 cond->opaque = XN_NO_HANDLE; 00118 return 0; 00119 } 00120 00121 #ifdef __cplusplus 00122 } 00123 #endif 00124 00125 #endif /* __KERNEL__ || __XENO_SIM__ */ 00126 00127 #ifdef __cplusplus 00128 extern "C" { 00129 #endif 00130 00131 /* Public interface. */ 00132 00133 int rt_cond_create(RT_COND *cond, 00134 const char *name); 00135 00136 int rt_cond_delete(RT_COND *cond); 00137 00138 int rt_cond_signal(RT_COND *cond); 00139 00140 int rt_cond_broadcast(RT_COND *cond); 00141 00142 int rt_cond_wait(RT_COND *cond, 00143 RT_MUTEX *mutex, 00144 RTIME timeout); 00145 00146 int rt_cond_wait_until(RT_COND *cond, 00147 RT_MUTEX *mutex, 00148 RTIME timeout); 00149 00150 int rt_cond_inquire(RT_COND *cond, 00151 RT_COND_INFO *info); 00152 00153 #ifdef __cplusplus 00154 } 00155 #endif 00156 00157 #endif /* !_XENO_COND_H */