Skip to content

Commit 894339c

Browse files
committed
try regression fix
1 parent e13dc9b commit 894339c

File tree

1 file changed

+8
-37
lines changed

1 file changed

+8
-37
lines changed

src/afl-common.c

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,6 @@ u8 last_intr = 0;
5959
#define AFL_PATH "/usr/local/lib/afl/"
6060
#endif
6161

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-
8362
void *afl_memmem(const void *haystack, size_t haystacklen, const void *needle,
8463
size_t needlelen) {
8564

@@ -997,33 +976,25 @@ void read_bitmap(u8 *fname, u8 *map, size_t len) {
997976

998977
inline u64 get_cur_time(void) {
999978

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;
1003981

1004-
PFATAL("Failed to obtain timestamp (errno = %i: %s)\n", errno,
1005-
strerror(errno));
982+
gettimeofday(&tv, &tz);
1006983

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);
1010985

1011986
}
1012987

1013988
/* Get unix time in microseconds */
1014989

1015990
inline u64 get_cur_time_us(void) {
1016991

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;
1020994

1021-
PFATAL("Failed to obtain timestamp (errno = %i: %s)\n", errno,
1022-
strerror(errno));
1023-
1024-
}
995+
gettimeofday(&tv, &tz);
1025996

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;
1027998

1028999
}
10291000

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy