mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
tools/virtio: fix build for kmalloc_obj API and missing stubs
Add stubs for kmalloc_obj() and kmalloc_objs() to the tools/virtio test harness, matching the new kernel allocator API. Also add the DMA_ATTR_CPU_CACHE_CLEAN definition and include kernel.h from err.h for the unlikely() macro. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <a0bd4b5bed56c49626c92a754d7aceab3325de25.1780520728.git.mst@redhat.com>
This commit is contained in:
@@ -60,4 +60,6 @@ enum dma_data_direction {
|
||||
*/
|
||||
#define DMA_MAPPING_ERROR (~(dma_addr_t)0)
|
||||
|
||||
#define DMA_ATTR_CPU_CACHE_CLEAN (1UL << 11)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef ERR_H
|
||||
#define ERR_H
|
||||
#include <linux/kernel.h>
|
||||
#define MAX_ERRNO 4095
|
||||
|
||||
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
|
||||
|
||||
@@ -65,6 +65,12 @@ static inline void *kmalloc_array(unsigned n, size_t s, gfp_t gfp)
|
||||
return kmalloc(n * s, gfp);
|
||||
}
|
||||
|
||||
#define kmalloc_obj(VAR_OR_TYPE, ...) \
|
||||
((typeof(VAR_OR_TYPE) *)kmalloc(sizeof(typeof(VAR_OR_TYPE)), 0))
|
||||
|
||||
#define kmalloc_objs(VAR_OR_TYPE, COUNT, ...) \
|
||||
((typeof(VAR_OR_TYPE) *)kmalloc(sizeof(typeof(VAR_OR_TYPE)) * (COUNT), 0))
|
||||
|
||||
static inline void *kzalloc(size_t s, gfp_t gfp)
|
||||
{
|
||||
void *p = kmalloc(s, gfp);
|
||||
|
||||
Reference in New Issue
Block a user