Skip to contentSkip to conversation

perf tools: Add _GNU_SOURCE macro for strndup()

PATCH In review Liming Wang 2 participants 4 messages Dec 2, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Add _GNU_SOURCE macro for strndup()

strndup is a GNU extension. So add _GNU_SOURCE macro to avoid compiling error.

---
 tools/perf/util/string.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
tools/perf/util/string.c +3 -0
index 0977cf4..ea3eb39 100644
@@ -1,5 +1,8 @@
+#define _GNU_SOURCE
 #include <string.h>
 #include <stdlib.h>
+
+#undef _GNU_SOURCE
 #include "string.h"
 #include "util.h"
 
Signature · 1 line
1.6.0.3
#1 lore raw
Quoted 14 lines · Liming Wang

strndup is a GNU extension. So add _GNU_SOURCE macro to avoid compiling error.

---
 tools/perf/util/string.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
tools/perf/util/string.c +0 -0
index 0977cf4..ea3eb39 100644

tools/perf/util/string.c line 5

Quoted 5 lines
tools/perf/util/string.c +3 -0
@@ -1,5 +1,8 @@
+#define _GNU_SOURCE
 #include <string.h>
 #include <stdlib.h>
+
+#undef _GNU_SOURCE

I think those two "#include" can be removed,
because util.h include it.

Quoted 3 lines
tools/perf/util/string.c +0 -0
 #include "string.h"
 #include "util.h"
 
#2 lore raw
Quoted 11 lines · Xiao Guangrong
Quoted 9 lines · Liming Wang

strndup is a GNU extension. So add _GNU_SOURCE macro to avoid compiling error.

---
 tools/perf/util/string.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Quoted 13 lines

tools/perf/util/string.c line 5

Quoted 10 lines
tools/perf/util/string.c +3 -0
index 0977cf4..ea3eb39 100644
@@ -1,5 +1,8 @@
+#define _GNU_SOURCE
 #include <string.h>
 #include <stdlib.h>
+
+#undef _GNU_SOURCE

I think those two "#include" can be removed,
because util.h include it.

Agreed. It's a better method.

Liming Wang

Quoted 5 lines
Quoted 4 lines
tools/perf/util/string.c +0 -0
 #include "string.h"
 #include "util.h"
 
#3 lore raw

[tip:perf/core] perf tools: Fix _GNU_SOURCE macro related strndup() build error

In reply to Liming Wang
Commit-ID:  c19e33aa840e9202ef8d4c93056b59f3edc2208d
Gitweb:     http://git.kernel.org/tip/c19e33aa840e9202ef8d4c93056b59f3edc2208d
Author:     Liming Wang <[email protected]>
AuthorDate: Wed, 2 Dec 2009 14:11:46 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 2 Dec 2009 09:24:56 +0100

perf tools: Fix _GNU_SOURCE macro related strndup() build error

strndup is a GNU extension. So dont include string.h without defining _GNU_SOURCE (it results in a compile error otherwise).

Remove these includes as util.h does it already.

LKML-Reference: <[email protected]>

---
 tools/perf/util/string.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
tools/perf/util/string.c +0 -2
index 0977cf4..f24a8cc 100644
@@ -1,5 +1,3 @@
-#include <string.h>
-#include <stdlib.h>
 #include "string.h"
 #include "util.h"