1570af302Sopenharmony_ci/*
2570af302Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3570af302Sopenharmony_ci *
4570af302Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
5570af302Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
6570af302Sopenharmony_ci * deal in the Software without restriction, including without limitation the
7570af302Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8570af302Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
9570af302Sopenharmony_ci * furnished to do so, subject to the following conditions:
10570af302Sopenharmony_ci *
11570af302Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
12570af302Sopenharmony_ci * all copies or substantial portions of the Software.
13570af302Sopenharmony_ci *
14570af302Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15570af302Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16570af302Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17570af302Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18570af302Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19570af302Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20570af302Sopenharmony_ci * IN THE SOFTWARE.
21570af302Sopenharmony_ci */
22570af302Sopenharmony_ci
23570af302Sopenharmony_ci#ifndef _MUSL_MALLOC_DISPATCH_H
24570af302Sopenharmony_ci#define _MUSL_MALLOC_DISPATCH_H
25570af302Sopenharmony_ci
26570af302Sopenharmony_ci#include <stddef.h>
27570af302Sopenharmony_ci#include <stdint.h>
28570af302Sopenharmony_ci#include <stdio.h>
29570af302Sopenharmony_ci#include <stdbool.h>
30570af302Sopenharmony_ci
31570af302Sopenharmony_ci#ifdef __cplusplus
32570af302Sopenharmony_ciextern "C" {
33570af302Sopenharmony_ci#endif
34570af302Sopenharmony_citypedef void* (*MallocMmapType) (void*, size_t, int, int, int, off_t);
35570af302Sopenharmony_citypedef int (*MallocMunmapType) (void*, size_t);
36570af302Sopenharmony_citypedef void* (*MallocMallocType)(size_t);
37570af302Sopenharmony_citypedef void* (*MallocReallocType)(void*, size_t);
38570af302Sopenharmony_citypedef void* (*MallocCallocType)(size_t, size_t);
39570af302Sopenharmony_citypedef void* (*MallocVallocType)(size_t);
40570af302Sopenharmony_citypedef void (*MallocFreeType)(void*);
41570af302Sopenharmony_citypedef void* (*MallocAlignedAllocType)(size_t, size_t);
42570af302Sopenharmony_citypedef size_t (*MallocMallocUsableSizeType)(void*);
43570af302Sopenharmony_citypedef int (*MallocPrctlType)(int, ...);
44570af302Sopenharmony_ci
45570af302Sopenharmony_citypedef struct mallinfo (*MallinfoType)(void);
46570af302Sopenharmony_citypedef struct mallinfo2 (*Mallinfo2Type)(void);
47570af302Sopenharmony_citypedef int (*MallocIterateType)(void*, size_t, void (*callback)(void*, size_t, void*), void*);
48570af302Sopenharmony_citypedef void (*MallocDisableType)(void);
49570af302Sopenharmony_citypedef void (*MallocEnableType)(void);
50570af302Sopenharmony_citypedef int (*MallocInfoType)(int, FILE*);
51570af302Sopenharmony_citypedef void (*MallocStatsPrintType)(void (*) (void *, const char *), void *, const char *);
52570af302Sopenharmony_citypedef int (*MalloptType)(int, int);
53570af302Sopenharmony_citypedef ssize_t (*MallocBacktraceType)(void*, uintptr_t*, size_t);
54570af302Sopenharmony_citypedef void (*MemTrace)(void*, size_t, const char*, bool);
55570af302Sopenharmony_ci
56570af302Sopenharmony_citypedef bool (*GetHookFlagType)();
57570af302Sopenharmony_citypedef bool (*SetHookFlagType)(bool);
58570af302Sopenharmony_citypedef bool (*SendHookMiscData)(uint64_t, const char*, size_t, uint32_t);
59570af302Sopenharmony_citypedef void* (*GetHookConfig)();
60570af302Sopenharmony_ci
61570af302Sopenharmony_cistruct MallocDispatchType {
62570af302Sopenharmony_ci	MallocMmapType mmap;
63570af302Sopenharmony_ci	MallocMunmapType munmap;
64570af302Sopenharmony_ci	MallocMallocType malloc;
65570af302Sopenharmony_ci	MallocCallocType calloc;
66570af302Sopenharmony_ci	MallocReallocType realloc;
67570af302Sopenharmony_ci	MallocVallocType valloc;
68570af302Sopenharmony_ci	MallocFreeType free;
69570af302Sopenharmony_ci	MallocAlignedAllocType aligned_alloc;
70570af302Sopenharmony_ci	MallocMallocUsableSizeType malloc_usable_size;
71570af302Sopenharmony_ci	MallinfoType mallinfo;
72570af302Sopenharmony_ci	Mallinfo2Type mallinfo2;
73570af302Sopenharmony_ci	MallocIterateType malloc_iterate;
74570af302Sopenharmony_ci	MallocDisableType malloc_disable;
75570af302Sopenharmony_ci	MallocEnableType malloc_enable;
76570af302Sopenharmony_ci	MallocInfoType malloc_info;
77570af302Sopenharmony_ci	MallocStatsPrintType malloc_stats_print;
78570af302Sopenharmony_ci	MalloptType mallopt;
79570af302Sopenharmony_ci	MallocBacktraceType malloc_backtrace;
80570af302Sopenharmony_ci	GetHookFlagType get_hook_flag;
81570af302Sopenharmony_ci	SetHookFlagType set_hook_flag;
82570af302Sopenharmony_ci	MemTrace memtrace;
83570af302Sopenharmony_ci	MallocPrctlType prctl;
84570af302Sopenharmony_ci};
85570af302Sopenharmony_ci#ifdef __cplusplus
86570af302Sopenharmony_ci}
87570af302Sopenharmony_ci#endif
88570af302Sopenharmony_ci
89570af302Sopenharmony_ci#endif
90