Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Add kcalloc to ...



details:   https://anonhg.NetBSD.org/src/rev/ec3aa8cc9bf4
branches:  riastradh-drm2
changeset: 788138:ec3aa8cc9bf4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 24 02:24:44 2013 +0000

description:
Add kcalloc to <linux/slab.h>.

diffstat:

 sys/external/bsd/drm2/include/linux/slab.h |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (32 lines):

diff -r 98c7e87ff49b -r ec3aa8cc9bf4 sys/external/bsd/drm2/include/linux/slab.h
--- a/sys/external/bsd/drm2/include/linux/slab.h        Wed Jul 24 02:24:29 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/slab.h        Wed Jul 24 02:24:44 2013 +0000
@@ -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 @@
 }
 
 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);



Home | Main Index | Thread Index | Old Index