This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++ atomicity.h and ppc405 problem


Got it, at least mostly, thanks to trial-and-error and lots of grep.

Here is a patch for gcc3.0.2 which produces four libraries:
nof/libstdc++.a
nof/mcpu405/libstdc++.a
libstdc++.a
mcpu405/libstdc++.a

I'd like to suppress generation of mcpu405/libstdc++.a, since the ppc405
doesn't support hardware floating point, but I haven't figured out how.
Thinking about it makes my head hurt.

The patch conflates ppc403 and ppc405, so it's not worth using directly.
A patch for gcc3.1 would be similar except it could use -mcpu=405
in rs6000.h, and mcpu=405 in t-ppcos, and not get ppc403 and ppc405 mixed up.

Comments?
- Dan

(p.s. Fellow newbies: It's worth reading gcc/genmultilib as a supplement
to the scrawny manual section dealing with multilibs.
Also, which files in gcc/config are used is controlled by gcc/config.gcc.
The entry for powerpc-linux says
    tmake_file="rs6000/t-ppcos t-slibgcc-elf-ver t-linux rs6000/t-ppccomm"
Each of those is responsible for different things; it looks like
MULTILIB_OPTIONS is in t-ppcos.)

--- gcc-3.0.2/gcc/config/rs6000/t-ppcos.orig	Tue Apr  4 18:22:36 2000
+++ gcc-3.0.2/gcc/config/rs6000/t-ppcos	Thu Jul 18 22:13:29 2002
@@ -1,7 +1,7 @@
 # Multilibs for a powerpc hosted ELF target (linux, SVR4, solaris)
 
-MULTILIB_OPTIONS	= msoft-float
-MULTILIB_DIRNAMES	= nof
+MULTILIB_OPTIONS	= msoft-float mcpu=403
+MULTILIB_DIRNAMES	= nof mcpu405
 MULTILIB_EXTRA_OPTS	= fPIC mstrict-align
 MULTILIB_EXCEPTIONS	= 
--- gcc-3.0.2/gcc/config/rs6000/rs6000.h.orig	Thu Jul 18 15:27:37 2002
+++ gcc-3.0.2/gcc/config/rs6000/rs6000.h	Thu Jul 18 15:34:39 2002
@@ -62,7 +62,7 @@
 %{mcpu=rsc: -D_ARCH_PWR} \
 %{mcpu=rsc1: -D_ARCH_PWR} \
 %{mcpu=401: -D_ARCH_PPC} \
-%{mcpu=403: -D_ARCH_PPC} \
+%{mcpu=403: -D_ARCH_PPC -D__PPC405__} \
 %{mcpu=505: -D_ARCH_PPC} \
 %{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \
 %{mcpu=602: -D_ARCH_PPC} \
--- gcc-3.0.2/libstdc++-v3/config/cpu/powerpc/bits/atomicity.h.orig	Tue Feb 27 16:04:08 2001
+++ gcc-3.0.2/libstdc++-v3/config/cpu/powerpc/bits/atomicity.h	Thu Jul 18 13:36:39 2002
@@ -32,6 +32,18 @@
 
 typedef int _Atomic_word;
 
+#ifdef __PPC405__
+/* fix PPC405 specific bug: errata #77 - JRO 07/18/02 & dank
+   See erratum 77 in
+   http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/89DED00DEBFF54BF87256A8000491BA2/$file/405CR_C_errata_1_2.pdf
+   See also version 1.21 of arch/ppc/kernel/ppc_asm.h, Fri Sep 21 00:00:34 2001
+   in ChangeSet 1.489 at http://ppc.bkbits.net:8080/linuxppc_2_4_devel 
+*/
+#define	__LIBSTDCPP_PPC405_ERR77_SYNC	"sync \n\t"
+#else
+#define __LIBSTDCPP_PPC405_ERR77_SYNC
+#endif
+
 static inline _Atomic_word
 __attribute__ ((__unused__))
 __exchange_and_add (volatile _Atomic_word* __mem, int __val)
@@ -42,6 +54,7 @@
 	"0:\t"
 	"lwarx    %0,0,%2 \n\t"
 	"add%I3   %1,%0,%3 \n\t"
+	__LIBSTDCPP_PPC405_ERR77_SYNC
 	"stwcx.   %1,0,%2 \n\t"
 	"bne-     0b \n\t"
 	"/* End exchange & add */"
@@ -61,6 +74,7 @@
 	"0:\t"
 	"lwarx    %0,0,%1 \n\t"
 	"add%I2   %0,%0,%2 \n\t"
+	__LIBSTDCPP_PPC405_ERR77_SYNC
 	"stwcx.   %0,0,%1 \n\t"
 	"bne-     0b \n\t"
 	"/* End atomic add */"
@@ -81,6 +95,7 @@
 	"sub%I2c. %0,%0,%2 \n\t"
 	"cntlzw   %0,%0 \n\t"
 	"bne-     1f \n\t"
+	__LIBSTDCPP_PPC405_ERR77_SYNC
 	"stwcx.   %3,0,%1 \n\t"
 	"bne-     0b \n"
 	"1:\n\t"
@@ -100,6 +115,7 @@
 	"/* Inline always swap */\n"
 	"0:\t"
 	"lwarx    %0,0,%1 \n\t"
+	__LIBSTDCPP_PPC405_ERR77_SYNC
 	"stwcx.   %2,0,%1 \n\t"
 	"bne-     0b \n\t"
 	"/* End always swap */"
@@ -120,6 +136,7 @@
 	"lwarx    %0,0,%1 \n\t"
 	"cmpwi    %0,0 \n\t"
 	"bne-     1f \n\t"
+	__LIBSTDCPP_PPC405_ERR77_SYNC
 	"stwcx.   %2,0,%1 \n\t"
 	"bne-     0b \n"
 	"1:\n\t"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]