Module Name: src Committed By: riastradh Date: Wed Jul 24 01:59:05 UTC 2013
Modified Files: src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: slab.h Log Message: Add Linux-style kmalloc &c. to <linux/slab.h>. Defined in terms of malloc(9) with M_TEMP for now, since Linux's kfree doesn't pass the size, so using kmem(9) is inexpedient. To generate a diff of this commit: cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \ src/sys/external/bsd/drm2/include/linux/slab.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/include/linux/slab.h diff -u src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.2 --- src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.1 Wed Jul 24 00:33:12 2013 +++ src/sys/external/bsd/drm2/include/linux/slab.h Wed Jul 24 01:59:05 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: slab.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $ */ +/* $NetBSD: slab.h,v 1.1.2.2 2013/07/24 01:59:05 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -32,4 +32,30 @@ #ifndef _LINUX_SLAB_H_ #define _LINUX_SLAB_H_ +#include <sys/malloc.h> + +#include <uvm/uvm_extern.h> /* For PAGE_SIZE. */ + +/* XXX Should use kmem, but Linux kfree doesn't take the size. */ + +#define GFP_KERNEL M_WAITOK + +static inline void * +kmalloc(size_t size, int flags) +{ + return malloc(size, M_TEMP, flags); +} + +static inline void * +kzalloc(size_t size, int flags) +{ + return malloc(size, M_TEMP, (flags | M_ZERO)); +} + +static inline void +kfree(void *ptr) +{ + free(ptr, M_TEMP); +} + #endif /* _LINUX_SLAB_H_ */