mirror of
https://github.com/git-for-windows/git.git
synced 2026-03-25 19:43:19 -05:00
win32/pthread: avoid name clashes with winpthread
The mingw-w64 GCC seems to link implicitly to libwinpthread, which does implement a pthread emulation (that is more complete than Git's). Let's keep preferring Git's. To avoid linker errors where it thinks that the `pthread_self` and the `pthread_create` symbols are defined twice, let's give our version a `win32_` prefix, just like we already do for `pthread_join()`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -21,8 +21,8 @@ static unsigned __stdcall win32_start_routine(void *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pthread_create(pthread_t *thread, const void *unused,
|
int win32_pthread_create(pthread_t *thread, const void *unused,
|
||||||
void *(*start_routine)(void *), void *arg)
|
void *(*start_routine)(void *), void *arg)
|
||||||
{
|
{
|
||||||
thread->arg = arg;
|
thread->arg = arg;
|
||||||
thread->start_routine = start_routine;
|
thread->start_routine = start_routine;
|
||||||
@@ -53,7 +53,7 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_t pthread_self(void)
|
pthread_t win32_pthread_self(void)
|
||||||
{
|
{
|
||||||
pthread_t t = { NULL };
|
pthread_t t = { NULL };
|
||||||
t.tid = GetCurrentThreadId();
|
t.tid = GetCurrentThreadId();
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ typedef struct {
|
|||||||
DWORD tid;
|
DWORD tid;
|
||||||
} pthread_t;
|
} pthread_t;
|
||||||
|
|
||||||
int pthread_create(pthread_t *thread, const void *unused,
|
int win32_pthread_create(pthread_t *thread, const void *unused,
|
||||||
void *(*start_routine)(void*), void *arg);
|
void *(*start_routine)(void*), void *arg);
|
||||||
|
#define pthread_create win32_pthread_create
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To avoid the need of copying a struct, we use small macro wrapper to pass
|
* To avoid the need of copying a struct, we use small macro wrapper to pass
|
||||||
@@ -62,7 +63,8 @@ int pthread_create(pthread_t *thread, const void *unused,
|
|||||||
int win32_pthread_join(pthread_t *thread, void **value_ptr);
|
int win32_pthread_join(pthread_t *thread, void **value_ptr);
|
||||||
|
|
||||||
#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
|
#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
|
||||||
pthread_t pthread_self(void);
|
pthread_t win32_pthread_self(void);
|
||||||
|
#define pthread_self win32_pthread_self
|
||||||
|
|
||||||
static inline void NORETURN pthread_exit(void *ret)
|
static inline void NORETURN pthread_exit(void *ret)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user