diff options
author | carpintero-de-c <175505615+carpintero-de-c@users.noreply.github.com> | 2024-07-14 03:55:58 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-14 00:25:58 +0200 |
commit | 7c380a6612f00e4a7ed02364dc2b3769e8edc8f8 (patch) | |
tree | fd78a050b4fa1372f6d023f10f3513a76e1ee769 /src/afl-common.c | |
parent | 3f26818d973c4929857977b7cdfcf26cc0a84eb3 (diff) | |
download | afl++-7c380a6612f00e4a7ed02364dc2b3769e8edc8f8.tar.gz |
Replace gettimeofday with clock_gettime (#2159)
Diffstat (limited to 'src/afl-common.c')
-rw-r--r-- | src/afl-common.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/afl-common.c b/src/afl-common.c index efdb5d60..62432158 100644 --- a/src/afl-common.c +++ b/src/afl-common.c @@ -976,12 +976,11 @@ void read_bitmap(u8 *fname, u8 *map, size_t len) { inline u64 get_cur_time(void) { - struct timeval tv; - struct timezone tz; + struct timespec spec; - gettimeofday(&tv, &tz); + clock_gettime(CLOCK_REALTIME, &spec); - return (tv.tv_sec * 1000ULL) + (tv.tv_usec / 1000); + return (spec.tv_sec * 1000ULL) + (spec.tv_nsec / 1000000ULL); } @@ -989,19 +988,17 @@ inline u64 get_cur_time(void) { inline u64 get_cur_time_us(void) { - struct timeval tv; - struct timezone tz; + struct timespec spec; - gettimeofday(&tv, &tz); + clock_gettime(CLOCK_REALTIME, &spec); - return (tv.tv_sec * 1000000ULL) + tv.tv_usec; + return (spec.tv_sec * 1000000ULL) + (spec.tv_nsec / 1000ULL); } /* Describe integer. The buf should be at least 6 bytes to fit all ints we randomly see. Will return buf for convenience. */ - u8 *stringify_int(u8 *buf, size_t len, u64 val) { \ #define CHK_FORMAT(_divisor, _limit_mult, _fmt, _cast) \ |