aboutsummaryrefslogtreecommitdiff
path: root/src/afl-gotcpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/afl-gotcpu.c')
-rw-r--r--src/afl-gotcpu.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/afl-gotcpu.c b/src/afl-gotcpu.c
index fa629eb7..5aa9b35c 100644
--- a/src/afl-gotcpu.c
+++ b/src/afl-gotcpu.c
@@ -31,7 +31,7 @@
#endif
#ifdef __ANDROID__
- #include "android-ashmem.h"
+# include "android-ashmem.h"
#endif
#include <stdio.h>
#include <stdlib.h>
@@ -51,12 +51,11 @@
# define HAVE_AFFINITY 1
#endif /* __linux__ */
-
/* Get unix time in microseconds. */
static u64 get_cur_time_us(void) {
- struct timeval tv;
+ struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
@@ -65,7 +64,6 @@ static u64 get_cur_time_us(void) {
}
-
/* Get CPU usage in microseconds. */
static u64 get_cpu_usage_us(void) {
@@ -79,7 +77,6 @@ static u64 get_cpu_usage_us(void) {
}
-
/* Measure preemption rate. */
static u32 measure_preemption(u32 target_ms) {
@@ -96,14 +93,17 @@ repeat_loop:
v1 = CTEST_BUSY_CYCLES;
- while (v1--) v2++;
+ while (v1--)
+ v2++;
sched_yield();
en_t = get_cur_time_us();
if (en_t - st_t < target_ms * 1000) {
+
loop_repeats++;
goto repeat_loop;
+
}
/* Let's see what percentage of this time we actually had a chance to
@@ -111,22 +111,20 @@ repeat_loop:
en_c = get_cpu_usage_us();
- real_delta = (en_t - st_t) / 1000;
+ real_delta = (en_t - st_t) / 1000;
slice_delta = (en_c - st_c) / 1000;
return real_delta * 100 / slice_delta;
}
-
/* Do the benchmark thing. */
int main(int argc, char** argv) {
#ifdef HAVE_AFFINITY
- u32 cpu_cnt = sysconf(_SC_NPROCESSORS_ONLN),
- idle_cpus = 0, maybe_cpus = 0, i;
+ u32 cpu_cnt = sysconf(_SC_NPROCESSORS_ONLN), idle_cpus = 0, maybe_cpus = 0, i;
SAYF(cCYA "afl-gotcpu" VERSION cRST " by <lcamtuf@google.com>\n");
@@ -142,7 +140,7 @@ int main(int argc, char** argv) {
if (!fr) {
cpu_set_t c;
- u32 util_perc;
+ u32 util_perc;
CPU_ZERO(&c);
CPU_SET(i, &c);
@@ -159,7 +157,7 @@ int main(int argc, char** argv) {
} else if (util_perc < 250) {
- SAYF(" Core #%u: " cYEL "CAUTION " cRST "(%u%%)\n", i, util_perc);
+ SAYF(" Core #%u: " cYEL "CAUTION " cRST "(%u%%)\n", i, util_perc);
exit(1);
}
@@ -255,3 +253,4 @@ int main(int argc, char** argv) {
#endif /* ^HAVE_AFFINITY */
}
+