Skip to content

Commit 8960350

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 <[email protected]>
1 parent 4de6e75 commit 8960350

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

compat/win32/pthread.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ static unsigned __stdcall win32_start_routine(void *arg)
2121
return 0;
2222
}
2323

24-
int pthread_create(pthread_t *thread, const void *attr UNUSED,
25-
void *(*start_routine)(void *), void *arg)
24+
int win32_pthread_create(pthread_t *thread, const void *attr UNUSED,
25+
void *(*start_routine)(void *), void *arg)
2626
{
2727
thread->arg = arg;
2828
thread->start_routine = start_routine;
@@ -53,7 +53,7 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
5353
}
5454
}
5555

56-
pthread_t pthread_self(void)
56+
pthread_t win32_pthread_self(void)
5757
{
5858
pthread_t t = { NULL };
5959
t.tid = GetCurrentThreadId();

compat/win32/pthread.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ typedef struct {
5050
DWORD tid;
5151
} pthread_t;
5252

53-
int pthread_create(pthread_t *thread, const void *unused,
54-
void *(*start_routine)(void*), void *arg);
53+
int win32_pthread_create(pthread_t *thread, const void *unused,
54+
void *(*start_routine)(void*), void *arg);
55+
#define pthread_create win32_pthread_create
5556

5657
/*
5758
* 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,
6263
int win32_pthread_join(pthread_t *thread, void **value_ptr);
6364

6465
#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
65-
pthread_t pthread_self(void);
66+
pthread_t win32_pthread_self(void);
67+
#define pthread_self win32_pthread_self
6668

6769
static inline void NORETURN pthread_exit(void *ret)
6870
{

0 commit comments

Comments
 (0)