1157236Sjasone/*- 2157236Sjasone * Copyright (C) 2006 Jason Evans <jasone@FreeBSD.org>. 3157236Sjasone * All rights reserved. 4157236Sjasone * 5157236Sjasone * Redistribution and use in source and binary forms, with or without 6157236Sjasone * modification, are permitted provided that the following conditions 7157236Sjasone * are met: 8157236Sjasone * 1. Redistributions of source code must retain the above copyright 9157236Sjasone * notice(s), this list of conditions and the following disclaimer as 10157236Sjasone * the first lines of this file unmodified other than the possible 11157236Sjasone * addition of one or more copyright notices. 12157236Sjasone * 2. Redistributions in binary form must reproduce the above copyright 13157236Sjasone * notice(s), this list of conditions and the following disclaimer in 14157236Sjasone * the documentation and/or other materials provided with the 15157236Sjasone * distribution. 16157236Sjasone * 17157236Sjasone * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 18157236Sjasone * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19157236Sjasone * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20157236Sjasone * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 21157236Sjasone * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22157236Sjasone * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23157236Sjasone * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24157236Sjasone * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25157236Sjasone * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26157236Sjasone * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27157236Sjasone * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28157236Sjasone * 29157236Sjasone * $FreeBSD$ 30157236Sjasone */ 31157236Sjasone 32157236Sjasone#ifndef _MALLOC_NP_H_ 33157236Sjasone#define _MALLOC_NP_H_ 34160056Sjasone#include <sys/cdefs.h> 35160056Sjasone#include <sys/types.h> 36234370Sjasone#include <strings.h> 37157236Sjasone 38160056Sjasone__BEGIN_DECLS 39157236Sjasonesize_t malloc_usable_size(const void *ptr); 40234370Sjasone 41234370Sjasonevoid malloc_stats_print(void (*write_cb)(void *, const char *), 42234370Sjasone void *cbopaque, const char *opts); 43234370Sjasoneint mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, 44234370Sjasone size_t newlen); 45234370Sjasoneint mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp); 46234370Sjasoneint mallctlbymib(const size_t *mib, size_t miblen, void *oldp, 47234370Sjasone size_t *oldlenp, void *newp, size_t newlen); 48234370Sjasone 49234370Sjasone#define ALLOCM_LG_ALIGN(la) (la) 50234370Sjasone#define ALLOCM_ALIGN(a) (ffsl(a)-1) 51234370Sjasone#define ALLOCM_ZERO ((int)0x40) 52234370Sjasone#define ALLOCM_NO_MOVE ((int)0x80) 53234370Sjasone 54234370Sjasone#define ALLOCM_SUCCESS 0 55234370Sjasone#define ALLOCM_ERR_OOM 1 56234370Sjasone#define ALLOCM_ERR_NOT_MOVED 2 57234370Sjasone 58235780Shartiint allocm(void **ptr, size_t *rsize, size_t size, int flags) __nonnull(1); 59234370Sjasoneint rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, 60235780Sharti int flags) __nonnull(1); 61235780Shartiint sallocm(const void *ptr, size_t *rsize, int flags) __nonnull(1); 62235780Shartiint dallocm(void *ptr, int flags) __nonnull(1); 63234370Sjasoneint nallocm(size_t *rsize, size_t size, int flags); 64250991Smarcel 65250991Smarcelvoid * __calloc(size_t, size_t) __malloc_like; 66250991Smarcelvoid * __malloc(size_t) __malloc_like; 67250991Smarcelvoid * __realloc(void *, size_t); 68250991Smarcelvoid __free(void *); 69250991Smarcelint __posix_memalign(void **, size_t, size_t); 70250991Smarcelsize_t __malloc_usable_size(const void *); 71250991Smarcelint __allocm(void **, size_t *, size_t, int) __nonnull(1); 72250991Smarcelint __rallocm(void **, size_t *, size_t, size_t, int) __nonnull(1); 73250991Smarcelint __sallocm(const void *, size_t *, int) __nonnull(1); 74250991Smarcelint __dallocm(void *, int) __nonnull(1); 75250991Smarcelint __nallocm(size_t *, size_t, int); 76160056Sjasone__END_DECLS 77157236Sjasone 78157236Sjasone#endif /* _MALLOC_NP_H_ */ 79