blob: 850020b6bcbd8bb8192d9eebebd06aac30723c57 [file] [log] [blame]
#ifndef __BACKPORT_SLAB_H
#define __BACKPORT_SLAB_H
#include_next <linux/slab.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
/* This backports:
*
* commit a8203725dfded5c1f79dca3368a4a273e24b59bb
* Author: Xi Wang <xi.wang@gmail.com>
* Date: Mon Mar 5 15:14:41 2012 -0800
*
* slab: introduce kmalloc_array()
*/
#include <linux/kernel.h> /* for SIZE_MAX */
#define kmalloc_array LINUX_BACKPORT(kmalloc_array)
static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
{
if (size != 0 && n > SIZE_MAX / size)
return NULL;
return __kmalloc(n * size, flags);
}
#endif
#endif /* __BACKPORT_SLAB_H */