mirror of
https://github.com/git-for-windows/git.git
synced 2026-02-04 03:33:01 -06:00
win32/pthread: avoid name clashes with winpthread
When asking the mingw-w64 variant of GCC to compile C11 code, it seems to link implicitly to libwinpthread, which does implement a pthread emulation (that is more complete than Git's). In preparation for vendoring in mimalloc (which requires C11 support), let's keep preferring Git's own pthread emulation. 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:
parent
c132a44d8a
commit
77e482b305
@ -21,8 +21,8 @@ static unsigned __stdcall win32_start_routine(void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *thread, const void *attr UNUSED,
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
int win32_pthread_create(pthread_t *thread, const void *attr UNUSED,
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
thread->arg = arg;
|
||||
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 };
|
||||
t.tid = GetCurrentThreadId();
|
||||
|
||||
@ -49,8 +49,9 @@ typedef struct {
|
||||
DWORD tid;
|
||||
} pthread_t;
|
||||
|
||||
int pthread_create(pthread_t *thread, const void *unused,
|
||||
void *(*start_routine)(void*), void *arg);
|
||||
int win32_pthread_create(pthread_t *thread, const void *unused,
|
||||
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
|
||||
@ -61,7 +62,8 @@ int pthread_create(pthread_t *thread, const void *unused,
|
||||
int win32_pthread_join(pthread_t *thread, void **value_ptr);
|
||||
|
||||
#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
|
||||
|
||||
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user