Skip to contentSkip to conversation

libbpf: add _GNU_SOURCE for reallocarray to ringbuf.c

PATCH Applied Andrii Nakryiko 3 participants 3 messages Jun 1, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: add _GNU_SOURCE for reallocarray to ringbuf.c

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")
---
 tools/lib/bpf/ringbuf.c | 3 +++
 1 file changed, 3 insertions(+)
tools/lib/bpf/ringbuf.c +3 -0
index bc10fa1d43c7..4fc6c6cbb4eb 100644
@@ -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>
Signature · 1 line
2.24.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andrii Nakryiko

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")
#2 lore raw
Quoted 11 lines · Song Liu
Quoted 7 lines · Andrii Nakryiko

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")

Applied. Thanks