OSDN Git Service

2004-02-25 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / config / cpu / mips / atomicity.h
index 3d0c7a1..0871342 100644 (file)
@@ -1,6 +1,6 @@
-// Low-level functions for atomic operations.
+// Low-level functions for atomic operations: MIPS version  -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_ATOMICITY_H 1
+#include <bits/atomicity.h>
 
-typedef int _Atomic_word;
-
-static inline int
-__attribute__ ((__unused__))
-__exchange_and_add(volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
 {
-  int __result, __tmp;
-
-  __asm__ __volatile__
-    ("/* Inline exchange & add */\n\t"
-     "1:\n\t"
-     ".set     push\n\t"
+  _Atomic_word
+  __attribute__ ((__unused__))
+  __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+  {
+    _Atomic_word __result, __tmp;
+    
+    __asm__ __volatile__
+      ("/* Inline exchange & add */\n\t"
+       "1:\n\t"
+       ".set   push\n\t"
 #if _MIPS_SIM == _ABIO32
-     ".set     mips2\n\t"
+       ".set   mips2\n\t"
 #endif
-     "ll       %0,%3\n\t"
-     "addu     %1,%4,%0\n\t"
-     "sc       %1,%2\n\t"
-     ".set     pop\n\t"
-     "beqz     %1,1b\n\t"
-     "/* End exchange & add */"
-     : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
-     : "m" (*__mem), "r"(__val));
-
-  return __result;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add(volatile _Atomic_word* __mem, int __val)
-{
-  int __result;
-
-  __asm__ __volatile__
-    ("/* Inline atomic add */\n\t"
-     "1:\n\t"
-     ".set     push\n\t"
+       "ll     %0,%3\n\t"
+       "addu   %1,%4,%0\n\t"
+       "sc     %1,%2\n\t"
+       ".set   pop\n\t"
+       "beqz   %1,1b\n\t"
+       "/* End exchange & add */"
+       : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
+       : "m" (*__mem), "r"(__val));
+    
+    return __result;
+  }
+  
+  void
+  __attribute__ ((__unused__))
+  __atomic_add(volatile _Atomic_word* __mem, int __val)
+  {
+    _Atomic_word __result;
+    
+    __asm__ __volatile__
+      ("/* Inline atomic add */\n\t"
+       "1:\n\t"
+       ".set   push\n\t"
 #if _MIPS_SIM == _ABIO32
-     ".set     mips2\n\t"
+       ".set   mips2\n\t"
 #endif
-     "ll       %0,%2\n\t"
-     "addu     %0,%3,%0\n\t"
-     "sc       %0,%1\n\t"
-     ".set     pop\n\t"
-     "beqz     %0,1b\n\t"
-     "/* End atomic add */"
-     : "=&r"(__result), "=m"(*__mem)
+       "ll     %0,%2\n\t"
+       "addu   %0,%3,%0\n\t"
+       "sc     %0,%1\n\t"
+       ".set   pop\n\t"
+       "beqz   %0,1b\n\t"
+       "/* End atomic add */"
+       : "=&r"(__result), "=m"(*__mem)
      : "m" (*__mem), "r"(__val));
-}
-
-#endif /* atomicity.h */
+  }
+} // namespace __gnu_cxx