1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1987, 1993 5 * The Regents of the University of California. 6 * Copyright (c) 2005, 2009 Robert N. M. Watson 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)malloc.h 8.5 (Berkeley) 5/3/95 34 * $FreeBSD: releng/12.2/sys/sys/malloc.h 365383 2020-09-06 17:40:35Z wulf $ 35 */ 36 37 #ifndef _SYS_MALLOC_H_ 38 #define _SYS_MALLOC_H_ 39 40 #include <sys/types.h> 41 #include <los_memory.h> 42 43 #define M_NOWAIT 0x0001 /* do not block */ 44 #define M_WAITOK 0x0002 /* ok to block */ 45 #define M_ZERO 0x0100 /* bzero the allocation */ 46 #define M_NOVM 0x0200 /* don't ask VM for pages */ 47 #define M_USE_RESERVE 0x0400 /* can alloc out of reserve memory */ 48 #define M_NODUMP 0x0800 /* don't dump pages in this allocation */ 49 #define M_FIRSTFIT 0x1000 /* Only for vmem, fast fit. */ 50 #define M_BESTFIT 0x2000 /* Only for vmem, low fragmentation. */ 51 52 #define M_MAGIC 877983977 /* time when first defined :-) */ 53 #define MINALLOCSIZE 4 54 55 /* 56 * * Public data structure describing a malloc type. Private data is hung off 57 * * of ks_handle to avoid encoding internal malloc(9) data structures in 58 * * modules, which will statically allocate struct malloc_type. 59 * */ 60 struct malloc_type { 61 struct malloc_type *ks_next; /* Next in global chain. */ 62 u_long ks_magic; /* Detect programmer error. */ 63 const char *ks_shortdesc; /* Printable type name. */ 64 void *ks_handle; /* Priv. data, was lo_class. */ 65 }; 66 67 68 #define MALLOC_DEFINE(type, shortdesc, longdesc) \ 69 struct malloc_type type[1] = { \ 70 { NULL, M_MAGIC, shortdesc, NULL } \ 71 }; 72 73 #define bsd_malloc(size, type, flags) zalloc(size) 74 #define bsd_free(addr, type) free(addr) 75 #define bsd_strdup(p,x) strdup(p) 76 77 #endif /* !_SYS_MALLOC_H_ */ 78