00001
00049 #ifndef _RTAI_SEM_H
00050 #define _RTAI_SEM_H
00051
00052 #include <nucleus/synch.h>
00053 #include <rtai/types.h>
00054
00055
00056 #define S_PRIO XNSYNCH_PRIO
00057 #define S_FIFO XNSYNCH_FIFO
00058
00059 typedef struct rt_sem_info {
00060
00061 unsigned long count;
00062
00063 int nwaiters;
00064
00065 char name[XNOBJECT_NAME_LEN];
00066
00067 } RT_SEM_INFO;
00068
00069 typedef struct rt_sem_placeholder {
00070 rt_handle_t opaque;
00071 } RT_SEM_PLACEHOLDER;
00072
00073 #if defined(__KERNEL__) || defined(__RTAI_SIM__)
00074
00075 #define RTAI_SEM_MAGIC 0x55550303
00076
00077 typedef struct rt_sem {
00078
00079 unsigned magic;
00080
00081 xnsynch_t synch_base;
00082
00083 unsigned long count;
00084
00085 rt_handle_t handle;
00086
00087 char name[XNOBJECT_NAME_LEN];
00088
00089 #if defined(__KERNEL__) && defined(CONFIG_RTAI_OPT_FUSION)
00090 int source;
00091 #endif
00092
00093 } RT_SEM;
00094
00095 #ifdef __cplusplus
00096 extern "C" {
00097 #endif
00098
00099 int __sem_pkg_init(void);
00100
00101 void __sem_pkg_cleanup(void);
00102
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106
00107 #else
00108
00109 typedef RT_SEM_PLACEHOLDER RT_SEM;
00110
00111 int rt_sem_bind(RT_SEM *sem,
00112 const char *name);
00113
00114 static inline int rt_sem_unbind (RT_SEM *sem)
00115
00116 {
00117 sem->opaque = RT_HANDLE_INVALID;
00118 return 0;
00119 }
00120
00121 #endif
00122
00123 #ifdef __cplusplus
00124 extern "C" {
00125 #endif
00126
00127
00128
00129 int rt_sem_create(RT_SEM *sem,
00130 const char *name,
00131 unsigned long icount,
00132 int mode);
00133
00134 int rt_sem_delete(RT_SEM *sem);
00135
00136 int rt_sem_p(RT_SEM *sem,
00137 RTIME timeout);
00138
00139 int rt_sem_v(RT_SEM *sem);
00140
00141 int rt_sem_broadcast(RT_SEM *sem);
00142
00143 int rt_sem_inquire(RT_SEM *sem,
00144 RT_SEM_INFO *info);
00145
00146 #ifdef __cplusplus
00147 }
00148 #endif
00149
00150 #endif