xref: /dflybsd-src/sys/dev/drm/include/linux/slab.h (revision c8480522dfdef8b1fdbce67fb729641e9f89e75d)
1158486a6SFrançois Tigeot /*
2158486a6SFrançois Tigeot  * Copyright (c) 2015 François Tigeot
3158486a6SFrançois Tigeot  * All rights reserved.
4158486a6SFrançois Tigeot  *
5158486a6SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6158486a6SFrançois Tigeot  * modification, are permitted provided that the following conditions
7158486a6SFrançois Tigeot  * are met:
8158486a6SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9158486a6SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10158486a6SFrançois Tigeot  *    disclaimer.
11158486a6SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12158486a6SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13158486a6SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14158486a6SFrançois Tigeot  *
15158486a6SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16158486a6SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17158486a6SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18158486a6SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19158486a6SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20158486a6SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21158486a6SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22158486a6SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23158486a6SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24158486a6SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25158486a6SFrançois Tigeot  */
26158486a6SFrançois Tigeot 
27158486a6SFrançois Tigeot #ifndef _LINUX_SLAB_H_
28158486a6SFrançois Tigeot #define _LINUX_SLAB_H_
29158486a6SFrançois Tigeot 
30f43360b9SFrançois Tigeot #include <linux/gfp.h>
3129f241cfSFrançois Tigeot #include <linux/types.h>
32f43360b9SFrançois Tigeot 
33*c8480522SFrançois Tigeot MALLOC_DECLARE(M_DRM);
34*c8480522SFrançois Tigeot 
35f43360b9SFrançois Tigeot #define kzalloc(size, flags)	kmalloc(size, M_DRM, flags | M_ZERO)
36f43360b9SFrançois Tigeot 
37158486a6SFrançois Tigeot #define kfree(ptr)	do {		\
38158486a6SFrançois Tigeot 	if (ptr != NULL)		\
39158486a6SFrançois Tigeot 		kfree(ptr, M_DRM);	\
40158486a6SFrançois Tigeot } while (0)
41158486a6SFrançois Tigeot 
42e0b9e154SSascha Wildner #define kcalloc(n, size, flags)	kzalloc((n) * (size), flags)
4329f241cfSFrançois Tigeot 
44158486a6SFrançois Tigeot #endif	/* _LINUX_SLAB_H_ */
45