[07/10] examples/vhost_blk: fix build with pkg-config

Message ID 20201110151219.4893-8-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Series Examples compilation fixes |


Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand Nov. 10, 2020, 3:12 p.m. UTC
  vhost_blk.c: In function ‘ctrlr_worker’:
vhost_blk.c:543:2: warning: implicit declaration of function ‘CPU_ZERO’
  543 |  CPU_ZERO(&cpuset);
      |  ^~~~~~~~
vhost_blk.c:544:2: warning: implicit declaration of function ‘CPU_SET’
  544 |  CPU_SET(0, &cpuset);
      |  ^~~~~~~
vhost_blk.c:545:2: warning: implicit declaration of function
‘pthread_setaffinity_np’ [-Wimplicit-function-declaration]
  545 |  pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
      |  ^~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cczpiMWH.o: in function `ctrlr_worker':
vhost_blk.c:(.text+0x1076): undefined reference to `CPU_ZERO'
/usr/bin/ld: vhost_blk.c:(.text+0x1082): undefined reference to
collect2: error: ld returned 1 exit status
gmake: *** [Makefile:34: build/vhost-blk-shared] Error 1

Explicitly pass _GNU_SOURCE and include missing headers (rather than
rely on automagic inclusion from other system headers).

Fixes: c19beb3f38cd ("examples/vhost_blk: introduce vhost storage sample")

Signed-off-by: David Marchand <david.marchand@redhat.com>
 examples/vhost_blk/vhost_blk.c | 6 ++++++
 1 file changed, 6 insertions(+)


diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 8f5d61a589..bb293d492f 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -2,6 +2,12 @@ 
  * Copyright(c) 2010-2019 Intel Corporation
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#include <pthread.h>
+#include <sched.h>
 #include <stdint.h>
 #include <unistd.h>
 #include <stdbool.h>