Explorar o código

m68k: fix linuxthreads compile for coldfire

The tas instruction is not available for most coldfire CPU's.
Use bset instead in this case as already used in linuxthreads.old.
Waldemar Brodkorb %!s(int64=11) %!d(string=hai) anos
pai
achega
edda0488a6

+ 15 - 5
libpthread/linuxthreads/sysdeps/m68k/pspinlock.c

@@ -27,10 +27,15 @@ __pthread_spin_lock (pthread_spinlock_t *lock)
   unsigned int val;
 
   do
-    __asm__ __volatile__ ("tas %1; sne %0"
-		  : "=dm" (val), "=m" (*lock)
-		  : "m" (*lock)
-		  : "cc");
+    __asm__ __volatile__ (
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+		"tas %1; sne %0"
+#else
+		"bset #7,%1; sne %0"
+#endif
+		: "=dm" (val), "=m" (*lock)
+		: "m" (*lock)
+		: "cc");
   while (val);
 
   return 0;
@@ -43,7 +48,12 @@ __pthread_spin_trylock (pthread_spinlock_t *lock)
 {
   unsigned int val;
 
-  __asm__ __volatile__ ("tas %1; sne %0"
+  __asm__ __volatile__ (
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+		"tas %1; sne %0"
+#else
+		"bset #7,%1; sne %0"
+#endif
 		: "=dm" (val), "=m" (*lock)
 		: "m" (*lock)
 		: "cc");

+ 9 - 2
libpthread/linuxthreads/sysdeps/m68k/pt-machine.h

@@ -28,12 +28,18 @@
 #endif
 
 /* Spinlock implementation; required.  */
+PT_EI long int testandset (int *spinlock);
 PT_EI long int
 testandset (int *spinlock)
 {
   char ret;
 
-  __asm__ __volatile__("tas %1; sne %0"
+  __asm__ __volatile__(
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+	"tas %1; sne %0"
+#else
+	"bset #7,%1; sne %0"
+#endif
        : "=dm"(ret), "=m"(*spinlock)
        : "m"(*spinlock)
        : "cc");
@@ -50,6 +56,7 @@ register char * stack_pointer __asm__ ("%sp");
 
 /* Compare-and-swap for semaphores. */
 
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__mc68000)
 #define HAS_COMPARE_AND_SWAP
 PT_EI int
 __compare_and_swap (long int *p, long int oldval, long int newval)
@@ -63,5 +70,5 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
 
   return ret;
 }
-
+#endif
 #endif /* pt-machine.h */

+ 2 - 0
libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c

@@ -16,7 +16,9 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <netdb.h>
+#ifdef __UCLIBC_HAS_TLS__
 #include <tls.h>
+#endif
 #include <linuxthreads/internals.h>
 #include <sysdep-cancel.h>