00001
00022 #ifndef _RTAI_SEM_H
00023 #define _RTAI_SEM_H
00024
00025 #include <nucleus/synch.h>
00026 #include <rtai/types.h>
00027
00028
00029 #define S_PRIO XNSYNCH_PRIO
00030 #define S_FIFO XNSYNCH_FIFO
00031 #define S_PULSE 0x100
00032
00033 typedef struct rt_sem_info {
00034
00035 unsigned long count;
00036
00037 int nwaiters;
00038
00039 char name[XNOBJECT_NAME_LEN];
00040
00041 } RT_SEM_INFO;
00042
00043 typedef struct rt_sem_placeholder {
00044 rt_handle_t opaque;
00045 } RT_SEM_PLACEHOLDER;
00046
00047 #if defined(__KERNEL__) || defined(__RTAI_SIM__)
00048
00049 #define RTAI_SEM_MAGIC 0x55550303
00050
00051 typedef struct rt_sem {
00052
00053 unsigned magic;
00054
00055 xnsynch_t synch_base;
00056
00057 unsigned long count;
00058
00059 int mode;
00060
00061 rt_handle_t handle;
00062
00063 char name[XNOBJECT_NAME_LEN];
00064
00065 #if defined(__KERNEL__) && defined(CONFIG_RTAI_OPT_FUSION)
00066 pid_t cpid;
00067 #endif
00068
00069 } RT_SEM;
00070
00071 #ifdef __cplusplus
00072 extern "C" {
00073 #endif
00074
00075 int __sem_pkg_init(void);
00076
00077 void __sem_pkg_cleanup(void);
00078
00079 #ifdef __cplusplus
00080 }
00081 #endif
00082
00083 #else
00084
00085 typedef RT_SEM_PLACEHOLDER RT_SEM;
00086
00087 #ifdef __cplusplus
00088 extern "C" {
00089 #endif
00090
00091 int rt_sem_bind(RT_SEM *sem,
00092 const char *name);
00093
00094 static inline int rt_sem_unbind (RT_SEM *sem)
00095
00096 {
00097 sem->opaque = RT_HANDLE_INVALID;
00098 return 0;
00099 }
00100
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104
00105 #endif
00106
00107 #ifdef __cplusplus
00108 extern "C" {
00109 #endif
00110
00111
00112
00113 int rt_sem_create(RT_SEM *sem,
00114 const char *name,
00115 unsigned long icount,
00116 int mode);
00117
00118 int rt_sem_delete(RT_SEM *sem);
00119
00120 int rt_sem_p(RT_SEM *sem,
00121 RTIME timeout);
00122
00123 int rt_sem_v(RT_SEM *sem);
00124
00125 int rt_sem_broadcast(RT_SEM *sem);
00126
00127 int rt_sem_inquire(RT_SEM *sem,
00128 RT_SEM_INFO *info);
00129
00130 #ifdef __cplusplus
00131 }
00132 #endif
00133
00134 #endif