2008-03-01 03:45:59 +03:00
|
|
|
#include <sys/rwlock.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
int
|
2008-03-07 02:42:37 +03:00
|
|
|
__rw_read_held(krwlock_t *rwlp)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
|
|
|
BUG_ON(rwlp->rw_magic != RW_MAGIC);
|
|
|
|
|
2008-03-07 02:42:37 +03:00
|
|
|
if (__rw_lock_held(rwlp) && rwlp->rw_owner == NULL) {
|
2008-02-26 23:36:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2008-02-27 22:09:51 +03:00
|
|
|
|
2008-02-26 23:36:04 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2008-03-07 02:42:37 +03:00
|
|
|
EXPORT_SYMBOL(__rw_read_held);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
int
|
2008-03-07 02:42:37 +03:00
|
|
|
__rw_write_held(krwlock_t *rwlp)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
|
|
|
BUG_ON(rwlp->rw_magic != RW_MAGIC);
|
|
|
|
|
2008-03-07 02:42:37 +03:00
|
|
|
if (rwlp->rw_owner == current) {
|
2008-02-26 23:36:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-07 02:42:37 +03:00
|
|
|
EXPORT_SYMBOL(__rw_write_held);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
int
|
2008-03-07 02:42:37 +03:00
|
|
|
__rw_lock_held(krwlock_t *rwlp)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
|
|
|
BUG_ON(rwlp->rw_magic != RW_MAGIC);
|
|
|
|
|
2008-03-07 02:42:37 +03:00
|
|
|
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
|
|
|
|
if (rwlp->rw_sem.activity != 0) {
|
|
|
|
#else
|
|
|
|
if (rwlp->rw_sem.count != 0) {
|
|
|
|
#endif
|
2008-02-26 23:36:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-07 02:42:37 +03:00
|
|
|
EXPORT_SYMBOL(__rw_lock_held);
|