PATCH: Support MIPS II
H . J . Lu
hjl@lucon.org
Thu Apr 25 16:08:00 GMT 2002
On Thu, Apr 25, 2002 at 02:59:53PM -0700, Richard Henderson wrote:
> On Thu, Apr 25, 2002 at 01:51:16PM -0700, H . J . Lu wrote:
> > +#ifndef _BITS_ATOMICITY_H
> > +
> > +#define _BITS_ATOMICITY_H 1
> > +
> > +static inline int
> > +__attribute__ ((unused))
> > +__exchange_and_add (volatile _Atomic_word *__mem, int __val)
> > +{
> > + int __result = *__mem;
> > + *__mem += __val;
> > + return __result;
> > +}
>
> At minimum this should have the same #warning that m68k has
> about not actually being atomic.
>
I am enclosing a new patch.
> And really this is incorrect for any operating system that
> emulates ll/sc. Like Linux, and I suspect others.
>
Even on Linux, it is hard to tell if the kernel really supports ll/sc
emulation or not. I just want to help real MIPS II cores.
H.J.
-------------- next part --------------
2002-04-25 H.J. Lu <hjl@gnu.org>
* config/cpu/mips/bits/atomicity.h: Support MIPS I and II.
* configure.target (cpu_include_dir): Set to `config/cpu/mips'
for mips
--- libstdc++-v3/config/cpu/mips/bits/atomicity.h.mips Fri Oct 5 20:46:34 2001
+++ libstdc++-v3/config/cpu/mips/bits/atomicity.h Thu Apr 25 16:01:30 2002
@@ -1,6 +1,6 @@
-// Low-level functions for atomic operations. MIPS II version.
+// Low-level functions for atomic operations. Mips version.
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -28,13 +28,17 @@
// the GNU General Public License.
#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
-
-// #include <sgidefs.h>
-// #ifdef (_MIPS_ISA_MIPS2)
typedef int _Atomic_word;
+#ifdef _MIPS_ISA
+
+#include <sgidefs.h>
+
+#if _MIPS_ISA >= _MIPS_ISA_MIPS2
+
+#define _BITS_ATOMICITY_H 1
+
static inline int
__attribute__ ((unused))
__exchange_and_add (volatile _Atomic_word *__mem, int __val)
@@ -42,7 +46,7 @@ __exchange_and_add (volatile _Atomic_wor
int __result, __tmp;
__asm__ __volatile__
- ("/* Inline exchange & add */\n\t"
+ ("/* Inline exchange & add */\n"
"1:\n\t"
"ll %0,%3\n\t"
"addu %1,%4,%0\n\t"
@@ -63,7 +67,7 @@ __atomic_add (volatile _Atomic_word *__m
int __result;
__asm__ __volatile__
- ("/* Inline atomic add */\n\t"
+ ("/* Inline atomic add */\n"
"1:\n\t"
"ll %0,%2\n\t"
"addu %0,%3,%0\n\t"
@@ -75,4 +79,34 @@ __atomic_add (volatile _Atomic_word *__m
: "memory");
}
+#endif /* _MIPS_ISA >= _MIPS_ISA_MIPS2 */
+
+#endif /* !_MIPS_ISA */
+
+#ifndef _BITS_ATOMICITY_H
+
+#define _BITS_ATOMICITY_H 1
+
+#warning "__exchange_and_add is not atomic for this target"
+
+static inline int
+__attribute__ ((unused))
+__exchange_and_add (volatile _Atomic_word *__mem, int __val)
+{
+ int __result = *__mem;
+ *__mem += __val;
+ return __result;
+}
+
+#warning "__atomic_add is not atomic for this target"
+
+static inline void
+__attribute__ ((unused))
+__atomic_add (volatile _Atomic_word *__mem, int __val)
+{
+ *__mem += __val;
+}
+
+#endif
+
#endif /* atomicity.h */
--- libstdc++-v3/configure.target.mips Sat Jan 19 11:06:36 2002
+++ libstdc++-v3/configure.target Sat Feb 2 19:50:14 2002
@@ -43,6 +43,9 @@ case "${target_cpu}" in
m68k | m680[246]0)
cpu_include_dir="config/cpu/m68k"
;;
+ mips*)
+ cpu_include_dir=config/cpu/mips
+ ;;
powerpc | rs6000)
cpu_include_dir="config/cpu/powerpc"
;;
More information about the Gcc-patches
mailing list