[threads] Added missing initializers, check errors on mutex/cond calls

This commit is contained in:
Scott Shambarger
2017-01-13 17:32:59 -05:00
parent ca6836f638
commit b54d94fda6
8 changed files with 207 additions and 93 deletions

View File

@@ -8,6 +8,7 @@
#include <stdint.h>
#include <time.h>
#include <pthread.h>
struct onekeyval {
char *name;
@@ -96,4 +97,27 @@ timespec_add(struct timespec time1, struct timespec time2);
int
timespec_cmp(struct timespec time1, struct timespec time2);
/* mutex wrappers with checks */
void
fork_mutex_init(pthread_mutex_t *mutex);
void
fork_mutex_lock(pthread_mutex_t *mutex);
void
fork_mutex_unlock(pthread_mutex_t *mutex);
void
fork_mutex_destroy(pthread_mutex_t *mutex);
/* condition wrappers with checks */
void
fork_cond_init(pthread_cond_t *cond);
void
fork_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
int
fork_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *ts);
void
fork_cond_signal(pthread_cond_t *cond);
void
fork_cond_destroy(pthread_cond_t *cond);
#endif /* !__MISC_H__ */