|
Removed
Link Here
|
| 1 |
--- src/porttime/ptlinux.c.orig 2021-07-17 02:14:06 UTC |
| 2 |
+++ src/porttime/ptlinux.c |
| 3 |
@@ -1,3 +1,4 @@ |
| 4 |
+ |
| 5 |
/* ptlinux.c -- portable timer implementation for linux */ |
| 6 |
|
| 7 |
|
| 8 |
@@ -31,14 +32,14 @@ CHANGE LOG |
| 9 |
#include "porttime.h" |
| 10 |
#include "sys/time.h" |
| 11 |
#include "sys/resource.h" |
| 12 |
-#include "sys/timeb.h" |
| 13 |
#include "pthread.h" |
| 14 |
|
| 15 |
#define TRUE 1 |
| 16 |
#define FALSE 0 |
| 17 |
|
| 18 |
static int time_started_flag = FALSE; |
| 19 |
-static struct timeb time_offset = {0, 0, 0, 0}; |
| 20 |
+static struct timeval *time_offset; |
| 21 |
+ |
| 22 |
static pthread_t pt_thread_pid; |
| 23 |
static int pt_thread_created = FALSE; |
| 24 |
|
| 25 |
@@ -79,7 +80,8 @@ static void *Pt_CallbackProc(void *p) |
| 26 |
PtError Pt_Start(int resolution, PtCallback *callback, void *userData) |
| 27 |
{ |
| 28 |
if (time_started_flag) return ptNoError; |
| 29 |
- ftime(&time_offset); /* need this set before process runs */ |
| 30 |
+ gettimeofday(time_offset, NULL); |
| 31 |
+ |
| 32 |
if (callback) { |
| 33 |
int res; |
| 34 |
pt_callback_parameters *parms = (pt_callback_parameters *) |
| 35 |
@@ -121,10 +123,12 @@ int Pt_Started() |
| 36 |
PtTimestamp Pt_Time() |
| 37 |
{ |
| 38 |
long seconds, milliseconds; |
| 39 |
- struct timeb now; |
| 40 |
- ftime(&now); |
| 41 |
- seconds = now.time - time_offset.time; |
| 42 |
- milliseconds = now.millitm - time_offset.millitm; |
| 43 |
+ struct timeval *now; |
| 44 |
+ |
| 45 |
+ gettimeofday(now, NULL); |
| 46 |
+ |
| 47 |
+ seconds = now->tv_sec - time_offset->tv_sec; |
| 48 |
+ milliseconds = now->tv_usec - time_offset->tv_usec; |
| 49 |
return seconds * 1000 + milliseconds; |
| 50 |
} |
| 51 |
|