This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch,libstdc++] Fix (again) m68k/atomicity.h
- From: Bernardo Innocenti <bernie at develer dot com>
- To: libstdc++ at gcc dot gnu dot org, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Oct 2003 14:46:49 +0200
- Subject: [patch,libstdc++] Fix (again) m68k/atomicity.h
- Organization: Develer S.r.l.
Hello,
this patch enables the TAS instruction for ColdFire 5400 cores
and fixes one bug introduced in my previous atomicity.h
reorganization.
We can't rely on __mc68000__ to detect a bare 68000 or 68010
because this symbol is always defined for *all* m68k targets.
Diff made this patch somewhat unreadable because it gets confused
by similar lines. What it really does is reversing the order of
the third macro with the second, so that the 68000 version comes
last (in the #else block) and we can check explicitly for CPU32
and MCF5400 in the second macro (the #elif block).
Bootstrapped on m68k-uclinux with multilib enabled
(m5200, m5206e, m528x, m5307, m5407, m68000, mcpu32).
2003-10-16 Bernardo Innocenti <bernie@develer.com>
* config/cpu/m68k/atomicity.h (__exchange_and_add): Use TAS on
__mcf5400__. Don't rely on __mc68000__ to detect a bare 68000.
Document SMP safeness of asm macros.
diff -u -3 -p -r1.5 atomicity.h
--- libstdc++-v3/config/cpu/m68k/atomicity.h 7 Aug 2003 20:55:22 -0000 1.5
+++ libstdc++-v3/config/cpu/m68k/atomicity.h 12 Oct 2003 22:03:53 -0000
@@ -94,22 +94,25 @@ __exchange_and_add (volatile _Atomic_wor
{
_Atomic_word __result;
-// bset with no immediate addressing
-#if defined(__mcf5200__) || defined(__mcf5300__) || defined(__mcf5400__)
+// bset with no immediate addressing (not SMP-safe)
+#if defined(__mcf5200__) || defined(__mcf5300__)
__asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b"
: /* no outputs */
: "a"(&__Atomicity_lock<0>::_S_atomicity_lock)
: "cc", "memory");
-// bset with immediate addressing
-#elif defined(__mc68000__)
- __asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b"
+// CPU32 and MCF5400 support test-and-set (SMP-safe).
+#elif defined(__mcpu32__) || defined(__mcf5400__)
+ __asm__ __volatile__("1: tas %0\n\tjbne 1b"
: "+m"(__Atomicity_lock<0>::_S_atomicity_lock)
: /* none */
: "cc");
-#else // 680x0, cpu32, 5400 support test-and-set.
- __asm__ __volatile__("1: tas %0\n\tjbne 1b"
+// Use bset with immediate addressing for 68000/68010 (not SMP-safe)
+// NOTE: TAS is available on the 68000, but unsupported by some Amiga
+// memory controllers.
+#else
+ __asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b"
: "+m"(__Atomicity_lock<0>::_S_atomicity_lock)
: /* none */
: "cc");
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/
Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html