cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

rwlock_types.h (1814B)


      1#ifndef __LINUX_RWLOCK_TYPES_H
      2#define __LINUX_RWLOCK_TYPES_H
      3
      4#if !defined(__LINUX_SPINLOCK_TYPES_H)
      5# error "Do not include directly, include spinlock_types.h"
      6#endif
      7
      8#ifdef CONFIG_DEBUG_LOCK_ALLOC
      9# define RW_DEP_MAP_INIT(lockname)					\
     10	.dep_map = {							\
     11		.name = #lockname,					\
     12		.wait_type_inner = LD_WAIT_CONFIG,			\
     13	}
     14#else
     15# define RW_DEP_MAP_INIT(lockname)
     16#endif
     17
     18#ifndef CONFIG_PREEMPT_RT
     19/*
     20 * generic rwlock type definitions and initializers
     21 *
     22 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
     23 * Released under the General Public License (GPL).
     24 */
     25typedef struct {
     26	arch_rwlock_t raw_lock;
     27#ifdef CONFIG_DEBUG_SPINLOCK
     28	unsigned int magic, owner_cpu;
     29	void *owner;
     30#endif
     31#ifdef CONFIG_DEBUG_LOCK_ALLOC
     32	struct lockdep_map dep_map;
     33#endif
     34} rwlock_t;
     35
     36#define RWLOCK_MAGIC		0xdeaf1eed
     37
     38#ifdef CONFIG_DEBUG_SPINLOCK
     39#define __RW_LOCK_UNLOCKED(lockname)					\
     40	(rwlock_t)	{	.raw_lock = __ARCH_RW_LOCK_UNLOCKED,	\
     41				.magic = RWLOCK_MAGIC,			\
     42				.owner = SPINLOCK_OWNER_INIT,		\
     43				.owner_cpu = -1,			\
     44				RW_DEP_MAP_INIT(lockname) }
     45#else
     46#define __RW_LOCK_UNLOCKED(lockname) \
     47	(rwlock_t)	{	.raw_lock = __ARCH_RW_LOCK_UNLOCKED,	\
     48				RW_DEP_MAP_INIT(lockname) }
     49#endif
     50
     51#define DEFINE_RWLOCK(x)	rwlock_t x = __RW_LOCK_UNLOCKED(x)
     52
     53#else /* !CONFIG_PREEMPT_RT */
     54
     55#include <linux/rwbase_rt.h>
     56
     57typedef struct {
     58	struct rwbase_rt	rwbase;
     59	atomic_t		readers;
     60#ifdef CONFIG_DEBUG_LOCK_ALLOC
     61	struct lockdep_map	dep_map;
     62#endif
     63} rwlock_t;
     64
     65#define __RWLOCK_RT_INITIALIZER(name)					\
     66{									\
     67	.rwbase = __RWBASE_INITIALIZER(name),				\
     68	RW_DEP_MAP_INIT(name)						\
     69}
     70
     71#define __RW_LOCK_UNLOCKED(name) __RWLOCK_RT_INITIALIZER(name)
     72
     73#define DEFINE_RWLOCK(name)						\
     74	rwlock_t name = __RW_LOCK_UNLOCKED(name)
     75
     76#endif /* CONFIG_PREEMPT_RT */
     77
     78#endif /* __LINUX_RWLOCK_TYPES_H */