diff options
| author | pme <pme@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-11-08 19:24:41 +0000 |
|---|---|---|
| committer | pme <pme@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-11-08 19:24:41 +0000 |
| commit | f41d3dfdafdead0723b47be8cebde9fdcee02b9c (patch) | |
| tree | c7f543d86d5a82e9a59d5ac7b9fc9e12e499f6ac | |
| parent | 0ef2dfb001f078a3b1324e05c0063583ddd18a07 (diff) | |
| download | ppe42-gcc-f41d3dfdafdead0723b47be8cebde9fdcee02b9c.tar.gz ppe42-gcc-f41d3dfdafdead0723b47be8cebde9fdcee02b9c.zip | |
2002-11-07 Phil Edwards <pme@gcc.gnu.org>
Richard Earnshaw <rearnsha@arm.com>
* config/cpu/generic/atomicity.h: Provide atomic __exchange_and_add
and __atomic_add.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58929 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
| -rw-r--r-- | libstdc++-v3/config/cpu/generic/atomicity.h | 27 |
2 files changed, 27 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4d803091c4b..bf57cd766de 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2002-11-07 Phil Edwards <pme@gcc.gnu.org> + Richard Earnshaw <rearnsha@arm.com> + + * config/cpu/generic/atomicity.h: Provide atomic __exchange_and_add + and __atomic_add. + 2002-11-08 Paolo Carlini <pcarlini@unitus.it> * config/locale/gnu/monetary_members.cc diff --git a/libstdc++-v3/config/cpu/generic/atomicity.h b/libstdc++-v3/config/cpu/generic/atomicity.h index fca2b83d584..2cf6c3ced68 100644 --- a/libstdc++-v3/config/cpu/generic/atomicity.h +++ b/libstdc++-v3/config/cpu/generic/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: Generic version -*- C++ -*- -// Copyright (C) 1999, 2001 Free Software Foundation, Inc. +// Copyright (C) 1999, 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 @@ -30,22 +30,37 @@ #ifndef _BITS_ATOMICITY_H #define _BITS_ATOMICITY_H 1 +#include <bits/gthr.h> + typedef int _Atomic_word; +namespace __gnu_cxx +{ + __gthread_mutex_t _Atomic_add_mutex __attribute__ ((__weak__)) + = __GTHREAD_MUTEX_INIT; +} + static inline _Atomic_word __attribute__ ((__unused__)) -__exchange_and_add (_Atomic_word* __mem, int __val) +__exchange_and_add (volatile _Atomic_word* __mem, int __val) { - _Atomic_word __result = *__mem; - *__mem += __val; + _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 (_Atomic_word* __mem, int __val) +__atomic_add (volatile _Atomic_word* __mem, int __val) { - *__mem += __val; + (void) __exchange_and_add (__mem, __val); } #endif /* atomicity.h */ |

