| 1 | /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) |
| 2 | * |
| 3 | * wrapper/vzalloc.h |
| 4 | * |
| 5 | * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com> |
| 6 | */ |
| 7 | |
| 8 | #ifndef _LTTNG_WRAPPER_VZALLOC_H |
| 9 | #define _LTTNG_WRAPPER_VZALLOC_H |
| 10 | |
| 11 | #include <linux/version.h> |
| 12 | #include <linux/vmalloc.h> |
| 13 | |
| 14 | #if LTTNG_KERNEL_RANGE(2,6,36, 2,6,37) |
| 15 | static inline |
| 16 | void *lttng_vzalloc(unsigned long size) |
| 17 | { |
| 18 | void *ret; |
| 19 | ret = vmalloc(size); |
| 20 | if (!ret) |
| 21 | return NULL; |
| 22 | memset(ret, 0, size); |
| 23 | return ret; |
| 24 | } |
| 25 | #else |
| 26 | static inline |
| 27 | void *lttng_vzalloc(unsigned long size) |
| 28 | { |
| 29 | return vzalloc(size); |
| 30 | } |
| 31 | #endif |
| 32 | |
| 33 | |
| 34 | #endif /* _LTTNG_WRAPPER_VZALLOC_H */ |