xref: /openbsd-src/sys/dev/pci/drm/include/linux/slab.h (revision 3374c67d44f9b75b98444cbf63020f777792342e)
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 
19 static inline void *
20 kmalloc(size_t size, int flags)
21 {
22 	return malloc(size, M_DRM, flags);
23 }
24 
25 static inline void *
26 kmalloc_array(size_t n, size_t size, int flags)
27 {
28 	if (n != 0 && SIZE_MAX / n < size)
29 		return NULL;
30 	return malloc(n * size, M_DRM, flags);
31 }
32 
33 static inline void *
34 kcalloc(size_t n, size_t size, int flags)
35 {
36 	if (n != 0 && SIZE_MAX / n < size)
37 		return NULL;
38 	return malloc(n * size, M_DRM, flags | M_ZERO);
39 }
40 
41 static inline void *
42 kzalloc(size_t size, int flags)
43 {
44 	return malloc(size, M_DRM, flags | M_ZERO);
45 }
46 
47 static inline void
48 kfree(const void *objp)
49 {
50 	free((void *)objp, M_DRM, 0);
51 }
52 
53 #endif
54