diff mbox series

[v2,08/11] examples/vhost_blk: fix build with pkg-config

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand Nov. 13, 2020, 12:24 p.m. UTC
vhost_blk.c: In function ‘ctrlr_worker’:
vhost_blk.c:543:2: warning: implicit declaration of function ‘CPU_ZERO’
[-Wimplicit-function-declaration]
  543 |  CPU_ZERO(&cpuset);
      |  ^~~~~~~~
vhost_blk.c:544:2: warning: implicit declaration of function ‘CPU_SET’
[-Wimplicit-function-declaration]
  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
`CPU_SET'
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>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/vhost_blk/vhost_blk.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Maxime Coquelin Nov. 13, 2020, 1 p.m. UTC | #1
On 11/13/20 1:24 PM, David Marchand wrote:
> vhost_blk.c: In function ‘ctrlr_worker’:
> vhost_blk.c:543:2: warning: implicit declaration of function ‘CPU_ZERO’
> [-Wimplicit-function-declaration]
>   543 |  CPU_ZERO(&cpuset);
>       |  ^~~~~~~~
> vhost_blk.c:544:2: warning: implicit declaration of function ‘CPU_SET’
> [-Wimplicit-function-declaration]
>   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
> `CPU_SET'
> 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>
> Acked-by: Bruce Richardson <bruce.richardson@intel.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
> +#endif
> +#include <pthread.h>
> +#include <sched.h>
> +
>  #include <stdint.h>
>  #include <unistd.h>
>  #include <stdbool.h>
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
diff mbox series

Patch

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
+#endif
+#include <pthread.h>
+#include <sched.h>
+
 #include <stdint.h>
 #include <unistd.h>
 #include <stdbool.h>