Commit 727dad10 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar

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: default avatarArnaldo 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: default avatarIngo Molnar <mingo@elte.hu>
parent 36479484
...@@ -290,17 +290,10 @@ static inline char *gitstrchrnul(const char *s, int c) ...@@ -290,17 +290,10 @@ static inline char *gitstrchrnul(const char *s, int c)
* Wrappers: * Wrappers:
*/ */
extern char *xstrdup(const char *str); extern char *xstrdup(const char *str);
extern void *xmalloc(size_t size); extern void *xmalloc(size_t size) __attribute__((weak));
extern void *xmemdupz(const void *data, size_t len); extern void *xmemdupz(const void *data, size_t len);
extern char *xstrndup(const char *str, size_t len); extern char *xstrndup(const char *str, size_t len);
extern void *xrealloc(void *ptr, size_t size); extern void *xrealloc(void *ptr, size_t size) __attribute__((weak));
extern void *xcalloc(size_t nmemb, size_t size);
extern void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
extern ssize_t xread(int fd, void *buf, size_t len);
extern ssize_t xwrite(int fd, const void *buf, size_t len);
extern int xdup(int fd);
extern FILE *xfdopen(int fd, const char *mode);
extern int xmkstemp(char *template);
static inline void *zalloc(size_t size) static inline void *zalloc(size_t size)
{ {
......
...@@ -79,43 +79,12 @@ void *xrealloc(void *ptr, size_t size) ...@@ -79,43 +79,12 @@ void *xrealloc(void *ptr, size_t size)
return ret; return ret;
} }
void *xcalloc(size_t nmemb, size_t size)
{
void *ret = calloc(nmemb, size);
if (!ret && (!nmemb || !size))
ret = calloc(1, 1);
if (!ret) {
release_pack_memory(nmemb * size, -1);
ret = calloc(nmemb, size);
if (!ret && (!nmemb || !size))
ret = calloc(1, 1);
if (!ret)
die("Out of memory, calloc failed");
}
return ret;
}
void *xmmap(void *start, size_t length,
int prot, int flags, int fd, off_t offset)
{
void *ret = mmap(start, length, prot, flags, fd, offset);
if (ret == MAP_FAILED) {
if (!length)
return NULL;
release_pack_memory(length, fd);
ret = mmap(start, length, prot, flags, fd, offset);
if (ret == MAP_FAILED)
die("Out of memory? mmap failed: %s", strerror(errno));
}
return ret;
}
/* /*
* xread() is the same a read(), but it automatically restarts read() * xread() is the same a read(), but it automatically restarts read()
* operations with a recoverable error (EAGAIN and EINTR). xread() * operations with a recoverable error (EAGAIN and EINTR). xread()
* DOES NOT GUARANTEE that "len" bytes is read even if the data is available. * DOES NOT GUARANTEE that "len" bytes is read even if the data is available.
*/ */
ssize_t xread(int fd, void *buf, size_t len) static ssize_t xread(int fd, void *buf, size_t len)
{ {
ssize_t nr; ssize_t nr;
while (1) { while (1) {
...@@ -131,7 +100,7 @@ ssize_t xread(int fd, void *buf, size_t len) ...@@ -131,7 +100,7 @@ ssize_t xread(int fd, void *buf, size_t len)
* operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
* GUARANTEE that "len" bytes is written even if the operation is successful. * GUARANTEE that "len" bytes is written even if the operation is successful.
*/ */
ssize_t xwrite(int fd, const void *buf, size_t len) static ssize_t xwrite(int fd, const void *buf, size_t len)
{ {
ssize_t nr; ssize_t nr;
while (1) { while (1) {
...@@ -179,29 +148,3 @@ ssize_t write_in_full(int fd, const void *buf, size_t count) ...@@ -179,29 +148,3 @@ ssize_t write_in_full(int fd, const void *buf, size_t count)
return total; return total;
} }
int xdup(int fd)
{
int ret = dup(fd);
if (ret < 0)
die("dup failed: %s", strerror(errno));
return ret;
}
FILE *xfdopen(int fd, const char *mode)
{
FILE *stream = fdopen(fd, mode);
if (stream == NULL)
die("Out of memory? fdopen failed: %s", strerror(errno));
return stream;
}
int xmkstemp(char *template)
{
int fd;
fd = mkstemp(template);
if (fd < 0)
die("Unable to create temporary file: %s", strerror(errno));
return fd;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment