remove macro indentation from code-format

This commit is contained in:
Andrea Fioraldi
2019-09-03 20:43:11 +02:00
parent 0d7ecd4327
commit 7151651ea9
28 changed files with 221 additions and 232 deletions

View File

@ -45,31 +45,14 @@ def custom_format(filename):
src, _ = p.communicate() src, _ = p.communicate()
src = str(src, "utf-8") src = str(src, "utf-8")
macro_indent = 0
in_define = False in_define = False
last_line = None last_line = None
out = "" out = ""
for line in src.split("\n"): for line in src.split("\n"):
if line.startswith("#"): if line.startswith("#"):
i = macro_indent if line.startswith("#define"):
if line.startswith("#end") and macro_indent > 0:
macro_indent -= 1
i -= 1
elif line.startswith("#el") and macro_indent > 0:
i -= 1
elif line.startswith("#if") and not (line.startswith("#ifndef") and (line.endswith("_H") or line.endswith("H_"))):
macro_indent += 1
elif line.startswith("#define"):
in_define = True in_define = True
r = "#" + (i * " ") + line[1:]
if i != 0 and line.endswith("\\"):
r = r[:-1]
while r[-1].isspace() and len(r) != (len(line)-1):
r = r[:-1]
r += "\\"
if len(r) <= COLUMN_LIMIT:
line = r
elif "/*" in line and not line.strip().startswith("/*") and line.endswith("*/") and len(line) < (COLUMN_LIMIT-2): elif "/*" in line and not line.strip().startswith("/*") and line.endswith("*/") and len(line) < (COLUMN_LIMIT-2):
cmt_start = line.rfind("/*") cmt_start = line.rfind("/*")

View File

@ -398,9 +398,9 @@ static const u8* main_payload_32 =
recognize .string. */ recognize .string. */
#ifdef __APPLE__ #ifdef __APPLE__
# define CALL_L64(str) "call _" str "\n" #define CALL_L64(str) "call _" str "\n"
#else #else
# define CALL_L64(str) "call " str "@PLT\n" #define CALL_L64(str) "call " str "@PLT\n"
#endif /* ^__APPLE__ */ #endif /* ^__APPLE__ */
static const u8* main_payload_64 = static const u8* main_payload_64 =
@ -737,9 +737,9 @@ static const u8* main_payload_64 =
#ifdef __APPLE__ #ifdef __APPLE__
" .comm __afl_area_ptr, 8\n" " .comm __afl_area_ptr, 8\n"
# ifndef COVERAGE_ONLY #ifndef COVERAGE_ONLY
" .comm __afl_prev_loc, 8\n" " .comm __afl_prev_loc, 8\n"
# endif /* !COVERAGE_ONLY */ #endif /* !COVERAGE_ONLY */
" .comm __afl_fork_pid, 4\n" " .comm __afl_fork_pid, 4\n"
" .comm __afl_temp, 4\n" " .comm __afl_temp, 4\n"
" .comm __afl_setup_failure, 1\n" " .comm __afl_setup_failure, 1\n"
@ -747,9 +747,9 @@ static const u8* main_payload_64 =
#else #else
" .lcomm __afl_area_ptr, 8\n" " .lcomm __afl_area_ptr, 8\n"
# ifndef COVERAGE_ONLY #ifndef COVERAGE_ONLY
" .lcomm __afl_prev_loc, 8\n" " .lcomm __afl_prev_loc, 8\n"
# endif /* !COVERAGE_ONLY */ #endif /* !COVERAGE_ONLY */
" .lcomm __afl_fork_pid, 4\n" " .lcomm __afl_fork_pid, 4\n"
" .lcomm __afl_temp, 4\n" " .lcomm __afl_temp, 4\n"
" .lcomm __afl_setup_failure, 1\n" " .lcomm __afl_setup_failure, 1\n"

View File

