Module Name:    src
Committed By:   riastradh
Date:           Wed Jul 24 02:24:44 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: slab.h

Log Message:
Add kcalloc to <linux/slab.h>.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    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.3 src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.3	Wed Jul 24 02:01:28 2013
+++ src/sys/external/bsd/drm2/include/linux/slab.h	Wed Jul 24 02:24:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: slab.h,v 1.1.2.3 2013/07/24 02:01:28 riastradh Exp $	*/
+/*	$NetBSD: slab.h,v 1.1.2.4 2013/07/24 02:24:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,6 +34,8 @@
 
 #include <sys/malloc.h>
 
+#include <machine/limits.h>
+
 #include <uvm/uvm_extern.h>	/* For PAGE_SIZE.  */
 
 /* XXX Should use kmem, but Linux kfree doesn't take the size.  */
@@ -53,6 +55,13 @@ kzalloc(size_t size, int flags)
 }
 
 static inline void *
+kcalloc(size_t n, size_t size, int flags)
+{
+	KASSERT((SIZE_MAX / n) <= size);
+	return malloc((n * size), M_TEMP, (flags | M_ZERO));
+}
+
+static inline void *
 krealloc(void *ptr, size_t size, int flags)
 {
 	return realloc(ptr, size, M_TEMP, flags);

Reply via email to