mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 02:28:09 +00:00
indenting preprocessor directives breaks compilation and cant be fixed, reverting ... :-(
This commit is contained in:
@ -33,11 +33,11 @@
|
||||
|
||||
void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
# if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
cpu_set_t c;
|
||||
# elif defined(__NetBSD__)
|
||||
#elif defined(__NetBSD__)
|
||||
cpuset_t * c;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
u8 cpu_used[4096] = {0};
|
||||
u32 i;
|
||||
@ -51,7 +51,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
}
|
||||
|
||||
# if defined(__linux__)
|
||||
#if defined(__linux__)
|
||||
DIR * d;
|
||||
struct dirent *de;
|
||||
d = opendir("/proc");
|
||||
@ -112,7 +112,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
# elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
struct kinfo_proc *procs;
|
||||
size_t nprocs;
|
||||
size_t proccount;
|
||||
@ -133,7 +133,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
for (i = 0; i < proccount; i++) {
|
||||
|
||||
# if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__)
|
||||
if (!strcmp(procs[i].ki_comm, "idle")) continue;
|
||||
|
||||
// fix when ki_oncpu = -1
|
||||
@ -143,16 +143,16 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
if (oncpu != -1 && oncpu < sizeof(cpu_used) && procs[i].ki_pctcpu > 60)
|
||||
cpu_used[oncpu] = 1;
|
||||
# elif defined(__DragonFly__)
|
||||
#elif defined(__DragonFly__)
|
||||
if (procs[i].kp_lwp.kl_cpuid < sizeof(cpu_used) &&
|
||||
procs[i].kp_lwp.kl_pctcpu > 10)
|
||||
cpu_used[procs[i].kp_lwp.kl_cpuid] = 1;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ck_free(procs);
|
||||
# elif defined(__NetBSD__)
|
||||
#elif defined(__NetBSD__)
|
||||
struct kinfo_proc2 *procs;
|
||||
size_t nprocs;
|
||||
size_t proccount;
|
||||
@ -181,15 +181,15 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
}
|
||||
|
||||
ck_free(procs);
|
||||
# else
|
||||
# warning \
|
||||
"For this platform we do not have free CPU binding code yet. If possible, please supply a PR to https://github.com/AFLplusplus/AFLplusplus"
|
||||
# endif
|
||||
#else
|
||||
#warning \
|
||||
"For this platform we do not have free CPU binding code yet. If possible, please supply a PR to https://github.com/AFLplusplus/AFLplusplus"
|
||||
#endif
|
||||
|
||||
size_t cpu_start = 0;
|
||||
|
||||
try:
|
||||
# ifndef __ANDROID__
|
||||
#ifndef __ANDROID__
|
||||
for (i = cpu_start; i < afl->cpu_core_count; i++) {
|
||||
|
||||
if (!cpu_used[i]) { break; }
|
||||
@ -198,12 +198,12 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
if (i == afl->cpu_core_count) {
|
||||
|
||||
# else
|
||||
#else
|
||||
for (i = afl->cpu_core_count - cpu_start - 1; i > -1; i--)
|
||||
if (!cpu_used[i]) break;
|
||||
if (i == -1) {
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
SAYF("\n" cLRD "[-] " cRST
|
||||
"Uh-oh, looks like all %d CPU cores on your system are allocated to\n"
|
||||
@ -221,16 +221,16 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
afl->cpu_aff = i;
|
||||
|
||||
# if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
CPU_ZERO(&c);
|
||||
CPU_SET(i, &c);
|
||||
# elif defined(__NetBSD__)
|
||||
#elif defined(__NetBSD__)
|
||||
c = cpuset_create();
|
||||
if (c == NULL) PFATAL("cpuset_create failed");
|
||||
cpuset_set(i, c);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# if defined(__linux__)
|
||||
#if defined(__linux__)
|
||||
if (sched_setaffinity(0, sizeof(c), &c)) {
|
||||
|
||||
if (cpu_start == afl->cpu_core_count) {
|
||||
@ -246,7 +246,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
}
|
||||
|
||||
# elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
if (pthread_setaffinity_np(pthread_self(), sizeof(c), &c)) {
|
||||
|
||||
if (cpu_start == afl->cpu_core_count)
|
||||
@ -258,7 +258,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
||||
|
||||
}
|
||||
|
||||
# elif defined(__NetBSD__)
|
||||
#elif defined(__NetBSD__)
|
||||
if (pthread_setaffinity_np(pthread_self(), cpuset_size(c), c)) {
|
||||
|
||||
if (cpu_start == afl->cpu_core_count)
|
||||
@ -271,10 +271,10 @@ if (pthread_setaffinity_np(pthread_self(), cpuset_size(c), c)) {
|
||||
}
|
||||
|
||||
cpuset_destroy(c);
|
||||
# else
|
||||
#else
|
||||
// this will need something for other platforms
|
||||
// TODO: Solaris/Illumos has processor_bind ... might worth a try
|
||||
# endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@ -1565,7 +1565,7 @@ void check_crash_handling(void) {
|
||||
until I get a box to test the code. So, for now, we check for crash
|
||||
reporting the awful way. */
|
||||
|
||||
# if !TARGET_OS_IPHONE
|
||||
#if !TARGET_OS_IPHONE
|
||||
if (system("launchctl list 2>/dev/null | grep -q '\\.ReportCrash$'")) return;
|
||||
|
||||
SAYF(
|
||||
@ -1583,7 +1583,7 @@ void check_crash_handling(void) {
|
||||
" launchctl unload -w ${SL}/LaunchAgents/${PL}.plist\n"
|
||||
" sudo launchctl unload -w ${SL}/LaunchDaemons/${PL}.Root.plist\n");
|
||||
|
||||
# endif
|
||||
#endif
|
||||
if (!get_afl_env("AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES"))
|
||||
FATAL("Crash reporter detected");
|
||||
|
||||
@ -1778,26 +1778,26 @@ void get_core_count(afl_state_t *afl) {
|
||||
|
||||
/* On *BSD systems, we can just use a sysctl to get the number of CPUs. */
|
||||
|
||||
# ifdef __APPLE__
|
||||
#ifdef __APPLE__
|
||||
|
||||
if (sysctlbyname("hw.logicalcpu", &afl->cpu_core_count, &s, NULL, 0) < 0)
|
||||
return;
|
||||
|
||||
# else
|
||||
#else
|
||||
|
||||
int s_name[2] = {CTL_HW, HW_NCPU};
|
||||
|
||||
if (sysctl(s_name, 2, &afl->cpu_core_count, &s, NULL, 0) < 0) return;
|
||||
|
||||
# endif /* ^__APPLE__ */
|
||||
#endif /* ^__APPLE__ */
|
||||
|
||||
#else
|
||||
|
||||
# ifdef HAVE_AFFINITY
|
||||
#ifdef HAVE_AFFINITY
|
||||
|
||||
afl->cpu_core_count = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
|
||||
# else
|
||||
#else
|
||||
|
||||
FILE *f = fopen("/proc/stat", "r");
|
||||
u8 tmp[1024];
|
||||
@ -1809,7 +1809,7 @@ void get_core_count(afl_state_t *afl) {
|
||||
|
||||
fclose(f);
|
||||
|
||||
# endif /* ^HAVE_AFFINITY */
|
||||
#endif /* ^HAVE_AFFINITY */
|
||||
|
||||
#endif /* ^(__APPLE__ || __FreeBSD__ || __OpenBSD__) */
|
||||
|
||||
@ -2102,12 +2102,12 @@ void check_binary(afl_state_t *afl, u8 *fname) {
|
||||
|
||||
#else
|
||||
|
||||
# if !defined(__arm__) && !defined(__arm64__)
|
||||
#if !defined(__arm__) && !defined(__arm64__)
|
||||
if ((f_data[0] != 0xCF || f_data[1] != 0xFA || f_data[2] != 0xED) &&
|
||||
(f_data[0] != 0xCA || f_data[1] != 0xFE || f_data[2] != 0xBA))
|
||||
FATAL("Program '%s' is not a 64-bit or universal Mach-O binary",
|
||||
afl->fsrv.target_path);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* ^!__APPLE__ */
|
||||
|
||||
|
Reference in New Issue
Block a user