malloc_np.h revision 234370
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: head/include/malloc_np.h 234370 2012-04-17 07:22:14Z jasone $ 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 58234370Sjasoneint allocm(void **ptr, size_t *rsize, size_t size, int flags) 59234370Sjasone __attribute__(nonnull(1)); 60234370Sjasoneint rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, 61234370Sjasone int flags) __attribute__(nonnull(1)); 62234370Sjasoneint sallocm(const void *ptr, size_t *rsize, int flags) 63234370Sjasone __attribute__(nonnull(1)); 64234370Sjasoneint dallocm(void *ptr, int flags) __attribute__(nonnull(1)); 65234370Sjasoneint nallocm(size_t *rsize, size_t size, int flags); 66160056Sjasone__END_DECLS 67157236Sjasone 68157236Sjasone#endif /* _MALLOC_NP_H_ */ 69