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