[parisc-linux-cvs] gcc amodra

amodra@one.net.au amodra@one.net.au
Thu, 31 May 2001 01:04:37 +0930


On Wed, May 30, 2001 at 09:16:51AM -0600, Alan Modra wrote:
> CVSROOT:	/home/cvs/parisc
> Module name:	gcc
> Changes by:	amodra	01/05/30 09:16:51
> 
> Modified files:
> 	libstdc++-v3   : ChangeLog.puffin 
> 	libstdc++-v3/config/cpu/hppa/bits: atomicity.h 
> 	libstdc++-v3/include/bits: basic_string.h basic_string.tcc 


libstdc++-v3/ChangeLog.puffin
	* config/cpu/hppa/bits/atomicity.h: Conditionalize alt_lock hacks
	on MALLOC_ALIGNS_TO_16BYTE.
	* include/bits/basic_string.h (_S_empty_rep_storage): 16 byte align.
	* include/bits/basic_string.tcc (_S_empty_rep_storage): Here too.


Index: libstdc++-v3/config/cpu/hppa/bits/atomicity.h
===================================================================
RCS file: /home/cvs/parisc/gcc/libstdc++-v3/config/cpu/hppa/bits/atomicity.h,v
retrieving revision 1.5
diff -u -p -r1.5 atomicity.h
--- atomicity.h	2001/04/09 04:08:00	1.5
+++ atomicity.h	2001/05/30 14:59:10
@@ -20,6 +20,9 @@
 #ifndef _BITS_ATOMICITY_H
 #define _BITS_ATOMICITY_H	1
 
+/* Define this to 1 when everyone is using a sensible glibc.  */
+#undef MALLOC_ALIGNS_TO_16BYTE
+
 /* Load and clear, the only PA-RISC atomic read-write operation.  Some
    cpus only support ldcw on 16 byte aligned words.  *sigh*.  */
 static inline int
@@ -43,15 +46,23 @@ __pa_spin_lock (volatile int* lock)
 
 class _Atomic_counter {
  public:
+  int lock;
+  int count;
+#if ! MALLOC_ALIGNS_TO_16BYTE
   /* Two locks???  Well, malloc allocates to 8 byte boundaries, and
      thus either lock or alt_lock will be 16 byte aligned.  Use
      whichever one gets the right alignment.  */
-  int lock;
-  int count;
   int alt_lock;
+#endif
 
   inline
-  _Atomic_counter() { lock = 1; alt_lock = 1; }
+  _Atomic_counter()
+  {
+    lock = 1;
+#if ! MALLOC_ALIGNS_TO_16BYTE
+    alt_lock = 1;
+#endif
+  }
 
   inline int
   operator=(const int __val) { return this->count = __val; }
@@ -69,7 +80,11 @@ typedef class _Atomic_counter _Atomic_wo
 
 /* This is horrible, but how else can we get the static initializer
    correct with our lock(s) set non-zero? */
+#if MALLOC_ALIGNS_TO_16BYTE
+#define _S_EMPTY_REP_INIT = { 0, 0, 1, 0, 0 }
+#else
 #define _S_EMPTY_REP_INIT = { 0, 0, 1, 0, 1, 0 }
+#endif
 
 
 static inline int
@@ -78,7 +93,11 @@ __exchange_and_add (_Atomic_word* mem, i
 {
   int result;
   int tmp;
+#if MALLOC_ALIGNS_TO_16BYTE
+  int *lock = &mem->lock;
+#else
   int *lock = (int *) ((long) &mem->alt_lock & ~15);
+#endif
 
   tmp = __pa_spin_lock (lock);
   result = mem->count;
@@ -93,7 +112,11 @@ __attribute__ ((__unused__))
 __atomic_add (_Atomic_word* mem, int val)
 {
   int tmp;
+#if MALLOC_ALIGNS_TO_16BYTE
+  int *lock = &mem->lock;
+#else
   int *lock = (int *) ((long) &mem->alt_lock & ~15);
+#endif
 
   tmp = __pa_spin_lock (lock);
   mem->count += val;
Index: libstdc++-v3/include/bits/basic_string.h
===================================================================
RCS file: /home/cvs/parisc/gcc/libstdc++-v3/include/bits/basic_string.h,v
retrieving revision 1.7
diff -u -p -r1.7 basic_string.h
--- basic_string.h	2001/04/09 04:08:00	1.7
+++ basic_string.h	2001/05/30 14:59:16
@@ -233,7 +233,7 @@ namespace std {
       static size_type _S_empty_rep_storage[
 	(sizeof(_Rep) + sizeof(_CharT)
 	 + sizeof(size_type) - 1)/sizeof(size_type)]
-      __attribute__ ((__aligned__ (8)));
+      __attribute__ ((__aligned__ (16)));
 
       _CharT* 
       _M_data() const 
Index: libstdc++-v3/include/bits/basic_string.tcc
===================================================================
RCS file: /home/cvs/parisc/gcc/libstdc++-v3/include/bits/basic_string.tcc,v
retrieving revision 1.6
diff -u -p -r1.6 basic_string.tcc
--- basic_string.tcc	2001/04/09 04:08:00	1.6
+++ basic_string.tcc	2001/05/30 14:59:20
@@ -62,7 +62,7 @@ namespace std
     typename basic_string<_CharT, _Traits, _Alloc>::size_type
     basic_string<_CharT, _Traits, _Alloc>::_S_empty_rep_storage[
     (sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)]
-    __attribute__ ((__aligned__ (8)))
+    __attribute__ ((__aligned__ (16)))
 #ifdef _S_EMPTY_REP_INIT
     _S_EMPTY_REP_INIT
 #endif