Commit e27ce379 by J"orn Rennecke Committed by Joern Rennecke

atomicity.h: Replace broken generic code with current copy of generic/atomicity.h .

	* config/cpu/sh/atomicity.h: Replace broken generic code with current
	copy of generic/atomicity.h .

From-SVN: r103274
parent a132dad6
2005-08-19 J"orn Rennecke <joern.rennecke@st.com>
* config/cpu/sh/atomicity.h: Replace broken generic code with current
copy of generic/atomicity.h .
2005-08-17 Kelley Cook <kcook@gcc.gnu.org> 2005-08-17 Kelley Cook <kcook@gcc.gnu.org>
* All files: Update FSF address. * All files: Update FSF address.
......
// Low-level functions for atomic operations: Generic version -*- C++ -*- // Low-level functions for atomic operations: Generic version -*- C++ -*-
// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -69,55 +70,38 @@ __atomic_add (volatile _Atomic_word* __mem, int __val) ...@@ -69,55 +70,38 @@ __atomic_add (volatile _Atomic_word* __mem, int __val)
: "r0"); : "r0");
} }
#else #else /* !__SH4A__ */
/* This is generic/atomicity.h */ /* This is generic/atomicity.h */
#include <bits/gthr.h> #include <bits/atomicity.h>
#include <bits/concurrence.h>
#define _GLIBCPP_NEED_GENERIC_MUTEX namespace __gnu_internal
typedef int _Atomic_word;
namespace __gnu_cxx
{ {
extern __gthread_mutex_t _Atomic_add_mutex; __glibcxx_mutex_define_initialized(atomic_mutex);
} // namespace __gnu_internal
#ifndef __GTHREAD_MUTEX_INIT
extern __gthread_once_t _Atomic_add_mutex_once;
extern void __gthread_atomic_add_mutex_once();
#endif
}
static inline _Atomic_word namespace __gnu_cxx
__attribute__ ((__unused__))
__exchange_and_add (volatile _Atomic_word* __mem, int __val)
{ {
#ifndef __GTHREAD_MUTEX_INIT _Atomic_word
__gthread_once (&__gnu_cxx::_Atomic_add_mutex_once, __attribute__ ((__unused__))
__gnu_cxx::__gthread_atomic_add_mutex_once); __exchange_and_add(volatile _Atomic_word* __mem, int __val)
#endif {
__glibcxx_mutex_lock(__gnu_internal::atomic_mutex);
_Atomic_word __result; _Atomic_word __result;
__gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex);
__result = *__mem; __result = *__mem;
*__mem += __val; *__mem += __val;
__glibcxx_mutex_unlock(__gnu_internal::atomic_mutex);
__gthread_mutex_unlock (&__gnu_cxx::_Atomic_add_mutex);
return __result; return __result;
} }
static inline void
__attribute__ ((__unused__))
__atomic_add (volatile _Atomic_word* __mem, int __val)
{
(void) __exchange_and_add (__mem, __val);
}
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val)
{ __exchange_and_add(__mem, __val); }
} // namespace __gnu_cxx
#endif #endif /* !__SH4A__ */
#endif /* atomicity.h */ #endif /* atomicity.h */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment