2009-12-02 06:37:28

by tip-bot for Liming Wang

[permalink] [raw]
Subject: [PATCH] perf tools: Add _GNU_SOURCE macro for strndup()

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

Signed-off-by: Liming Wang <[email protected]>
Acked-by: Frederic Weisbecker <[email protected]>
---
tools/perf/util/string.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 0977cf4..ea3eb39 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -1,5 +1,8 @@
+#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
+
+#undef _GNU_SOURCE
#include "string.h"
#include "util.h"

--
1.6.0.3


2009-12-02 08:12:30

by tip-bot for Liming Wang

[permalink] [raw]
Subject: Re: [PATCH] perf tools: Add _GNU_SOURCE macro for strndup()

Xiao Guangrong wrote:
>
> Liming Wang wrote:
>> strndup is a GNU extension. So add _GNU_SOURCE macro
>> to avoid compiling error.
>>
>> Signed-off-by: Liming Wang <[email protected]>
>> Acked-by: Frederic Weisbecker <[email protected]>
>> ---
>> tools/perf/util/string.c | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
>> index 0977cf4..ea3eb39 100644
>> --- a/tools/perf/util/string.c
>> +++ b/tools/perf/util/string.c
>> @@ -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
>
>> #include "string.h"
>> #include "util.h"
>>
>

2009-12-02 08:05:56

by Xiao Guangrong

[permalink] [raw]
Subject: Re: [PATCH] perf tools: Add _GNU_SOURCE macro for strndup()



Liming Wang wrote:
> strndup is a GNU extension. So add _GNU_SOURCE macro
> to avoid compiling error.
>
> Signed-off-by: Liming Wang <[email protected]>
> Acked-by: Frederic Weisbecker <[email protected]>
> ---
> tools/perf/util/string.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
> index 0977cf4..ea3eb39 100644
> --- a/tools/perf/util/string.c
> +++ b/tools/perf/util/string.c
> @@ -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.

> #include "string.h"
> #include "util.h"
>

2009-12-02 08:32:01

by tip-bot for Liming Wang

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

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.

Signed-off-by: Liming Wang <[email protected]>
Acked-by: Frederic Weisbecker <[email protected]>
Acked-by: Xiao Guangrong <[email protected]>
Cc: [email protected]
Cc: [email protected]
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/util/string.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 0977cf4..f24a8cc 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -1,5 +1,3 @@
-#include <string.h>
-#include <stdlib.h>
#include "string.h"
#include "util.h"