summaryrefslogtreecommitdiff
path: root/libfuse-lite/fuse_misc.h (plain)
blob: 5f02165a0fe39c376bdd5ea475424f9ea7b41b4d
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
15static 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
25typedef struct _pthread_rwlock_t
26{
27// struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
28 int __rw_readers; /* Number of readers */
29// _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */
30// _pthread_descr __rw_read_waiting; /* Threads waiting for reading */
31// _pthread_descr __rw_write_waiting; /* Threads waiting for writing */
32 int __rw_kind; /* Reader/Writer preference selection */
33 int __rw_pshared; /* Shared between processes or not */
34} pthread_rwlock_t;
35
36typedef struct
37{
38 int __lockkind;
39 int __pshared;
40} pthread_rwlockattr_t;
41
42
43static inline int pthread_rwlock_init (pthread_rwlock_t * __rwlock,
44 pthread_rwlockattr_t *__attr)
45{
46 return 1;
47}
48
49static inline int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
50{
51 return 1;
52}
53
54
55
56/* Acquire read lock for RWLOCK. */
57static inline int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
58{
59 return 1;
60}
61
62
63/* Acquire write lock for RWLOCK. */
64static inline int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
65{
66 return 1;
67}
68
69
70
71
72/* Unlock RWLOCK. */
73static inline int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
74{
75 return 1;
76}
77
78
79
80#ifdef HAVE_STRUCT_STAT_ST_ATIM
81/* Linux */
82#define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atim.tv_nsec)
83#define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctim.tv_nsec)
84#define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtim.tv_nsec)
85#define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atim.tv_nsec = (val)
86#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtim.tv_nsec = (val)
87#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
88/* FreeBSD */
89#define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimespec.tv_nsec)
90#define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimespec.tv_nsec)
91#define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimespec.tv_nsec)
92#define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimespec.tv_nsec = (val)
93#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimespec.tv_nsec = (val)
94#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC)
95#define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimensec)
96#define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimensec)
97#define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimensec)
98#define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimensec = (val)
99#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimensec = (val)
100#else
101#define ST_ATIM_NSEC(stbuf) 0
102#define ST_CTIM_NSEC(stbuf) 0
103#define ST_MTIM_NSEC(stbuf) 0
104#define ST_ATIM_NSEC_SET(stbuf, val) do { } while (0)
105#define ST_MTIM_NSEC_SET(stbuf, val) do { } while (0)
106#endif
107