2012-12-07 12:32:24 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper header to declare all the supported malloc functions.
|
|
|
|
* MALLOC_DECL arguments are:
|
|
|
|
* - function name
|
|
|
|
* - return type
|
|
|
|
* - argument types
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef malloc_decls_h
|
|
|
|
# define malloc_decls_h
|
|
|
|
|
2012-12-07 12:32:24 +04:00
|
|
|
# include "jemalloc_types.h"
|
|
|
|
|
2015-01-07 03:58:36 +03:00
|
|
|
#ifndef MALLOC_USABLE_SIZE_CONST_PTR
|
|
|
|
#define MALLOC_USABLE_SIZE_CONST_PTR const
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef MALLOC_USABLE_SIZE_CONST_PTR void * usable_ptr_t;
|
2012-12-07 12:32:24 +04:00
|
|
|
|
|
|
|
# define MALLOC_FUNCS_MALLOC 1
|
|
|
|
# define MALLOC_FUNCS_JEMALLOC 2
|
|
|
|
# define MALLOC_FUNCS_INIT 4
|
2014-11-18 13:21:06 +03:00
|
|
|
# define MALLOC_FUNCS_BRIDGE 8
|
|
|
|
# define MALLOC_FUNCS_ALL (MALLOC_FUNCS_INIT | MALLOC_FUNCS_BRIDGE | \
|
2016-08-23 15:45:00 +03:00
|
|
|
MALLOC_FUNCS_MALLOC | MALLOC_FUNCS_JEMALLOC)
|
2012-12-07 12:32:24 +04:00
|
|
|
|
2012-12-07 12:32:24 +04:00
|
|
|
#endif /* malloc_decls_h */
|
|
|
|
|
2012-12-07 12:32:24 +04:00
|
|
|
#ifndef MALLOC_FUNCS
|
2016-08-23 15:45:00 +03:00
|
|
|
# define MALLOC_FUNCS (MALLOC_FUNCS_MALLOC | MALLOC_FUNCS_JEMALLOC)
|
2012-12-07 12:32:24 +04:00
|
|
|
#endif
|
|
|
|
|
2012-12-07 12:32:24 +04:00
|
|
|
#ifdef MALLOC_DECL
|
2015-05-26 09:48:21 +03:00
|
|
|
# ifndef MALLOC_DECL_VOID
|
|
|
|
# define MALLOC_DECL_VOID(func, ...) MALLOC_DECL(func, void, __VA_ARGS__)
|
|
|
|
# endif
|
|
|
|
|
2012-12-07 12:32:24 +04:00
|
|
|
# if MALLOC_FUNCS & MALLOC_FUNCS_INIT
|
|
|
|
MALLOC_DECL(init, void, const malloc_table_t *)
|
|
|
|
# endif
|
2014-11-18 13:21:06 +03:00
|
|
|
# if MALLOC_FUNCS & MALLOC_FUNCS_BRIDGE
|
|
|
|
MALLOC_DECL(get_bridge, struct ReplaceMallocBridge*, void)
|
|
|
|
# endif
|
2012-12-07 12:32:24 +04:00
|
|
|
# if MALLOC_FUNCS & MALLOC_FUNCS_MALLOC
|
2012-12-07 12:32:24 +04:00
|
|
|
MALLOC_DECL(malloc, void *, size_t)
|
|
|
|
MALLOC_DECL(posix_memalign, int, void **, size_t, size_t)
|
|
|
|
MALLOC_DECL(aligned_alloc, void *, size_t, size_t)
|
|
|
|
MALLOC_DECL(calloc, void *, size_t, size_t)
|
|
|
|
MALLOC_DECL(realloc, void *, void *, size_t)
|
2015-05-26 09:48:21 +03:00
|
|
|
MALLOC_DECL_VOID(free, void *)
|
2012-12-07 12:32:24 +04:00
|
|
|
MALLOC_DECL(memalign, void *, size_t, size_t)
|
|
|
|
MALLOC_DECL(valloc, void *, size_t)
|
|
|
|
MALLOC_DECL(malloc_usable_size, size_t, usable_ptr_t)
|
|
|
|
MALLOC_DECL(malloc_good_size, size_t, size_t)
|
2012-12-07 12:32:24 +04:00
|
|
|
# endif
|
|
|
|
# if MALLOC_FUNCS & MALLOC_FUNCS_JEMALLOC
|
2015-05-26 09:48:21 +03:00
|
|
|
MALLOC_DECL_VOID(jemalloc_stats, jemalloc_stats_t *)
|
|
|
|
MALLOC_DECL_VOID(jemalloc_purge_freed_pages, void)
|
|
|
|
MALLOC_DECL_VOID(jemalloc_free_dirty_pages, void)
|
2012-12-07 12:32:24 +04:00
|
|
|
# endif
|
2015-05-26 09:48:21 +03:00
|
|
|
|
|
|
|
# undef MALLOC_DECL_VOID
|
2012-12-07 12:32:24 +04:00
|
|
|
#endif /* MALLOC_DECL */
|
|
|
|
|
|
|
|
#undef MALLOC_DECL
|
2012-12-07 12:32:24 +04:00
|
|
|
#undef MALLOC_FUNCS
|