Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2018-12-01 00:39:57 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-12-01 17:11:12 +0300
commit2b72887ac834b0f0f675baff1af90771c7e36c87 (patch)
tree2b96f67889d54a94cbfef5b2f5fddab28828e511 /winsup/cygwin/strace.cc
parent166914ea8c86b5e569a5fef226e602a4d279897b (diff)
Cygwin: clocks: fix a hang on pre-Windows 10 machines
when calling clocks too early in DLL init, the vtables are not correctly set up for some reason. Calls to init() from now() fail because the init pointer in the vtable is NULL. Real life example is mintty which runs into a minor problem at startup, triggering a system_printf call. Strace is another problem, it's called the first time prior to any class initialization. Workaround is to make sure that no virtual methods are called in an early stage. Make init() non-virtual and convert resolution() to a virtual method instead. Add a special non-virtual clk_monotonic_t::strace_usecs. While at it: - Inline internal-only methods. - Drop the `inited' member. Convert period/ticks_per_sec toa union. Initialize period/ticks_per_sec via InterlockeExchange64. - Fix GetTickCount64 usage. No, it's not returning ticks but milliseconds since boot (unbiased). - Fix comment indentation. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/strace.cc')
-rw-r--r--winsup/cygwin/strace.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc
index 21c2d6d4a..35f8a59ae 100644
--- a/winsup/cygwin/strace.cc
+++ b/winsup/cygwin/strace.cc
@@ -82,14 +82,12 @@ strace::dll_info ()
int
strace::microseconds ()
{
- /* Need a local clock instance because this function is called before
- the global constructors of the inferior process have been called. */
- static clk_monotonic_t clock_monotonic;
static LONGLONG process_start NO_COPY;
+ clk_monotonic_t *clk = (clk_monotonic_t *) get_clock (CLOCK_MONOTONIC);
if (!process_start)
- process_start = clock_monotonic.usecs ();
- return (int) (clock_monotonic.usecs () - process_start);
+ process_start = clk->strace_usecs ();
+ return (int) (clk->strace_usecs () - process_start);
}
static int __stdcall