Skip to content

Commit 0eeee5f

Browse files
mstsirkingregkh
authored andcommitted
tools/virtio: fix build
[ Upstream commit a24ce06 ] We use a spinlock now so add a stub. Ignore bogus uninitialized variable warnings. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2aef43a commit 0eeee5f

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

‎tools/virtio/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ test: virtio_test vringh_test
44
virtio_test: virtio_ring.o virtio_test.o
55
vringh_test: vringh_test.o vringh.o virtio_ring.o
66

7-
CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h
7+
CFLAGS += -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h
8+
LDFLAGS += -lpthread
89
vpath %.c ../../drivers/virtio ../../drivers/vhost
910
mod:
1011
${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}

‎tools/virtio/linux/spinlock.h‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef SPINLOCK_H_STUB
2+
#define SPINLOCK_H_STUB
3+
4+
#include <pthread.h>
5+
6+
typedef pthread_spinlock_t spinlock_t;
7+
8+
static inline void spin_lock_init(spinlock_t *lock)
9+
{
10+
int r = pthread_spin_init(lock, 0);
11+
assert(!r);
12+
}
13+
14+
static inline void spin_lock(spinlock_t *lock)
15+
{
16+
int ret = pthread_spin_lock(lock);
17+
assert(!ret);
18+
}
19+
20+
static inline void spin_unlock(spinlock_t *lock)
21+
{
22+
int ret = pthread_spin_unlock(lock);
23+
assert(!ret);
24+
}
25+
26+
static inline void spin_lock_bh(spinlock_t *lock)
27+
{
28+
spin_lock(lock);
29+
}
30+
31+
static inline void spin_unlock_bh(spinlock_t *lock)
32+
{
33+
spin_unlock(lock);
34+
}
35+
36+
static inline void spin_lock_irq(spinlock_t *lock)
37+
{
38+
spin_lock(lock);
39+
}
40+
41+
static inline void spin_unlock_irq(spinlock_t *lock)
42+
{
43+
spin_unlock(lock);
44+
}
45+
46+
static inline void spin_lock_irqsave(spinlock_t *lock, unsigned long f)
47+
{
48+
spin_lock(lock);
49+
}
50+
51+
static inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long f)
52+
{
53+
spin_unlock(lock);
54+
}
55+
56+
#endif

‎tools/virtio/linux/virtio.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define LINUX_VIRTIO_H
44
#include <linux/scatterlist.h>
55
#include <linux/kernel.h>
6+
#include <linux/spinlock.h>
67

78
struct device {
89
void *parent;
@@ -12,6 +13,7 @@ struct virtio_device {
1213
struct device dev;
1314
u64 features;
1415
struct list_head vqs;
16+
spinlock_t vqs_list_lock;
1517
};
1618

1719
struct virtqueue {

0 commit comments

Comments
 (0)