#ifdef PARTITION_ALLOC_SHIM_ALLOCATOR_SHIM_OVERRIDE_GLIBC_WEAK_SYMBOLS_H_
#error This header is meant to be included only once by allocator_shim.cc
#endif
#ifndef PARTITION_ALLOC_SHIM_ALLOCATOR_SHIM_OVERRIDE_GLIBC_WEAK_SYMBOLS_H_
#define PARTITION_ALLOC_SHIM_ALLOCATOR_SHIM_OVERRIDE_GLIBC_WEAK_SYMBOLS_H_
#include "partition_alloc/buildflags.h"
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include <features.h>
#include <malloc.h>
#include <unistd.h>
#include <new>
#include "partition_alloc/shim/allocator_shim_internals.h"
#if !defined(__MALLOC_HOOK_VOLATILE)
#define MALLOC_HOOK_MAYBE_VOLATILE …
#else
#define MALLOC_HOOK_MAYBE_VOLATILE …
#endif
extern "C" {
namespace {
void* GlibcMallocHook(size_t size, const void* caller) { … }
void* GlibcReallocHook(void* ptr, size_t size, const void* caller) { … }
void GlibcFreeHook(void* ptr, const void* caller) { … }
void* GlibcMemalignHook(size_t align, size_t size, const void* caller) { … }
}
__attribute__((visibility("default"))) void* (
*MALLOC_HOOK_MAYBE_VOLATILE __malloc_hook)(size_t,
const void*) = …;
__attribute__((visibility("default"))) void* (
*MALLOC_HOOK_MAYBE_VOLATILE __realloc_hook)(void*, size_t, const void*) = …;
__attribute__((visibility("default"))) void (
*MALLOC_HOOK_MAYBE_VOLATILE __free_hook)(void*,
const void*) = …;
__attribute__((visibility("default"))) void* (
*MALLOC_HOOK_MAYBE_VOLATILE __memalign_hook)(size_t, size_t, const void*) = …;
SHIM_ALWAYS_EXPORT void* __libc_malloc(size_t size) { … }
SHIM_ALWAYS_EXPORT void __libc_free(void* ptr) { … }
SHIM_ALWAYS_EXPORT void* __libc_realloc(void* ptr, size_t size) { … }
SHIM_ALWAYS_EXPORT void* __libc_calloc(size_t n, size_t size) { … }
SHIM_ALWAYS_EXPORT void __libc_cfree(void* ptr) { … }
SHIM_ALWAYS_EXPORT void* __libc_memalign(size_t align, size_t s) { … }
SHIM_ALWAYS_EXPORT void* __libc_valloc(size_t size) { … }
SHIM_ALWAYS_EXPORT void* __libc_pvalloc(size_t size) { … }
SHIM_ALWAYS_EXPORT int __posix_memalign(void** r, size_t a, size_t s) { … }
}
#if !defined(__GLIBC__)
#error The target platform does not seem to use Glibc. Disable the allocator \
shim by setting use_allocator_shim=false in GN args.
#endif
#endif
#endif