summaryrefslogtreecommitdiff
path: root/src/lib/shm_rbuff_ll.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-08-03 14:51:41 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-03 15:19:16 +0200
commit5bb3bea07b0ff38e4646ed6f835d9bdac6beced6 (patch)
treeb071a0a3c396aa850a9024000a382165b0c00380 /src/lib/shm_rbuff_ll.c
parentb92eac2e9f6d686a9e2f748f8097aedbb373395c (diff)
downloadouroboros-5bb3bea07b0ff38e4646ed6f835d9bdac6beced6.tar.gz
ouroboros-5bb3bea07b0ff38e4646ed6f835d9bdac6beced6.zip
build: Add check for robust mutexes
This adds a check for robust mutexes. The constant HAVE_ROBUST_MUTEX is set accordingly in config.h. It also adds some other fixes to make the prototype compile on the Hurd.
Diffstat (limited to 'src/lib/shm_rbuff_ll.c')
-rw-r--r--src/lib/shm_rbuff_ll.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/shm_rbuff_ll.c b/src/lib/shm_rbuff_ll.c
index 1e072b21..757f65c8 100644
--- a/src/lib/shm_rbuff_ll.c
+++ b/src/lib/shm_rbuff_ll.c
@@ -127,7 +127,7 @@ struct shm_rbuff * shm_rbuff_create(pid_t api, int port_id)
rb->del = rb->add + 1;
pthread_mutexattr_init(&mattr);
-#ifndef __APPLE__
+#ifdef HAVE_ROBUST_MUTEX
pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST);
#endif
pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
@@ -299,7 +299,7 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
ts_add(&abstime, timeout, &abstime);
}
-#ifdef __APPLE__
+#ifndef HAVE_ROBUST_MUTEX
pthread_mutex_lock(rb->lock);
#else
if (pthread_mutex_lock(rb->lock) == EOWNERDEAD)
@@ -315,7 +315,7 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
&abstime);
else
idx = -pthread_cond_wait(rb->add, rb->lock);
-#ifndef __APPLE__
+#ifdef HAVE_ROBUST_MUTEX
if (idx == -EOWNERDEAD)
pthread_mutex_consistent(rb->lock);
#endif
@@ -356,7 +356,7 @@ void shm_rbuff_fini(struct shm_rbuff * rb)
if (shm_rbuff_empty(rb))
return;
-#ifdef __APPLE__
+#ifndef HAVE_ROBUST_MUTEX
pthread_mutex_lock(rb->lock);
#else
if (pthread_mutex_lock(rb->lock) == EOWNERDEAD)
@@ -367,7 +367,7 @@ void shm_rbuff_fini(struct shm_rbuff * rb)
(void *) rb->lock);
while (!shm_rbuff_empty(rb))
-#ifdef __APPLE__
+#ifndef HAVE_ROBUST_MUTEX
pthread_cond_wait(rb->del, rb->lock);
#else
if (pthread_cond_wait(rb->del, rb->lock) == EOWNERDEAD)