added lazy init for static build

This commit is contained in:
Jeff Hill
1998-06-16 01:52:32 +00:00
parent a0be9a16b3
commit b439063760
2 changed files with 42 additions and 2 deletions

View File

@@ -18,6 +18,7 @@
static unsigned long offset_secs;
static DWORD prev_time = 0;
static UINT res;
static char init = 0;
/*
* init_osi_time has to be called before using the timer,
@@ -27,6 +28,10 @@ int init_osi_time ()
{
TIMECAPS tc;
if (init) {
return 1;
}
if (timeGetDevCaps (&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
fprintf (stderr, "init_osi_time: cannot get timer info\n");
@@ -42,13 +47,19 @@ int init_osi_time ()
prev_time = timeGetTime();
offset_secs = (long)time(NULL) - (long)prev_time/1000;
init = 1;
return 0;
}
int exit_osi_time ()
{
if (!init) {
return 0;
}
timeEndPeriod (res);
init = 0;
return 0;
}
@@ -59,7 +70,16 @@ int exit_osi_time ()
//
osiTime osiTime::getCurrent ()
{
unsigned long now;
unsigned long now;
/*
* this allows the code to work when it is in an object
* library (in addition to inside a dll)
*/
if (!init) {
init_osi_time();
init = 1;
}
/* MS Online help:
* Note that the value returned by the timeGetTime function is

View File

@@ -18,6 +18,7 @@
static unsigned long offset_secs;
static DWORD prev_time = 0;
static UINT res;
static char init = 0;
/*
* init_osi_time has to be called before using the timer,
@@ -27,6 +28,10 @@ int init_osi_time ()
{
TIMECAPS tc;
if (init) {
return 1;
}
if (timeGetDevCaps (&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
fprintf (stderr, "init_osi_time: cannot get timer info\n");
@@ -42,13 +47,19 @@ int init_osi_time ()
prev_time = timeGetTime();
offset_secs = (long)time(NULL) - (long)prev_time/1000;
init = 1;
return 0;
}
int exit_osi_time ()
{
if (!init) {
return 0;
}
timeEndPeriod (res);
init = 0;
return 0;
}
@@ -59,7 +70,16 @@ int exit_osi_time ()
//
osiTime osiTime::getCurrent ()
{
unsigned long now;
unsigned long now;
/*
* this allows the code to work when it is in an object
* library (in addition to inside a dll)
*/
if (!init) {
init_osi_time();
init = 1;
}
/* MS Online help:
* Note that the value returned by the timeGetTime function is