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:
Johannes Schindelin 2019-10-20 22:08:58 +02:00
parent 2a876cc579
commit c4e5bb652c
2 changed files with 8 additions and 6 deletions

View File

@ -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();

View File

@ -50,8 +50,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
@ -62,7 +63,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
static inline void NORETURN pthread_exit(void *ret)
{