]> wimlib.net Git - wimlib/blob - include/wimlib/threads.h
mount_image.c: add fallback definitions of RENAME_* constants
[wimlib] / include / wimlib / threads.h
1 #ifndef _WIMLIB_THREADS_H
2 #define _WIMLIB_THREADS_H
3
4 #include <stdbool.h>
5
6 #ifdef _WIN32
7
8 struct thread {
9         void *win32_thread;
10         void *(*thrproc)(void *);
11         void *arg;
12 };
13
14 struct mutex { void *win32_crit; };
15 #define MUTEX_INITIALIZER { NULL }
16
17 struct condvar { void *win32_cond; };
18
19 #else /* _WIN32 */
20
21 #include <pthread.h>
22
23 struct thread { pthread_t pthread; };
24
25 struct mutex { pthread_mutex_t pthread_mutex; };
26 #define MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
27
28 struct condvar { pthread_cond_t pthread_cond; };
29
30 #endif /* !_WIN32 */
31
32 bool thread_create(struct thread *t, void *(*thrproc)(void *), void *arg);
33 void thread_join(struct thread *t);
34 bool mutex_init(struct mutex *m);
35 void mutex_destroy(struct mutex *m);
36 void mutex_lock(struct mutex *m);
37 void mutex_unlock(struct mutex *m);
38 bool condvar_init(struct condvar *c);
39 void condvar_destroy(struct condvar *c);
40 void condvar_wait(struct condvar *c, struct mutex *m);
41 void condvar_signal(struct condvar *c);
42 void condvar_broadcast(struct condvar *c);
43
44 #endif /* _WIMLIB_THREADS_H */