diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-02-09 10:50:44 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-02-09 10:50:44 +0000 |
commit | fd1a5bfb6a22ccc1be8c8b0d4944f31b96b8f490 (patch) | |
tree | 464e271f52d748c6736922ef0474ed2612346db8 /sys/dev | |
parent | 479e5dfe04dc4631a05931b8527186457e61d814 (diff) |
add some more linux compat functions for memory allocation
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 22 |
1 files changed, 21 insertions, 1 deletions
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 */ @@ -247,6 +247,14 @@ kmalloc(size_t size, int 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) { if (n == 0 || SIZE_MAX / n < size) @@ -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); \ |