1 /* Public domain. */ 2 3 #ifndef _LINUX_SLAB_H 4 #define _LINUX_SLAB_H 5 6 #include <sys/types.h> 7 #include <sys/malloc.h> 8 9 #include <linux/types.h> 10 #include <linux/workqueue.h> 11 #include <linux/gfp.h> 12 13 #include <linux/processor.h> /* for CACHELINESIZE */ 14 15 #define ARCH_KMALLOC_MINALIGN CACHELINESIZE 16 17 #define ZERO_SIZE_PTR NULL 18 #define ZERO_OR_NULL_PTR(x) ((x) == NULL) 19 20 static inline void * 21 kmalloc(size_t size, int flags) 22 { 23 return malloc(size, M_DRM, flags); 24 } 25 26 static inline void * 27 kmalloc_array(size_t n, size_t size, int flags) 28 { 29 if (n != 0 && SIZE_MAX / n < size) 30 return NULL; 31 return malloc(n * size, M_DRM, flags); 32 } 33 34 static inline void * 35 kcalloc(size_t n, size_t size, int flags) 36 { 37 if (n != 0 && SIZE_MAX / n < size) 38 return NULL; 39 return malloc(n * size, M_DRM, flags | M_ZERO); 40 } 41 42 static inline void * 43 kzalloc(size_t size, int flags) 44 { 45 return malloc(size, M_DRM, flags | M_ZERO); 46 } 47 48 static inline void 49 kfree(const void *objp) 50 { 51 free((void *)objp, M_DRM, 0); 52 } 53 54 #endif 55