From fd1a5bfb6a22ccc1be8c8b0d4944f31b96b8f490 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Sun, 9 Feb 2014 10:50:44 +0000 Subject: add some more linux compat functions for memory allocation --- sys/dev/pci/drm/drmP.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 7cdeb084883..d90a9a80451 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -1,4 +1,4 @@ -/* $OpenBSD: drmP.h,v 1.166 2014/02/04 22:19:53 kettenis Exp $ */ +/* $OpenBSD: drmP.h,v 1.167 2014/02/09 10:50:43 jsg Exp $ */ /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com */ @@ -246,6 +246,14 @@ kmalloc(size_t size, int flags) return malloc(size, M_DRM, flags); } +static inline void * +kmalloc_array(size_t n, size_t size, int flags) +{ + if (n == 0 || SIZE_MAX / n < size) + return NULL; + return malloc(n * size, M_DRM, flags); +} + static inline void * kcalloc(size_t n, size_t size, int flags) { @@ -266,6 +274,18 @@ kfree(void *objp) free(objp, M_DRM); } +static inline void * +vzalloc(unsigned long size) +{ + return malloc(size, M_DRM, M_WAITOK | M_CANFAIL | M_ZERO); +} + +static inline void +vfree(void *objp) +{ + free(objp, M_DRM); +} + #define min_t(t, a, b) ({ \ t __min_a = (a); \ t __min_b = (b); \ -- cgit v1.2.3