]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/rtl/rwlock.h
2b1da25160741d8b3309e9df691ce6441141f665
[orte.git] / orte / include / rtl / rwlock.h
1 /*
2  *  $Id: rwlock.h,v 0.0.0.1             2003/12/19 
3  *
4  *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
5  *
6  *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
7  *  --------------------------------------------------------------------
8  *
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.
13  *  
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.
18  *  
19  */
20
21 #ifndef _RWLOCK_H
22 #define _RWLOCK_H
23
24 #define PTW32_RWLOCK_MAGIC 0xfacade2
25 #define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1)
26
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;
36   int               nMagic;
37 };
38               
39 struct pthread_rwlockattr_t_ {
40   int               pshared;
41 };
42 extern void ptw32_rwlock_cancelwrwait(void * arg);
43
44 extern int
45 ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock);
46
47 extern int pthread_rwlock_init(pthread_rwlock_t *lock,
48                                const pthread_rwlockattr_t *attr);
49
50 extern int pthread_rwlock_destroy(pthread_rwlock_t *lock);
51
52 extern int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
53
54 extern int pthread_rwlock_trywrlock(pthread_rwlock_t *);
55
56 extern int pthread_rwlock_rdlock(pthread_rwlock_t *lock);
57
58 extern int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
59                                       const struct timespec *abstime);
60
61 extern int pthread_rwlock_wrlock(pthread_rwlock_t *lock);
62
63 extern int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
64                                       const struct timespec *abstime);
65
66 extern int pthread_rwlock_unlock(pthread_rwlock_t *lock);
67
68 extern int pthread_rwlockattr_init(pthread_rwlockattr_t * attr);
69
70 extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * attr);
71
72 extern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * attr,
73                                           int *pshared);
74
75 extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
76                                           int pshared);
77
78
79 #endif /* _RWLOCK_H */