[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: nptl 0.30



Ulrich Drepper writes:

> With these sources out I hope the ppc and s390 people will update their
> parts.  We will have to do quite a bit of cleanup now, in preparation of
> adding the code the the glibc archive.

With the patch below plus the _pthread_cleanup_push patch that I
posted earlier (and that Jakub also reposted), I get no test failures
in NPTL on PPC32.  I have also included a couple of changes that PPC64
will need.

As a minor point, I think the __lll_test_and_set name is confusing for
what it does, which is really an exchange operation.  I would expect a
test_and_set operation to set the variable to 1 and tell me if it was
zero previously.  IMHO __lll_exchange would be a better name.

Also, I notice that sysdeps/unix/sysv/linux/lowlevellock.c.rej somehow
sneaked into nptl-0.30.tar.bz2.

Regards,
Paul.

diff -urN nptl-0.30/nptl/sysdeps/powerpc/tls.h libc/nptl/sysdeps/powerpc/tls.h
--- nptl-0.30/nptl/sysdeps/powerpc/tls.h	2003-03-17 22:22:52.000000000 +1100
+++ libc/nptl/sysdeps/powerpc/tls.h	2003-03-19 11:55:04.000000000 +1100
@@ -54,10 +54,8 @@
 /* The TP points to the start of the thread blocks.  */
 # define TLS_DTV_AT_TP	1
 
-/* For 32-bit, we use the multiple_threads field in the pthread struct */
-#ifndef __powerpc64__
+/* We use the multiple_threads field in the pthread struct.  */
 # define TLS_MULTIPLE_THREADS_IN_TCB	1
-#endif
 
 /* Get the thread descriptor definition.  */
 # include <nptl/descr.h>
diff -urN nptl-0.30/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
--- nptl-0.30/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h	2003-03-18 11:24:58.000000000 +1100
+++ libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h	2003-03-19 09:47:32.000000000 +1100
@@ -122,16 +122,26 @@
      __val;								      \
   })
 
+/* Set *futex to newval.  Returns the old value.  */
+#define __lll_test_and_set(futex, newval) \
+  ({ int __val;								      \
+     __asm __volatile (__lll_rel_instr "\n"				      \
+		       "1:	lwarx	%0,0,%2\n"			      \
+		       "	stwcx.	%3,0,%2\n"			      \
+		       "	bne-	1b\n"				      \
+		       "2:"						      \
+		       : "=&r" (__val), "=m" (*futex)			      \
+		       : "r" (futex), "r" (newval), "1" (*futex)	      \
+		       : "cr0", "memory");				      \
+     __val;								      \
+  })
+
 #define lll_mutex_unlock(lock) \
   (void) ({								      \
     int *__futex = &(lock);						      \
-     __asm __volatile (__lll_rel_instr ::: "memory");			      \
-    int __val = __lll_add (__futex, -1);				      \
-    if (__builtin_expect (__val != 1, 0))				      \
-      {									      \
-	*__futex = 0;							      \
-	lll_futex_wake (__futex, 1);					      \
-      }									      \
+    int __val = __lll_test_and_set (__futex, 0);			      \
+    if (__builtin_expect (__val > 1, 0))				      \
+      lll_futex_wake (__futex, 1);					      \
   })
 
 #define lll_mutex_islocked(futex) \
diff -urN nptl-0.30/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h libc/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
--- nptl-0.30/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h	2003-03-17 22:22:52.000000000 +1100
+++ libc/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h	2003-03-19 11:56:14.000000000 +1100
@@ -86,11 +86,11 @@
 
 # ifndef __ASSEMBLER__
 #  define SINGLE_THREAD_P						\
-  __builtin_expect (THREAD_GETMEM (THREAD_SELF, multiple_threads) \
-		    == 0, 1)
+  __builtin_expect (THREAD_GETMEM (THREAD_SELF,				\
+				   header.multiple_threads) == 0, 1)
 # else
 #   define SINGLE_THREAD_P						\
-  lwz   10,MULTIPLE_THREADS_OFFSET(13);				\
+  lwz   10,MULTIPLE_THREADS_OFFSET(13);					\
   cmpdi 10,0
 # endif
 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]