diff options
Diffstat (limited to 'contrib/libstdc++/config/cpu/generic/atomicity.h')
-rw-r--r-- | contrib/libstdc++/config/cpu/generic/atomicity.h | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/contrib/libstdc++/config/cpu/generic/atomicity.h b/contrib/libstdc++/config/cpu/generic/atomicity.h index 829a77c..f30005a 100644 --- a/contrib/libstdc++/config/cpu/generic/atomicity.h +++ b/contrib/libstdc++/config/cpu/generic/atomicity.h @@ -1,6 +1,6 @@ // 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 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 @@ -27,51 +27,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> +#include <bits/concurrence.h> -#include <bits/gthr.h> - -#define _GLIBCPP_NEED_GENERIC_MUTEX - -typedef int _Atomic_word; - -namespace __gnu_cxx -{ - extern __gthread_mutex_t _Atomic_add_mutex; - -#ifndef __GTHREAD_MUTEX_INIT - extern __gthread_once_t _Atomic_add_mutex_once; - extern void __gthread_atomic_add_mutex_once(); -#endif -} - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_internal { -#ifndef __GTHREAD_MUTEX_INIT - __gthread_once (&__gnu_cxx::_Atomic_add_mutex_once, - __gnu_cxx::__gthread_atomic_add_mutex_once); -#endif + __glibcxx_mutex_define_initialized(atomic_mutex); +} // namespace __gnu_internal - _Atomic_word __result; - - __gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex); - - __result = *__mem; - *__mem += __val; - - __gthread_mutex_unlock (&__gnu_cxx::_Atomic_add_mutex); - return __result; -} - - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_cxx { - (void) __exchange_and_add (__mem, __val); -} - -#endif /* atomicity.h */ + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + __glibcxx_mutex_lock(__gnu_internal::atomic_mutex); + _Atomic_word __result; + __result = *__mem; + *__mem += __val; + __glibcxx_mutex_unlock(__gnu_internal::atomic_mutex); + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __exchange_and_add(__mem, __val); } +} // namespace __gnu_cxx |