winpthreads: Fix building for ARM and ARM64 The libgcc stubs aren't necessary if building this when using compiler-rt, after those stubs are available. Just make the fake libgcc assembly file a no-op if targeting another architecture. Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-libraries/winpthreads/src/libgcc/dll_dependency.S b/mingw-w64-libraries/winpthreads/src/libgcc/dll_dependency.S index 2262eb0..0496e94 100644 --- a/mingw-w64-libraries/winpthreads/src/libgcc/dll_dependency.S +++ b/mingw-w64-libraries/winpthreads/src/libgcc/dll_dependency.S
@@ -1,4 +1,5 @@ /* Implementation for gcc's internal stack-allocation routines. */ +#if defined(__i386__) || defined(__x86_64__) .global ___chkstk .global __alloca @@ -86,3 +87,4 @@ pushl 4(%eax) ret #endif +#endif
diff --git a/mingw-w64-libraries/winpthreads/src/spinlock.c b/mingw-w64-libraries/winpthreads/src/spinlock.c index e55e929..2032d60 100644 --- a/mingw-w64-libraries/winpthreads/src/spinlock.c +++ b/mingw-w64-libraries/winpthreads/src/spinlock.c
@@ -53,7 +53,13 @@ volatile spinlock_word_t *lk = (volatile spinlock_word_t *)lock; while (unlikely(__sync_lock_test_and_set(lk, 0) == 0)) do { +#if defined(__i386__) || defined(__x86_64__) asm("pause" ::: "memory"); +#elif defined(__arm__) || defined(__aarch64__) + asm("wfe" ::: "memory"); +#else +#error Unsupported architecture +#endif } while (*lk == 0); return 0; }
diff --git a/mingw-w64-libraries/winpthreads/src/thread.c b/mingw-w64-libraries/winpthreads/src/thread.c index fafd915..2b7c7be 100644 --- a/mingw-w64-libraries/winpthreads/src/thread.c +++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1237,8 +1237,12 @@ GetThreadContext(tv->h, &ctxt); #ifdef _M_X64 ctxt.Rip = (uintptr_t) _pthread_invoke_cancel; -#else +#elif defined(_M_IX86) ctxt.Eip = (uintptr_t) _pthread_invoke_cancel; +#elif defined(_M_ARM) || defined(_M_ARM64) + ctxt.Pc = (uintptr_t) _pthread_invoke_cancel; +#else +#error Unsupported architecture #endif SetThreadContext (tv->h, &ctxt);