Module Name: src Committed By: riastradh Date: Sun Dec 19 01:02:17 UTC 2021
Modified Files: src/sys/external/bsd/drm2/include/linux: mm.h Log Message: Define kvmalloc_array. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/mm.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/mm.h diff -u src/sys/external/bsd/drm2/include/linux/mm.h:1.13 src/sys/external/bsd/drm2/include/linux/mm.h:1.14 --- src/sys/external/bsd/drm2/include/linux/mm.h:1.13 Sun Feb 23 15:46:40 2020 +++ src/sys/external/bsd/drm2/include/linux/mm.h Sun Dec 19 01:02:17 2021 @@ -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 @@ get_num_physpages(void) 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