about summary refs log tree commit diff
path: root/include/common.h
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-03-09 09:30:25 +0100
committerGitHub <noreply@github.com>2020-03-09 09:30:25 +0100
commit8e953d99314203f5c996b4a327403563b1c4ec00 (patch)
treef123d9863f22821ebfd024294ac97c8e54b8a6d0 /include/common.h
parent9f89bbd5ec7c151e5c4e9fe4069e6bc0922b8aa7 (diff)
parent1a582d54e51eccfecb724ef04cc17cd852193b7a (diff)
downloadafl++-8e953d99314203f5c996b4a327403563b1c4ec00.tar.gz
Merge pull request #240 from rish9101/refactor
Remove get_cut_time function from multiple places and refactor code
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index ad1f81fb..0d7f4f0b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -25,6 +25,8 @@
 
 #ifndef __AFLCOMMON_H
 #define __AFLCOMMON_H
+
+#include <sys/time.h>
 #include "types.h"
 
 extern u8* target_path;                 /* Path to target binary            */
@@ -37,3 +39,29 @@ char** get_wine_argv(u8* own_loc, char** argv, int argc);
 char*  get_afl_env(char* env);
 #endif
 
+/* Get unix time in milliseconds */
+
+static u64 get_cur_time(void) {
+
+  struct timeval  tv;
+  struct timezone tz;
+
+  gettimeofday(&tv, &tz);
+
+  return (tv.tv_sec * 1000ULL) + (tv.tv_usec / 1000);
+
+}
+
+/* Get unix time in microseconds */
+
+static u64 get_cur_time_us(void) {
+
+  struct timeval  tv;
+  struct timezone tz;
+
+  gettimeofday(&tv, &tz);
+
+  return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
+
+}
+