Subversion Repositories Shiroi

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 nishi 1
/* $Id: thread.c 1 2024-08-28 08:10:28Z nishi $ */
2
 
3
#ifdef __MINGW32__
4
#include <process.h>
5
#include <windows.h>
6
HANDLE thr;
7
#else
8
#include <pthread.h>
9
pthread_t th;
10
#endif
11
 
12
#include "shiroi.h"
13
 
14
extern shiroi_t shiroi;
15
 
16
#ifdef __MINGW32__
17
unsigned int WINAPI loop(LPVOID arg) {
18
#else
19
void* loop(void* arg) {
20
#endif
21
	shiroi_loop(&shiroi);
22
#ifdef __MINGW32__
23
	return 0;
24
#else
25
	return NULL;
26
#endif
27
}
28
 
29
void thread_start(void) {
30
#ifdef __MINGW32__
31
	thr = (HANDLE)_beginthreadex(NULL, 0, loop, NULL, 0, NULL);
32
#else
33
	pthread_create(&th, NULL, loop, NULL);
34
#endif
35
}
36
 
37
void thread_end(void) {
38
#ifdef __MINGW32__
39
	WaitForSingleObject(thr, INFINITE);
40
#else
41
	pthread_join(th, NULL);
42
#endif
43
}