This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: powerpc libc 2.2
On Mon, 26 Jun 2000, Geoff Keating wrote:
> > Cc: libc-alpha@sourceware.cygnus.com
> > Reply-To: drepper@cygnus.com (Ulrich Drepper)
> > From: Ulrich Drepper <drepper@redhat.com>
> > Date: 26 Jun 2000 11:41:05 -0700
> >
> > Geoff Keating <geoffk@cygnus.com> writes:
> > > For 2.2, glibc on powerpc will require a gcc newer than 2.95.* to
> >
> > You mean it needs the mainline sourceware compiler?
>
> Yes. There's a bug in 2.95 involving asm and memory clobbers, another
> one involving complex results. (As I mentioned before, there's the
> whole exception-handling issue too.)
I was able to compile it with the current gcc-2_95-branch+DWARFEH/PPC+a bunch
of backported mainline patches. I try to get the backported patches into
gcc-2.95.3-release. The testsuite passes with this compiler, except for:
gcc -nostdlib -nostartfiles -o /cvsx/glibc22/obj/elf/vismain
-Wl,-dynamic-linker=/lib/ld.so.1 /cvsx/glibc22/obj/csu/crt1.o
/cvsx/glibc22/obj/csu/crti.o `gcc --print-file-name=crtbegin.o`
/cvsx/glibc22/obj/elf/vismain.o /cvsx/glibc22/obj/elf/vismod1.so
/cvsx/glibc22/obj/elf/vismod2.so
-Wl,-rpath-link=/cvsx/glibc22/obj:/cvsx/glibc22/obj/math:/cvsx/glibc22/obj/elf:/cvsx/glibc22/obj/dlfcn:/cvsx/glibc22/obj/nss:/cvsx/glibc22/obj/nis:/cvsx/glibc22/obj/rt:/cvsx/glibc22/obj/resolv:/cvsx/glibc22/obj/crypt:/cvsx/glibc22/obj/linuxthreads
/cvsx/glibc22/obj/libc.so.6 /cvsx/glibc22/obj/libc_nonshared.a
-lgcc `gcc --print-file-name=crtend.o` /cvsx/glibc22/obj/csu/crtn.o
GCONV_PATH=/cvsx/glibc22/obj/iconvdata \
LD_PRELOAD=/cvsx/glibc22/obj/elf/vismod3.so /cvsx/glibc22/obj/elf/ld.so.1
--library-path
/cvsx/glibc22/obj:/cvsx/glibc22/obj/math:/cvsx/glibc22/obj/elf:/cvsx/glibc22/obj/dlfcn:/cvsx/glibc22/obj/nss:/cvsx/glibc22/obj/nis:/cvsx/glibc22/obj/rt:/cvsx/glibc22/obj/resolv:/cvsx/glibc22/obj/crypt:/cvsx/glibc22/obj/linuxthreads
/cvsx/glibc22/obj/elf/vismain > /cvsx/glibc22/obj/elf/vismain.out
Didn't expect signal from child: got `Illegal instruction'
make[2]: *** [/cvsx/glibc22/obj/elf/vismain.out] Error 1
But this is probably because the binutils-2.9.5.0.41 is too old for the
visibility stuff. I also needed the appended patch, due to the sudden rebirth
of testandset :-).
Franz.
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/06/27 13:13:15
@@ -28,15 +28,41 @@
/* 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. */
#define CURRENT_STACK_FRAME stack_pointer
register char * stack_pointer __asm__ ("r1");
+/* Spinlock implementation; required. */
+#if BROKEN_PPC_ASM_CR0
+static
+#else
+extern inline
+#endif
+int
+testandset (long int *spinlock)
+{
+ int ret;
+
+ MEMORY_BARRIER ();
+ __asm__ __volatile__(
+ "0: lwarx %0,0,%1 ;"
+ " cmpwi %0,0;"
+ " bne 1f;"
+ " stwcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(spinlock), "r"(1)
+ : "cr0", "memory");
+ MEMORY_BARRIER ();
+ return ret != 0;
+}
+
/* 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
#if BROKEN_PPC_ASM_CR0
@@ -50,7 +76,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;"