mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* times.cc (hires_ms::prime): More debugging.
(hires_ms::usecs): Ditto.
This commit is contained in:
parent
39dd399c50
commit
f359a29fc8
@ -1,3 +1,8 @@
|
||||
2005-11-04 Christopher Faylor <cgf@timesys.com>
|
||||
|
||||
* times.cc (hires_ms::prime): More debugging.
|
||||
(hires_ms::usecs): Ditto.
|
||||
|
||||
2005-11-03 Christopher Faylor <cgf@timesys.com>
|
||||
|
||||
* times.cc (stupid_printf): Define and use throughout -- temporarily.
|
||||
|
@ -240,8 +240,8 @@ frok::child (void *)
|
||||
cygbench ("fork-child");
|
||||
ld_preload ();
|
||||
fixup_hooks_after_fork ();
|
||||
cygwin_finished_initializing = true;
|
||||
_my_tls.fixup_after_fork ();
|
||||
cygwin_finished_initializing = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -144,8 +144,11 @@ totimeval (struct timeval *dst, FILETIME *src, int sub, int flag)
|
||||
dst->tv_sec = x / (long long) (1e6);
|
||||
}
|
||||
|
||||
hires_ms NO_COPY gtod;
|
||||
UINT hires_ms::minperiod;
|
||||
hires_ms gtod;
|
||||
UINT NO_COPY hires_ms::minperiod; /* minperiod needs to be NO_COPY since it
|
||||
is a trigger for setting timeBeginPeriod
|
||||
which needs to be set once for every
|
||||
program. */
|
||||
|
||||
/* FIXME: Make thread safe */
|
||||
extern "C" int
|
||||
@ -631,15 +634,16 @@ hires_ms::prime ()
|
||||
FILETIME f;
|
||||
|
||||
stupid_printf ("entering, minperiod %d", minperiod);
|
||||
if (!minperiod)
|
||||
if (timeGetDevCaps (&tc, sizeof (tc)) != TIMERR_NOERROR)
|
||||
minperiod = 1;
|
||||
else
|
||||
{
|
||||
stupid_printf ("timeGetDevCaps succeeded");
|
||||
minperiod = min (max (tc.wPeriodMin, 1), tc.wPeriodMax);
|
||||
timeBeginPeriod (minperiod);
|
||||
}
|
||||
if (minperiod)
|
||||
/* done previously */;
|
||||
else if (timeGetDevCaps (&tc, sizeof (tc)) != TIMERR_NOERROR)
|
||||
minperiod = 1;
|
||||
else
|
||||
{
|
||||
minperiod = min (max (tc.wPeriodMin, 1), tc.wPeriodMax);
|
||||
stupid_printf ("timeGetDevCaps succeeded. tc.wPeriodMin %u, tc.wPeriodMax %u, minperiod %u", tc.wPeriodMin, tc.wPeriodMax, minperiod);
|
||||
timeBeginPeriod (minperiod);
|
||||
}
|
||||
stupid_printf ("inited %d");
|
||||
|
||||
if (!inited)
|
||||
@ -668,17 +672,23 @@ stupid_printf ("returning");
|
||||
LONGLONG
|
||||
hires_ms::usecs (bool justdelta)
|
||||
{
|
||||
stupid_printf ("before call to prime(), minperiod %u, process priority %d", minperiod, GetThreadPriority (GetCurrentThread ()));
|
||||
if (!minperiod) /* NO_COPY variable */
|
||||
prime ();
|
||||
stupid_printf ("after call to prime(), process priority %d", GetThreadPriority (GetCurrentThread ()));
|
||||
|
||||
DWORD now = timeGetTime ();
|
||||
stupid_printf ("after call to timeGetTime, process priority %d", GetThreadPriority (GetCurrentThread ()));
|
||||
if ((int) (now - initime_ms) < 0)
|
||||
{
|
||||
stupid_printf ("special casing, process priority %d", GetThreadPriority (GetCurrentThread ()));
|
||||
inited = 0;
|
||||
prime ();
|
||||
now = timeGetTime ();
|
||||
}
|
||||
// FIXME: Not sure how this will handle the 49.71 day wrap around
|
||||
LONGLONG res = initime_us.QuadPart + ((LONGLONG) (now - initime_ms) * 1000);
|
||||
stupid_printf ("res %U, process priority %d", res, GetThreadPriority (GetCurrentThread ()));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user