@@ -59,27 +59,6 @@ u8 last_intr = 0;
59
59
#define AFL_PATH "/usr/local/lib/afl/"
60
60
#endif
61
61
62
- /* - Some BSD (i.e.: FreeBSD) offer the FAST clock source as
63
- * equivalent to Linux COARSE clock source. Aliasing COARSE to
64
- * FAST on such systems when COARSE is not already defined.
65
- * - macOS has no support of CLOCK_MONOTONIC_COARSE clock type.
66
- */
67
- #if defined(OS_DARWIN ) || defined(OS_SUNOS ) || defined(__APPLE__ ) || \
68
- defined(__sun ) || defined(__NetBSD__ )
69
- #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
70
- #elif defined(OS_FREEBSD )
71
- #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
72
- #endif
73
-
74
- /* Convert seconds to milliseconds. */
75
- #define SEC_TO_MS (sec ) ((sec) * 1000)
76
- /* Convert seconds to microseconds. */
77
- #define SEC_TO_US (sec ) ((sec) * 1000000)
78
- /* Convert nanoseconds to milliseconds. */
79
- #define NS_TO_MS (ns ) ((ns) / 1000000)
80
- /* Convert nanoseconds to microseconds. */
81
- #define NS_TO_US (ns ) ((ns) / 1000)
82
-
83
62
void * afl_memmem (const void * haystack , size_t haystacklen , const void * needle ,
84
63
size_t needlelen ) {
85
64
@@ -997,33 +976,25 @@ void read_bitmap(u8 *fname, u8 *map, size_t len) {
997
976
998
977
inline u64 get_cur_time (void ) {
999
978
1000
- struct timespec ts ;
1001
- int rc = clock_gettime (CLOCK_MONOTONIC_COARSE , & ts );
1002
- if (unlikely (rc == -1 )) {
979
+ struct timeval tv ;
980
+ struct timezone tz ;
1003
981
1004
- PFATAL ("Failed to obtain timestamp (errno = %i: %s)\n" , errno ,
1005
- strerror (errno ));
982
+ gettimeofday (& tv , & tz );
1006
983
1007
- }
1008
-
1009
- return SEC_TO_MS ((uint64_t )ts .tv_sec ) + NS_TO_MS ((uint64_t )ts .tv_nsec );
984
+ return (tv .tv_sec * 1000ULL ) + (tv .tv_usec / 1000 );
1010
985
1011
986
}
1012
987
1013
988
/* Get unix time in microseconds */
1014
989
1015
990
inline u64 get_cur_time_us (void ) {
1016
991
1017
- struct timespec ts ;
1018
- int rc = clock_gettime (CLOCK_MONOTONIC_COARSE , & ts );
1019
- if (unlikely (rc == -1 )) {
992
+ struct timeval tv ;
993
+ struct timezone tz ;
1020
994
1021
- PFATAL ("Failed to obtain timestamp (errno = %i: %s)\n" , errno ,
1022
- strerror (errno ));
1023
-
1024
- }
995
+ gettimeofday (& tv , & tz );
1025
996
1026
- return SEC_TO_US (( uint64_t ) ts .tv_sec ) + NS_TO_US (( uint64_t ) ts . tv_nsec ) ;
997
+ return ( tv .tv_sec * 1000000ULL ) + tv . tv_usec ;
1027
998
1028
999
}
1029
1000
0 commit comments