diff options
author | midipix <writeonce@midipix.org> | 2015-03-15 21:23:01 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2015-03-15 21:23:01 -0400 |
commit | 85dfca6c714af903bb4d0175402c0be4a9061309 (patch) | |
tree | 2a6432df290f600285b238617c24e777d61c64bd /libiberty/neutral.c | |
parent | a065efe48a05850452a90a89c2d78f09358f4e79 (diff) | |
download | cbb-gcc-4.6.4-85dfca6c714af903bb4d0175402c0be4a9061309.tar.bz2 cbb-gcc-4.6.4-85dfca6c714af903bb4d0175402c0be4a9061309.tar.xz |
libiberty: neutral.c: provide x-prefixed variants of standard interfaces
for backward compatibility, and adjust the build-system accordingly.
signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information.
Diffstat (limited to 'libiberty/neutral.c')
-rw-r--r-- | libiberty/neutral.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libiberty/neutral.c b/libiberty/neutral.c new file mode 100644 index 000000000..a92ff1a0a --- /dev/null +++ b/libiberty/neutral.c @@ -0,0 +1,34 @@ +#define _GNU_SOURCE + +#include <stddef.h> +#include <errno.h> +#include <unistd.h> +#include <stdio.h> + +#include <config.h> + +void xexit(int status) {_exit(status); return;} +int xatexit(void (*function)(void)) {return atexit(function);} +void * xcalloc(size_t nmemb, size_t size) {return calloc(nmemb,size);} +void * xrealloc(void *ptr, size_t size) {return realloc(ptr,size);} +char * xstrdup(const char *s) {return strdup(s);} +char * xstrndup(const char *s, size_t n) {return strndup(s,n);} +char * xstrerror(int errnum) {return strerror(errnum);} +void * xmalloc(size_t block_size) {return malloc(block_size);} + +void * xmemdup (const void * src, size_t copy_size, size_t alloc_size) +{ + void * dst = calloc (1, alloc_size); + return dst ? memcpy(dst, src, copy_size) : 0; +} + +void xmalloc_set_program_name (const char *s) +{ + return; +} + +void xmalloc_failed (size_t size) +{ + fputs("malloc failed, aborting.\n\0",stderr); + _exit(1); +} |