blob: 86309896fd88ac72e882218b0eaad45f396488d5
1 | /* |
2 | FUSE: Filesystem in Userspace |
3 | Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> |
4 | |
5 | This program can be distributed under the terms of the GNU LGPLv2. |
6 | See the file COPYING.LIB |
7 | */ |
8 | |
9 | #include "config.h" |
10 | #include <pthread.h> |
11 | |
12 | #ifndef USE_UCLIBC |
13 | #define fuse_mutex_init(mut) pthread_mutex_init(mut, NULL) |
14 | #else |
15 | static inline void fuse_mutex_init(pthread_mutex_t *mut) |
16 | { |
17 | pthread_mutexattr_t attr; |
18 | pthread_mutexattr_init(&attr); |
19 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); |
20 | pthread_mutex_init(mut, &attr); |
21 | pthread_mutexattr_destroy(&attr); |
22 | } |
23 | #endif |
24 | |
25 | #ifdef HAVE_STRUCT_STAT_ST_ATIM |
26 | /* Linux */ |
27 | #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atim.tv_nsec) |
28 | #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctim.tv_nsec) |
29 | #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtim.tv_nsec) |
30 | #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atim.tv_nsec = (val) |
31 | #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtim.tv_nsec = (val) |
32 | #elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC) |
33 | /* FreeBSD */ |
34 | #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimespec.tv_nsec) |
35 | #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimespec.tv_nsec) |
36 | #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimespec.tv_nsec) |
37 | #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimespec.tv_nsec = (val) |
38 | #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimespec.tv_nsec = (val) |
39 | #elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC) |
40 | #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimensec) |
41 | #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimensec) |
42 | #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimensec) |
43 | #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimensec = (val) |
44 | #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimensec = (val) |
45 | #else |
46 | #define ST_ATIM_NSEC(stbuf) 0 |
47 | #define ST_CTIM_NSEC(stbuf) 0 |
48 | #define ST_MTIM_NSEC(stbuf) 0 |
49 | #define ST_ATIM_NSEC_SET(stbuf, val) do { } while (0) |
50 | #define ST_MTIM_NSEC_SET(stbuf, val) do { } while (0) |
51 | #endif |
52 |