aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/compat/pthread.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/include/compat/pthread.h b/include/compat/pthread.h
index 19eea13..b2db760 100644
--- a/include/compat/pthread.h
+++ b/include/compat/pthread.h
@@ -18,17 +18,18 @@
18struct pthread_once { 18struct pthread_once {
19 INIT_ONCE once; 19 INIT_ONCE once;
20}; 20};
21
22typedef struct pthread_once pthread_once_t; 21typedef struct pthread_once pthread_once_t;
23 22
24static BOOL CALLBACK _pthread_once_win32_cb(PINIT_ONCE once, PVOID param, PVOID *context) 23static inline BOOL CALLBACK
24_pthread_once_win32_cb(PINIT_ONCE once, PVOID param, PVOID *context)
25{ 25{
26 void (*cb) (void) = param; 26 void (*cb) (void) = param;
27 cb(); 27 cb();
28 return TRUE; 28 return TRUE;
29} 29}
30 30
31static int pthread_once(pthread_once_t *once, void (*cb) (void)) 31static inline int
32pthread_once(pthread_once_t *once, void (*cb) (void))
32{ 33{
33 BOOL rc = InitOnceExecuteOnce(&once->once, _pthread_once_win32_cb, cb, NULL); 34 BOOL rc = InitOnceExecuteOnce(&once->once, _pthread_once_win32_cb, cb, NULL);
34 if (rc == 0) 35 if (rc == 0)
@@ -37,6 +38,25 @@ static int pthread_once(pthread_once_t *once, void (*cb) (void))
37 return 0; 38 return 0;
38} 39}
39 40
41struct pthread {
42 HANDLE handle;
43};
44typedef struct pthread pthread_t;
45
46static inline pthread_t
47pthread_self(void)
48{
49 pthread_t self;
50 self.handle = GetCurrentThread();
51 return self;
52}
53
54static inline int
55pthread_equal(pthread_t t1, pthread_t t2)
56{
57 return t1.handle == t2.handle;
58}
59
40#else 60#else
41#include_next <pthread.h> 61#include_next <pthread.h>
42#endif 62#endif