2 * 2008+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
21 #ifdef HAVE_PTHREAD_SPINLOCK
23 pthread_spinlock_t lock
;
26 static inline int dnet_lock_init(struct dnet_lock
*l
)
28 return -pthread_spin_init(&l
->lock
, 0);
31 static inline void dnet_lock_destroy(struct dnet_lock
*l
)
33 pthread_spin_destroy(&l
->lock
);
36 static inline void dnet_lock_lock(struct dnet_lock
*l
)
38 pthread_spin_lock(&l
->lock
);
41 static inline void dnet_lock_unlock(struct dnet_lock
*l
)
43 pthread_spin_unlock(&l
->lock
);
50 static inline int dnet_lock_init(struct dnet_lock
*l
)
52 return -pthread_mutex_init(&l
->lock
, NULL
);
55 static inline void dnet_lock_destroy(struct dnet_lock
*l
)
57 pthread_mutex_destroy(&l
->lock
);
60 static inline void dnet_lock_lock(struct dnet_lock
*l
)
62 pthread_mutex_lock(&l
->lock
);
65 static inline void dnet_lock_unlock(struct dnet_lock
*l
)
67 pthread_mutex_unlock(&l
->lock
);
71 #endif /* __DNET_LOCK_H */