00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _RTAI_RWL_H
00020 #define _RTAI_RWL_H
00021
00022 #include <rtai_sem.h>
00023
00024 struct rtai_rwlock;
00025
00026 #ifdef __KERNEL__
00027
00028 #ifndef __cplusplus
00029
00030 typedef struct rtai_rwlock {
00031 SEM wrmtx,
00032 wrsem,
00033 rdsem;
00034 } RWL;
00035
00036 #else
00037 extern "C" {
00038 #endif
00039
00040 RTAI_SYSCALL_MODE int rt_typed_rwl_init(RWL *rwl, int type);
00041
00042 #define rt_rwl_init(rwl) rt_typed_rwl_init(rwl, RESEM_RECURS)
00043
00044 RTAI_SYSCALL_MODE int rt_rwl_delete(struct rtai_rwlock *rwl);
00045
00046 RTAI_SYSCALL_MODE RWL *_rt_named_rwl_init(unsigned long rwl_name);
00047
00048 RTAI_SYSCALL_MODE int rt_named_rwl_delete(RWL *rwl);
00049
00050 RTAI_SYSCALL_MODE int rt_rwl_rdlock(struct rtai_rwlock *rwl);
00051
00052 RTAI_SYSCALL_MODE int rt_rwl_rdlock_if(struct rtai_rwlock *rwl);
00053
00054 RTAI_SYSCALL_MODE int rt_rwl_rdlock_until(struct rtai_rwlock *rwl, RTIME time);
00055
00056 RTAI_SYSCALL_MODE int rt_rwl_rdlock_timed(struct rtai_rwlock *rwl, RTIME delay);
00057
00058 RTAI_SYSCALL_MODE int rt_rwl_wrlock(struct rtai_rwlock *rwl);
00059
00060 RTAI_SYSCALL_MODE int rt_rwl_wrlock_if(struct rtai_rwlock *rwl);
00061
00062 RTAI_SYSCALL_MODE int rt_rwl_wrlock_until(struct rtai_rwlock *rwl, RTIME time);
00063
00064 RTAI_SYSCALL_MODE int rt_rwl_wrlock_timed(struct rtai_rwlock *rwl, RTIME delay);
00065
00066 RTAI_SYSCALL_MODE int rt_rwl_unlock(struct rtai_rwlock *rwl);
00067
00068 #ifdef __cplusplus
00069 }
00070 #endif
00071
00072 #else
00073
00074 #ifdef __cplusplus
00075 extern "C" {
00076 #endif
00077
00078 #define rt_rwl_init(rwl) rt_typed_rwl_init(rwl, RESEM_RECURS)
00079
00080 RTAI_PROTO(struct rtai_rwlock *, rt_typed_rwl_init,(unsigned long name, int type))
00081 {
00082 struct { unsigned long name; long type; } arg = { name, type };
00083 return (struct rtai_rwlock *)rtai_lxrt(BIDX, SIZARG, LXRT_RWL_INIT, &arg).v[LOW];
00084 }
00085
00086 RTAI_PROTO(int, rt_rwl_delete,(struct rtai_rwlock *rwl))
00087 {
00088 struct { struct rtai_rwlock *rwl; } arg = { rwl };
00089 return rtai_lxrt(BIDX, SIZARG, LXRT_RWL_DELETE, &arg).i[LOW];
00090 }
00091
00092 RTAI_PROTO(struct rtai_rwlock *, rt_named_rwl_init,(const char *name))
00093 {
00094 struct { const char *name; } arg = { name };
00095 return (struct rtai_rwlock *)rtai_lxrt(BIDX, SIZARG, NAMED_RWL_INIT, &arg).v[LOW];
00096 }
00097
00098 RTAI_PROTO(int, rt_named_rwl_delete,(struct rtai_rwlock *rwl))
00099 {
00100 struct { struct rtai_rwlock *rwl; } arg = { rwl };
00101 return rtai_lxrt(BIDX, SIZARG, NAMED_RWL_DELETE, &arg).i[LOW];
00102 }
00103
00104 RTAI_PROTO(int, rt_rwl_rdlock,(struct rtai_rwlock *rwl))
00105 {
00106 struct { struct rtai_rwlock *rwl; } arg = { rwl };
00107 return rtai_lxrt(BIDX, SIZARG, RWL_RDLOCK, &arg).i[LOW];
00108 }
00109
00110 RTAI_PROTO(int, rt_rwl_rdlock_if,(struct rtai_rwlock *rwl))
00111 {
00112 struct { void *rwl; } arg = { rwl };
00113 return rtai_lxrt(BIDX, SIZARG, RWL_RDLOCK_IF, &arg).i[LOW];
00114 }
00115
00116 RTAI_PROTO(int, rt_rwl_rdlock_until,(struct rtai_rwlock *rwl, RTIME time))
00117 {
00118 struct { struct rtai_rwlock *rwl; RTIME time; } arg = { rwl, time };
00119 return rtai_lxrt(BIDX, SIZARG, RWL_RDLOCK_UNTIL, &arg).i[LOW];
00120 }
00121
00122 RTAI_PROTO(int, rt_rwl_rdlock_timed,(struct rtai_rwlock *rwl, RTIME delay))
00123 {
00124 struct { struct rtai_rwlock *rwl; RTIME delay; } arg = { rwl, delay };
00125 return rtai_lxrt(BIDX, SIZARG, RWL_RDLOCK_TIMED, &arg).i[LOW];
00126 }
00127
00128 RTAI_PROTO(int, rt_rwl_wrlock,(struct rtai_rwlock *rwl))
00129 {
00130 struct { struct rtai_rwlock *rwl; } arg = { rwl };
00131 return rtai_lxrt(BIDX, SIZARG, RWL_WRLOCK, &arg).i[LOW];
00132 }
00133
00134 RTAI_PROTO(int, rt_rwl_wrlock_if,(struct rtai_rwlock *rwl))
00135 {
00136 struct { struct rtai_rwlock *rwl; } arg = { rwl };
00137 return rtai_lxrt(BIDX, SIZARG, RWL_WRLOCK_IF, &arg).i[LOW];
00138 }
00139
00140 RTAI_PROTO(int, rt_rwl_wrlock_until,(struct rtai_rwlock *rwl, RTIME time))
00141 {
00142 struct { struct rtai_rwlock *rwl; RTIME time; } arg = { rwl, time };
00143 return rtai_lxrt(BIDX, SIZARG, RWL_WRLOCK_UNTIL, &arg).i[LOW];
00144 }
00145
00146 RTAI_PROTO(int, rt_rwl_wrlock_timed,(struct rtai_rwlock *rwl, RTIME delay))
00147 {
00148 struct { struct rtai_rwlock *rwl; RTIME delay; } arg = { rwl, delay };
00149 return rtai_lxrt(BIDX, SIZARG, RWL_WRLOCK_TIMED, &arg).i[LOW];
00150 }
00151
00152 RTAI_PROTO(int, rt_rwl_unlock,(struct rtai_rwlock *rwl))
00153 {
00154 struct { struct rtai_rwlock *rwl; } arg = { rwl };
00155 return rtai_lxrt(BIDX, SIZARG, RWL_UNLOCK, &arg).i[LOW];
00156 }
00157
00158 #ifdef __cplusplus
00159 }
00160 #endif
00161
00162 #endif
00163
00164 #if !defined(__KERNEL__) || defined(__cplusplus)
00165
00166 typedef struct rtai_rwlock {
00167 int opaque;
00168 } RWL;
00169
00170 #endif
00171
00172 #endif