diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-24 09:05:17 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-24 10:37:03 -0500 |
commit | 727dad10c17cbaade3cb6a56bd4863a4630f4d13 (patch) | |
tree | 3961f31b7c1a0b54b3c972b61937eb0a7ab2db0e /tools/perf | |
parent | 364794845cbc49e638b83d7ef739524291e1e961 (diff) |
perf tools: Remove unused wrapper routines
And also make xrealloc and xmalloc weak symbols so that we don't
have this problem:
/usr/lib/gcc/x86_64-redhat-linux/4.4.1/../../../../lib64/libiberty.a(xmalloc.o):
In function `xrealloc':
(.text+0xc0): multiple definition of `xrealloc'
libperf.a(wrapper.o):/home/acme_unencrypted/git/linux-2.6-tip/tools/perf/util/wrapper.c:67:
first defined here
collect2: ld returned 1 exit status
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1259071517-3242-4-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/util.h | 11 | ||||
-rw-r--r-- | tools/perf/util/wrapper.c | 61 |
2 files changed, 4 insertions, 68 deletions
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 30c5517f2f91..c673d8825883 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -290,17 +290,10 @@ static inline char *gitstrchrnul(const char *s, int c) | |||
290 | * Wrappers: | 290 | * Wrappers: |
291 | */ | 291 | */ |
292 | extern char *xstrdup(const char *str); | 292 | extern char *xstrdup(const char *str); |
293 | extern void *xmalloc(size_t size); | 293 | extern void *xmalloc(size_t size) __attribute__((weak)); |
294 | extern void *xmemdupz(const void *data, size_t len); | 294 | extern void *xmemdupz(const void *data, size_t len); |
295 | extern char *xstrndup(const char *str, size_t len); | 295 | extern char *xstrndup(const char *str, size_t len); |
296 | extern void *xrealloc(void *ptr, size_t size); | 296 | extern void *xrealloc(void *ptr, size_t size) __attribute__((weak)); |
297 | extern void *xcalloc(size_t nmemb, size_t size); | ||
298 | extern void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset); | ||
299 | extern ssize_t xread(int fd, void *buf, size_t len); | ||
300 | extern ssize_t xwrite(int fd, const void *buf, size_t len); | ||
301 | extern int xdup(int fd); | ||
302 | extern FILE *xfdopen(int fd, const char *mode); | ||
303 | extern int xmkstemp(char *template); | ||
304 | 297 | ||
305 | static inline void *zalloc(size_t size) | 298 | static inline void *zalloc(size_t size) |
306 | { | 299 | { |
diff --git a/tools/perf/util/wrapper.c b/tools/perf/util/wrapper.c index 4574ac28396f..bf44ca85d23b 100644 --- a/tools/perf/util/wrapper.c +++ b/tools/perf/util/wrapper.c | |||
@@ -79,43 +79,12 @@ void *xrealloc(void *ptr, size_t size) | |||
79 | return ret; | 79 | return ret; |
80 | } | 80 | } |
81 | 81 | ||
82 | void *xcalloc(size_t nmemb, size_t size) | ||
83 | { | ||
84 | void *ret = calloc(nmemb, size); | ||
85 | if (!ret && (!nmemb || !size)) | ||
86 | ret = calloc(1, 1); | ||
87 | if (!ret) { | ||
88 | release_pack_memory(nmemb * size, -1); | ||
89 | ret = calloc(nmemb, size); | ||
90 | if (!ret && (!nmemb || !size)) | ||
91 | ret = calloc(1, 1); | ||
92 | if (!ret) | ||
93 | die("Out of memory, calloc failed"); | ||
94 | } | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | void *xmmap(void *start, size_t length, | ||
99 | int prot, int flags, int fd, off_t offset) | ||
100 | { | ||
101 | void *ret = mmap(start, length, prot, flags, fd, offset); | ||
102 | if (ret == MAP_FAILED) { | ||
103 | if (!length) | ||
104 | return NULL; | ||
105 | release_pack_memory(length, fd); | ||
106 | ret = mmap(start, length, prot, flags, fd, offset); | ||
107 | if (ret == MAP_FAILED) | ||
108 | die("Out of memory? mmap failed: %s", strerror(errno)); | ||
109 | } | ||
110 | return ret; | ||
111 | } | ||
112 | |||
113 | /* | 82 | /* |
114 | * xread() is the same a read(), but it automatically restarts read() | 83 | * xread() is the same a read(), but it automatically restarts read() |
115 | * operations with a recoverable error (EAGAIN and EINTR). xread() | 84 | * operations with a recoverable error (EAGAIN and EINTR). xread() |
116 | * DOES NOT GUARANTEE that "len" bytes is read even if the data is available. | 85 | * DOES NOT GUARANTEE that "len" bytes is read even if the data is available. |
117 | */ | 86 | */ |
118 | ssize_t xread(int fd, void *buf, size_t len) | 87 | static ssize_t xread(int fd, void *buf, size_t len) |
119 | { | 88 | { |
120 | ssize_t nr; | 89 | ssize_t nr; |
121 | while (1) { | 90 | while (1) { |
@@ -131,7 +100,7 @@ ssize_t xread(int fd, void *buf, size_t len) | |||
131 | * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT | 100 | * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT |
132 | * GUARANTEE that "len" bytes is written even if the operation is successful. | 101 | * GUARANTEE that "len" bytes is written even if the operation is successful. |
133 | */ | 102 | */ |
134 | ssize_t xwrite(int fd, const void *buf, size_t len) | 103 | static ssize_t xwrite(int fd, const void *buf, size_t len) |
135 | { | 104 | { |
136 | ssize_t nr; | 105 | ssize_t nr; |
137 | while (1) { | 106 | while (1) { |
@@ -179,29 +148,3 @@ ssize_t write_in_full(int fd, const void *buf, size_t count) | |||
179 | 148 | ||
180 | return total; | 149 | return total; |
181 | } | 150 | } |
182 | |||
183 | int xdup(int fd) | ||
184 | { | ||
185 | int ret = dup(fd); | ||
186 | if (ret < 0) | ||
187 | die("dup failed: %s", strerror(errno)); | ||
188 | return ret; | ||
189 | } | ||
190 | |||
191 | FILE *xfdopen(int fd, const char *mode) | ||
192 | { | ||
193 | FILE *stream = fdopen(fd, mode); | ||
194 | if (stream == NULL) | ||
195 | die("Out of memory? fdopen failed: %s", strerror(errno)); | ||
196 | return stream; | ||
197 | } | ||
198 | |||
199 | int xmkstemp(char *template) | ||
200 | { | ||
201 | int fd; | ||
202 | |||
203 | fd = mkstemp(template); | ||
204 | if (fd < 0) | ||
205 | die("Unable to create temporary file: %s", strerror(errno)); | ||
206 | return fd; | ||
207 | } | ||