malloc_np.h revision 256281
1/*- 2 * Copyright (C) 2006 Jason Evans <jasone@FreeBSD.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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 15 * distribution. 16 * 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. 28 * 29 * $FreeBSD: stable/10/include/malloc_np.h 250991 2013-05-25 18:59:11Z marcel $ 30 */ 31 32#ifndef _MALLOC_NP_H_ 33#define _MALLOC_NP_H_ 34#include <sys/cdefs.h> 35#include <sys/types.h> 36#include <strings.h> 37 38__BEGIN_DECLS 39size_t malloc_usable_size(const void *ptr); 40 41void malloc_stats_print(void (*write_cb)(void *, const char *), 42 void *cbopaque, const char *opts); 43int mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, 44 size_t newlen); 45int mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp); 46int mallctlbymib(const size_t *mib, size_t miblen, void *oldp, 47 size_t *oldlenp, void *newp, size_t newlen); 48 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) 53 54#define ALLOCM_SUCCESS 0 55#define ALLOCM_ERR_OOM 1 56#define ALLOCM_ERR_NOT_MOVED 2 57 58int allocm(void **ptr, size_t *rsize, size_t size, int flags) __nonnull(1); 59int rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, 60 int flags) __nonnull(1); 61int sallocm(const void *ptr, size_t *rsize, int flags) __nonnull(1); 62int dallocm(void *ptr, int flags) __nonnull(1); 63int nallocm(size_t *rsize, size_t size, int flags); 64 65void * __calloc(size_t, size_t) __malloc_like; 66void * __malloc(size_t) __malloc_like; 67void * __realloc(void *, size_t); 68void __free(void *); 69int __posix_memalign(void **, size_t, size_t); 70size_t __malloc_usable_size(const void *); 71int __allocm(void **, size_t *, size_t, int) __nonnull(1); 72int __rallocm(void **, size_t *, size_t, size_t, int) __nonnull(1); 73int __sallocm(const void *, size_t *, int) __nonnull(1); 74int __dallocm(void *, int) __nonnull(1); 75int __nallocm(size_t *, size_t, int); 76__END_DECLS 77 78#endif /* _MALLOC_NP_H_ */ 79