void osdep_init( void ) { char buf[MAX_PATH + 1]; char *end; size_t l; real_start.sec = 0; real_start.usec = 0; get_rtclock( &real_start ); if ( getenv( LARCENY_ROOT ) == NULL ) { if ( GetModuleFileName(NULL, buf, MAX_PATH + 1) == 0 ) goto giveup; if ( (end = strrchr(buf, '\\')) == NULL ) goto giveup; *end = '\0'; if ( osdep_setenv(LARCENY_ROOT, buf, 1) ) panic_exit( "Couldn't set LARCENY_ROOT" ); } return; giveup: return; }
/* Return the current time in milliseconds since initialization */ unsigned osdep_realclock( void ) { stat_time_t now; get_rtclock( &now ); return now.sec * 1000 + now.usec / 1000; }
/* Fill in the structures with real, user, system times. */ void osdep_time_used( stat_time_t *real, stat_time_t *user, stat_time_t *system ) { if (real != 0) get_rtclock( real ); if (user != 0 || system != 0) { unsigned t = clock(); if (user != 0) { user->sec = t / CLOCKS_PER_SEC; user->usec = ((t - (user->sec * CLOCKS_PER_SEC))*1000000)/CLOCKS_PER_SEC; } if (system != 0) { system->sec = 0; system->usec = 0; } } }
/* Fill in the structures with real, user, system times. */ void osdep_time_used( stat_time_t *real, stat_time_t *user, stat_time_t *system ) { if (real != 0) get_rtclock( real ); if (user != 0 || system != 0) { unsigned t = clock(); if (user != 0) { user->sec = t / CLOCKS_PER_SEC; user->usec = ((t - (user->sec * CLOCKS_PER_SEC))*1000000)/CLOCKS_PER_SEC; } if (system != 0) { // FIXME: missing // Looks like the API function to use is GetProcessTimes(), it might also // provide a better value for the user time. system->sec = 0; system->usec = 0; } } }
void osdep_init( void ) { real_start.sec = 0; real_start.usec = 0; get_rtclock( &real_start ); }