2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2011 Daniel Borkmann.
5 * Subject to the GPL, version 2.
14 pthread_spinlock_t lock
;
22 pthread_rwlock_t lock
;
25 static inline int spinlock_init(struct spinlock
*l
)
27 return -pthread_spin_init(&l
->lock
, 0);
30 static inline void spinlock_destroy(struct spinlock
*l
)
32 pthread_spin_destroy(&l
->lock
);
35 static inline void spinlock_lock(struct spinlock
*l
)
37 pthread_spin_lock(&l
->lock
);
40 static inline void spinlock_unlock(struct spinlock
*l
)
42 pthread_spin_unlock(&l
->lock
);
45 static inline int mutexlock_init(struct mutexlock
*l
)
47 return -pthread_mutex_init(&l
->lock
, 0);
50 static inline void mutexlock_destroy(struct mutexlock
*l
)
52 pthread_mutex_destroy(&l
->lock
);
55 static inline void mutexlock_lock(struct mutexlock
*l
)
57 pthread_mutex_lock(&l
->lock
);
60 static inline void mutexlock_unlock(struct mutexlock
*l
)
62 pthread_mutex_unlock(&l
->lock
);
65 static inline int rwlock_init(struct rwlock
*l
)
67 return -pthread_rwlock_init(&l
->lock
, 0);
70 static inline void rwlock_destroy(struct rwlock
*l
)
72 pthread_rwlock_destroy(&l
->lock
);
75 static inline void rwlock_rd_lock(struct rwlock
*l
)
77 pthread_rwlock_rdlock(&l
->lock
);
80 static inline void rwlock_wr_lock(struct rwlock
*l
)
82 pthread_rwlock_wrlock(&l
->lock
);
85 static inline void rwlock_unlock(struct rwlock
*l
)
87 pthread_rwlock_unlock(&l
->lock
);
90 #endif /* LOCKING_H */