summaryrefslogtreecommitdiffstats
path: root/regressions/ck_cohort/ck_cohort.h
blob: b0d7f0a483e1fe6482cad186e915bd3daf0652e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define LOCK_NAME "ck_cohort"
#define LOCK_DEFINE									\
	static ck_spinlock_fas_t global_fas_lock = CK_SPINLOCK_FAS_INITIALIZER;		\
	static ck_spinlock_fas_t local_fas_lock = CK_SPINLOCK_FAS_INITIALIZER;		\
	static void									\
	ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context)	\
	{										\
		(void)context;								\
		ck_spinlock_fas_lock(lock);						\
	}										\
											\
	static void									\
	ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context)	\
	{										\
		(void)context;								\
		ck_spinlock_fas_unlock(lock);						\
	}										\
											\
	static bool									\
	ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context)	\
	{										\
		(void)context;								\
		return ck_spinlock_fas_locked(lock);					\
	}										\
	CK_COHORT_PROTOTYPE(fas_fas,							\
	    ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context,	\
	    ck_spinlock_fas_locked_with_context, ck_spinlock_fas_lock_with_context,	\
	    ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context)	\
	static CK_COHORT_INSTANCE(fas_fas) CK_CC_CACHELINE cohort = CK_COHORT_INITIALIZER


#define LOCK_INIT CK_COHORT_INIT(fas_fas, &cohort, &global_fas_lock, &local_fas_lock,   \
	CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT)
#define LOCK CK_COHORT_LOCK(fas_fas, &cohort, NULL, NULL)
#define UNLOCK CK_COHORT_UNLOCK(fas_fas, &cohort, NULL, NULL)