[vlc-commits] contrib: pthreads: Backport a winpthreads patch to fix building for armv7/aarch64

Martin Storsjö git at videolan.org
Mon May 21 11:09:43 CEST 2018


vlc | branch: master | Martin Storsjö <martin at martin.st> | Mon May 21 12:08:50 2018 +0300| [8ceae50d2e3c037dade05953b175ebabf3fdd7c3] | committer: Martin Storsjö

contrib: pthreads: Backport a winpthreads patch to fix building for armv7/aarch64

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8ceae50d2e3c037dade05953b175ebabf3fdd7c3
---

 ...inpthreads-Fix-building-for-ARM-and-ARM64.patch | 75 ++++++++++++++++++++++
 contrib/src/pthreads/rules.mak                     |  1 +
 2 files changed, 76 insertions(+)

diff --git a/contrib/src/pthreads/0001-winpthreads-Fix-building-for-ARM-and-ARM64.patch b/contrib/src/pthreads/0001-winpthreads-Fix-building-for-ARM-and-ARM64.patch
new file mode 100644
index 0000000000..e37909958a
--- /dev/null
+++ b/contrib/src/pthreads/0001-winpthreads-Fix-building-for-ARM-and-ARM64.patch
@@ -0,0 +1,75 @@
+From 43a3c0bdb1f9e31db1d096d67aed0d575b6e2093 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
+Date: Fri, 4 May 2018 12:05:20 +0300
+Subject: [PATCH] winpthreads: Fix building for ARM and ARM64
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+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 at martin.st>
+---
+ mingw-w64-libraries/winpthreads/src/libgcc/dll_dependency.S | 2 ++
+ mingw-w64-libraries/winpthreads/src/spinlock.c              | 6 ++++++
+ mingw-w64-libraries/winpthreads/src/thread.c                | 6 +++++-
+ 3 files changed, 13 insertions(+), 1 deletion(-)
+
+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 @@ chkstk_end:
+ 	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 @@ pthread_spin_lock (pthread_spinlock_t *lock)
+   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 @@ pthread_cancel (pthread_t t)
+ 	  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);
+ 
+-- 
+2.7.4
+
diff --git a/contrib/src/pthreads/rules.mak b/contrib/src/pthreads/rules.mak
index d660a9da6c..b7d2b57681 100644
--- a/contrib/src/pthreads/rules.mak
+++ b/contrib/src/pthreads/rules.mak
@@ -14,6 +14,7 @@ $(TARBALLS)/mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2:
 
 pthreads: mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2 .sum-pthreads
 	$(UNPACK)
+	$(APPLY) $(SRC)/pthreads/0001-winpthreads-Fix-building-for-ARM-and-ARM64.patch
 	$(MOVE)
 
 .pthreads: pthreads



More information about the vlc-commits mailing list