summaryrefslogtreecommitdiff
path: root/mt.c
blob: e5b241e7a1eca4ac0d5be01bbb3ebd82a2b9b90f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}