diff mbox series

[bpf-next] libbpf: add _GNU_SOURCE for reallocarray to ringbuf.c

Message ID 20200601202601.2139477-1-andriin@fb.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf-next] libbpf: add _GNU_SOURCE for reallocarray to ringbuf.c | expand

Commit Message

Andrii Nakryiko June 1, 2020, 8:26 p.m. UTC
On systems with recent enough glibc, reallocarray compat won't kick in, so
reallocarray() itself has to come from stdlib.h include. But _GNU_SOURCE is
necessary to enable it. So add it.

Fixes: 4cff2ba58bf1 ("libbpf: Add BPF ring buffer support")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/ringbuf.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Song Liu June 1, 2020, 8:35 p.m. UTC | #1
On Mon, Jun 1, 2020 at 1:26 PM Andrii Nakryiko <andriin@fb.com> wrote:
>
> On systems with recent enough glibc, reallocarray compat won't kick in, so
> reallocarray() itself has to come from stdlib.h include. But _GNU_SOURCE is
> necessary to enable it. So add it.
>
> Fixes: 4cff2ba58bf1 ("libbpf: Add BPF ring buffer support")
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Acked-by: Song Liu <songliubraving@fb.com>
Alexei Starovoitov June 1, 2020, 10:14 p.m. UTC | #2
On Mon, Jun 1, 2020 at 1:36 PM Song Liu <song@kernel.org> wrote:
>
> On Mon, Jun 1, 2020 at 1:26 PM Andrii Nakryiko <andriin@fb.com> wrote:
> >
> > On systems with recent enough glibc, reallocarray compat won't kick in, so
> > reallocarray() itself has to come from stdlib.h include. But _GNU_SOURCE is
> > necessary to enable it. So add it.
> >
> > Fixes: 4cff2ba58bf1 ("libbpf: Add BPF ring buffer support")
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
>
> Acked-by: Song Liu <songliubraving@fb.com>

Applied. Thanks
diff mbox series

Patch

diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c
index bc10fa1d43c7..4fc6c6cbb4eb 100644
--- a/tools/lib/bpf/ringbuf.c
+++ b/tools/lib/bpf/ringbuf.c
@@ -4,6 +4,9 @@ 
  *
  * Copyright (C) 2020 Facebook, Inc.
  */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>