remove deprecated luminance texture generation
[voxelands-alt.git] / inc / thread.h
blobad6462738de1c8b4a81b4e54938b3fdbef44c678
1 #ifndef _THREAD_H_
2 #define _THREAD_H_
4 #include "common.h"
6 #ifdef WIN32
7 #include <windows.h>
8 #else
9 #include <pthread.h>
10 #endif
12 #ifndef _HAVE_THREADID_TYPE
13 #define _HAVE_THREADID_TYPE
14 #ifdef WIN32
15 typedef DWORD threadid_t;
16 #else
17 typedef pthread_t threadid_t;
18 #endif
19 #endif
21 #ifndef _HAVE_THREAD_TYPE
22 #define _HAVE_THREAD_TYPE
23 #include "array.h"
24 typedef struct thread_s {
25 struct thread_s *prev;
26 struct thread_s *next;
27 #ifndef WIN32
28 pthread_t thread;
29 pthread_attr_t attr;
30 #else
31 HANDLE thread;
32 #endif
33 unsigned int state;
34 int exit;
35 void *(*func)();
36 array_t *args;
37 } thread_t;
38 #endif
40 #ifndef _HAVE_MUTEX_TYPE
41 #define _HAVE_MUTEX_TYPE
42 typedef struct mutex_s {
43 struct mutex_s *prev;
44 struct mutex_s *next;
45 #ifndef WIN32
46 pthread_mutexattr_t attr;
47 pthread_mutex_t mut;
48 #else
49 CRITICAL_SECTION mut;
50 #endif
51 threadid_t id;
52 int count;
53 } mutex_t;
54 #endif
56 /* defined in thread.c */
57 thread_t *thread_create(void *(*func)(), array_t *args);
58 void thread_free(thread_t *t);
59 void thread_exit(thread_t *t, int state);
60 void thread_stop(thread_t *t);
61 int thread_wake(thread_t *t);
62 void thread_wait(thread_t *t);
63 threadid_t thread_get_current_id(void);
64 mutex_t *mutex_create(void);
65 void mutex_free(mutex_t *m);
66 void mutex_lock(mutex_t *m);
67 int mutex_trylock(mutex_t *m);
68 void mutex_unlock(mutex_t *m);
69 void mutex_unlock_complete(mutex_t *m);
71 #endif