This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: debug container mutex association
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, "libstdc++\@gcc.gnu.org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 29 Dec 2017 17:09:57 +0100
- Subject: Re: debug container mutex association
- Authentication-results: sourceware.org; auth=none
- References: <46b4f297-c0da-b0b0-03ef-bba019b97ec7@gmail.com> <20160914090036.GC17376@redhat.com> <b0588485-586b-d2cf-42b9-14d5fb34961c@gmail.com> <20160915085143.GJ17376@redhat.com> <2af7879c-bef5-7874-b5ae-722ad3a1e171@gmail.com>
On Sep 19 2016, François Dumont <frs.dumont@gmail.com> wrote:
> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/mutex_association.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/mutex_association.cc
> new file mode 100644
> index 0000000..a3c56e2
> --- /dev/null
> +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/mutex_association.cc
> @@ -0,0 +1,42 @@
> +// Copyright (C) 2016 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 3, 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 COPYING3. If not see
> +// <http://www.gnu.org/licenses/>.
> +//
> +
> +#include <set>
> +#include <debug/vector>
> +
> +#include <testsuite_hooks.h>
> +
> +class container : public __gnu_debug::_Safe_sequence<container>
> +{
> +public:
> + __gnu_cxx::__mutex&
> + get_mutex()
> + { return this->_M_get_mutex(); }
> +};
> +
> +int
> +main()
> +{
> + std::set<__gnu_cxx::__mutex*> mutexes;
> + container conts[17];
> +
> + for (int i = 0; i != 16; ++i)
> + VERIFY( mutexes.insert(&conts[i].get_mutex()).second );
There will be less than 16 unique mutexes, if sizeof(container) has more
trailing zero bits than alignof(__gnu_debug::vector<int>).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."