xref: /haiku/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_misc.h (revision a79773546fc6078cc42c41b19ff76ca2626eac6b)
18553e89eSIngo Weinhold /*
28553e89eSIngo Weinhold   FUSE: Filesystem in Userspace
38553e89eSIngo Weinhold   Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
48553e89eSIngo Weinhold 
58553e89eSIngo Weinhold   This program can be distributed under the terms of the GNU LGPLv2.
68553e89eSIngo Weinhold   See the file COPYING.LIB
78553e89eSIngo Weinhold */
88553e89eSIngo Weinhold 
98553e89eSIngo Weinhold #include "config.h"
108553e89eSIngo Weinhold #include <pthread.h>
118553e89eSIngo Weinhold 
128553e89eSIngo Weinhold /* Versioned symbols confuse the dynamic linker in uClibc */
13*a7977354SIngo Weinhold #if !defined(__UCLIBC__) && !defined(__HAIKU__)
148553e89eSIngo Weinhold #define FUSE_SYMVER(x) __asm__(x)
158553e89eSIngo Weinhold #else
168553e89eSIngo Weinhold #define FUSE_SYMVER(x)
178553e89eSIngo Weinhold #endif
188553e89eSIngo Weinhold 
198553e89eSIngo Weinhold #ifndef USE_UCLIBC
208553e89eSIngo Weinhold #define fuse_mutex_init(mut) pthread_mutex_init(mut, NULL)
218553e89eSIngo Weinhold #else
228553e89eSIngo Weinhold /* Is this hack still needed? */
fuse_mutex_init(pthread_mutex_t * mut)238553e89eSIngo Weinhold static inline void fuse_mutex_init(pthread_mutex_t *mut)
248553e89eSIngo Weinhold {
258553e89eSIngo Weinhold 	pthread_mutexattr_t attr;
268553e89eSIngo Weinhold 	pthread_mutexattr_init(&attr);
278553e89eSIngo Weinhold 	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
288553e89eSIngo Weinhold 	pthread_mutex_init(mut, &attr);
298553e89eSIngo Weinhold 	pthread_mutexattr_destroy(&attr);
308553e89eSIngo Weinhold }
318553e89eSIngo Weinhold #endif
328553e89eSIngo Weinhold 
338553e89eSIngo Weinhold #ifdef HAVE_STRUCT_STAT_ST_ATIM
348553e89eSIngo Weinhold /* Linux */
358553e89eSIngo Weinhold #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atim.tv_nsec)
368553e89eSIngo Weinhold #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctim.tv_nsec)
378553e89eSIngo Weinhold #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtim.tv_nsec)
388553e89eSIngo Weinhold #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atim.tv_nsec = (val)
398553e89eSIngo Weinhold #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtim.tv_nsec = (val)
408553e89eSIngo Weinhold #elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
418553e89eSIngo Weinhold /* FreeBSD */
428553e89eSIngo Weinhold #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimespec.tv_nsec)
438553e89eSIngo Weinhold #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimespec.tv_nsec)
448553e89eSIngo Weinhold #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimespec.tv_nsec)
458553e89eSIngo Weinhold #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimespec.tv_nsec = (val)
468553e89eSIngo Weinhold #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimespec.tv_nsec = (val)
478553e89eSIngo Weinhold #else
488553e89eSIngo Weinhold #define ST_ATIM_NSEC(stbuf) 0
498553e89eSIngo Weinhold #define ST_CTIM_NSEC(stbuf) 0
508553e89eSIngo Weinhold #define ST_MTIM_NSEC(stbuf) 0
518553e89eSIngo Weinhold #define ST_ATIM_NSEC_SET(stbuf, val) do { } while (0)
528553e89eSIngo Weinhold #define ST_MTIM_NSEC_SET(stbuf, val) do { } while (0)
538553e89eSIngo Weinhold #endif
54