Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/drm2/include/linux Define kvmalloc_array.



details:   https://anonhg.NetBSD.org/src/rev/c9e62c88c524
branches:  trunk
changeset: 1027873:c9e62c88c524
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:02:17 2021 +0000

description:
Define kvmalloc_array.

diffstat:

 sys/external/bsd/drm2/include/linux/mm.h |  13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diffs (34 lines):

diff -r c33fb24a2918 -r c9e62c88c524 sys/external/bsd/drm2/include/linux/mm.h
--- a/sys/external/bsd/drm2/include/linux/mm.h  Sun Dec 19 01:02:10 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/mm.h  Sun Dec 19 01:02:17 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mm.h,v 1.13 2020/02/23 15:46:40 ad Exp $       */
+/*     $NetBSD: mm.h,v 1.14 2021/12/19 01:02:17 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 
 #include <asm/page.h>
 #include <linux/shrinker.h>
+#include <linux/slab.h>
 
 struct file;
 
@@ -80,6 +81,16 @@
        return uvmexp.npages;
 }
 
+static inline void *
+kvmalloc_array(size_t nelem, size_t elemsize, gfp_t gfp)
+{
+
+       KASSERT(elemsize != 0);
+       if (nelem > SIZE_MAX/elemsize)
+               return NULL;
+       return kmalloc(nelem * elemsize, gfp);
+}
+
 /*
  * XXX Requires that kmalloc in <linux/slab.h> and vmalloc in
  * <linux/vmalloc.h> both use malloc(9).  If you change either of



Home | Main Index | Thread Index | Old Index