2 * Copyright (C) 2006 Jason Evans <jasone@FreeBSD.org>.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice(s), this list of conditions and the following disclaimer as
10 * the first lines of this file unmodified other than the possible
11 * addition of one or more copyright notices.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice(s), this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 #include <sys/types.h>
39 size_t malloc_usable_size(const void *ptr);
41 void malloc_stats_print(void (*write_cb)(void *, const char *),
42 void *cbopaque, const char *opts);
43 int mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
45 int mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp);
46 int mallctlbymib(const size_t *mib, size_t miblen, void *oldp,
47 size_t *oldlenp, void *newp, size_t newlen);
49 #define ALLOCM_LG_ALIGN(la) (la)
50 #define ALLOCM_ALIGN(a) (ffsl(a)-1)
51 #define ALLOCM_ZERO ((int)0x40)
52 #define ALLOCM_NO_MOVE ((int)0x80)
54 #define ALLOCM_SUCCESS 0
55 #define ALLOCM_ERR_OOM 1
56 #define ALLOCM_ERR_NOT_MOVED 2
58 int allocm(void **ptr, size_t *rsize, size_t size, int flags) __nonnull(1);
59 int rallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
60 int flags) __nonnull(1);
61 int sallocm(const void *ptr, size_t *rsize, int flags) __nonnull(1);
62 int dallocm(void *ptr, int flags) __nonnull(1);
63 int nallocm(size_t *rsize, size_t size, int flags);
65 void * __calloc(size_t, size_t) __malloc_like;
66 void * __malloc(size_t) __malloc_like;
67 void * __realloc(void *, size_t);
69 int __posix_memalign(void **, size_t, size_t);
70 size_t __malloc_usable_size(const void *);
71 int __allocm(void **, size_t *, size_t, int) __nonnull(1);
72 int __rallocm(void **, size_t *, size_t, size_t, int) __nonnull(1);
73 int __sallocm(const void *, size_t *, int) __nonnull(1);
74 int __dallocm(void *, int) __nonnull(1);
75 int __nallocm(size_t *, size_t, int);
78 #endif /* _MALLOC_NP_H_ */