From: Andreas Schwab <schwab@linux-m68k.org>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: Jonathan Wakely <jwakely@redhat.com>,
"libstdc++\@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: debug container mutex association
Date: Fri, 29 Dec 2017 16:10:00 -0000 [thread overview]
Message-ID: <87lghlikh6.fsf@linux-m68k.org> (raw)
In-Reply-To: <2af7879c-bef5-7874-b5ae-722ad3a1e171@gmail.com> (=?utf-8?Q?=22Fran=C3=A7ois?= Dumont"'s message of "Mon, 19 Sep 2016 21:56:58 +0200")
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."
prev parent reply other threads:[~2017-12-29 16:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-13 20:37 François Dumont
2016-09-14 9:01 ` Jonathan Wakely
2016-09-14 20:53 ` François Dumont
2016-09-15 9:15 ` Jonathan Wakely
2016-09-19 20:19 ` François Dumont
2016-09-20 8:58 ` Jonathan Wakely
2016-09-27 15:39 ` Jonathan Wakely
2016-09-27 21:14 ` François Dumont
2016-09-20 9:20 ` Jonathan Wakely
2016-09-26 11:55 ` Jonathan Wakely
2016-09-26 12:23 ` Andreas Schwab
2016-09-26 22:09 ` François Dumont
2016-09-27 10:32 ` Jonathan Wakely
2016-09-28 19:35 ` François Dumont
2016-09-28 19:47 ` Jonathan Wakely
2017-12-29 16:10 ` Andreas Schwab [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lghlikh6.fsf@linux-m68k.org \
--to=schwab@linux-m68k.org \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).