This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: testandset on powerpc
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: testandset on powerpc
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Sat, 22 Jul 2000 02:27:44 +0200
- Cc: Geoff Keating <geoffk at cygnus dot com>,libc-alpha at sourceware dot cygnus dot com,Greg McGary <greg at mcgary dot org>
- References: <Geoff Keating's message of "Tue, 18 Jul 2000 08:52:27 -0700"> <hopuobs7rf.fsf@maclaurin.suse.de> <ho4s5j1wn1.fsf@maclaurin.suse.de>
On Fri, 21 Jul 2000, Andreas Jaeger wrote:
> >>>>> Andreas Jaeger writes:
> >>>>>
> >>>>> Franz Sirl writes:
>
> Franz> I have done a patch which defines IMPLEMENT_TAS_AS_CAS in
> powerpc/pt-machine.h and Franz> define testandset(p) to
> !__compare_and_swap(p,0,1) in spinlock.h then. I haven't sent it AJ> That
> sounds fine. Please send the patch for review.
>
> Hi Franz,
>
> what happened to your fix? Is it working? In that case please send
> it soon to get ppc working again.
I finally found the main problem, Greg's bounded pointer work rendered
sysdeps/powerpc/strchr.S unusable without bounded pointers. The build
finishes now and make check passes nearly all tests. Since all the thread
tests pass, I believe my threads patch is correct. For the rest of the
failing tests I hopefully can take a look over the weekend.
Greg, my patch for strchr.S is probably not correct for the bounded pointer
case, so please have a look again.
Franz.
? obj
? sysdeps/powerpc/murx
Index: linuxthreads/spinlock.h
===================================================================
RCS file: /cvs/glibc/libc/linuxthreads/spinlock.h,v
retrieving revision 1.15
diff -u -p -r1.15 spinlock.h
--- linuxthreads/spinlock.h 2000/07/19 06:24:02 1.15
+++ linuxthreads/spinlock.h 2000/07/22 00:17:02
@@ -48,6 +48,10 @@ static inline int compare_and_swap(long
#elif defined(HAS_COMPARE_AND_SWAP)
+#ifdef IMPLEMENT_TAS_WITH_CAS
+#define testandset(p) !__compare_and_swap(p, 0, 1)
+#endif
+
#ifdef HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
static inline int
Index: linuxthreads/sysdeps/powerpc/pt-machine.h
===================================================================
RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/powerpc/pt-machine.h,v
retrieving revision 1.6
diff -u -p -r1.6 pt-machine.h
--- linuxthreads/sysdeps/powerpc/pt-machine.h 2000/04/11 17:34:36 1.6
+++ linuxthreads/sysdeps/powerpc/pt-machine.h 2000/07/22 00:17:02
@@ -28,7 +28,7 @@
/* For multiprocessor systems, we want to ensure all memory accesses
are completed before we reset a lock. On other systems, we still
need to make sure that the compiler has flushed everything to memory. */
-#define MEMORY_BARRIER() __asm__ ("sync" : : : "memory")
+#define MEMORY_BARRIER() __asm__ __volatile__ ("sync" : : : "memory")
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
@@ -36,9 +36,11 @@
register char * stack_pointer __asm__ ("r1");
/* Compare-and-swap for semaphores. */
-/* note that test-and-set(x) is the same as compare-and-swap(x, 0, 1) */
+/* note that test-and-set(x) is the same as !compare-and-swap(x, 0, 1) */
#define HAS_COMPARE_AND_SWAP
+#define IMPLEMENT_TAS_WITH_CAS
+
#if BROKEN_PPC_ASM_CR0
static
#else
@@ -50,7 +52,7 @@ __compare_and_swap (long int *p, long in
int ret;
MEMORY_BARRIER ();
- __asm__ (
+ __asm__ __volatile__ (
"0: lwarx %0,0,%1 ;"
" xor. %0,%3,%0;"
" bne 1f;"
Index: sysdeps/powerpc/strchr.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/powerpc/strchr.S,v
retrieving revision 1.4
diff -u -p -r1.4 strchr.S
--- sysdeps/powerpc/strchr.S 2000/07/04 00:24:42 1.4
+++ sysdeps/powerpc/strchr.S 2000/07/22 00:17:14
@@ -34,7 +34,7 @@ ENTRY (BP_SYM (strchr))
# define rCHR r5 /* byte we're looking for, spread over the whole word */
# define rWORD r8 /* the current word */
#else
-# define rSTR r3 /* current word pointer */
+# define rSTR r8 /* current word pointer */
# define rCHR r4 /* byte we're looking for, spread over the whole word */
# define rWORD r5 /* the current word */
#endif
@@ -52,10 +52,10 @@ ENTRY (BP_SYM (strchr))
rlwimi rCHR, rCHR, 8, 16, 23
li rMASK, -1
rlwimi rCHR, rCHR, 16, 0, 15
- rlwinm rIGN, rSTR, 3, 27, 28
+ rlwinm rIGN, rRTN, 3, 27, 28
lis rFEFE, -0x101
lis r7F7F, 0x7f7f
- clrrwi rSTR, rSTR, 2
+ clrrwi rSTR, rRTN, 2
addi rFEFE, rFEFE, -0x101
addi r7F7F, r7F7F, 0x7f7f
/* Test the first (partial?) word. */
@@ -90,7 +90,7 @@ L(loopentry):
happened, though. */
L(missed):
and. rTMP1, rTMP1, rTMP2
- li rSTR, 0
+ li rRTN, 0
STORE_RETURN_VALUE (rSTR)
beqlr
/* It did happen. Decide which one was first...
@@ -108,7 +108,7 @@ L(missed):
bgtlr
cntlzw rCLZB, rTMP2
srwi rCLZB, rCLZB, 3
- add rSTR, rSTR, rCLZB
+ add rRTN, rSTR, rCLZB
CHECK_BOUNDS_HIGH_RTN (rSTR, rTMP2, twlge)
STORE_RETURN_VALUE (rSTR)
blr
@@ -121,7 +121,7 @@ L(foundit):
cntlzw rCLZB, rTMP2
subi rSTR, rSTR, 4
srwi rCLZB, rCLZB, 3
- add rSTR, rSTR, rCLZB
+ add rRTN, rSTR, rCLZB
CHECK_BOUNDS_HIGH_RTN (rSTR, rTMP2, twlge)
STORE_RETURN_VALUE (rSTR)
blr