diff options
author | van Hauser <vh@thc.org> | 2020-05-10 11:35:31 +0200 |
---|---|---|
committer | van Hauser <vh@thc.org> | 2020-05-10 11:35:31 +0200 |
commit | 26f8708fede1b15e6a93709d0baa2e5f481e082d (patch) | |
tree | d7884710e287db77b2067a489a374a7bfdb8b724 /libdislocator/libdislocator.so.c | |
parent | 3beec8d4fa037a8814b697d238727b729214e805 (diff) | |
download | afl++-26f8708fede1b15e6a93709d0baa2e5f481e082d.tar.gz |
fix warning, code format
Diffstat (limited to 'libdislocator/libdislocator.so.c')
-rw-r--r-- | libdislocator/libdislocator.so.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/libdislocator/libdislocator.so.c b/libdislocator/libdislocator.so.c index 73ddc292..496cf0f0 100644 --- a/libdislocator/libdislocator.so.c +++ b/libdislocator/libdislocator.so.c @@ -30,39 +30,39 @@ #include <sys/mman.h> #ifdef __APPLE__ -#include <mach/vm_statistics.h> +# include <mach/vm_statistics.h> #endif #ifdef __FreeBSD__ -#include <sys/param.h> +# include <sys/param.h> #endif #if defined(__linux__) && !defined(__ANDROID__) -#include <unistd.h> -#include <sys/syscall.h> -#ifdef __NR_getrandom -#define arc4random_buf(p, l) \ - do { \ - \ - ssize_t rd = syscall(__NR_getrandom, p, l, 0); \ - if (rd != l) DEBUGF("getrandom failed"); \ - \ - } while (0) - -#else -#include <time.h> -#define arc4random_buf(p, l) \ - do { \ - \ - srand(time(NULL)); \ - u32 i; \ - u8 *ptr = (u8 *)p; \ - for (i = 0; i < l; i++) \ - ptr[i] = rand() % INT_MAX; \ - \ - } while (0) - -#endif +# include <unistd.h> +# include <sys/syscall.h> +# ifdef __NR_getrandom +# define arc4random_buf(p, l) \ + do { \ + ssize_t rd = syscall(__NR_getrandom, p, l, 0); \ + if (rd != l) DEBUGF("getrandom failed"); \ + \ + + } while (0) + +# else +# include <time.h> +# define arc4random_buf(p, l) \ + do { \ + srand(time(NULL)); \ + u32 i; \ + u8 *ptr = (u8 *)p; \ + for (i = 0; i < l; i++) \ + ptr[i] = rand() % INT_MAX; \ + \ + + } while (0) + +# endif #endif #include "config.h" @@ -83,11 +83,11 @@ typedef struct { #define ALLOC_ALIGN_SIZE (_Alignof(max_align_t)) #ifndef PAGE_SIZE -#define PAGE_SIZE 4096 +# define PAGE_SIZE 4096 #endif /* !PAGE_SIZE */ #ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON +# define MAP_ANONYMOUS MAP_ANON #endif /* !MAP_ANONYMOUS */ #define SUPER_PAGE_SIZE 1 << 21 @@ -148,8 +148,8 @@ static u8 alloc_verbose, /* Additional debug messages */ align_allocations; /* Force alignment to sizeof(void*) */ #if defined __OpenBSD__ || defined __APPLE__ -#define __thread -#warning no thread support available +# define __thread +# warning no thread support available #endif static __thread size_t total_mem; /* Currently allocated mem */ @@ -192,13 +192,13 @@ static void *__dislocator_alloc(size_t len) { #if defined(USEHUGEPAGE) sp = (rlen >= SUPER_PAGE_SIZE && !(rlen % SUPER_PAGE_SIZE)); -#if defined(__APPLE__) +# if defined(__APPLE__) if (sp) fd = VM_FLAGS_SUPERPAGE_SIZE_2MB; -#elif defined(__linux__) +# elif defined(__linux__) if (sp) flags |= MAP_HUGETLB; -#elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) if (sp) flags |= MAP_ALIGNED_SUPER; -#endif +# endif #else (void)sp; #endif @@ -208,13 +208,13 @@ static void *__dislocator_alloc(size_t len) { /* We try one more time with regular call */ if (ret == MAP_FAILED) { -#if defined(__APPLE__) +# if defined(__APPLE__) fd = -1; -#elif defined(__linux__) +# elif defined(__linux__) flags &= -MAP_HUGETLB; -#elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) flags &= -MAP_ALIGNED_SUPER; -#endif +# endif ret = (u8 *)mmap(NULL, tlen, PROT_READ | PROT_WRITE, flags, fd, 0); } |