@ -27,12 +27,12 @@
#define MESSAGES_TO_STDOUT #define MESSAGES_TO_STDOUT
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
# define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "android-ashmem.h" #include "android-ashmem.h"
#endif #endif
#include "config.h" #include "config.h"
@ -69,21 +69,21 @@
#include <sys/file.h> #include <sys/file.h>
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
# include <sys/sysctl.h> #include <sys/sysctl.h>
# define HAVE_ARC4RANDOM 1 #define HAVE_ARC4RANDOM 1
#endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */ #endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */
/* For systems that have sched_setaffinity; right now just Linux, but one /* For systems that have sched_setaffinity; right now just Linux, but one
can hope... */ can hope... */
#ifdef __linux__ #ifdef __linux__
# define HAVE_AFFINITY 1 #define HAVE_AFFINITY 1
#endif /* __linux__ */ #endif /* __linux__ */
#ifndef SIMPLE_FILES #ifndef SIMPLE_FILES
# define CASE_PREFIX "id:" #define CASE_PREFIX "id:"
#else #else
# define CASE_PREFIX "id_" #define CASE_PREFIX "id_"
#endif /* ^!SIMPLE_FILES */ #endif /* ^!SIMPLE_FILES */
struct queue_entry { struct queue_entry {
@ -432,7 +432,7 @@ extern s32
/* Python stuff */ /* Python stuff */
#ifdef USE_PYTHON #ifdef USE_PYTHON
# include <Python.h> #include <Python.h>
extern PyObject* py_module; extern PyObject* py_module;

View File

@ -105,18 +105,22 @@
#define CHECK_PTR(_p) do { \ #define CHECK_PTR(_p) do { \
\ \
\ \
\
if (_p) { \ if (_p) { \
\ \
\ \
\
if (ALLOC_C1(_p) ^ ALLOC_MAGIC_C1) {\ if (ALLOC_C1(_p) ^ ALLOC_MAGIC_C1) {\
\ \
\ \
\
if (ALLOC_C1(_p) == ALLOC_MAGIC_F) \ if (ALLOC_C1(_p) == ALLOC_MAGIC_F) \
ABORT("Use after free."); \ ABORT("Use after free."); \
else ABORT("Corrupted head alloc canary."); \ else ABORT("Corrupted head alloc canary."); \
\ \
} \ } \
\ \
\
if (ALLOC_C2(_p) ^ ALLOC_MAGIC_C2) \ if (ALLOC_C2(_p) ^ ALLOC_MAGIC_C2) \
ABORT("Corrupted tail alloc canary."); \ ABORT("Corrupted tail alloc canary."); \
\ \
@ -124,7 +128,9 @@
\ \
\ \
\ \
\
} while (0) } while (0)
*/ */
#define CHECK_PTR_EXPR(_p) \ #define CHECK_PTR_EXPR(_p) \
@ -371,16 +377,16 @@ static inline u8* DFL_ck_memdup_str(u8* mem, u32 size) {
/* In non-debug mode, we just do straightforward aliasing of the above functions /* In non-debug mode, we just do straightforward aliasing of the above functions
to user-visible names such as ck_alloc(). */ to user-visible names such as ck_alloc(). */
# define ck_alloc DFL_ck_alloc #define ck_alloc DFL_ck_alloc
# define ck_alloc_nozero DFL_ck_alloc_nozero #define ck_alloc_nozero DFL_ck_alloc_nozero
# define ck_realloc DFL_ck_realloc #define ck_realloc DFL_ck_realloc
# define ck_realloc_block DFL_ck_realloc_block #define ck_realloc_block DFL_ck_realloc_block
# define ck_strdup DFL_ck_strdup #define ck_strdup DFL_ck_strdup
# define ck_memdup DFL_ck_memdup #define ck_memdup DFL_ck_memdup
# define ck_memdup_str DFL_ck_memdup_str #define ck_memdup_str DFL_ck_memdup_str
# define ck_free DFL_ck_free #define ck_free DFL_ck_free
# define alloc_report() #define alloc_report()
#else #else
@ -389,7 +395,7 @@ static inline u8* DFL_ck_memdup_str(u8* mem, u32 size) {
/* Alloc tracking data structures: */ /* Alloc tracking data structures: */
# define ALLOC_BUCKETS 4096 #define ALLOC_BUCKETS 4096
struct TRK_obj { struct TRK_obj {
@ -399,25 +405,25 @@ struct TRK_obj {
}; };
# ifdef AFL_MAIN #ifdef AFL_MAIN
struct TRK_obj* TRK[ALLOC_BUCKETS]; struct TRK_obj* TRK[ALLOC_BUCKETS];
u32 TRK_cnt[ALLOC_BUCKETS]; u32 TRK_cnt[ALLOC_BUCKETS];
# define alloc_report() TRK_report() #define alloc_report() TRK_report()
# else #else
extern struct TRK_obj* TRK[ALLOC_BUCKETS]; extern struct TRK_obj* TRK[ALLOC_BUCKETS];
extern u32 TRK_cnt[ALLOC_BUCKETS]; extern u32 TRK_cnt[ALLOC_BUCKETS];
# define alloc_report() #define alloc_report()
# endif /* ^AFL_MAIN */ #endif /* ^AFL_MAIN */
/* Bucket-assigning function for a given pointer: */ /* Bucket-assigning function for a given pointer: */
# define TRKH(_ptr) (((((u32)(_ptr)) >> 16) ^ ((u32)(_ptr))) % ALLOC_BUCKETS) #define TRKH(_ptr) (((((u32)(_ptr)) >> 16) ^ ((u32)(_ptr))) % ALLOC_BUCKETS)
/* Add a new entry to the list of allocated objects. */ /* Add a new entry to the list of allocated objects. */
@ -569,25 +575,25 @@ static inline void TRK_ck_free(void* ptr, const char* file, const char* func,
/* Aliasing user-facing names to tracking functions: */ /* Aliasing user-facing names to tracking functions: */
# define ck_alloc(_p1) TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__) #define ck_alloc(_p1) TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
#define ck_alloc_nozero(_p1) TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__) #define ck_alloc_nozero(_p1) TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
# define ck_realloc(_p1, _p2)\ #define ck_realloc(_p1, _p2) \
TRK_ck_realloc(_p1, _p2, __FILE__, __FUNCTION__, __LINE__) TRK_ck_realloc(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
# define ck_realloc_block(_p1, _p2)\ #define ck_realloc_block(_p1, _p2) \
TRK_ck_realloc_block(_p1, _p2, __FILE__, __FUNCTION__, __LINE__) TRK_ck_realloc_block(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
# define ck_strdup(_p1) TRK_ck_strdup(_p1, __FILE__, __FUNCTION__, __LINE__) #define ck_strdup(_p1) TRK_ck_strdup(_p1, __FILE__, __FUNCTION__, __LINE__)
# define ck_memdup(_p1, _p2)\ #define ck_memdup(_p1, _p2) \
TRK_ck_memdup(_p1, _p2, __FILE__, __FUNCTION__, __LINE__) TRK_ck_memdup(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
# define ck_memdup_str(_p1, _p2)\ #define ck_memdup_str(_p1, _p2) \
TRK_ck_memdup_str(_p1, _p2, __FILE__, __FUNCTION__, __LINE__) TRK_ck_memdup_str(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
# define ck_free(_p1) TRK_ck_free(_p1, __FILE__, __FUNCTION__, __LINE__) #define ck_free(_p1) TRK_ck_free(_p1, __FILE__, __FUNCTION__, __LINE__)
#endif /* ^!DEBUG_BUILD */ #endif /* ^!DEBUG_BUILD */

View File

@ -8,10 +8,10 @@
#include <sys/mman.h> #include <sys/mman.h>
#if __ANDROID_API__ >= 26 #if __ANDROID_API__ >= 26
# define shmat bionic_shmat #define shmat bionic_shmat
# define shmctl bionic_shmctl #define shmctl bionic_shmctl
# define shmdt bionic_shmdt #define shmdt bionic_shmdt
# define shmget bionic_shmget #define shmget bionic_shmget
#endif #endif
#include <sys/shm.h> #include <sys/shm.h>
#undef shmat #undef shmat

View File

@ -50,9 +50,9 @@
/* Default memory limit for child process (MB): */ /* Default memory limit for child process (MB): */
#ifndef __x86_64__ #ifndef __x86_64__
# define MEM_LIMIT 25 #define MEM_LIMIT 25
#else #else
# define MEM_LIMIT 50 #define MEM_LIMIT 50
#endif /* ^!__x86_64__ */ #endif /* ^!__x86_64__ */
/* Default memory limit when running in QEMU mode (MB): */ /* Default memory limit when running in QEMU mode (MB): */

View File

@ -28,77 +28,77 @@
#ifdef USE_COLOR #ifdef USE_COLOR
# define cBLK "\x1b[0;30m" #define cBLK "\x1b[0;30m"
# define cRED "\x1b[0;31m" #define cRED "\x1b[0;31m"
# define cGRN "\x1b[0;32m" #define cGRN "\x1b[0;32m"
# define cBRN "\x1b[0;33m" #define cBRN "\x1b[0;33m"
# define cBLU "\x1b[0;34m" #define cBLU "\x1b[0;34m"
# define cMGN "\x1b[0;35m" #define cMGN "\x1b[0;35m"
# define cCYA "\x1b[0;36m" #define cCYA "\x1b[0;36m"
# define cLGR "\x1b[0;37m" #define cLGR "\x1b[0;37m"
# define cGRA "\x1b[1;90m" #define cGRA "\x1b[1;90m"
# define cLRD "\x1b[1;91m" #define cLRD "\x1b[1;91m"
# define cLGN "\x1b[1;92m" #define cLGN "\x1b[1;92m"
# define cYEL "\x1b[1;93m" #define cYEL "\x1b[1;93m"
# define cLBL "\x1b[1;94m" #define cLBL "\x1b[1;94m"
# define cPIN "\x1b[1;95m" #define cPIN "\x1b[1;95m"
# define cLCY "\x1b[1;96m" #define cLCY "\x1b[1;96m"
# define cBRI "\x1b[1;97m" #define cBRI "\x1b[1;97m"
# define cRST "\x1b[0m" #define cRST "\x1b[0m"
# define bgBLK "\x1b[40m" #define bgBLK "\x1b[40m"
# define bgRED "\x1b[41m" #define bgRED "\x1b[41m"
# define bgGRN "\x1b[42m" #define bgGRN "\x1b[42m"
# define bgBRN "\x1b[43m" #define bgBRN "\x1b[43m"
# define bgBLU "\x1b[44m" #define bgBLU "\x1b[44m"
# define bgMGN "\x1b[45m" #define bgMGN "\x1b[45m"
# define bgCYA "\x1b[46m" #define bgCYA "\x1b[46m"
# define bgLGR "\x1b[47m" #define bgLGR "\x1b[47m"
# define bgGRA "\x1b[100m" #define bgGRA "\x1b[100m"
# define bgLRD "\x1b[101m" #define bgLRD "\x1b[101m"
# define bgLGN "\x1b[102m" #define bgLGN "\x1b[102m"
# define bgYEL "\x1b[103m" #define bgYEL "\x1b[103m"
# define bgLBL "\x1b[104m" #define bgLBL "\x1b[104m"
# define bgPIN "\x1b[105m" #define bgPIN "\x1b[105m"
# define bgLCY "\x1b[106m" #define bgLCY "\x1b[106m"
# define bgBRI "\x1b[107m" #define bgBRI "\x1b[107m"
#else #else
# define cBLK "" #define cBLK ""
# define cRED "" #define cRED ""
# define cGRN "" #define cGRN ""
# define cBRN "" #define cBRN ""
# define cBLU "" #define cBLU ""
# define cMGN "" #define cMGN ""
# define cCYA "" #define cCYA ""
# define cLGR "" #define cLGR ""
# define cGRA "" #define cGRA ""
# define cLRD "" #define cLRD ""
# define cLGN "" #define cLGN ""
# define cYEL "" #define cYEL ""
# define cLBL "" #define cLBL ""
# define cPIN "" #define cPIN ""
# define cLCY "" #define cLCY ""
# define cBRI "" #define cBRI ""
# define cRST "" #define cRST ""
# define bgBLK "" #define bgBLK ""
# define bgRED "" #define bgRED ""
# define bgGRN "" #define bgGRN ""
# define bgBRN "" #define bgBRN ""
# define bgBLU "" #define bgBLU ""
# define bgMGN "" #define bgMGN ""
# define bgCYA "" #define bgCYA ""
# define bgLGR "" #define bgLGR ""
# define bgGRA "" #define bgGRA ""
# define bgLRD "" #define bgLRD ""
# define bgLGN "" #define bgLGN ""
# define bgYEL "" #define bgYEL ""
# define bgLBL "" #define bgLBL ""
# define bgPIN "" #define bgPIN ""
# define bgLCY "" #define bgLCY ""
# define bgBRI "" #define bgBRI ""
#endif /* ^USE_COLOR */ #endif /* ^USE_COLOR */
@ -108,39 +108,39 @@
#ifdef FANCY_BOXES #ifdef FANCY_BOXES
# define SET_G1 "\x1b)0" /* Set G1 for box drawing */ #define SET_G1 "\x1b)0" /* Set G1 for box drawing */
# define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */ #define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */
# define bSTART "\x0e" /* Enter G1 drawing mode */ #define bSTART "\x0e" /* Enter G1 drawing mode */
# define bSTOP "\x0f" /* Leave G1 drawing mode */ #define bSTOP "\x0f" /* Leave G1 drawing mode */
# define bH "q" /* Horizontal line */ #define bH "q" /* Horizontal line */
# define bV "x" /* Vertical line */ #define bV "x" /* Vertical line */
# define bLT "l" /* Left top corner */ #define bLT "l" /* Left top corner */
# define bRT "k" /* Right top corner */ #define bRT "k" /* Right top corner */
# define bLB "m" /* Left bottom corner */ #define bLB "m" /* Left bottom corner */
# define bRB "j" /* Right bottom corner */ #define bRB "j" /* Right bottom corner */
# define bX "n" /* Cross */ #define bX "n" /* Cross */
# define bVR "t" /* Vertical, branch right */ #define bVR "t" /* Vertical, branch right */
# define bVL "u" /* Vertical, branch left */ #define bVL "u" /* Vertical, branch left */
# define bHT "v" /* Horizontal, branch top */ #define bHT "v" /* Horizontal, branch top */
# define bHB "w" /* Horizontal, branch bottom */ #define bHB "w" /* Horizontal, branch bottom */
#else #else
# define SET_G1 "" #define SET_G1 ""
# define RESET_G1 "" #define RESET_G1 ""
# define bSTART "" #define bSTART ""
# define bSTOP "" #define bSTOP ""
# define bH "-" #define bH "-"
# define bV "|" #define bV "|"
# define bLT "+" #define bLT "+"
# define bRT "+" #define bRT "+"
# define bLB "+" #define bLB "+"
# define bRB "+" #define bRB "+"
# define bX "+" #define bX "+"
# define bVR "+" #define bVR "+"
# define bVL "+" #define bVL "+"
# define bHT "+" #define bHT "+"
# define bHB "+" #define bHB "+"
#endif /* ^FANCY_BOXES */ #endif /* ^FANCY_BOXES */
@ -161,9 +161,9 @@
/* Just print stuff to the appropriate stream. */ /* Just print stuff to the appropriate stream. */
#ifdef MESSAGES_TO_STDOUT #ifdef MESSAGES_TO_STDOUT
# define SAYF(x...) printf(x) #define SAYF(x...) printf(x)
#else #else
# define SAYF(x...) fprintf(stderr, x) #define SAYF(x...) fprintf(stderr, x)
#endif /* ^MESSAGES_TO_STDOUT */ #endif /* ^MESSAGES_TO_STDOUT */
/* Show a prefixed warning. */ /* Show a prefixed warning. */

View File

@ -5,20 +5,20 @@ void handle_timeout(int sig);
void init_forkserver(char **argv); void init_forkserver(char **argv);
#ifdef __APPLE__ #ifdef __APPLE__
# define MSG_FORK_ON_APPLE \ #define MSG_FORK_ON_APPLE \
" - On MacOS X, the semantics of fork() syscalls are non-standard and " \ " - On MacOS X, the semantics of fork() syscalls are non-standard and " \
"may\n" \ "may\n" \
" break afl-fuzz performance optimizations when running " \ " break afl-fuzz performance optimizations when running " \
"platform-specific\n" \ "platform-specific\n" \
" targets. To fix this, set AFL_NO_FORKSRV=1 in the environment.\n\n" " targets. To fix this, set AFL_NO_FORKSRV=1 in the environment.\n\n"
#else #else
# define MSG_FORK_ON_APPLE "" #define MSG_FORK_ON_APPLE ""
#endif #endif
#ifdef RLIMIT_AS #ifdef RLIMIT_AS
# define MSG_ULIMIT_USAGE " ( ulimit -Sv $[%llu << 10];" #define MSG_ULIMIT_USAGE " ( ulimit -Sv $[%llu << 10];"
#else #else
# define MSG_ULIMIT_USAGE " ( ulimit -Sd $[%llu << 10];" #define MSG_ULIMIT_USAGE " ( ulimit -Sd $[%llu << 10];"
#endif /* ^RLIMIT_AS */ #endif /* ^RLIMIT_AS */
#endif #endif

View File

@ -31,7 +31,7 @@
#ifdef __x86_64__ #ifdef __x86_64__
# define ROL64(_x, _r) ((((u64)(_x)) << (_r)) | (((u64)(_x)) >> (64 - (_r)))) #define ROL64(_x, _r) ((((u64)(_x)) << (_r)) | (((u64)(_x)) >> (64 - (_r))))
static inline u32 hash32(const void* key, u32 len, u32 seed) { static inline u32 hash32(const void* key, u32 len, u32 seed) {
@ -66,7 +66,7 @@ static inline u32 hash32(const void* key, u32 len, u32 seed) {
#else #else
# define ROL32(_x, _r) ((((u32)(_x)) << (_r)) | (((u32)(_x)) >> (32 - (_r)))) #define ROL32(_x, _r) ((((u32)(_x)) << (_r)) | (((u32)(_x)) >> (32 - (_r))))
static inline u32 hash32(const void* key, u32 len, u32 seed) { static inline u32 hash32(const void* key, u32 len, u32 seed) {

View File

@ -52,8 +52,8 @@ typedef int32_t s32;
typedef int64_t s64; typedef int64_t s64;
#ifndef MIN #ifndef MIN
# define MIN(_a, _b) ((_a) > (_b) ? (_b) : (_a)) #define MIN(_a, _b) ((_a) > (_b) ? (_b) : (_a))
# define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b)) #define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#endif /* !MIN */ #endif /* !MIN */
#define SWAP16(_x) \ #define SWAP16(_x) \
@ -74,9 +74,9 @@ typedef int64_t s64;
}) })
#ifdef AFL_LLVM_PASS #ifdef AFL_LLVM_PASS
# define AFL_R(x) (random() % (x)) #define AFL_R(x) (random() % (x))
#else #else
# define R(x) (random() % (x)) #define R(x) (random() % (x))
#endif /* ^AFL_LLVM_PASS */ #endif /* ^AFL_LLVM_PASS */
#define STRINGIFY_INTERNAL(x) #x #define STRINGIFY_INTERNAL(x) #x
@ -85,11 +85,11 @@ typedef int64_t s64;
#define MEM_BARRIER() __asm__ volatile("" ::: "memory") #define MEM_BARRIER() __asm__ volatile("" ::: "memory")
#if __GNUC__ < 6 #if __GNUC__ < 6
# define likely(_x) (_x) #define likely(_x) (_x)
# define unlikely(_x) (_x) #define unlikely(_x) (_x)
#else #else
# define likely(_x) __builtin_expect(!!(_x), 1) #define likely(_x) __builtin_expect(!!(_x), 1)
# define unlikely(_x) __builtin_expect(!!(_x), 0) #define unlikely(_x) __builtin_expect(!!(_x), 0)
#endif #endif
#endif /* ! _HAVE_TYPES_H */ #endif /* ! _HAVE_TYPES_H */

View File

@ -29,11 +29,11 @@
#include "types.h" #include "types.h"
#ifndef PAGE_SIZE #ifndef PAGE_SIZE
# define PAGE_SIZE 4096 #define PAGE_SIZE 4096
#endif /* !PAGE_SIZE */ #endif /* !PAGE_SIZE */
#ifndef MAP_ANONYMOUS #ifndef MAP_ANONYMOUS
# define MAP_ANONYMOUS MAP_ANON #define MAP_ANONYMOUS MAP_ANON
#endif /* !MAP_ANONYMOUS */ #endif /* !MAP_ANONYMOUS */
/* Error / message handling: */ /* Error / message handling: */

View File

@ -27,7 +27,7 @@
#include "../config.h" #include "../config.h"
#ifndef __linux__ #ifndef __linux__
# error "Sorry, this library is Linux-specific for now!" #error "Sorry, this library is Linux-specific for now!"
#endif /* !__linux__ */ #endif /* !__linux__ */
/* Mapping data and such */ /* Mapping data and such */

View File

@ -1,9 +1,9 @@
#ifndef __MARK_NODES__ #ifndef __MARK_NODES__
# define __MARK_NODES__ #define __MARK_NODES__
# include "llvm/IR/BasicBlock.h" #include "llvm/IR/BasicBlock.h"
# include "llvm/IR/Function.h" #include "llvm/IR/Function.h"
# include <vector> #include <vector>
std::pair<std::vector<llvm::BasicBlock *>, std::vector<llvm::BasicBlock *>> std::pair<std::vector<llvm::BasicBlock *>, std::vector<llvm::BasicBlock *>>
markNodes(llvm::Function *F); markNodes(llvm::Function *F);

View File

@ -20,7 +20,7 @@
*/ */
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "android-ashmem.h" #include "android-ashmem.h"
#endif #endif
#include "config.h" #include "config.h"
#include "types.h" #include "types.h"
@ -42,9 +42,9 @@
the LLVM-generated runtime initialization pass, not before. */ the LLVM-generated runtime initialization pass, not before. */
#ifdef USE_TRACE_PC #ifdef USE_TRACE_PC
# define CONST_PRIO 5 #define CONST_PRIO 5
#else #else
# define CONST_PRIO 0 #define CONST_PRIO 0
#endif /* ^USE_TRACE_PC */ #endif /* ^USE_TRACE_PC */
#include <sys/mman.h> #include <sys/mman.h>

View File

@ -33,7 +33,7 @@
#include "pmparser.h" #include "pmparser.h"
#ifndef __linux__ #ifndef __linux__
# error "Sorry, this library is Linux-specific for now!" #error "Sorry, this library is Linux-specific for now!"
#endif /* !__linux__ */ #endif /* !__linux__ */
/* Change this value to tune the compare coverage */ /* Change this value to tune the compare coverage */

View File

@ -13,19 +13,19 @@ implied warranty.
*/ */
#ifndef H_PMPARSER #ifndef H_PMPARSER
# define H_PMPARSER #define H_PMPARSER
# include <stdio.h> #include <stdio.h>
# include <stdlib.h> #include <stdlib.h>
# include <unistd.h> #include <unistd.h>
# include <string.h> #include <string.h>
# include <sys/types.h> #include <sys/types.h>
# include <sys/stat.h> #include <sys/stat.h>
# include <fcntl.h> #include <fcntl.h>
# include <errno.h> #include <errno.h>
# include <linux/limits.h> #include <linux/limits.h>
// maximum line length in a procmaps file // maximum line length in a procmaps file
# define PROCMAPS_LINE_MAX_LENGTH (PATH_MAX + 100) #define PROCMAPS_LINE_MAX_LENGTH (PATH_MAX + 100)
/** /**
* procmaps_struct * procmaps_struct
* @desc hold all the information about an area in the process's VM * @desc hold all the information about an area in the process's VM

View File

@ -36,7 +36,7 @@
/* NeverZero */ /* NeverZero */
#if (defined(__x86_64__) || defined(__i386__)) && defined(AFL_QEMU_NOT_ZERO) #if (defined(__x86_64__) || defined(__i386__)) && defined(AFL_QEMU_NOT_ZERO)
# define INC_AFL_AREA(loc) \ #define INC_AFL_AREA(loc) \
asm volatile( \ asm volatile( \
"incb (%0, %1, 1)\n" \ "incb (%0, %1, 1)\n" \
"adcb $0, (%0, %1, 1)\n" \ "adcb $0, (%0, %1, 1)\n" \
@ -44,6 +44,6 @@
: "r"(afl_area_ptr), "r"(loc) \ : "r"(afl_area_ptr), "r"(loc) \
: "memory", "eax") : "memory", "eax")
#else #else
# define INC_AFL_AREA(loc) afl_area_ptr[loc]++ #define INC_AFL_AREA(loc) afl_area_ptr[loc]++
#endif #endif

View File

@ -22,7 +22,7 @@
#define AFL_MAIN #define AFL_MAIN
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "android-ashmem.h" #include "android-ashmem.h"
#endif #endif
#include "config.h" #include "config.h"
#include "types.h" #include "types.h"

View File

@ -74,9 +74,9 @@ static u8 use_64bit = 1;
static u8 use_64bit = 0; static u8 use_64bit = 0;
# ifdef __APPLE__ #ifdef __APPLE__
# error "Sorry, 32-bit Apple platforms are not supported." #error "Sorry, 32-bit Apple platforms are not supported."
# endif /* __APPLE__ */ #endif /* __APPLE__ */
#endif /* ^__x86_64__ */ #endif /* ^__x86_64__ */

View File

@ -13,7 +13,7 @@
/* Detect @@ in args. */ /* Detect @@ in args. */
#ifndef __glibc__ #ifndef __glibc__
# include <unistd.h> #include <unistd.h>
#endif #endif
void detect_file_args(char** argv, u8* prog_in) { void detect_file_args(char** argv, u8* prog_in) {

View File

@ -1491,25 +1491,25 @@ void get_core_count(void) {
/* On *BSD systems, we can just use a sysctl to get the number of CPUs. */ /* On *BSD systems, we can just use a sysctl to get the number of CPUs. */
# ifdef __APPLE__ #ifdef __APPLE__
if (sysctlbyname("hw.logicalcpu", &cpu_core_count, &s, NULL, 0) < 0) return; if (sysctlbyname("hw.logicalcpu", &cpu_core_count, &s, NULL, 0) < 0) return;
# else #else
int s_name[2] = {CTL_HW, HW_NCPU}; int s_name[2] = {CTL_HW, HW_NCPU};
if (sysctl(s_name, 2, &cpu_core_count, &s, NULL, 0) < 0) return; if (sysctl(s_name, 2, &cpu_core_count, &s, NULL, 0) < 0) return;
# endif /* ^__APPLE__ */ #endif /* ^__APPLE__ */
#else #else
# ifdef HAVE_AFFINITY #ifdef HAVE_AFFINITY
cpu_core_count = sysconf(_SC_NPROCESSORS_ONLN); cpu_core_count = sysconf(_SC_NPROCESSORS_ONLN);
# else #else
FILE* f = fopen("/proc/stat", "r"); FILE* f = fopen("/proc/stat", "r");
u8 tmp[1024]; u8 tmp[1024];
@ -1521,7 +1521,7 @@ void get_core_count(void) {
fclose(f); fclose(f);
# endif /* ^HAVE_AFFINITY */ #endif /* ^HAVE_AFFINITY */
#endif /* ^(__APPLE__ || __FreeBSD__ || __OpenBSD__) */ #endif /* ^(__APPLE__ || __FreeBSD__ || __OpenBSD__) */
@ -1772,10 +1772,10 @@ void check_binary(u8* fname) {
#else #else
# if !defined(__arm__) && !defined(__arm64__) #if !defined(__arm__) && !defined(__arm64__)
if (f_data[0] != 0xCF || f_data[1] != 0xFA || f_data[2] != 0xED) if (f_data[0] != 0xCF || f_data[1] != 0xFA || f_data[2] != 0xED)
FATAL("Program '%s' is not a 64-bit Mach-O binary", target_path); FATAL("Program '%s' is not a 64-bit Mach-O binary", target_path);
# endif #endif
#endif /* ^!__APPLE__ */ #endif /* ^!__APPLE__ */

View File

@ -2242,11 +2242,11 @@ retry_splicing:
out_buf = ck_alloc_nozero(len); out_buf = ck_alloc_nozero(len);
memcpy(out_buf, in_buf, len); memcpy(out_buf, in_buf, len);
# ifdef USE_PYTHON #ifdef USE_PYTHON
goto python_stage; goto python_stage;
# else #else
goto havoc_stage; goto havoc_stage;
# endif #endif
} }

View File

@ -27,10 +27,10 @@
static void usage(u8* argv0) { static void usage(u8* argv0) {
#ifdef USE_PYTHON #ifdef USE_PYTHON
# define PHYTON_SUPPORT\ #define PHYTON_SUPPORT \
"Compiled with Python 2.7 module support, see docs/python_mutators.txt\n" "Compiled with Python 2.7 module support, see docs/python_mutators.txt\n"
#else #else
# define PHYTON_SUPPORT "" #define PHYTON_SUPPORT ""
#endif #endif
SAYF( SAYF(
@ -616,9 +616,9 @@ int main(int argc, char** argv) {
get_core_count(); get_core_count();
# ifdef HAVE_AFFINITY #ifdef HAVE_AFFINITY
bind_to_free_cpu(); bind_to_free_cpu();
# endif /* HAVE_AFFINITY */ #endif /* HAVE_AFFINITY */
check_crash_handling(); check_crash_handling();
check_cpu_governor(); check_cpu_governor();
@ -635,12 +635,12 @@ int main(int argc, char** argv) {
setup_dirs_fds(); setup_dirs_fds();
# ifdef USE_PYTHON #ifdef USE_PYTHON
if (init_py()) FATAL("Failed to initialize Python module"); if (init_py()) FATAL("Failed to initialize Python module");
# else #else
if (getenv("AFL_PYTHON_MODULE")) if (getenv("AFL_PYTHON_MODULE"))
FATAL("Your AFL binary was built without Python support"); FATAL("Your AFL binary was built without Python support");
# endif #endif
setup_cmdline_file(argv + optind); setup_cmdline_file(argv + optind);
@ -867,9 +867,9 @@ stop_fuzzing:
alloc_report(); alloc_report();
# ifdef USE_PYTHON #ifdef USE_PYTHON
finalize_py(); finalize_py();
# endif #endif
OKF("We're done here. Have a nice day!\n"); OKF("We're done here. Have a nice day!\n");

View File

@ -27,11 +27,11 @@
#define AFL_MAIN #define AFL_MAIN
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
# define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "android-ashmem.h" #include "android-ashmem.h"
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -48,7 +48,7 @@
#include "debug.h" #include "debug.h"
#ifdef __linux__ #ifdef __linux__
# define HAVE_AFFINITY 1 #define HAVE_AFFINITY 1
#endif /* __linux__ */ #endif /* __linux__ */
/* Get unix time in microseconds. */ /* Get unix time in microseconds. */

View File

@ -5,7 +5,7 @@
#define AFL_MAIN #define AFL_MAIN
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "android-ashmem.h" #include "android-ashmem.h"
#endif #endif
#include "config.h" #include "config.h"
#include "types.h" #include "types.h"
@ -32,8 +32,8 @@
#include <sys/mman.h> #include <sys/mman.h>
#ifndef USEMMAP #ifndef USEMMAP
# include <sys/ipc.h> #include <sys/ipc.h>
# include <sys/shm.h> #include <sys/shm.h>
#endif #endif
extern unsigned char *trace_bits; extern unsigned char *trace_bits;

View File

@ -24,7 +24,7 @@
#define AFL_MAIN #define AFL_MAIN
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "android-ashmem.h" #include "android-ashmem.h"
#endif #endif
#include "config.h" #include "config.h"
#include "types.h" #include "types.h"

View File

@ -22,7 +22,7 @@
#define AFL_MAIN #define AFL_MAIN
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "android-ashmem.h" #include "android-ashmem.h"
#endif #endif
#include "config.h" #include "config.h"

View File

@ -35,7 +35,7 @@
/* NeverZero */ /* NeverZero */
#if (defined(__x86_64__) || defined(__i386__)) && defined(AFL_QEMU_NOT_ZERO) #if (defined(__x86_64__) || defined(__i386__)) && defined(AFL_QEMU_NOT_ZERO)
# define INC_AFL_AREA(loc) \ #define INC_AFL_AREA(loc) \
asm volatile( \ asm volatile( \
"incb (%0, %1, 1)\n" \ "incb (%0, %1, 1)\n" \
"adcb $0, (%0, %1, 1)\n" \ "adcb $0, (%0, %1, 1)\n" \
@ -43,6 +43,6 @@
: "r"(afl_area_ptr), "r"(loc) \ : "r"(afl_area_ptr), "r"(loc) \
: "memory", "eax") : "memory", "eax")
#else #else
# define INC_AFL_AREA(loc) afl_area_ptr[loc]++ #define INC_AFL_AREA(loc) afl_area_ptr[loc]++
#endif #endif