annotate libstdc++-v3/testsuite/util/slow_clock.h @ 155:da32f4b04d38

fix __code name conflict
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 17:51:46 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
1 // -*- C++ -*-
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
2
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
3 // Copyright (C) 2018-2020 Free Software Foundation, Inc.
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
4
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
5 // This library is free software; you can redistribute it and/or
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
6 // modify it under the terms of the GNU General Public License as
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
7 // published by the Free Software Foundation; either version 3, or (at
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
8 // your option) any later version.
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
9
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
10 // This library is distributed in the hope that it will be useful, but
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
13 // General Public License for more details.
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
14
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
15 // You should have received a copy of the GNU General Public License
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
16 // along with this library; see the file COPYING3. If not see
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
17 // <http://www.gnu.org/licenses/>.
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
18
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
19
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
20 // A clock that ticks at a third of the speed of system_clock that can be used
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
21 // to ensure that functions with timeouts don't erroneously return early.
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
22
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
23 #include <chrono>
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
24
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
25 struct slow_clock
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
26 {
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
27 using rep = std::chrono::system_clock::rep;
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
28 using period = std::chrono::system_clock::period;
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
29 using duration = std::chrono::system_clock::duration;
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
30 using time_point = std::chrono::time_point<slow_clock, duration>;
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
31 static constexpr bool is_steady = false;
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
32
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
33 static time_point now()
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
34 {
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
35 auto real = std::chrono::system_clock::now();
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
36 return time_point{real.time_since_epoch() / 3};
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
37 }
1830386684a0 gcc-9.2.0
anatofuz
parents:
diff changeset
38 };