This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH (3.0.X branch): Move fix for libstdc++/5037?
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 27 Dec 2001 02:44:03 -0600 (CST)
- Subject: PATCH (3.0.X branch): Move fix for libstdc++/5037?
- Reply-to: rittle at labs dot mot dot com
Bootstrapped 3.0.X branch on sparc-sun-solaris2.7 with no regressions.
Fixes multithreaded test case of libstdc++/5037.
If possible, I would like an authoritative answer on whether
libstdc++/5037 should be closed with or without this patch being moved
to the 3.0.X branch. Discussion on libstdc++ reached agreement that
it can only affect sparc ports (obvious from file touched) and is
fully upward and downward compatible with all released versions of gcc
3.0. However, the root bug is only fixed when all code is recompiled.
[Aside: To my knowledge, there are still no threaded test cases in our
testsuite. For lack of a better mechanism, such cases that depend on
POSIX threads would have to be skipped entirely and/or XFAIL'd
whenever ``gcc -v'' reports anything other than ``Thread model:
posix''. Even if we constrain ourselves to adding only POSIX tests,
the non-trivial matter of non-portable linkage and/or multilib flags
remains.]
2001-12-26 Nathan Myers <ncm@cantrip.org>
Loren Rittle <ljrittle@acm.org>
libstdc++/5037 (copy from trunk 2001-12-07 and 2001-12-11)
* config/cpu/sparc/sparc32/bits/atomicity.h
(struct __Atomicity_lock<__inst>): Add.
(__Atomicity_lock<__inst>::_S_atomicity_lock): Add.
(__Atomicity_lock<0>::_S_atomicity_lock): Add.
(__exchange_and_add): Use __Atomicity_lock<0>::_S_atomicity_lock
instead of lock local to static function.
(__atomic_add): Likewise.
Index: config/cpu/sparc/sparc32/bits/atomicity.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/cpu/sparc/sparc32/bits/atomicity.h,v
retrieving revision 1.2.6.1
diff -c -r1.2.6.1 atomicity.h
*** atomicity.h 2001/02/28 00:04:10 1.2.6.1
--- atomicity.h 2001/12/27 05:21:35
***************
*** 32,42 ****
typedef int _Atomic_word;
static int
__attribute__ ((__unused__))
__exchange_and_add (volatile _Atomic_word* __mem, int __val)
{
- static unsigned char __lock;
_Atomic_word __result, __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t"
--- 32,52 ----
typedef int _Atomic_word;
+ template <int __inst>
+ struct __Atomicity_lock
+ {
+ static unsigned char _S_atomicity_lock;
+ };
+
+ template <int __inst>
+ unsigned char __Atomicity_lock<__inst>::_S_atomicity_lock = 0;
+
+ template unsigned char __Atomicity_lock<0>::_S_atomicity_lock;
+
static int
__attribute__ ((__unused__))
__exchange_and_add (volatile _Atomic_word* __mem, int __val)
{
_Atomic_word __result, __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t"
***************
*** 44,56 ****
" bne 1b\n\t"
" nop"
: "=&r" (__tmp)
! : "r" (&__lock)
: "memory");
__result = *__mem;
*__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */
! : "r" (&__lock)
: "memory");
return __result;
}
--- 54,66 ----
" bne 1b\n\t"
" nop"
: "=&r" (__tmp)
! : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
__result = *__mem;
*__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */
! : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
return __result;
}
***************
*** 59,65 ****
__attribute__ ((__unused__))
__atomic_add (volatile _Atomic_word* __mem, int __val)
{
- static unsigned char __lock;
_Atomic_word __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t"
--- 69,74 ----
***************
*** 67,78 ****
" bne 1b\n\t"
" nop"
: "=&r" (__tmp)
! : "r" (&__lock)
: "memory");
*__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */
! : "r" (&__lock)
: "memory");
}
--- 76,87 ----
" bne 1b\n\t"
" nop"
: "=&r" (__tmp)
! : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
*__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */
! : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
}