2 * $Id: rwlock.h,v 0.0.0.1 2003/12/19
4 * AUTHOR: Petr Smolik petr.smolik@wo.cz
6 * ORTE - OCERA Real-Time Ethernet http://www.ocera.org/
7 * --------------------------------------------------------------------
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
24 #define PTW32_RWLOCK_MAGIC 0xfacade2
25 #define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1)
27 typedef struct pthread_rwlock_t_ *pthread_rwlock_t;
28 typedef struct pthread_rwlockattr_t_ *pthread_rwlockattr_t;
29 struct pthread_rwlock_t_ {
30 pthread_mutex_t mtxExclusiveAccess;
31 pthread_mutex_t mtxSharedAccessCompleted;
32 pthread_cond_t cndSharedAccessCompleted;
33 int nSharedAccessCount;
34 int nExclusiveAccessCount;
35 int nCompletedSharedAccessCount;
39 struct pthread_rwlockattr_t_ {
42 extern void ptw32_rwlock_cancelwrwait(void * arg);
45 ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock);
47 extern int pthread_rwlock_init(pthread_rwlock_t *lock,
48 const pthread_rwlockattr_t *attr);
50 extern int pthread_rwlock_destroy(pthread_rwlock_t *lock);
52 extern int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
54 extern int pthread_rwlock_trywrlock(pthread_rwlock_t *);
56 extern int pthread_rwlock_rdlock(pthread_rwlock_t *lock);
58 extern int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
59 const struct timespec *abstime);
61 extern int pthread_rwlock_wrlock(pthread_rwlock_t *lock);
63 extern int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
64 const struct timespec *abstime);
66 extern int pthread_rwlock_unlock(pthread_rwlock_t *lock);
68 extern int pthread_rwlockattr_init(pthread_rwlockattr_t * attr);
70 extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * attr);
72 extern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * attr,
75 extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
79 #endif /* _RWLOCK_H */