This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.

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

# [PATCH][SH] Fix SH4A atomicity.h

• From: Andrew Stubbs <ams at codesourcery dot com>
• To: gcc-patches at gcc dot gnu dot org
• Date: Thu, 02 Apr 2009 14:26:27 +0100
• Subject: [PATCH][SH] Fix SH4A atomicity.h

Hi all,

The SH4A/SH4AL implementation of atomicity.h is broken. The problem is that it won't link because the symbols are in the wrong namespace. There's also some evidence of C programming in C++. I don't understand how this could ever have worked for anybody.

This patch fixes the problem. It's a bit hard to see what's changed due to the indent change. Here's an alternative diff ignoring whitespace:

```--- atomicity.h (revision 145441)
+++ atomicity.h (working copy)
@@ -30,12 +30,13 @@```

#ifdef __SH4A__

```-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_ATOMICITY_H   1
+#include <ext/atomicity.h>```

```+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
typedef int _Atomic_word;```

```-static inline _Atomic_word
+  _Atomic_word
__attribute__ ((__unused__))
__exchange_and_add (volatile _Atomic_word* __mem, int __val)
{
@@ -56,7 +57,7 @@
}```

```-static inline void
+  void
__attribute__ ((__unused__))
__atomic_add (volatile _Atomic_word* __mem, int __val)
{
@@ -70,7 +71,7 @@
: "r0");
}```

```-#endif
+_GLIBCXX_END_NAMESPACE```

#else /* !__SH4A__ */

OK?

Andrew
```2009-01-30  Andrew Stubbs  <ams@codesourcery.com>

gcc/libstdc++-v3/
* config/cpu/sh/atomicity.h: Put the SH4A specific functions in the
__gnu_cxx namespace.  Remove "static inline".

---
src/gcc-mainline/libstdc++-v3/config/cpu/sh/atomicity.h |   75 ++++++++--------
1 files changed, 38 insertions(+), 37 deletions(-)

Index: src/gcc-mainline/libstdc++-v3/config/cpu/sh/atomicity.h
===================================================================
--- src/gcc-mainline/libstdc++-v3/config/cpu/sh/atomicity.h.orig
+++ src/gcc-mainline/libstdc++-v3/config/cpu/sh/atomicity.h
@@ -30,47 +30,48 @@

#ifdef __SH4A__

-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_ATOMICITY_H	1
+#include <ext/atomicity.h>

-typedef int _Atomic_word;
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)

-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word* __mem, int __val)
-{
-  _Atomic_word __result;
+  typedef int _Atomic_word;

-  __asm__ __volatile__
-    ("0:\n"
-     "\tmovli.l\t@%2,r0\n"
-     "\tmov\tr0,%1\n"
-     "\tmovco.l\tr0,@%2\n"
-     "\tbf\t0b"
-     : "+m" (*__mem), "=r" (__result)
-     : "r" (__mem), "rI08" (__val)
-     : "r0");
-
-  return __result;
-}
-
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
-{
-  asm("0:\n"
-      "\tmovli.l\t@%1,r0\n"
-      "\tmovco.l\tr0,@%1\n"
-      "\tbf\t0b"
-      : "+m" (*__mem)
-      : "r" (__mem), "rI08" (__val)
-      : "r0");
-}
+  _Atomic_word
+  __attribute__ ((__unused__))
+  __exchange_and_add (volatile _Atomic_word* __mem, int __val)
+  {
+    _Atomic_word __result;

-#endif
+    __asm__ __volatile__
+      ("0:\n"
+       "\tmovli.l\t@%2,r0\n"
+       "\tmov\tr0,%1\n"
+       "\tmovco.l\tr0,@%2\n"
+       "\tbf\t0b"
+       : "+m" (*__mem), "=r" (__result)
+       : "r" (__mem), "rI08" (__val)
+       : "r0");
+
+    return __result;
+  }
+
+
+  void
+  __attribute__ ((__unused__))
+  __atomic_add (volatile _Atomic_word* __mem, int __val)
+  {
+    asm("0:\n"
+	"\tmovli.l\t@%1,r0\n"
+	"\tmovco.l\tr0,@%1\n"
+	"\tbf\t0b"
+	: "+m" (*__mem)
+	: "r" (__mem), "rI08" (__val)
+	: "r0");
+  }
+
+_GLIBCXX_END_NAMESPACE

#else /* !__SH4A__ */

```

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