* [PATCH] perf: add GCC optimization to memory allocating functions
@ 2010-11-26 13:24 Davidlohr Bueso
2010-11-26 13:27 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Davidlohr Bueso @ 2010-11-26 13:24 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ingo Molnar, Paul Mackerras, Peter Zijlstra, LKML
From: Davidlohr Bueso <dave@gnu.org>
We can benefit from the alloc_size attribute in xrealloc and zalloc.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
tools/perf/util/util.h | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 7562707..41a5067 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -182,10 +182,11 @@ static inline char *gitstrchrnul(const char *s, int c)
* Wrappers:
*/
extern char *xstrdup(const char *str);
-extern void *xrealloc(void *ptr, size_t size) __attribute__((weak));
+extern void *xrealloc(void *ptr, size_t size) __attribute__((weak, alloc_size(2)));
-static inline void *zalloc(size_t size)
+static inline __attribute__((alloc_size(1)))
+void *zalloc(size_t size)
{
return calloc(1, size);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf: add GCC optimization to memory allocating functions
2010-11-26 13:24 [PATCH] perf: add GCC optimization to memory allocating functions Davidlohr Bueso
@ 2010-11-26 13:27 ` Peter Zijlstra
2010-11-26 13:36 ` Davidlohr Bueso
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2010-11-26 13:27 UTC (permalink / raw)
To: dave; +Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Paul Mackerras, LKML
On Fri, 2010-11-26 at 10:24 -0300, Davidlohr Bueso wrote:
> From: Davidlohr Bueso <dave@gnu.org>
>
> We can benefit from the alloc_size attribute in xrealloc and zalloc.
What's this alloc_size attribute do?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf: add GCC optimization to memory allocating functions
2010-11-26 13:27 ` Peter Zijlstra
@ 2010-11-26 13:36 ` Davidlohr Bueso
0 siblings, 0 replies; 3+ messages in thread
From: Davidlohr Bueso @ 2010-11-26 13:36 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Paul Mackerras, LKML
On Fri, 2010-11-26 at 14:27 +0100, Peter Zijlstra wrote:
> On Fri, 2010-11-26 at 10:24 -0300, Davidlohr Bueso wrote:
> > From: Davidlohr Bueso <dave@gnu.org>
> >
> > We can benefit from the alloc_size attribute in xrealloc and zalloc.
>
> What's this alloc_size attribute do?
>
Quoting from http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html:
"The alloc_size attribute is used to tell the compiler that the function
return value points to memory, where the size is given by one or two of
the functions parameters. GCC uses this information to improve the
correctness of __builtin_object_size."
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-26 13:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-26 13:24 [PATCH] perf: add GCC optimization to memory allocating functions Davidlohr Bueso
2010-11-26 13:27 ` Peter Zijlstra
2010-11-26 13:36 ` Davidlohr Bueso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox