* cygheap.h (init_cygheap::_gtod): New hires_ms element.

* hires.h (hires_ms::minperiod): Remove static designation.
(hires::began_period): New field.
* signal.cc: Include headers required for cygheap.h now that gtod lives in the
cygheap.
* timer.c: Ditto.
* times.cc (gtod): Delete variable.
(gtod::minperiod): Ditto.
(gtod::began_period): Define.
(hires_ms::prime): Add more debugging output.  Call timeBeginPeriod only when
!began_period.
This commit is contained in:
Christopher Faylor 2005-11-04 20:45:56 +00:00
parent f359a29fc8
commit 72319550c1
6 changed files with 40 additions and 8 deletions

View File

@ -1,3 +1,17 @@
2005-11-04 Christopher Faylor <cgf@timesys.com>
* cygheap.h (init_cygheap::_gtod): New hires_ms element.
* hires.h (hires_ms::minperiod): Remove static designation.
(hires::began_period): New field.
* signal.cc: Include headers required for cygheap.h now that gtod lives
in the cygheap.
* timer.c: Ditto.
* times.cc (gtod): Delete variable.
(gtod::minperiod): Ditto.
(gtod::began_period): Define.
(hires_ms::prime): Add more debugging output. Call timeBeginPeriod
only when !began_period.
2005-11-04 Christopher Faylor <cgf@timesys.com> 2005-11-04 Christopher Faylor <cgf@timesys.com>
* times.cc (hires_ms::prime): More debugging. * times.cc (hires_ms::prime): More debugging.

View File

@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
#include "hires.h"
#undef cfree #undef cfree
enum cygheap_types enum cygheap_types
@ -298,6 +300,7 @@ struct init_cygheap
pid_t pid; /* my pid */ pid_t pid; /* my pid */
HANDLE pid_handle; /* handle for my pid */ HANDLE pid_handle; /* handle for my pid */
hook_chain hooks; hook_chain hooks;
hires_ms _gtod;
void close_ctty (); void close_ctty ();
}; };

View File

@ -41,7 +41,8 @@ class hires_ms : hires_base
{ {
DWORD initime_ms; DWORD initime_ms;
LARGE_INTEGER initime_us; LARGE_INTEGER initime_us;
static UINT minperiod; UINT minperiod;
static bool began_period;
UINT prime (); UINT prime ();
public: public:
LONGLONG usecs (bool justdelta); LONGLONG usecs (bool justdelta);
@ -50,5 +51,5 @@ class hires_ms : hires_base
}; };
extern hires_ms gtod; #define gtod cygheap->_gtod
#endif /*__HIRES_H__*/ #endif /*__HIRES_H__*/

View File

@ -21,6 +21,10 @@ details. */
#include "hires.h" #include "hires.h"
#include "security.h" #include "security.h"
#include "cygtls.h" #include "cygtls.h"
#include "path.h"
#include "fhandler.h"
#include "dtable.h"
#include "cygheap.h"
int sigcatchers; /* FIXME: Not thread safe. */ int sigcatchers; /* FIXME: Not thread safe. */

View File

@ -18,6 +18,10 @@ details. */
#include "cygtls.h" #include "cygtls.h"
#include "sigproc.h" #include "sigproc.h"
#include "sync.h" #include "sync.h"
#include "path.h"
#include "fhandler.h"
#include "dtable.h"
#include "cygheap.h"
#define TT_MAGIC 0x513e4a1c #define TT_MAGIC 0x513e4a1c
struct timer_tracker struct timer_tracker

View File

@ -144,8 +144,7 @@ totimeval (struct timeval *dst, FILETIME *src, int sub, int flag)
dst->tv_sec = x / (long long) (1e6); dst->tv_sec = x / (long long) (1e6);
} }
hires_ms gtod; bool NO_COPY hires_ms::began_period; /* minperiod needs to be NO_COPY since it
UINT NO_COPY hires_ms::minperiod; /* minperiod needs to be NO_COPY since it
is a trigger for setting timeBeginPeriod is a trigger for setting timeBeginPeriod
which needs to be set once for every which needs to be set once for every
program. */ program. */
@ -633,18 +632,25 @@ hires_ms::prime ()
TIMECAPS tc; TIMECAPS tc;
FILETIME f; FILETIME f;
stupid_printf ("entering, minperiod %d", minperiod); stupid_printf ("entering, minperiod %d, began_period %d", minperiod, began_period);
if (minperiod) if (minperiod)
/* done previously */; /* done previously */;
else if (timeGetDevCaps (&tc, sizeof (tc)) != TIMERR_NOERROR) else if (timeGetDevCaps (&tc, sizeof (tc)) != TIMERR_NOERROR)
{stupid_printf ("timeGetDevCaps failed, %E");
minperiod = 1; minperiod = 1;
}
else 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); }
stupid_printf ("inited %d, minperiod %u, began_period %d", minperiod, began_period);
if (!began_period)
{ {
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); timeBeginPeriod (minperiod);
began_period = true;
stupid_printf ("timeBeginPeriod called");
} }
stupid_printf ("inited %d");
if (!inited) if (!inited)
{ {