typedef struct spin_lock spinlock_t;
#define DEFINE_SPINLOCK(lock) spinlock_t lock = { }
-#define LASSERT_SPIN_LOCKED(lock) do { (void)sizeof(lock); } while (0)
-#define LINVRNT_SPIN_LOCKED(lock) do { (void)sizeof(lock); } while (0)
-#define LASSERT_SEM_LOCKED(sem) do { (void)sizeof(sem); } while (0)
-#define LASSERT_MUTEX_LOCKED(x) do { (void)sizeof(x); } while (0)
#define __SPIN_LOCK_UNLOCKED(x) ((spinlock_t) {})
void spin_lock_init(spinlock_t *lock);
struct completion {
unsigned int done;
- cfs_waitq_t wait;
+ wait_queue_head_t wait;
};
#endif /* HAVE_LIBPTHREAD */
void down_read(struct rw_semaphore *s);
int down_read_trylock(struct rw_semaphore *s);
void down_write(struct rw_semaphore *s);
+void downgrade_write(struct rw_semaphore *s);
int down_write_trylock(struct rw_semaphore *s);
void up_read(struct rw_semaphore *s);
void up_write(struct rw_semaphore *s);
/*
* Atomic for single-threaded user-space
*/
-typedef struct { volatile int counter; } cfs_atomic_t;
-
-#define CFS_ATOMIC_INIT(i) { (i) }
-
-#define cfs_atomic_read(a) ((a)->counter)
-#define cfs_atomic_set(a,b) do {(a)->counter = b; } while (0)
-#define cfs_atomic_dec_and_test(a) ((--((a)->counter)) == 0)
-#define cfs_atomic_dec_and_lock(a,b) ((--((a)->counter)) == 0)
-#define cfs_atomic_inc(a) (((a)->counter)++)
-#define cfs_atomic_dec(a) do { (a)->counter--; } while (0)
-#define cfs_atomic_add(b,a) do {(a)->counter += b;} while (0)
-#define cfs_atomic_add_return(n,a) ((a)->counter += n)
-#define cfs_atomic_inc_return(a) cfs_atomic_add_return(1,a)
-#define cfs_atomic_sub(b,a) do {(a)->counter -= b;} while (0)
-#define cfs_atomic_sub_return(n,a) ((a)->counter -= n)
-#define cfs_atomic_dec_return(a) cfs_atomic_sub_return(1,a)
-#define cfs_atomic_add_unless(v, a, u) \
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i) { (i) }
+
+#define atomic_read(a) ((a)->counter)
+#define atomic_set(a,b) do {(a)->counter = b; } while (0)
+#define atomic_dec_and_test(a) ((--((a)->counter)) == 0)
+#define atomic_dec_and_lock(a,b) ((--((a)->counter)) == 0)
+#define atomic_inc(a) (((a)->counter)++)
+#define atomic_dec(a) do { (a)->counter--; } while (0)
+#define atomic_add(b,a) do {(a)->counter += b;} while (0)
+#define atomic_add_return(n,a) ((a)->counter += n)
+#define atomic_inc_return(a) atomic_add_return(1,a)
+#define atomic_sub(b,a) do {(a)->counter -= b;} while (0)
+#define atomic_sub_return(n,a) ((a)->counter -= n)
+#define atomic_dec_return(a) atomic_sub_return(1,a)
+#define atomic_add_unless(v, a, u) \
((v)->counter != u ? (v)->counter += a : 0)
-#define cfs_atomic_inc_not_zero(v) cfs_atomic_add_unless((v), 1, 0)
-#define cfs_atomic_cmpxchg(v, ov, nv) \
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+#define atomic_cmpxchg(v, ov, nv) \
((v)->counter == ov ? ((v)->counter = nv, ov) : (v)->counter)
#ifdef HAVE_LIBPTHREAD