Skip to content

Commit 98d32ae

Browse files
committed
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 <[email protected]>
1 parent e05197d commit 98d32ae

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compat/win32/pthread.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static unsigned __stdcall win32_start_routine(void *arg)
2121
return 0;
2222
}
2323

24-
int pthread_create(pthread_t *thread, const void *unused,
24+
int win32_pthread_create(pthread_t *thread, const void *unused,
2525
void *(*start_routine)(void*), void *arg)
2626
{
2727
thread->arg = arg;
@@ -50,7 +50,7 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
5050
}
5151
}
5252

53-
pthread_t pthread_self(void)
53+
pthread_t win32_pthread_self(void)
5454
{
5555
pthread_t t = { NULL };
5656
t.tid = GetCurrentThreadId();

compat/win32/pthread.h

+5-3
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)