1
/* Copyright (c) 2009 PrimeBase Technologies GmbH
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* 2009-01-20 Vladimir Kolesnikov
24
#ifndef __xt_locklist_h__
25
#define __xt_locklist_h__
28
#define XT_THREAD_LOCK_INFO
36
struct xt_mutex_struct;
37
struct xt_rwlock_struct;
42
#ifdef XT_THREAD_LOCK_INFO
44
#define LOCKLIST_ARG_SUFFIX(name) #name " in " __FUNCTION__ "() at " __FILE__ ":" QUOTE(__LINE__)
47
* An instance of this class keeps information about a lock kept by a thread.
48
* There's a list of XTThreadLockInfo instances per thread. An instance can be
49
* included into several thread lists in case of shared locks.
51
typedef struct XTThreadLockInfo {
53
enum LockType { SPIN_LOCK, RW_MUTEX, MUTEX, RW_LOCK, FAST_LOCK, FAST_RW_LOCK, SPIN_RW_LOCK };
55
XTThreadLockInfo *li_prev;
56
LockType li_lock_type;
59
XTSpinLock *li_spin_lock; // SPIN_LOCK
60
XTRWMutex *li_rw_mutex; // RW_MUTEX
61
XTFastLock *li_fast_lock; // FAST_LOCK
62
XTFastRWLock *li_fast_rwlock; // FAST_RW_LOCK
63
XTSpinRWLock *li_spin_rwlock; // SPIN_RW_LOCK
64
xt_mutex_struct *li_mutex; // MUTEX
65
xt_rwlock_struct *li_rwlock; // RW_LOCK
68
XTThreadLockInfoRec, *XTThreadLockInfoPtr;
70
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinLock *lock);
71
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTRWMutex *lock);
72
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTFastLock *lock);
73
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTFastRWLock *lock);
74
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinRWLock *lock);
75
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_mutex_struct *lock);
76
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_rwlock_struct *lock);
77
void xt_thread_lock_info_free(XTThreadLockInfoPtr ptr);
79
void xt_thread_lock_info_add_owner (XTThreadLockInfoPtr ptr);
80
void xt_thread_lock_info_release_owner (XTThreadLockInfoPtr ptr);
82
#endif // XT_THREAD_LOCK_INFO
83
#endif // __xt_locklist_h__