]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/rtl/rwlock.h
Reformat the sources with orte/uncrustify script
[orte.git] / orte / include / rtl / rwlock.h
1 /*
2  *  $Id: rwlock.h,v 0.0.0.1             2003/12/19
3  *
4  *  -------------------------------------------------------------------
5  *                                ORTE
6  *                      Open Real-Time Ethernet
7  *
8  *                      Copyright (C) 2001-2006
9  *  Department of Control Engineering FEE CTU Prague, Czech Republic
10  *                      http://dce.felk.cvut.cz
11  *                      http://www.ocera.org
12  *
13  *  Author:              Petr Smolik    petr@smoliku.cz
14  *  Advisor:             Pavel Pisa
15  *  Project Responsible: Zdenek Hanzalek
16  *  --------------------------------------------------------------------
17  *
18  *  This program is free software; you can redistribute it and/or modify
19  *  it under the terms of the GNU General Public License as published by
20  *  the Free Software Foundation; either version 2 of the License, or
21  *  (at your option) any later version.
22  *
23  *  This program is distributed in the hope that it will be useful,
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *  GNU General Public License for more details.
27  *
28  */
29
30 #ifndef _RWLOCK_H
31 #define _RWLOCK_H
32
33 #define PTW32_RWLOCK_MAGIC 0xfacade2
34 #define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)-1)
35
36 typedef struct pthread_rwlock_t_ *pthread_rwlock_t;
37 typedef struct pthread_rwlockattr_t_ *pthread_rwlockattr_t;
38 struct pthread_rwlock_t_ {
39   pthread_mutex_t   mtxExclusiveAccess;
40   pthread_mutex_t   mtxSharedAccessCompleted;
41   pthread_cond_t    cndSharedAccessCompleted;
42   int               nSharedAccessCount;
43   int               nExclusiveAccessCount;
44   int               nCompletedSharedAccessCount;
45   int               nMagic;
46 };
47
48 struct pthread_rwlockattr_t_ {
49   int               pshared;
50 };
51 extern void
52 ptw32_rwlock_cancelwrwait(void *arg);
53
54 extern int
55 ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock);
56
57 extern int
58 pthread_rwlock_init(pthread_rwlock_t *lock,
59                     const pthread_rwlockattr_t *attr);
60
61 extern int
62 pthread_rwlock_destroy(pthread_rwlock_t *lock);
63
64 extern int
65 pthread_rwlock_tryrdlock(pthread_rwlock_t *);
66
67 extern int
68 pthread_rwlock_trywrlock(pthread_rwlock_t *);
69
70 extern int
71 pthread_rwlock_rdlock(pthread_rwlock_t *lock);
72
73 extern int
74 pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
75                            const struct timespec *abstime);
76
77 extern int
78 pthread_rwlock_wrlock(pthread_rwlock_t *lock);
79
80 extern int
81 pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
82                            const struct timespec *abstime);
83
84 extern int
85 pthread_rwlock_unlock(pthread_rwlock_t *lock);
86
87 extern int
88 pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
89
90 extern int
91 pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
92
93 extern int
94 pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr,
95                               int *pshared);
96
97 extern int
98 pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,
99                               int pshared);
100
101
102 #endif /* _RWLOCK_H */