diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-08-01 23:12:41 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-08-01 23:12:41 +0200 |
commit | a239f9feadd015fa91d391df01365dcade8ce503 (patch) | |
tree | 979554817c2069a525e94e2ad5f6346b53e19eb5 /mt.c | |
parent | 9f2fccfdc2eae83efbde1e3ae94a2cc220537983 (diff) |
Threaded communication (icmpd)
Diffstat (limited to 'mt.c')
-rw-r--r-- | mt.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#include <assert.h> +#include "mt.h" + + +void mt_mutex_init(struct mt_mutex *mut) { + assert(pthread_mutex_init(&mut->m, NULL) == 0); +} + +void mt_mutex_destroy(struct mt_mutex *mut) { + assert(pthread_mutex_destroy(&mut->m) == 0); +} + +void mt_mutex_lock(struct mt_mutex *mut) { + assert(pthread_mutex_lock(&mut->m) == 0); +} + +void mt_mutex_unlock(struct mt_mutex *mut) { + assert(pthread_mutex_unlock(&mut->m) == 0); +} + +void mt_thread_create(struct mt_thread *th, void* (*callback)(void*), void *arg) { + assert(pthread_create(&th->t, NULL, callback, arg) == 0); +} + +void* mt_thread_join(struct mt_thread *th) { + void *ret; + assert(pthread_join(th->t, &ret)); + return ret; +} |