7 pthread_spinlock_t lock
;
15 pthread_rwlock_t lock
;
18 static inline int spinlock_init(struct spinlock
*l
)
20 return -pthread_spin_init(&l
->lock
, 0);
23 static inline void spinlock_destroy(struct spinlock
*l
)
25 pthread_spin_destroy(&l
->lock
);
28 static inline void spinlock_lock(struct spinlock
*l
)
30 pthread_spin_lock(&l
->lock
);
33 static inline void spinlock_unlock(struct spinlock
*l
)
35 pthread_spin_unlock(&l
->lock
);
38 static inline int mutexlock_init(struct mutexlock
*l
)
40 return -pthread_mutex_init(&l
->lock
, 0);
43 static inline void mutexlock_destroy(struct mutexlock
*l
)
45 pthread_mutex_destroy(&l
->lock
);
48 static inline void mutexlock_lock(struct mutexlock
*l
)
50 pthread_mutex_lock(&l
->lock
);
53 static inline void mutexlock_unlock(struct mutexlock
*l
)
55 pthread_mutex_unlock(&l
->lock
);
58 static inline int rwlock_init(struct rwlock
*l
)
60 return -pthread_rwlock_init(&l
->lock
, 0);
63 static inline void rwlock_destroy(struct rwlock
*l
)
65 pthread_rwlock_destroy(&l
->lock
);
68 static inline void rwlock_rd_lock(struct rwlock
*l
)
70 pthread_rwlock_rdlock(&l
->lock
);
73 static inline void rwlock_wr_lock(struct rwlock
*l
)
75 pthread_rwlock_wrlock(&l
->lock
);
78 static inline void rwlock_unlock(struct rwlock
*l
)
80 pthread_rwlock_unlock(&l
->lock
);
83 #endif /* LOCKING_H */