diff options
author | ng0 <ng0@n0.is> | 2019-11-19 22:52:32 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-11-19 22:52:32 +0000 |
commit | b264f99648c52ef3e597f77417fde5c468858bb4 (patch) | |
tree | 20e2bf6cd684aa69a0d6d19aab899b861c5b78dc | |
parent | a50c5483263126e197376dc5bed3d4a6f570c08a (diff) | |
download | gnunet-fuse-b264f99648c52ef3e597f77417fde5c468858bb4.tar.gz gnunet-fuse-b264f99648c52ef3e597f77417fde5c468858bb4.zip |
mutex: pthread_np is not widespread on *BSD. FreeBSD points out that
the functions we are using are deprecated and pthread functions should
be used instead. Since we use them for Solaris, move the BSD define to
them. We should instead turn this into an else, as listing N + 1
operating systems definitions is bad style, for now just see if this
is usable.
Furthermore assume that pthread_np exists on Linux - which seems
to be unnecessary because this was previously guarded by BSD.
-rw-r--r-- | src/fuse/mutex.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/fuse/mutex.c b/src/fuse/mutex.c index 24c7036..55078fd 100644 --- a/src/fuse/mutex.c +++ b/src/fuse/mutex.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "mutex.h" | 26 | #include "mutex.h" |
27 | 27 | ||
28 | #include <pthread.h> | 28 | #include <pthread.h> |
29 | #if BSD | 29 | #ifdef LINUX |
30 | # include <pthread_np.h> | 30 | # include <pthread_np.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
@@ -73,10 +73,7 @@ GNUNET_mutex_create (int isRecursive) | |||
73 | #if LINUX | 73 | #if LINUX |
74 | GNUNET_assert (0 == pthread_mutexattr_setkind_np | 74 | GNUNET_assert (0 == pthread_mutexattr_setkind_np |
75 | (&attr, PTHREAD_MUTEX_RECURSIVE_NP)); | 75 | (&attr, PTHREAD_MUTEX_RECURSIVE_NP)); |
76 | #elif BSD | 76 | #elif BSD || SOLARIS || OSX || WINDOWS |
77 | GNUNET_assert (0 == pthread_mutexattr_setkind_np | ||
78 | (&attr, PTHREAD_MUTEX_RECURSIVE)); | ||
79 | #elif SOLARIS || OSX || WINDOWS | ||
80 | GNUNET_assert (0 == pthread_mutexattr_settype | 77 | GNUNET_assert (0 == pthread_mutexattr_settype |
81 | (&attr, PTHREAD_MUTEX_RECURSIVE)); | 78 | (&attr, PTHREAD_MUTEX_RECURSIVE)); |
82 | #endif | 79 | #endif |
@@ -110,7 +107,7 @@ GNUNET_mutex_lock (struct GNUNET_Mutex * mutex) | |||
110 | { | 107 | { |
111 | if (0 != (errno = pthread_mutex_lock (&mutex->pt))) | 108 | if (0 != (errno = pthread_mutex_lock (&mutex->pt))) |
112 | { | 109 | { |
113 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "pthread_mutex_unlock"); | 110 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "pthread_mutex_unlock"); |
114 | GNUNET_assert (0); | 111 | GNUNET_assert (0); |
115 | } | 112 | } |
116 | } | 113 | } |
@@ -121,7 +118,7 @@ GNUNET_mutex_unlock (struct GNUNET_Mutex * mutex) | |||
121 | { | 118 | { |
122 | if (0 != (errno = pthread_mutex_unlock (&mutex->pt))) | 119 | if (0 != (errno = pthread_mutex_unlock (&mutex->pt))) |
123 | { | 120 | { |
124 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "pthread_mutex_unlock"); | 121 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "pthread_mutex_unlock"); |
125 | GNUNET_assert (0); | 122 | GNUNET_assert (0); |
126 | } | 123 | } |
127 | } | 124 | } |