xref: /illumos-gate/usr/src/compat/bhyve/sys/malloc.h (revision d0b3c59b)
1bf21cd93STycho Nightingale /*
2bf21cd93STycho Nightingale  * This file and its contents are supplied under the terms of the
3bf21cd93STycho Nightingale  * Common Development and Distribution License ("CDDL"), version 1.0.
4bf21cd93STycho Nightingale  * You may only use this file in accordance with the terms of version
5bf21cd93STycho Nightingale  * 1.0 of the CDDL.
6bf21cd93STycho Nightingale  *
7bf21cd93STycho Nightingale  * A full copy of the text of the CDDL should have accompanied this
8bf21cd93STycho Nightingale  * source.  A copy of the CDDL is also available via the Internet at
9bf21cd93STycho Nightingale  * http://www.illumos.org/license/CDDL.
10bf21cd93STycho Nightingale  */
11bf21cd93STycho Nightingale 
12bf21cd93STycho Nightingale /*
13bf21cd93STycho Nightingale  * Copyright 2013 Pluribus Networks Inc.
14bf21cd93STycho Nightingale  */
15bf21cd93STycho Nightingale 
16bf21cd93STycho Nightingale #ifndef _COMPAT_FREEBSD_SYS_MALLOC_H_
17bf21cd93STycho Nightingale #define	_COMPAT_FREEBSD_SYS_MALLOC_H_
18bf21cd93STycho Nightingale 
19bf21cd93STycho Nightingale /*
20bf21cd93STycho Nightingale  * flags to malloc.
21bf21cd93STycho Nightingale  */
22bf21cd93STycho Nightingale #define	M_NOWAIT	0x0001		/* do not block */
23bf21cd93STycho Nightingale #define	M_WAITOK	0x0002		/* ok to block */
24bf21cd93STycho Nightingale #define	M_ZERO		0x0100		/* bzero the allocation */
25bf21cd93STycho Nightingale 
26bf21cd93STycho Nightingale struct malloc_type {
27bf21cd93STycho Nightingale 	const char	*ks_shortdesc;	/* Printable type name. */
28bf21cd93STycho Nightingale };
29bf21cd93STycho Nightingale 
30bf21cd93STycho Nightingale #ifdef	_KERNEL
31bf21cd93STycho Nightingale #define	MALLOC_DEFINE(type, shortdesc, longdesc)			\
32bf21cd93STycho Nightingale 	struct malloc_type type[1] = {					\
33bf21cd93STycho Nightingale 		{ shortdesc }						\
34bf21cd93STycho Nightingale 	}
35bf21cd93STycho Nightingale 
36bf21cd93STycho Nightingale #define	MALLOC_DECLARE(type)						\
37bf21cd93STycho Nightingale 	extern struct malloc_type type[1]
38bf21cd93STycho Nightingale 
39bf21cd93STycho Nightingale void	free(void *addr, struct malloc_type *type);
40bf21cd93STycho Nightingale void	*malloc(unsigned long size, struct malloc_type *type, int flags);
41bf21cd93STycho Nightingale void	*old_malloc(unsigned long size, struct malloc_type *type , int flags);
424c87aefeSPatrick Mooney void	*contigmalloc(unsigned long, struct malloc_type *, int, vm_paddr_t,
434c87aefeSPatrick Mooney     vm_paddr_t, unsigned long, vm_paddr_t);
444c87aefeSPatrick Mooney void	contigfree(void *, unsigned long, struct malloc_type *);
454c87aefeSPatrick Mooney 
464c87aefeSPatrick Mooney 
47bf21cd93STycho Nightingale #endif	/* _KERNEL */
48bf21cd93STycho Nightingale 
49bf21cd93STycho Nightingale #endif	/* _COMPAT_FREEBSD_SYS_MALLOC_H_ */
50