Commit 7334e285 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Greg Kroah-Hartman

ptr_ring: fix up after recent ptr_ring changes

[ Upstream commit 5790eabc ]

Add more stubs to make it build.

Fixes: 81fbfe8a ("ptr_ring: use kmalloc_array()")
Signed-off-by: 's avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
parent 503c3941
......@@ -15,24 +15,41 @@
#define unlikely(x) (__builtin_expect(!!(x), 0))
#define likely(x) (__builtin_expect(!!(x), 1))
#define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a))
#define SIZE_MAX (~(size_t)0)
typedef pthread_spinlock_t spinlock_t;
typedef int gfp_t;
static void *kmalloc(unsigned size, gfp_t gfp)
{
return memalign(64, size);
}
#define __GFP_ZERO 0x1
static void *kzalloc(unsigned size, gfp_t gfp)
static void *kmalloc(unsigned size, gfp_t gfp)
{
void *p = memalign(64, size);
if (!p)
return p;
memset(p, 0, size);
if (gfp & __GFP_ZERO)
memset(p, 0, size);
return p;
}
static inline void *kzalloc(unsigned size, gfp_t flags)
{
return kmalloc(size, flags | __GFP_ZERO);
}
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);
}
static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
{
return kmalloc_array(n, size, flags | __GFP_ZERO);
}
static void kfree(void *p)
{
if (p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment