]> git.proxmox.com Git - wasi-libc.git/blame - dlmalloc/src/wrapper.c
Fix ssize_t redefinition mismatch. (#10)
[wasi-libc.git] / dlmalloc / src / wrapper.c
CommitLineData
dbfccac2
DG
1/* Define configuration macros for dlmalloc. */
2
3/* WebAssembly doesn't have mmap-style memory allocation. */
4#define HAVE_MMAP 0
5
6/* WebAssembly doesn't support shrinking linear memory. */
7#define MORECORE_CANNOT_TRIM 1
8
9/* Disable sanity checks to reduce code size. */
10#define ABORT __builtin_unreachable()
11
12/* If threads are enabled, enable support for threads. */
13#ifndef WASM_THREAD_MODEL_SINGLE
14#define USE_LOCKS 1
15#endif
16
17/* Make malloc deterministic. */
18#define LACKS_TIME_H 1
19
20/* WebAssembly has no sched_yield or similar. */
21#define LACKS_SCHED_H
22
23/* Disable malloc statistics generation to reduce code size. */
24#define NO_MALLINFO 1
25#define NO_MALLOC_STATS 1
26
27/*
28 * Declare errno values used by dlmalloc. We define them like this to avoid
29 * putting specific errno values in the ABI.
30 */
31extern const int __ENOMEM;
32#define ENOMEM __ENOMEM
33extern const int __EINVAL;
34#define EINVAL __EINVAL
35
36/* Prefix dlmalloc's names with 'dl'. We wrap them with public names below. */
37#define USE_DL_PREFIX 1
38#define DLMALLOC_EXPORT static inline
39
40/* Include the upstream dlmalloc's malloc.c. */
41#include "malloc.c"
42
43/* Export the public names. */
44
45void *malloc(size_t size) {
46 return dlmalloc(size);
47}
48
49void free(void *ptr) {
50 return dlfree(ptr);
51}
52
53void *calloc(size_t nmemb, size_t size) {
54 return dlcalloc(nmemb, size);
55}
56
57void *realloc(void *ptr, size_t size) {
58 return dlrealloc(ptr, size);
59}
60
61int posix_memalign(void **memptr, size_t alignment, size_t size) {
62 return dlposix_memalign(memptr, alignment, size);
63}