diff options
author | Dimitris Vyzovitis <vyzo@media.mit.edu> | 2001-10-03 21:19:31 +0000 |
---|---|---|
committer | Loren J. Rittle <ljrittle@gcc.gnu.org> | 2001-10-03 21:19:31 +0000 |
commit | 8bf4eeece3076a35dbfe8d7385b4fef2488337d6 (patch) | |
tree | 434b86749df20dfd37c844d9000f55dd45c8a0ec /libstdc++-v3 | |
parent | b52a8930ff4e8b14b1ab65ca91529e041273ddec (diff) | |
download | gcc-8bf4eeece3076a35dbfe8d7385b4fef2488337d6.zip gcc-8bf4eeece3076a35dbfe8d7385b4fef2488337d6.tar.gz gcc-8bf4eeece3076a35dbfe8d7385b4fef2488337d6.tar.bz2 |
stl_threads.h (_Atomic_swap): New function.
* include/bits/stl_threads.h (_Atomic_swap): New function.
(_Swap_lock_struct<__dummy>::_S_swap_lock): New data.
* testsuite/ext/rope.cc: New file.
From-SVN: r45999
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_threads.h | 22 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/ext/rope.cc | 38 |
3 files changed, 66 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 65ec49e..bff3412 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2001-10-03 Dimitris Vyzovitis <vyzo@media.mit.edu> + + * include/bits/stl_threads.h (_Atomic_swap): New function. + (_Swap_lock_struct<__dummy>::_S_swap_lock): New data. + * testsuite/ext/rope.cc: New file. + 2001-10-02 Benjamin Kosnik <bkoz@redhat.com> * config/locale/time_members_gnu.h: Remove. diff --git a/libstdc++-v3/include/bits/stl_threads.h b/libstdc++-v3/include/bits/stl_threads.h index b1278c1..dd27422 100644 --- a/libstdc++-v3/include/bits/stl_threads.h +++ b/libstdc++-v3/include/bits/stl_threads.h @@ -202,6 +202,28 @@ struct _Refcount_Base // later, if required. You can start by cloning the __STL_PTHREADS // path while making the obvious changes. Later it could be optimized // to use the atomicity.h abstraction layer from libstdc++-v3. +// vyzo: simple _Atomic_swap implementation following the guidelines above + // We use a template here only to get a unique initialized instance. + template<int __dummy> + struct _Swap_lock_struct { + static __gthread_mutex_t _S_swap_lock; + }; + + template<int __dummy> + __gthread_mutex_t + _Swap_lock_struct<__dummy>::_S_swap_lock = __GTHREAD_MUTEX_INIT; + + // This should be portable, but performance is expected + // to be quite awful. This really needs platform specific + // code. + inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) { + __gthread_mutex_lock(&_Swap_lock_struct<0>::_S_swap_lock); + unsigned long __result = *__p; + *__p = __q; + __gthread_mutex_unlock(&_Swap_lock_struct<0>::_S_swap_lock); + return __result; + } + #else // GCC extension end # ifdef __STL_SGI_THREADS diff --git a/libstdc++-v3/testsuite/ext/rope.cc b/libstdc++-v3/testsuite/ext/rope.cc new file mode 100644 index 0000000..79eecf8 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/rope.cc @@ -0,0 +1,38 @@ +// 2001-10-03 From: Dimitris Vyzovitis <vyzo@media.mit.edu> + +// Copyright (C) 2001 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// rope (SGI extension) + +#include <ext/rope> +#include <iostream> + +void test01() +{ + std::crope foo; + foo += "bar"; + const char* data = foo.c_str(); + std::cout << data << std::endl; +} + +int main() +{ + test01(); + return 0; +} |