Changeset View
Changeset View
Standalone View
Standalone View
agent/protect.c
Context not available. | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <time.h> | |||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
Context not available. | |||||
#ifdef HAVE_W32_SYSTEM | #ifdef HAVE_W32_SYSTEM | ||||
FILETIME creation_time, exit_time, kernel_time, user_time; | FILETIME creation_time, exit_time, kernel_time, user_time; | ||||
#else | #else | ||||
clock_t ticks; | unsigned long ms; | ||||
#endif | #endif | ||||
}; | }; | ||||
Context not available. | |||||
&data->creation_time, &data->exit_time, | &data->creation_time, &data->exit_time, | ||||
&data->kernel_time, &data->user_time); | &data->kernel_time, &data->user_time); | ||||
# endif | # endif | ||||
#elif defined (CLOCK_THREAD_CPUTIME_ID) | |||||
struct timespec tmp; | |||||
clock_gettime (CLOCK_THREAD_CPUTIME_ID, &tmp); | |||||
/* Convert from seconds + nanoseconds to milliseconds. */ | |||||
data->ms = (unsigned long)((tmp.tv_sec * 1000000000 + tmp.tv_nsec) | |||||
/ 1000000.0); | |||||
#else | #else | ||||
struct tms tmp; | struct tms tmp; | ||||
static long ticks_per_second; | |||||
if (!ticks_per_second) | |||||
ticks_per_second = sysconf (_SC_CLK_TCK); | |||||
times (&tmp); | times (&tmp); | ||||
data->ticks = tmp.tms_utime; | /* Convert from clock ticks to milliseconds. */ | ||||
data->ms = (unsigned long)((tmp.tms_utime / (double)ticks_per_second) | |||||
* 1000); | |||||
#endif | #endif | ||||
} | } | ||||
Context not available. | |||||
return (unsigned long)((t2 - t1)/10000); | return (unsigned long)((t2 - t1)/10000); | ||||
} | } | ||||
#else | #else | ||||
return (unsigned long)((((double) (stoptime.ticks - starttime->ticks)) | return stoptime.ms - starttime->ms; | ||||
/CLOCKS_PER_SEC)*10000000); | |||||
#endif | #endif | ||||
} | } | ||||
Context not available. |