fn() is not a valid C prototype

This commit is contained in:
Frank Denis 2019-06-25 12:16:36 +02:00
parent c6c1d5fffd
commit 236cd2e65c
7 changed files with 40 additions and 40 deletions

View File

@ -39,7 +39,7 @@ static inline bool mi_atomic_compare_exchange(volatile uintptr_t* p, uintptr_t e
// Atomically exchange a value.
static inline uintptr_t mi_atomic_exchange(volatile uintptr_t* p, uintptr_t exchange);
static inline void mi_atomic_yield();
static inline void mi_atomic_yield(void);
// Atomically compare and exchange a pointer; returns `true` if successful.
static inline bool mi_atomic_compare_exchange_ptr(volatile void** p, void* newp, void* compare) {
@ -85,7 +85,7 @@ static inline bool mi_atomic_compare_exchange(volatile uintptr_t* p, uintptr_t e
static inline uintptr_t mi_atomic_exchange(volatile uintptr_t* p, uintptr_t exchange) {
return (uintptr_t)RC64(_InterlockedExchange)((volatile intptr_t*)p, (intptr_t)exchange);
}
static inline void mi_atomic_yield() {
static inline void mi_atomic_yield(void) {
YieldProcessor();
}
static inline int64_t mi_atomic_add(volatile int64_t* p, int64_t add) {
@ -150,23 +150,23 @@ static inline uintptr_t mi_atomic_exchange(volatile uintptr_t* p, uintptr_t exch
#if defined(__cplusplus)
#include <thread>
static inline void mi_atomic_yield() {
static inline void mi_atomic_yield(void) {
std::this_thread::yield();
}
#elif (defined(__GNUC__) || defined(__clang__)) && \
(defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__))
#if defined(__x86_64__) || defined(__i386__)
static inline void mi_atomic_yield() {
static inline void mi_atomic_yield(void) {
asm volatile ("pause" ::: "memory");
}
#elif defined(__arm__) || defined(__aarch64__)
static inline void mi_atomic_yield() {
static inline void mi_atomic_yield(void) {
asm volatile("yield");
}
#endif
#else
#include <unistd.h>
static inline void mi_atomic_yield() {
static inline void mi_atomic_yield(void) {
sleep(0);
}
#endif

View File

@ -24,7 +24,7 @@ void _mi_verbose_message(const char* fmt, ...);
// "init.c"
extern mi_stats_t _mi_stats_main;
extern const mi_page_t _mi_page_empty;
bool _mi_is_main_thread();
bool _mi_is_main_thread(void);
uintptr_t _mi_ptr_cookie(const void* p);
uintptr_t _mi_random_shuffle(uintptr_t x);
uintptr_t _mi_random_init(uintptr_t seed /* can be zero */);
@ -38,7 +38,7 @@ bool _mi_os_protect(void* addr, size_t size);
bool _mi_os_unprotect(void* addr, size_t size);
void* _mi_os_alloc_aligned(size_t size, size_t alignment, mi_os_tld_t* tld);
size_t _mi_os_page_size();
size_t _mi_os_page_size(void);
uintptr_t _mi_align_up(uintptr_t sz, size_t alignment);
// "segment.c"
@ -145,7 +145,7 @@ extern bool _mi_process_is_initialized;
extern mi_decl_thread mi_heap_t* _mi_heap_default; // default heap to allocate from
static inline mi_heap_t* mi_get_default_heap() {
static inline mi_heap_t* mi_get_default_heap(void) {
#ifdef MI_TLS_RECURSE_GUARD
// on some platforms, like macOS, the dynamic loader calls `malloc`
// to initialize thread local data. To avoid recursion, we need to avoid
@ -288,15 +288,15 @@ static inline void mi_block_set_next(mi_page_t* page, mi_block_t* block, mi_bloc
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static inline uintptr_t _mi_thread_id() mi_attr_noexcept {
static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
// Windows: works on Intel and ARM in both 32- and 64-bit
return (uintptr_t)NtCurrentTeb();
return (uintptr_t)NtCurrentTeb(void);
}
#elif (defined(__GNUC__) || defined(__clang__)) && \
(defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__))
// TLS register on x86 is in the FS or GS register
// see: https://akkadia.org/drepper/tls.pdf
static inline uintptr_t _mi_thread_id() mi_attr_noexcept {
static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
uintptr_t tid;
#if defined(__i386__)
__asm__("movl %%gs:0, %0" : "=r" (tid) : : ); // 32-bit always uses GS
@ -313,7 +313,7 @@ static inline uintptr_t _mi_thread_id() mi_attr_noexcept {
}
#else
// otherwise use standard C
static inline uintptr_t _mi_thread_id() mi_attr_noexcept {
static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
return (uintptr_t)&_mi_heap_default;
}
#endif

View File

@ -193,7 +193,7 @@ static size_t mi__msize_dbg_term(void* p, int block_type) {
// ------------------------------------------------------
// implement our own global atexit handler
// ------------------------------------------------------
typedef void (cbfun_t)();
typedef void (cbfun_t)(void);
typedef int (atexit_fun_t)(cbfun_t* fn);
typedef uintptr_t encoded_t;
@ -229,7 +229,7 @@ static void init_canary()
// initialize the list
static void mi_initialize_atexit() {
static void mi_initialize_atexit(void) {
InitializeCriticalSection(&atexit_lock);
init_canary();
}
@ -495,12 +495,12 @@ mi_decl_export void mi_patches_disable(void) {
}
// Enable all patches normally
mi_decl_export bool mi_patches_enable() {
mi_decl_export bool mi_patches_enable(void) {
return _mi_patches_apply( PATCH_TARGET, NULL );
}
// Enable all patches in termination phase where free is a no-op
mi_decl_export bool mi_patches_enable_term() {
mi_decl_export bool mi_patches_enable_term(void) {
return _mi_patches_apply(PATCH_TARGET_TERM, NULL);
}
@ -544,7 +544,7 @@ static atexit_fun_t* crt_atexit = NULL;
static atexit_fun_t* crt_at_quick_exit = NULL;
static bool mi_patches_resolve() {
static bool mi_patches_resolve(void) {
// get all loaded modules
HANDLE process = GetCurrentProcess(); // always -1, no need to release
DWORD needed = 0;
@ -604,12 +604,12 @@ static void NTAPI mi_fls_unwind(PVOID value) {
return;
}
static void mi_patches_atexit() {
static void mi_patches_atexit(void) {
mi_execute_exit_list(&atexit_list);
mi_patches_enable_term(); // enter termination phase and patch realloc/free with a no-op
}
static void mi_patches_at_quick_exit() {
static void mi_patches_at_quick_exit(void) {
mi_execute_exit_list(&at_quick_exit_list);
mi_patches_enable_term(); // enter termination phase and patch realloc/free with a no-op
}

View File

@ -157,12 +157,12 @@ void mi_collect(bool force) mi_attr_noexcept {
Heap new
----------------------------------------------------------- */
mi_heap_t* mi_heap_get_default() {
mi_heap_t* mi_heap_get_default(void) {
mi_thread_init();
return mi_get_default_heap();
}
mi_heap_t* mi_heap_get_backing() {
mi_heap_t* mi_heap_get_backing(void) {
mi_heap_t* heap = mi_heap_get_default();
mi_assert_internal(heap!=NULL);
mi_heap_t* bheap = heap->tld->heap_backing;
@ -177,7 +177,7 @@ uintptr_t _mi_heap_random(mi_heap_t* heap) {
return r;
}
mi_heap_t* mi_heap_new() {
mi_heap_t* mi_heap_new(void) {
mi_heap_t* bheap = mi_heap_get_backing();
mi_heap_t* heap = mi_heap_malloc_tp(bheap, mi_heap_t);
if (heap==NULL) return NULL;

View File

@ -181,7 +181,7 @@ typedef struct mi_thread_data_s {
} mi_thread_data_t;
// Initialize the thread local default heap, called from `mi_thread_init`
static bool _mi_heap_init() {
static bool _mi_heap_init(void) {
if (mi_heap_is_initialized(_mi_heap_default)) return true;
if (_mi_is_main_thread()) {
// the main heap is statically allocated
@ -212,7 +212,7 @@ static bool _mi_heap_init() {
}
// Free the thread local default heap (called from `mi_thread_done`)
static bool _mi_heap_done() {
static bool _mi_heap_done(void) {
mi_heap_t* heap = _mi_heap_default;
if (!mi_heap_is_initialized(heap)) return true;
@ -285,7 +285,7 @@ static bool _mi_heap_done() {
#endif
// Set up handlers so `mi_thread_done` is called automatically
static void mi_process_setup_auto_thread_done() {
static void mi_process_setup_auto_thread_done(void) {
static bool tls_initialized = false; // fine if it races
if (tls_initialized) return;
tls_initialized = true;
@ -299,12 +299,12 @@ static void mi_process_setup_auto_thread_done() {
}
bool _mi_is_main_thread() {
bool _mi_is_main_thread(void) {
return (_mi_heap_main.thread_id==0 || _mi_heap_main.thread_id == _mi_thread_id());
}
// This is called from the `mi_malloc_generic`
void mi_thread_init() mi_attr_noexcept
void mi_thread_init(void) mi_attr_noexcept
{
// ensure our process has started already
mi_process_init();
@ -329,7 +329,7 @@ void mi_thread_init() mi_attr_noexcept
_mi_verbose_message("thread init: 0x%zx\n", _mi_thread_id());
}
void mi_thread_done() mi_attr_noexcept {
void mi_thread_done(void) mi_attr_noexcept {
// stats
mi_heap_t* heap = mi_get_default_heap();
if (!_mi_is_main_thread() && mi_heap_is_initialized(heap)) {
@ -350,7 +350,7 @@ void mi_thread_done() mi_attr_noexcept {
// --------------------------------------------------------
static void mi_process_done(void);
void mi_process_init() mi_attr_noexcept {
void mi_process_init(void) mi_attr_noexcept {
// ensure we are called once
if (_mi_process_is_initialized) return;
_mi_process_is_initialized = true;
@ -406,7 +406,7 @@ static void mi_process_done(void) {
#elif defined(__cplusplus)
// C++: use static initialization to detect process start
static bool _mi_process_init() {
static bool _mi_process_init(void) {
mi_process_init();
return (mi_main_thread_id != 0);
}
@ -414,7 +414,7 @@ static void mi_process_done(void) {
#elif defined(__GNUC__) || defined(__clang__)
// GCC,Clang: use the constructor attribute
static void __attribute__((constructor)) _mi_process_init() {
static void __attribute__((constructor)) _mi_process_init(void) {
mi_process_init();
}

View File

@ -50,7 +50,7 @@ static void* mi_align_down_ptr(void* p, size_t alignment) {
static void* os_pool_alloc(size_t size, size_t alignment, mi_os_tld_t* tld);
// cached OS page size
size_t _mi_os_page_size() {
size_t _mi_os_page_size(void) {
static size_t page_size = 0;
if (page_size == 0) {
#if defined(_WIN32)

View File

@ -256,15 +256,15 @@ static void _mi_stats_print(mi_stats_t* stats, double secs, FILE* out) mi_attr_n
}
static double mi_clock_end(double start);
static double mi_clock_start();
static double mi_clock_start(void);
static double mi_time_start = 0.0;
static mi_stats_t* mi_stats_get_default() {
static mi_stats_t* mi_stats_get_default(void) {
mi_heap_t* heap = mi_heap_get_default();
return &heap->tld->stats;
}
void mi_stats_reset() mi_attr_noexcept {
void mi_stats_reset(void) mi_attr_noexcept {
mi_stats_t* stats = mi_stats_get_default();
if (stats != &_mi_stats_main) { memset(stats, 0, sizeof(mi_stats_t)); }
memset(&_mi_stats_main, 0, sizeof(mi_stats_t));
@ -305,7 +305,7 @@ static double mi_to_seconds(LARGE_INTEGER t) {
return ((double)(t.QuadPart) / freq);
}
static double mi_clock_now() {
static double mi_clock_now(void) {
LARGE_INTEGER t;
QueryPerformanceCounter(&t);
return mi_to_seconds(t);
@ -313,14 +313,14 @@ static double mi_clock_now() {
#else
#include <time.h>
#ifdef CLOCK_REALTIME
static double mi_clock_now() {
static double mi_clock_now(void) {
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return (double)t.tv_sec + (1.0e-9 * (double)t.tv_nsec);
}
#else
// low resolution timer
static double mi_clock_now() {
static double mi_clock_now(void) {
return ((double)clock() / (double)CLOCKS_PER_SEC);
}
#endif
@ -329,7 +329,7 @@ static double mi_clock_now() {
static double mi_clock_diff = 0.0;
static double mi_clock_start() {
static double mi_clock_start(void) {
if (mi_clock_diff == 0.0) {
double t0 = mi_clock_now();
mi_clock_diff = mi_clock_now() - t0;