mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 05:02:12 +00:00
ptr_ring: fix up after recent ptr_ring changes
Add more stubs to make it build.
Fixes: 81fbfe8a
("ptr_ring: use kmalloc_array()")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
03e9f8a05b
commit
5790eabc6e
@ -16,24 +16,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)
|
||||
|
Loading…
Reference in New Issue
Block a user