2 * Copyright (C) 2009 Andrzej K. Haczewski <ahaczewski@gmail.com>
4 * DISCLAIMER: The implementation is Git-specific, it is subset of original
5 * Pthreads API, without lots of other features that Git doesn't use.
6 * Git also makes sure that the passed arguments are valid, so there's
7 * no need for double-checking.
10 #include "../../git-compat-util.h"
16 static unsigned __stdcall
win32_start_routine(void *arg
)
18 pthread_t
*thread
= arg
;
19 thread
->tid
= GetCurrentThreadId();
20 thread
->arg
= thread
->start_routine(thread
->arg
);
24 int pthread_create(pthread_t
*thread
, const void *unused
,
25 void *(*start_routine
)(void*), void *arg
)
28 thread
->start_routine
= start_routine
;
29 thread
->handle
= (HANDLE
)
30 _beginthreadex(NULL
, 0, win32_start_routine
, thread
, 0, NULL
);
38 int win32_pthread_join(pthread_t
*thread
, void **value_ptr
)
40 DWORD result
= WaitForSingleObject(thread
->handle
, INFINITE
);
44 *value_ptr
= thread
->arg
;
49 return err_win_to_posix(GetLastError());
53 pthread_t
pthread_self(void)
55 pthread_t t
= { NULL
};
56 t
.tid
= GetCurrentThreadId();