]> arthur.barton.de Git - netatalk.git/blob - libatalk/adouble/ad_lock.h
Merge master
[netatalk.git] / libatalk / adouble / ad_lock.h
1 #ifndef LIBATALK_ADOUBLE_AD_PRIVATE_H
2 #define LIBATALK_ADOUBLE_AD_PRIVATE_H 1
3
4 #include <atalk/adouble.h>
5
6 /* this is so that we can keep lists of fds referencing the same file                                                                                                                                                                                                         
7  * around. that way, we can honor locks created by the same process                                                                                                                                                                                                           
8  * with the same file. */
9
10 #define adf_lock_init(a) do { \
11         (a)->adf_lockmax = (a)->adf_lockcount = 0; \
12         (a)->adf_excl = 0;(a)->adf_lock = NULL; \
13     } while (0)
14
15 #define adf_lock_free(a) do { \
16         int i;\
17         if (!(a)->adf_lock) \
18             break; \
19         for (i = 0; i < (a)->adf_lockcount; i++) {\
20             adf_lock_t *lock = (a)->adf_lock + i;\
21             if (--(*lock->refcount) < 1)free(lock->refcount); \
22         }\
23         free((a)->adf_lock); \
24         adf_lock_init(a); \
25     } while (0)
26
27 #endif /* libatalk/adouble/ad_private.h */