aboutsummaryrefslogtreecommitdiff
path: root/libdislocator
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-12 11:12:25 +0200
committervan Hauser <vh@thc.org>2020-05-12 11:12:25 +0200
commit7b40d7b9420b2e3adb7d9afa88610199718dedba (patch)
treec420c91a6dcfde9a2bcffcdde22bb279cf72c243 /libdislocator
parenta578d719e1f556db07ca3c7e2fe38b7668c204d8 (diff)
downloadafl++-7b40d7b9420b2e3adb7d9afa88610199718dedba.tar.gz
new code formatting + applied
Diffstat (limited to 'libdislocator')
-rw-r--r--libdislocator/libdislocator.so.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/libdislocator/libdislocator.so.c b/libdislocator/libdislocator.so.c
index 73ddc292..1c22897c 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);
}