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.
16 pthread_spinlock_t lock
;
24 pthread_rwlock_t lock
;
27 static inline int spinlock_init(struct spinlock
*l
)
29 return -pthread_spin_init(&l
->lock
, 0);
32 static inline void spinlock_destroy(struct spinlock
*l
)
34 pthread_spin_destroy(&l
->lock
);
37 static inline void spinlock_lock(struct spinlock
*l
)
39 pthread_spin_lock(&l
->lock
);
42 static inline void spinlock_unlock(struct spinlock
*l
)
44 pthread_spin_unlock(&l
->lock
);
47 static inline int mutexlock_init(struct mutexlock
*l
)
49 return -pthread_mutex_init(&l
->lock
, 0);
52 static inline void mutexlock_destroy(struct mutexlock
*l
)
54 pthread_mutex_destroy(&l
->lock
);
57 static inline void mutexlock_lock(struct mutexlock
*l
)
59 pthread_mutex_lock(&l
->lock
);
62 static inline void mutexlock_unlock(struct mutexlock
*l
)
64 pthread_mutex_unlock(&l
->lock
);
67 static inline int rwlock_init(struct rwlock
*l
)
69 return -pthread_rwlock_init(&l
->lock
, 0);
72 static inline int rwlock_init2(struct rwlock
*l
,
73 pthread_rwlockattr_t
*restrict attr
)
75 return -pthread_rwlock_init(&l
->lock
, attr
);
78 static inline void rwlock_destroy(struct rwlock
*l
)
80 pthread_rwlock_destroy(&l
->lock
);
83 static inline void rwlock_rd_lock(struct rwlock
*l
)
85 pthread_rwlock_rdlock(&l
->lock
);
88 static inline void rwlock_wr_lock(struct rwlock
*l
)
90 pthread_rwlock_wrlock(&l
->lock
);
93 static inline void rwlock_unlock(struct rwlock
*l
)
95 pthread_rwlock_unlock(&l
->lock
);
98 #endif /* LOCKING_H */