diff options
-rw-r--r-- | libiberty/Makefile.in | 17 | ||||
-rwxr-xr-x | libiberty/configure | 240 | ||||
-rw-r--r-- | libiberty/configure.ac | 7 | ||||
-rw-r--r-- | libiberty/neutral.c | 34 |
4 files changed, 292 insertions, 6 deletions
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index ef35453c0..d43b56c83 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -122,7 +122,7 @@ COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR) $(HDEFINES) @a # (alphabetical), and add them to REQUIRED_OFILES, or # CONFIGURED_OFILES and funcs in configure.ac. Also run "make maint-deps" # to build the new rules. -CFILES = alloca.c argv.c asprintf.c atexit.c \ +CFILES = neutral.c alloca.c argv.c asprintf.c atexit.c \ basename.c bcmp.c bcopy.c bsearch.c bzero.c \ calloc.c choose-temp.c clock.c concat.c cp-demangle.c \ cp-demint.c cplus-dem.c crc32.c \ @@ -161,7 +161,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \ # These are always included in the library. The first four are listed # first and by compile time to optimize parallel builds. -REQUIRED_OFILES = \ +REQUIRED_OFILES = ./neutral.$(objext) \ ./regex.$(objext) ./cplus-dem.$(objext) ./cp-demangle.$(objext) \ ./md5.$(objext) ./sha1.$(objext) ./alloca.$(objext) \ ./argv.$(objext) \ @@ -590,7 +590,7 @@ $(CONFIGURED_OFILES): stamp-picdir ./cp-demangle.$(objext): $(srcdir)/cp-demangle.c config.h $(INCDIR)/ansidecl.h \ $(srcdir)/cp-demangle.h $(INCDIR)/demangle.h \ - $(INCDIR)/dyn-string.h $(INCDIR)/getopt.h $(INCDIR)/libiberty.h + $(INCDIR)/dyn-string.h $(INCDIR)/libiberty.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/cp-demangle.c -o pic/$@; \ else true; fi @@ -680,14 +680,13 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/getcwd.c $(OUTPUT_OPTION) -./getopt.$(objext): $(srcdir)/getopt.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/getopt.h +./getopt.$(objext): $(srcdir)/getopt.c config.h $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/getopt.c -o pic/$@; \ else true; fi $(COMPILE.c) $(srcdir)/getopt.c $(OUTPUT_OPTION) -./getopt1.$(objext): $(srcdir)/getopt1.c config.h $(INCDIR)/getopt.h +./getopt1.$(objext): $(srcdir)/getopt1.c config.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/getopt1.c -o pic/$@; \ else true; fi @@ -1240,3 +1239,9 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/xstrndup.c $(OUTPUT_OPTION) + +./neutral.$(objext): $(srcdir)/neutral.c + if [ x"$(PICFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(srcdir)/neutral.c -o pic/$@; \ + else true; fi + $(COMPILE.c) $(srcdir)/neutral.c $(OUTPUT_OPTION) diff --git a/libiberty/configure b/libiberty/configure index bdabe8d1a..236c052bc 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -12,6 +12,13 @@ ## M4sh Initialization. ## ## -------------------- ## + +# cbb: modern system defaults +if [ x"$cbb_neutral_libiberty" = x ]; then + cbb_neutral_libiberty=yes +fi + + # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : @@ -8204,3 +8211,236 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi + +if [ $cbb_neutral_libiberty = yes ]; then +# recreate config.h so that it correctly accounts for code already +# implemented in modern libc's + + +rm -f config.h +cat > config.h << __CONFIGURE_EOF + +/* this header was generated by libiberty/configure */ + +/* helper definitions */ +#define HAVE_CONFIG_H 1 +#define _GNU_SOURCE 1 + +/* libc includes */ +#include <stdarg.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <stddef.h> +#include <errno.h> +#include <getopt.h> +#include <signal.h> +#include <pthread.h> +#include <string.h> +#include <strings.h> +#include <sys/wait.h> + +/* libc symbols with DECL_ prefix(?) */ +#define HAVE_DECL_SBRK 1 /* used in xmalloc.c */ +#define HAVE_DECL_ASPRINTF 1 +#define HAVE_DECL_BASENAME 1 +#define HAVE_DECL_CALLOC 1 +#define HAVE_DECL_FFS 1 +#define HAVE_DECL_GETENV 1 +#define HAVE_DECL_PUTENV 1 +#define HAVE_DECL_SETENV 1 +#define HAVE_DECL_GETOPT 1 +#define HAVE_DECL_MALLOC 1 +#define HAVE_DECL_REALLOC 1 +#define HAVE_DECL_SNPRINTF 1 +#define HAVE_DECL_STRVERSCMP 1 +#define HAVE_DECL_VASPRINTF 1 +#define HAVE_DECL_VSNPRINTF 1 + +/* additional meta information */ +#define HAVE_SBRK 1 /* used in xmalloc.c */ +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_PSIGNAL 1 +#define HAVE_REGCOMP 1 +#define HAVE_WORKING_FORK 1 +#define HAVE_WORKING_VFORK 1 +#define HAVE___FSETLOCKING 1 +#define PACKAGE_BUGREPORT "" +#define PACKAGE_NAME "" +#define PACKAGE_STRING "" +#define PACKAGE_TARNAME "" +#define PACKAGE_URL "" +#define PACKAGE_VERSION "" +#define SIZEOF_INT 4 +#define STACK_DIRECTION -1 /* all modern targets */ +#define STDC_HEADERS 1 +#define UNSIGNED_64BIT_TYPE uint64_t + +#define HAVE_AIO_H 1 +#define HAVE_ALLOCA_H 1 +#define HAVE_AR_H 1 +#define HAVE_ASSERT_H 1 +#define HAVE_BYTESWAP_H 1 +#define HAVE_COMPLEX_H 1 +#define HAVE_CPIO_H 1 +#define HAVE_CRYPT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_DIRENT_H 1 +#define HAVE_DLFCN_H 1 +#define HAVE_ELF_H 1 +#define HAVE_ENDIAN_H 1 +#define HAVE_ERR_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_FEATURES_H 1 +#define HAVE_FENV_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_FMTMSG_H 1 +#define HAVE_FNMATCH_H 1 +#define HAVE_FTW_H 1 +#define HAVE_GELF_H 1 +#define HAVE_GETOPT_H 1 +#define HAVE_GLOB_H 1 +#define HAVE_GMP_H 1 +#define HAVE_GRP_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_IFADDRS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_ISO646_H 1 +#define HAVE_LANGINFO_H 1 +#define HAVE_LASTLOG_H 1 +#define HAVE_LIBELF_H 1 +#define HAVE_LIBGEN_H 1 +#define HAVE_LIBINTL_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_LINK_H 1 +#define HAVE_LOCALE_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MATH_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_MNTENT_H 1 +#define HAVE_MONETARY_H 1 +#define HAVE_MPC_H 1 +#define HAVE_MPF2MPFR_H 1 +#define HAVE_MPFR_H 1 +#define HAVE_MQUEUE_H 1 +#define HAVE_NETDB_H 1 +#define HAVE_NLIST_H 1 +#define HAVE_NL_TYPES_H 1 +#define HAVE_PATHS_H 1 +#define HAVE_POLL_H 1 +#define HAVE_PTHREAD_H 1 +#define HAVE_PTY_H 1 +#define HAVE_PWD_H 1 +#define HAVE_REGEX_H 1 +#define HAVE_RESOLV_H 1 +#define HAVE_SCHED_H 1 +#define HAVE_SEARCH_H 1 +#define HAVE_SEMAPHORE_H 1 +#define HAVE_SETJMP_H 1 +#define HAVE_SHADOW_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_SPAWN_H 1 +#define HAVE_STDALIGN_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_EXT_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDNORETURN_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STROPTS_H 1 +#define HAVE_SYSCALL_H 1 +#define HAVE_SYSEXITS_H 1 +#define HAVE_SYSLOG_H 1 +#define HAVE_TAR_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_TGMATH_H 1 +#define HAVE_THREADS_H 1 +#define HAVE_TIME_H 1 +#define HAVE_UCHAR_H 1 +#define HAVE_UCONTEXT_H 1 +#define HAVE_ULIMIT_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_UTIME_H 1 +#define HAVE_UTMP_H 1 +#define HAVE_UTMPX_H 1 +#define HAVE_VALUES_H 1 +#define HAVE_WAIT_H 1 +#define HAVE_WCHAR_H 1 +#define HAVE_WCTYPE_H 1 +#define HAVE_WORDEXP_H 1 +#define HAVE_SYS_ACCT_H 1 +#define HAVE_SYS_AUXV_H 1 +#define HAVE_SYS_CACHECTL_H 1 +#define HAVE_SYS_DIR_H 1 +#define HAVE_SYS_EPOLL_H 1 +#define HAVE_SYS_ERRNO_H 1 +#define HAVE_SYS_EVENTFD_H 1 +#define HAVE_SYS_FANOTIFY_H 1 +#define HAVE_SYS_FCNTL_H 1 +#define HAVE_SYS_FILE_H 1 +#define HAVE_SYS_FSUID_H 1 +#define HAVE_SYS_INOTIFY_H 1 +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_SYS_IO_H 1 +#define HAVE_SYS_IPC_H 1 +#define HAVE_SYS_KD_H 1 +#define HAVE_SYS_KLOG_H 1 +#define HAVE_SYS_MMAN_H 1 +#define HAVE_SYS_MOUNT_H 1 +#define HAVE_SYS_MSG_H 1 +#define HAVE_SYS_MTIO_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_PERSONALITY_H 1 +#define HAVE_SYS_POLL_H 1 +#define HAVE_SYS_PRCTL_H 1 +#define HAVE_SYS_PROCFS_H 1 +#define HAVE_SYS_PTRACE_H 1 +#define HAVE_SYS_QUOTA_H 1 +#define HAVE_SYS_REBOOT_H 1 +#define HAVE_SYS_REG_H 1 +#define HAVE_SYS_RESOURCE_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SEM_H 1 +#define HAVE_SYS_SENDFILE_H 1 +#define HAVE_SYS_SHM_H 1 +#define HAVE_SYS_SIGNALFD_H 1 +#define HAVE_SYS_SIGNAL_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_SYS_SOUNDCARD_H 1 +#define HAVE_SYS_STATFS_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_STATVFS_H 1 +#define HAVE_SYS_STROPTS_H 1 +#define HAVE_SYS_SWAP_H 1 +#define HAVE_SYS_SYSCALL_H 1 +#define HAVE_SYS_SYSINFO_H 1 +#define HAVE_SYS_SYSLOG_H 1 +#define HAVE_SYS_SYSMACROS_H 1 +#define HAVE_SYS_TERMIOS_H 1 +#define HAVE_SYS_TIMEB_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TIMERFD_H 1 +#define HAVE_SYS_TIMES_H 1 +#define HAVE_SYS_TIMEX_H 1 +#define HAVE_SYS_TTYDEFAULTS_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_UCONTEXT_H 1 +#define HAVE_SYS_UIO_H 1 +#define HAVE_SYS_UN_H 1 +#define HAVE_SYS_USER_H 1 +#define HAVE_SYS_UTSNAME_H 1 +#define HAVE_SYS_VFS_H 1 +#define HAVE_SYS_VT_H 1 +#define HAVE_SYS_WAIT_H 1 +#define HAVE_SYS_XATTR_H 1 + +__CONFIGURE_EOF +fi diff --git a/libiberty/configure.ac b/libiberty/configure.ac index 9f1ff0493..d9a6bfbf3 100644 --- a/libiberty/configure.ac +++ b/libiberty/configure.ac @@ -1,5 +1,12 @@ dnl Process this file with autoconf to produce a configure script + +# cbb: modern system defaults +if [ x"$cbb_neutral_libiberty" = x]; then + cbb_neutral_libiberty=yes +fi + + AC_PREREQ(2.64) AC_INIT AC_CONFIG_SRCDIR([xmalloc.c]) 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); +} |