summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dev.c1
-rw-r--r--src/lib/frct.c3
-rw-r--r--src/lib/notifier.c6
-rw-r--r--src/lib/shm_flow_set.c5
-rw-r--r--src/lib/shm_rbuff.c2
-rw-r--r--src/lib/shm_rbuff_ll.c9
-rw-r--r--src/lib/shm_rbuff_pthr.c9
-rw-r--r--src/lib/shm_rdrbuff.c5
-rw-r--r--src/lib/sockets.c12
-rw-r--r--src/lib/timerwheel.c3
10 files changed, 23 insertions, 32 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 032d57f5..ec4561b2 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -37,6 +37,7 @@
#include <ouroboros/sockets.h>
#include <ouroboros/fccntl.h>
#include <ouroboros/bitmap.h>
+#include <ouroboros/pthread.h>
#include <ouroboros/random.h>
#include <ouroboros/shm_flow_set.h>
#include <ouroboros/shm_rdrbuff.h>
diff --git a/src/lib/frct.c b/src/lib/frct.c
index 615d499c..7aaf037c 100644
--- a/src/lib/frct.c
+++ b/src/lib/frct.c
@@ -413,8 +413,7 @@ static int __frcti_window_wait(struct frcti * frcti,
frcti->open = false;
}
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) &frcti->mtx);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &frcti->mtx);
ret = -pthread_cond_timedwait(&frcti->cond,
&frcti->mtx,
diff --git a/src/lib/notifier.c b/src/lib/notifier.c
index 06f15681..1f600765 100644
--- a/src/lib/notifier.c
+++ b/src/lib/notifier.c
@@ -25,8 +25,9 @@
#include <ouroboros/errno.h>
#include <ouroboros/notifier.h>
#include <ouroboros/list.h>
+#include <ouroboros/utils.h>
+#include <ouroboros/pthread.h>
-#include <pthread.h>
#include <stdlib.h>
struct listener {
@@ -75,8 +76,7 @@ void notifier_event(int event,
pthread_rwlock_rdlock(&notifier.lock);
- pthread_cleanup_push((void (*) (void *)) pthread_rwlock_unlock,
- (void *) &notifier.lock)
+ pthread_cleanup_push(__cleanup_rwlock_unlock, &notifier.lock)
list_for_each(p, &notifier.listeners) {
struct listener * l = list_entry(p, struct listener, next);
diff --git a/src/lib/shm_flow_set.c b/src/lib/shm_flow_set.c
index 553a7a78..5a9bee6c 100644
--- a/src/lib/shm_flow_set.c
+++ b/src/lib/shm_flow_set.c
@@ -28,8 +28,8 @@
#include <ouroboros/time_utils.h>
#include <ouroboros/shm_flow_set.h>
#include <ouroboros/errno.h>
+#include <ouroboros/pthread.h>
-#include <pthread.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -346,8 +346,7 @@ ssize_t shm_flow_set_wait(const struct shm_flow_set * set,
pthread_mutex_consistent(set->lock);
#endif
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) set->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, set->lock);
while (set->heads[idx] == 0 && ret != -ETIMEDOUT) {
if (abstime != NULL) {
diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c
index b75477ba..361d5bb0 100644
--- a/src/lib/shm_rbuff.c
+++ b/src/lib/shm_rbuff.c
@@ -29,8 +29,8 @@
#include <ouroboros/time_utils.h>
#include <ouroboros/errno.h>
#include <ouroboros/fccntl.h>
+#include <ouroboros/pthread.h>
-#include <pthread.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdlib.h>
diff --git a/src/lib/shm_rbuff_ll.c b/src/lib/shm_rbuff_ll.c
index 1a81b926..eef8a2fb 100644
--- a/src/lib/shm_rbuff_ll.c
+++ b/src/lib/shm_rbuff_ll.c
@@ -100,8 +100,7 @@ int shm_rbuff_write_b(struct shm_rbuff * rb,
goto err;
}
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) rb->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, rb->lock);
while (!shm_rbuff_free(rb) && ret != -ETIMEDOUT) {
if (abstime != NULL)
@@ -174,8 +173,7 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
if (pthread_mutex_lock(rb->lock) == EOWNERDEAD)
pthread_mutex_consistent(rb->lock);
#endif
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) rb->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, rb->lock);
while (shm_rbuff_empty(rb) && (idx != -ETIMEDOUT)) {
if (abstime != NULL)
@@ -230,8 +228,7 @@ void shm_rbuff_fini(struct shm_rbuff * rb)
pthread_mutex_consistent(rb->lock);
#endif
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) rb->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, rb->lock);
while (!shm_rbuff_empty(rb))
#ifndef HAVE_ROBUST_MUTEX
diff --git a/src/lib/shm_rbuff_pthr.c b/src/lib/shm_rbuff_pthr.c
index aa79b477..cedbc7b1 100644
--- a/src/lib/shm_rbuff_pthr.c
+++ b/src/lib/shm_rbuff_pthr.c
@@ -106,8 +106,7 @@ int shm_rbuff_write_b(struct shm_rbuff * rb,
goto err;
}
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) rb->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, rb->lock);
while (!shm_rbuff_free(rb)
&& ret != -ETIMEDOUT
@@ -186,8 +185,7 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
return -EFLOWDOWN;
}
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) rb->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, rb->lock);
while (shm_rbuff_empty(rb)
&& (idx != -ETIMEDOUT)
@@ -263,8 +261,7 @@ void shm_rbuff_fini(struct shm_rbuff * rb)
if (pthread_mutex_lock(rb->lock) == EOWNERDEAD)
pthread_mutex_consistent(rb->lock);
#endif
- pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
- (void *) rb->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, rb->lock);
while (!shm_rbuff_empty(rb))
#ifndef HAVE_ROBUST_MUTEX
diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c
index 2c966376..e3552100 100644
--- a/src/lib/shm_rdrbuff.c
+++ b/src/lib/shm_rdrbuff.c
@@ -28,8 +28,8 @@
#include <ouroboros/shm_rdrbuff.h>
#include <ouroboros/shm_du_buff.h>
#include <ouroboros/time_utils.h>
+#include <ouroboros/pthread.h>
-#include <pthread.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
@@ -392,8 +392,7 @@ ssize_t shm_rdrbuff_alloc_b(struct shm_rdrbuff * rdrb,
if (pthread_mutex_lock(rdrb->lock) == EOWNERDEAD)
sanitize(rdrb);
#endif
- pthread_cleanup_push((void (*) (void *)) pthread_mutex_unlock,
- (void *) rdrb->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, rdrb->lock);
#ifdef SHM_RDRB_MULTI_BLOCK
if (blocks + *rdrb->head > (SHM_BUFFER_SIZE))
diff --git a/src/lib/sockets.c b/src/lib/sockets.c
index 391d41d5..8179d2b3 100644
--- a/src/lib/sockets.c
+++ b/src/lib/sockets.c
@@ -40,6 +40,11 @@
#define SOCK_TYPE SOCK_SEQPACKET
#endif
+void __cleanup_close_ptr(void * fd)
+{
+ close(*(int *) fd);
+}
+
int client_socket_open(char * file_name)
{
int sockfd;
@@ -95,11 +100,6 @@ int server_socket_open(char * file_name)
return sockfd;
}
-static void close_ptr(void * o)
-{
- close(*(int *) o);
-}
-
irm_msg_t * send_recv_irm_msg(irm_msg_t * msg)
{
int sockfd;
@@ -117,7 +117,7 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg)
return NULL;
}
- pthread_cleanup_push(close_ptr, &sockfd);
+ pthread_cleanup_push(__cleanup_close_ptr, &sockfd);
irm_msg__pack(msg, buf);
diff --git a/src/lib/timerwheel.c b/src/lib/timerwheel.c
index 55433a58..3c1a44b4 100644
--- a/src/lib/timerwheel.c
+++ b/src/lib/timerwheel.c
@@ -147,8 +147,7 @@ static void timerwheel_move(void)
pthread_mutex_lock(&rw.lock);
- pthread_cleanup_push((void (*) (void *)) pthread_mutex_unlock,
- (void *) &rw.lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &rw.lock);
clock_gettime(PTHREAD_COND_CLOCK, &now);