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