about summary refs log tree commit diff
path: root/src/afl-common.c
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2024-06-13 09:18:44 +0200
committervanhauser-thc <vh@thc.org>2024-06-13 09:19:11 +0200
commite7da8b9d6bf20b1cac960b1eccf3beac3fbf7901 (patch)
tree619b14542f1f9495360b024492898d6f6b819f92 /src/afl-common.c
parentc134df30db49bcabfd9de0ab9675e066a491c942 (diff)
downloadafl++-e7da8b9d6bf20b1cac960b1eccf3beac3fbf7901.tar.gz
Revert "MONOTONIC"
This reverts commit 0c9b460cc46aebfa4eb6e1fbe928895c0a8fcfbd.
Diffstat (limited to 'src/afl-common.c')
-rw-r--r--src/afl-common.c55
1 files changed, 12 insertions, 43 deletions
diff --git a/src/afl-common.c b/src/afl-common.c
index efe680a8..efdb5d60 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -59,43 +59,6 @@ u8  last_intr = 0;
   #define AFL_PATH "/usr/local/lib/afl/"
 #endif
 
-/* Convert seconds to milliseconds. */
-#define SEC_TO_MS(sec) ((sec) * 1000)
-/* Convert seconds to microseconds. */
-#define SEC_TO_US(sec) ((sec) * 1000000)
-/* Convert nanoseconds to milliseconds. */
-#define NS_TO_MS(ns) ((ns) / 1000000)
-/* Convert nanoseconds to microseconds. */
-#define NS_TO_US(ns) ((ns) / 1000)
-/* Convert seconds to milliseconds. */
-#define SEC_TO_MS(sec) ((sec) * 1000)
-/* Convert seconds to microseconds. */
-#define SEC_TO_US(sec) ((sec) * 1000000)
-/* Convert nanoseconds to milliseconds. */
-#define NS_TO_MS(ns) ((ns) / 1000000)
-/* Convert nanoseconds to microseconds. */
-#define NS_TO_US(ns) ((ns) / 1000)
-/* Convert nanoseconds to microseconds. */
-#define US_TO_MS(us) ((us) / 1000)
-/* Convert seconds to milliseconds. */
-#define SEC_TO_MS(sec) ((sec) * 1000)
-/* Convert seconds to microseconds. */
-#define SEC_TO_US(sec) ((sec) * 1000000)
-/* Convert nanoseconds to milliseconds. */
-#define NS_TO_MS(ns) ((ns) / 1000000)
-/* Convert nanoseconds to microseconds. */
-#define NS_TO_US(ns) ((ns) / 1000)
-/* Convert seconds to milliseconds. */
-#define SEC_TO_MS(sec) ((sec) * 1000)
-/* Convert seconds to microseconds. */
-#define SEC_TO_US(sec) ((sec) * 1000000)
-/* Convert nanoseconds to milliseconds. */
-#define NS_TO_MS(ns) ((ns) / 1000000)
-/* Convert nanoseconds to microseconds. */
-#define NS_TO_US(ns) ((ns) / 1000)
-/* Convert nanoseconds to microseconds. */
-#define US_TO_MS(us) ((us) / 1000)
-
 void *afl_memmem(const void *haystack, size_t haystacklen, const void *needle,
                  size_t needlelen) {
 
@@ -1013,9 +976,12 @@ void read_bitmap(u8 *fname, u8 *map, size_t len) {
 
 inline u64 get_cur_time(void) {
 
-  struct timespec ts;
-  (void)clock_gettime(CLOCK_MONOTONIC, &ts);
-  return (u64)(SEC_TO_MS((uint64_t)ts.tv_sec) + NS_TO_MS((uint64_t)ts.tv_nsec));
+  struct timeval  tv;
+  struct timezone tz;
+
+  gettimeofday(&tv, &tz);
+
+  return (tv.tv_sec * 1000ULL) + (tv.tv_usec / 1000);
 
 }
 
@@ -1023,9 +989,12 @@ inline u64 get_cur_time(void) {
 
 inline u64 get_cur_time_us(void) {
 
-  struct timespec ts;
-  (void)clock_gettime(CLOCK_MONOTONIC, &ts);
-  return (u64)(SEC_TO_US((uint64_t)ts.tv_sec) + NS_TO_US((uint64_t)ts.tv_nsec));
+  struct timeval  tv;
+  struct timezone tz;
+
+  gettimeofday(&tv, &tz);
+
+  return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
 
 }