diff options
author | Xavier Roche <roche@httrack.com> | 2017-04-01 18:12:33 +0200 |
---|---|---|
committer | Xavier Roche <roche@httrack.com> | 2017-04-01 18:12:33 +0200 |
commit | a83f70b6f8ade224a079a27b4f18fcb3fb0be0ca (patch) | |
tree | 6be9e53ddc8ffb41238ad63a5b2422080295b5b4 /src | |
parent | 68efe9e4a4671d051e40abd904c135f3033654c5 (diff) |
Use gettimeofday() instead of ftime()
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--] | src/htslib.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/htslib.c b/src/htslib.c index 40b79cc..f23d5e5 100644..100755 --- a/src/htslib.c +++ b/src/htslib.c @@ -68,7 +68,7 @@ Please visit our Website: http://www.httrack.com #include <time.h> #include <stdarg.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <fcntl.h> // pour utimbuf @@ -2575,11 +2575,13 @@ TStamp time_local(void) { // number of millisec since 1970 HTSEXT_API TStamp mtime_local(void) { #ifndef HTS_DO_NOT_USE_FTIME - struct timeb B; + struct timeval tv; + if (gettimeofday(&tv, NULL) != 0) { + assert(! "gettimeofday"); + } - ftime(&B); - return (TStamp) (((TStamp) B.time * (TStamp) 1000) - + ((TStamp) B.millitm)); + return (TStamp) (((TStamp) tv.tv_sec * (TStamp) 1000) + + ((TStamp) tv.tv_usec / (TStamp) 1000000)); #else // not precise.. return (TStamp) (((TStamp) time_local() * (TStamp) 1000) |