From b511696c555a03b6fc61e47d212e02d1d6554287 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 7 Feb 2022 11:54:57 +0100 Subject: [PATCH] clean up includes and remove non-portable includes This marginally increases the portability of hardened_malloc, eg. on OSX. --- h_malloc.c | 4 +--- memory.c | 3 +++ test/impossibly_large_malloc.c | 3 +-- test/invalid_malloc_object_size_small.c | 2 +- test/invalid_malloc_object_size_small_quarantine.c | 2 +- test/mallinfo.c | 3 +++ test/mallinfo2.c | 3 +++ test/malloc_info.c | 2 ++ test/malloc_object_size.c | 2 +- test/malloc_object_size_offset.c | 2 +- test/write_after_free_large.c | 1 - test/write_after_free_small.c | 1 - test/write_after_free_small_reuse.c | 1 - test/write_zero_size.c | 1 - 14 files changed, 17 insertions(+), 13 deletions(-) diff --git a/h_malloc.c b/h_malloc.c index b4b19e0..39ba84d 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -6,9 +6,7 @@ #include #include #include -#include -#include #include #include @@ -62,7 +60,7 @@ static_assert(N_ARENA <= 256, "maximum number of arenas is currently 256"); #if N_ARENA > 1 __attribute__((tls_model("initial-exec"))) -static thread_local unsigned thread_arena = N_ARENA; +static _Thread_local unsigned thread_arena = N_ARENA; static atomic_uint thread_arena_counter = 0; #else static const unsigned thread_arena = 0; diff --git a/memory.c b/memory.c index 2d995ef..04afc23 100644 --- a/memory.c +++ b/memory.c @@ -1,7 +1,10 @@ #include #include + +#ifdef LABEL_MEMORY #include +#endif #ifndef PR_SET_VMA #define PR_SET_VMA 0x53564d41 diff --git a/test/impossibly_large_malloc.c b/test/impossibly_large_malloc.c index 42b35df..63cdc0c 100644 --- a/test/impossibly_large_malloc.c +++ b/test/impossibly_large_malloc.c @@ -1,5 +1,4 @@ -#include -#include +#include #include "test_util.h" diff --git a/test/invalid_malloc_object_size_small.c b/test/invalid_malloc_object_size_small.c index 9adac5f..33cc78f 100644 --- a/test/invalid_malloc_object_size_small.c +++ b/test/invalid_malloc_object_size_small.c @@ -1,4 +1,4 @@ -#include +#include #include "test_util.h" diff --git a/test/invalid_malloc_object_size_small_quarantine.c b/test/invalid_malloc_object_size_small_quarantine.c index 9a365ae..1a26bc0 100644 --- a/test/invalid_malloc_object_size_small_quarantine.c +++ b/test/invalid_malloc_object_size_small_quarantine.c @@ -1,4 +1,4 @@ -#include +#include #include "test_util.h" diff --git a/test/mallinfo.c b/test/mallinfo.c index d38f92f..6008040 100644 --- a/test/mallinfo.c +++ b/test/mallinfo.c @@ -1,6 +1,9 @@ +#include #include +#if defined(__GLIBC__) || defined(__ANDROID__) #include +#endif #include "test_util.h" diff --git a/test/mallinfo2.c b/test/mallinfo2.c index 66c3445..ccabf48 100644 --- a/test/mallinfo2.c +++ b/test/mallinfo2.c @@ -1,6 +1,9 @@ #include +#include +#if defined(__GLIBC__) #include +#endif #include "test_util.h" diff --git a/test/malloc_info.c b/test/malloc_info.c index 3eda5e3..50b256f 100644 --- a/test/malloc_info.c +++ b/test/malloc_info.c @@ -1,7 +1,9 @@ #include #include +#if defined(__GLIBC__) || defined(__ANDROID__) #include +#endif #include "test_util.h" #include "../util.h" diff --git a/test/malloc_object_size.c b/test/malloc_object_size.c index 0710557..5ab9280 100644 --- a/test/malloc_object_size.c +++ b/test/malloc_object_size.c @@ -1,5 +1,5 @@ #include -#include +#include #include "test_util.h" diff --git a/test/malloc_object_size_offset.c b/test/malloc_object_size_offset.c index 3e30be9..d605906 100644 --- a/test/malloc_object_size_offset.c +++ b/test/malloc_object_size_offset.c @@ -1,5 +1,5 @@ #include -#include +#include #include "test_util.h" diff --git a/test/write_after_free_large.c b/test/write_after_free_large.c index e431916..9561b9f 100644 --- a/test/write_after_free_large.c +++ b/test/write_after_free_large.c @@ -1,5 +1,4 @@ #include -#include #include "test_util.h" diff --git a/test/write_after_free_small.c b/test/write_after_free_small.c index 0334ae9..7850cd6 100644 --- a/test/write_after_free_small.c +++ b/test/write_after_free_small.c @@ -1,5 +1,4 @@ #include -#include #include "test_util.h" diff --git a/test/write_after_free_small_reuse.c b/test/write_after_free_small_reuse.c index fb8071a..3318a91 100644 --- a/test/write_after_free_small_reuse.c +++ b/test/write_after_free_small_reuse.c @@ -1,5 +1,4 @@ #include -#include #include "test_util.h" #include "../util.h" diff --git a/test/write_zero_size.c b/test/write_zero_size.c index 1b54216..49d26ea 100644 --- a/test/write_zero_size.c +++ b/test/write_zero_size.c @@ -1,5 +1,4 @@ #include -#include #include "test_util.h"