include/native/cond.h

Go to the documentation of this file.
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 #else /* !CONFIG_XENO_OPT_NATIVE_COND */
00086 
00087 #define __native_cond_pkg_init()                ({ 0; })
00088 #define __native_cond_pkg_cleanup()             do { } while(0)
00089 #define __native_cond_flush_rq(rq)              do { } while(0)
00090 
00091 #endif /* !CONFIG_XENO_OPT_NATIVE_COND */
00092 
00093 #ifdef __cplusplus
00094 }
00095 #endif
00096 
00097 #else /* !(__KERNEL__ || __XENO_SIM__) */
00098 
00099 typedef RT_COND_PLACEHOLDER RT_COND;
00100 
00101 #ifdef __cplusplus
00102 extern "C" {
00103 #endif
00104 
00105 int rt_cond_bind(RT_COND *cond,
00106                  const char *name,
00107                  RTIME timeout);
00108 
00109 static inline int rt_cond_unbind (RT_COND *cond)
00110 
00111 {
00112     cond->opaque = XN_NO_HANDLE;
00113     return 0;
00114 }
00115 
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119 
00120 #endif /* __KERNEL__ || __XENO_SIM__ */
00121 
00122 #ifdef __cplusplus
00123 extern "C" {
00124 #endif
00125 
00126 /* Public interface. */
00127 
00128 int rt_cond_create(RT_COND *cond,
00129                    const char *name);
00130 
00131 int rt_cond_delete(RT_COND *cond);
00132 
00133 int rt_cond_signal(RT_COND *cond);
00134 
00135 int rt_cond_broadcast(RT_COND *cond);
00136 
00137 int rt_cond_wait(RT_COND *cond,
00138                  RT_MUTEX *mutex,
00139                  RTIME timeout);
00140 
00141 int rt_cond_inquire(RT_COND *cond,
00142                     RT_COND_INFO *info);
00143 
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147 
00148 #endif /* !_XENO_COND_H */

Generated on Mon Mar 24 18:02:40 2008 for Xenomai API by  doxygen 1.5.3