diff options
author | Benjamin Fleischer <fleiben@gmail.com> | 2013-01-08 14:53:09 +0100 |
---|---|---|
committer | Benjamin Fleischer <fleiben@gmail.com> | 2013-01-08 15:32:57 +0100 |
commit | 14581937282486ab7ce057ec79f226181ef1d45d (patch) | |
tree | 74dc8d75bcc78d1aae3f17d9975ebd9f0c60767c /compat/darwin_compat.h | |
parent | 66458931ddd09fc15244c5ddf3c1ec73e2fd08b9 (diff) | |
download | sshfs-14581937282486ab7ce057ec79f226181ef1d45d.tar sshfs-14581937282486ab7ce057ec79f226181ef1d45d.tar.gz sshfs-14581937282486ab7ce057ec79f226181ef1d45d.tar.bz2 sshfs-14581937282486ab7ce057ec79f226181ef1d45d.zip |
Add unnamed semaphore implementation for Mac OS X
In the past we relied on libosxfuse including a working unnamed semaphore
implmentation for Mac OS X. This will not be the case in future releases of
OSXFUSE, therefore we need to add our own implementation.
Diffstat (limited to 'compat/darwin_compat.h')
-rw-r--r-- | compat/darwin_compat.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/compat/darwin_compat.h b/compat/darwin_compat.h new file mode 100644 index 0000000..1cdbcce --- /dev/null +++ b/compat/darwin_compat.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2006-2008 Amit Singh/Google Inc. + * Copyright (c) 2011-2012 Benjamin Fleischer + */ + +#ifndef _DARWIN_COMPAT_ +#define _DARWIN_COMPAT_ + +#include <pthread.h> + +/* Semaphores */ + +struct __local_sem_t +{ + unsigned int count; + pthread_mutex_t count_lock; + pthread_cond_t count_cond; +}; + +typedef struct fuse_sem { + int id; + union { + struct __local_sem_t local; + } __data; +} darwin_sem_t; + +#define DARWIN_SEM_VALUE_MAX ((int32_t)32767) + +int darwin_sem_init(darwin_sem_t *sem, int pshared, unsigned int value); +int darwin_sem_destroy(darwin_sem_t *sem); +int darwin_sem_getvalue(darwin_sem_t *sem, unsigned int *value); +int darwin_sem_post(darwin_sem_t *sem); +int darwin_sem_timedwait(darwin_sem_t *sem, const struct timespec *abs_timeout); +int darwin_sem_trywait(darwin_sem_t *sem); +int darwin_sem_wait(darwin_sem_t *sem); + +/* Caller must not include <semaphore.h> */ + +typedef darwin_sem_t sem_t; + +#define sem_init(s, p, v) darwin_sem_init(s, p, v) +#define sem_destroy(s) darwin_sem_destroy(s) +#define sem_getvalue(s, v) darwin_sem_getvalue(s, v) +#define sem_post(s) darwin_sem_post(s) +#define sem_timedwait(s, t) darwin_sem_timedwait(s, t) +#define sem_trywait(s) darwin_sem_trywait(s) +#define sem_wait(s) darwin_sem_wait(s) + +#define SEM_VALUE_MAX DARWIN_SEM_VALUE_MAX + +#endif /* _DARWIN_COMPAT_ */ |