1 /* 2 * Copyright 2009, Colin Günther, coling@gmx.de. 3 * Copyright 2007, Hugo Santos. All Rights Reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef _FBSD_COMPAT_SYS_MALLOC_H_ 7 #define _FBSD_COMPAT_SYS_MALLOC_H_ 8 9 10 #include <malloc.h> 11 12 #include <vm/vm.h> 13 14 #include <sys/param.h> 15 #include <sys/queue.h> 16 #include <sys/_mutex.h> 17 18 19 /* 20 * flags to malloc. 21 */ 22 #define M_NOWAIT 0x0001 23 #define M_WAITOK 0x0002 24 #define M_ZERO 0x0100 25 26 #define M_MAGIC 877983977 /* time when first defined :-) */ 27 28 #define M_DEVBUF 0 29 30 31 struct malloc_type { 32 }; 33 34 35 void *_kernel_malloc(size_t size, int flags); 36 void _kernel_free(void *ptr); 37 38 void *_kernel_contigmalloc(const char *file, int line, size_t size, int flags, 39 vm_paddr_t low, vm_paddr_t high, unsigned long alignment, 40 unsigned long boundary); 41 void _kernel_contigfree(void *addr, unsigned long size); 42 43 #define kernel_malloc(size, base, flags) \ 44 _kernel_malloc(size, flags) 45 46 #define kernel_free(ptr, tag) \ 47 _kernel_free(ptr) 48 49 #define kernel_contigmalloc(size, type, flags, low, high, alignment, boundary) \ 50 _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \ 51 alignment, boundary) 52 53 #define kernel_contigfree(addr, size, base) \ 54 _kernel_contigfree(addr, size) 55 56 #ifdef FBSD_DRIVER 57 # define malloc(size, tag, flags) kernel_malloc(size, tag, flags) 58 # define free(pointer, tag) kernel_free(pointer, tag) 59 # define contigmalloc(size, type, flags, low, high, alignment, boundary) \ 60 _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \ 61 alignment, boundary) 62 # define contigfree(addr, size, base) \ 63 _kernel_contigfree(addr, size) 64 #endif 65 66 #define MALLOC_DEFINE(type, shortdesc, longdesc) int type[1] 67 68 #define MALLOC_DECLARE(type) \ 69 extern int type[1] 70 71 #endif /* _FBSD_COMPAT_SYS_MALLOC_H_ */ 72