Index: lib/Fuzzer/afl/afl_driver.cpp =================================================================== --- lib/Fuzzer/afl/afl_driver.cpp +++ lib/Fuzzer/afl/afl_driver.cpp @@ -50,6 +50,7 @@ */ #include +#include #include #include #include @@ -58,7 +59,6 @@ #include #include #include -#include // Platform detection. Copied from FuzzerInternal.h #ifdef __linux__ #define LIBFUZZER_LINUX 1 @@ -104,7 +104,7 @@ // Variables we need for writing to the extra stats file. static FILE *extra_stats_file = NULL; static uint32_t previous_peak_rss = 0; -static time_t slowest_unit_time_secs = 0; +auto slowest_unit_time_secs = std::chrono::seconds::zero(); static const int kNumExtraStats = 2; static const char *kExtraStatsFormatString = "peak_rss_mb : %u\n" "slowest_unit_time_sec : %u\n"; @@ -262,7 +262,6 @@ if (argc >= 2) N = atoi(argv[1]); assert(N > 0); - time_t unit_time_secs; int num_runs = 0; while (__afl_persistent_loop(N)) { ssize_t n_read = read(0, AflInputBuf, kMaxAflInputSize); @@ -272,19 +271,15 @@ uint8_t *copy = new uint8_t[n_read]; memcpy(copy, AflInputBuf, n_read); - struct timeval unit_start_time; - CHECK_ERROR(gettimeofday(&unit_start_time, NULL) == 0, - "Calling gettimeofday failed"); + auto unit_start_time = std::chrono::system_clock::now(); num_runs++; LLVMFuzzerTestOneInput(copy, n_read); - struct timeval unit_stop_time; - CHECK_ERROR(gettimeofday(&unit_stop_time, NULL) == 0, - "Calling gettimeofday failed"); + auto unit_time_secs = std::chrono::duration_cast( + std::chrono::system_clock::now() - unit_start_time); // Update slowest_unit_time_secs if we see a new max. - unit_time_secs = unit_stop_time.tv_sec - unit_start_time.tv_sec; if (slowest_unit_time_secs < unit_time_secs) slowest_unit_time_secs = unit_time_secs;