C99 bfd configury

Message ID 20210405055211.GG5425@bubble.grove.modra.org
State New
Headers show
Series
  • C99 bfd configury
Related show

Commit Message

Nick Clifton via Binutils April 5, 2021, 5:52 a.m.
Certain library headers and functions are required by C99.  This
removes configure tests for them.  The patch also removes AC_ISC_POSIX
and AC_HEADER_DIRENT, which the autoconf manual states are obsolescent.
sys/time.h is no longer tangled up with time.h so it can be handled by
the gprof configure.

	* configure.ac: Don't check for long long or long double type.
	Don't check for alloca.h, limits.h, stddef.h, stdlib.h, string.h,
	strings.h, time.h, wchar.h, wctype.h or sys/time.h.  Don't check
	for strtoull, free, malloc, realloc, getenv, strstr, snprintf,
	vsnprintf, strlen or setitimer.  Sort AC_CHECK_DECLS.
	(AC_ISC_POSIX): Don't invoke.
	(AC_HEADER_TIME, AC_HEADER_DIRENT, ACX_HEADER_STRING): Likewise.
	* sysdep.h: Remove many HAVE_*_H checks and fallback declarations.
	Do test HAVE_SYS_TYPES_H.  Don't include sys/time.h.  Reorder
	header order as per automake AC_INCLUDES_DEFAULT.
	* bfd-in.h: Include inttypes.h unconditionally.
	* bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Assume long long and
	long double are available.
	(bfd_scan_vma): Assume long long and strtoull are available.
	* elflink.c: Include limits.h unconditionally.
	* elfnn-riscv.c: Likewise.
	* wasm-module.c: Likewise.
	* hpux-core.c: Include dirent.h unconditionally.
	* trad-core.c: Likewise.
	* hosts/x86-64linux.h: Include stdlib.h unconditionally.
	* peXXigen.c: Remove HAVE_WCHAR_H and HAVE_WCTYPE_H checks.
	* elf32-m68hc1x.c: Don't include alloca-conf.h.
	* elf64-hppa.c: Likewise.
	* som.c: Likewise.
	* wasm-module.c: Likewise.
	* xsym.c: Likewise.
	* bfd-in2.h: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 1fbccca4161..a4888f9f7f2 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -78,23 +78,7 @@  typedef BFD_HOST_64_BIT bfd_int64_t;
 typedef BFD_HOST_U_64_BIT bfd_uint64_t;
 #endif
 
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if BFD_HOST_64BIT_LONG
-#  define BFD_PRI64 "l"
-# elif defined (__MSVCRT__)
-#  define BFD_PRI64 "I64"
-# else
-#  define BFD_PRI64 "ll"
-# endif
-# undef PRId64
-# define PRId64 BFD_PRI64 "d"
-# undef PRIu64
-# define PRIu64 BFD_PRI64 "u"
-# undef PRIx64
-# define PRIx64 BFD_PRI64 "x"
-#endif
+#include <inttypes.h>
 
 #if BFD_ARCH_SIZE >= 64
 #define BFD64
diff --git a/bfd/bfd.c b/bfd/bfd.c
index abe50939e24..6e5d3397d15 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1042,12 +1042,7 @@  _bfd_doprnt (FILE *stream, const char *format, union _bfd_doprnt_args *args)
 			*sptr++ = ptr[-1];
 			*sptr = '\0';
 #endif
-#if defined (__GNUC__) || defined (HAVE_LONG_LONG)
 			PRINT_TYPE (long long, ll);
-#else
-			/* Fake it and hope for the best.  */
-			PRINT_TYPE (long, l);
-#endif
 			break;
 		      }
 		  }
@@ -1062,14 +1057,7 @@  _bfd_doprnt (FILE *stream, const char *format, union _bfd_doprnt_args *args)
 		if (wide_width == 0)
 		  PRINT_TYPE (double, d);
 		else
-		  {
-#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
-		    PRINT_TYPE (long double, ld);
-#else
-		    /* Fake it and hope for the best.  */
-		    PRINT_TYPE (double, d);
-#endif
-		  }
+		  PRINT_TYPE (long double, ld);
 	      }
 	      break;
 	    case 's':
@@ -1271,11 +1259,7 @@  _bfd_doprnt_scan (const char *format, union _bfd_doprnt_args *args)
 			break;
 		      case 2:
 		      default:
-#if defined (__GNUC__) || defined (HAVE_LONG_LONG)
 			arg_type = LongLong;
-#else
-			arg_type = Long;
-#endif
 			break;
 		      }
 		  }
@@ -1290,13 +1274,7 @@  _bfd_doprnt_scan (const char *format, union _bfd_doprnt_args *args)
 		if (wide_width == 0)
 		  arg_type = Double;
 		else
-		  {
-#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
-		    arg_type = LongDouble;
-#else
-		    arg_type = Double;
-#endif
-		  }
+		  arg_type = LongDouble;
 	      }
 	      break;
 	    case 's':
@@ -1906,10 +1884,8 @@  bfd_scan_vma (const char *string, const char **end, int base)
   if (sizeof (bfd_vma) <= sizeof (unsigned long))
     return strtoul (string, (char **) end, base);
 
-#if defined (HAVE_STRTOULL) && defined (HAVE_LONG_LONG)
   if (sizeof (bfd_vma) <= sizeof (unsigned long long))
     return strtoull (string, (char **) end, base);
-#endif
 
   if (base == 0)
     {
diff --git a/bfd/configure.ac b/bfd/configure.ac
index cb43ebcf6de..5341c58ae68 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -22,7 +22,6 @@  AC_INIT([bfd], BFD_VERSION)
 AC_CONFIG_SRCDIR([libbfd.c])
 
 AC_CANONICAL_TARGET
-AC_ISC_POSIX
 
 AM_INIT_AUTOMAKE
 
@@ -205,8 +204,7 @@  BFD_HOST_64_BIT=
 BFD_HOST_U_64_BIT=
 BFD_HOSTPTR_T="unsigned long"
 
-AC_TYPE_LONG_DOUBLE
-AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
+AC_CHECK_SIZEOF(long long)
 AC_CHECK_SIZEOF(void *)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(int)
@@ -243,37 +241,16 @@  AC_SUBST(BFD_HOSTPTR_T)
 
 BFD_CC_FOR_BUILD
 
-AC_CHECK_HEADERS(alloca.h fcntl.h limits.h stddef.h stdlib.h string.h \
-		 strings.h sys/file.h sys/resource.h sys/stat.h sys/time.h \
-		 time.h unistd.h wchar.h wctype.h)
-AC_HEADER_TIME
-AC_HEADER_DIRENT
+AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
+		 unistd.h)
 
-ACX_HEADER_STRING
-AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno fls)
-AC_CHECK_FUNCS(strtoull getrlimit)
+AC_CHECK_FUNCS(fcntl fdopen fileno fls getgid getpagesize getrlimit getuid \
+	       sysconf)
 
-AC_CHECK_DECLS(basename)
-AC_CHECK_DECLS(ftello)
-AC_CHECK_DECLS(ftello64)
-AC_CHECK_DECLS(fseeko)
-AC_CHECK_DECLS(fseeko64)
+AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf])
 
 BFD_BINARY_FOPEN
 
-AC_CHECK_DECLS(ffs)
-AC_CHECK_DECLS(free)
-AC_CHECK_DECLS(getenv)
-AC_CHECK_DECLS(malloc)
-AC_CHECK_DECLS(realloc)
-AC_CHECK_DECLS(stpcpy)
-AC_CHECK_DECLS(strstr)
-AC_CHECK_DECLS(asprintf)
-AC_CHECK_DECLS(vasprintf)
-AC_CHECK_DECLS(snprintf)
-AC_CHECK_DECLS(vsnprintf)
-AC_CHECK_DECLS(strnlen)
-
 # Link in zlib if we can.  This allows us to read compressed debug sections.
 # This is used only by compress.c.
 AM_ZLIB
@@ -1089,6 +1066,7 @@  AC_SUBST(lt_cv_dlopen_libs)
 # Hopefully a reasonable assumption since fseeko et.al. should be
 # upward compatible.
 AC_CHECK_FUNCS(ftello ftello64 fseeko fseeko64 fopen64)
+AC_CHECK_DECLS([ftello, ftello64, fseeko, fseeko64, fopen64])
 if test x"$ac_cv_func_ftello" = xyes -a x"$ac_cv_func_fseeko" = xyes; then
     AC_CHECK_SIZEOF(off_t)
 fi
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index d000404e26f..0a815a1b6e4 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -20,7 +20,6 @@ 
    MA 02110-1301, USA.  */
 
 #include "sysdep.h"
-#include "alloca-conf.h"
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 7d9ebf8ffe2..2338d6c08aa 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -19,7 +19,6 @@ 
    MA 02110-1301, USA.  */
 
 #include "sysdep.h"
-#include "alloca-conf.h"
 #include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f8d63131680..e8f3a9edc62 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -32,9 +32,7 @@ 
 #include "plugin.h"
 #endif
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index b5be929ad1d..07089ef7b7e 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -34,9 +34,7 @@ 
 #include "objalloc.h"
 #include "cpu-riscv.h"
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/bfd/hosts/x86-64linux.h b/bfd/hosts/x86-64linux.h
index f828bcfc539..e8de43fba3e 100644
--- a/bfd/hosts/x86-64linux.h
+++ b/bfd/hosts/x86-64linux.h
@@ -31,13 +31,7 @@ 
 
 /* We define here only the symbols differing from their 64-bit variant.  */
 #include <sys/procfs.h>
-
-#ifdef HAVE_STDINT_H
 #include <stdint.h>
-#else
-typedef unsigned int uint32_t;
-typedef unsigned long long int uint64_t;
-#endif
 
 /* Unsigned 64-bit integer aligned to 8 bytes.  */
 typedef uint64_t __attribute__ ((__aligned__ (8))) a8_uint64_t;
diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c
index d84df68c823..3af7e6c5acd 100644
--- a/bfd/hpux-core.c
+++ b/bfd/hpux-core.c
@@ -48,19 +48,7 @@ 
 #endif /* HOST_HPPABSD */
 
 #include <sys/param.h>
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# ifdef HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# ifdef HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# ifdef HAVE_NDIR_H
-#  include <ndir.h>
-# endif
-#endif
+#include <dirent.h>
 #include <signal.h>
 #ifdef HPUX_CORE
 #include <machine/reg.h>
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index e7f1311b91a..b9a679a3701 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -70,12 +70,8 @@ 
 #include "coff/internal.h"
 #include "bfdver.h"
 #include "libiberty.h"
-#ifdef HAVE_WCHAR_H
 #include <wchar.h>
-#endif
-#ifdef HAVE_WCTYPE_H
 #include <wctype.h>
-#endif
 
 /* NOTE: it's strange to be including an architecture specific header
    in what's supposed to be general (to PE/PEI) code.  However, that's
@@ -3548,16 +3544,12 @@  rsrc_write_directory (rsrc_write_data * data,
   BFD_ASSERT (nt == next_entry);
 }
 
-#if defined HAVE_WCHAR_H && ! defined __CYGWIN__ && ! defined __MINGW32__
+#if ! defined __CYGWIN__ && ! defined __MINGW32__
 /* Return the length (number of units) of the first character in S,
    putting its 'ucs4_t' representation in *PUC.  */
 
 static unsigned int
-#if defined HAVE_WCTYPE_H
 u16_mbtouc (wint_t * puc, const unsigned short * s, unsigned int n)
-#else
-u16_mbtouc (wchar_t * puc, const unsigned short * s, unsigned int n)
-#endif
 {
   unsigned short c = * s;
 
@@ -3589,7 +3581,7 @@  u16_mbtouc (wchar_t * puc, const unsigned short * s, unsigned int n)
   *puc = 0xfffd;
   return 1;
 }
-#endif /* HAVE_WCHAR_H and not Cygwin/Mingw */
+#endif /* not Cygwin/Mingw */
 
 /* Perform a comparison of two entries.  */
 static signed int
@@ -3626,20 +3618,15 @@  rsrc_cmp (bool is_name, rsrc_entry * a, rsrc_entry * b)
   res = rscpcmp ((const wchar_t *) astring, (const wchar_t *) bstring,
 		 min (alen, blen));
 
-#elif defined HAVE_WCHAR_H
+#else
   {
     unsigned int  i;
 
     res = 0;
     for (i = min (alen, blen); i--; astring += 2, bstring += 2)
       {
-#if defined HAVE_WCTYPE_H
 	wint_t awc;
 	wint_t bwc;
-#else
-	wchar_t awc;
-	wchar_t bwc;
-#endif
 
 	/* Convert UTF-16 unicode characters into wchar_t characters
 	   so that we can then perform a case insensitive comparison.  */
@@ -3649,21 +3636,14 @@  rsrc_cmp (bool is_name, rsrc_entry * a, rsrc_entry * b)
 	if (Alen != Blen)
 	  return Alen - Blen;
 
-#ifdef HAVE_WCTYPE_H
 	awc = towlower (awc);
 	bwc = towlower (bwc);
 
 	res = awc - bwc;
-#else
-	res = wcsncasecmp (& awc, & bwc, 1);
-#endif
 	if (res)
 	  break;
       }
   }
-#else
-  /* Do the best we can - a case sensitive, untranslated comparison.  */
-  res = memcmp (astring, bstring, min (alen, blen) * 2);
 #endif
 
   if (res == 0)
diff --git a/bfd/som.c b/bfd/som.c
index 5719b202c35..5308ac5aa9e 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -22,7 +22,6 @@ 
    02110-1301, USA.  */
 
 #include "sysdep.h"
-#include "alloca-conf.h"
 #include "bfd.h"
 #include "libiberty.h"
 #include "libbfd.h"
diff --git a/bfd/sysdep.h b/bfd/sysdep.h
index c0b96ef0066..aa6b095fd05 100644
--- a/bfd/sysdep.h
+++ b/bfd/sysdep.h
@@ -27,54 +27,23 @@ 
 #endif
 
 #include "config.h"
-
-#ifdef HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-
 #include <stdio.h>
-#include <sys/types.h>
 
-#include <errno.h>
-#if !(defined(errno) || defined(_MSC_VER) && defined(_INC_ERRNO))
-extern int errno;
-#endif
-
-#ifdef STRING_WITH_STRINGS
-#include <string.h>
-#include <strings.h>
-#else
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#else
-extern char *strchr ();
-extern char *strrchr ();
-#endif
-#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
 #endif
 
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
-
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
+#include <stddef.h>
+#include <string.h>
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
+#include <errno.h>
+#include <time.h>
+
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif /* HAVE_SYS_RESOURCE_H */
@@ -123,30 +92,10 @@  extern char *strrchr ();
 extern int ffs (int);
 #endif
 
-#if !HAVE_DECL_FREE
-extern void free ();
-#endif
-
-#if !HAVE_DECL_GETENV
-extern char *getenv ();
-#endif
-
-#if !HAVE_DECL_MALLOC
-extern PTR malloc ();
-#endif
-
-#if !HAVE_DECL_REALLOC
-extern PTR realloc ();
-#endif
-
 #if !HAVE_DECL_STPCPY
 extern char *stpcpy (char *__dest, const char *__src);
 #endif
 
-#if !HAVE_DECL_STRSTR
-extern char *strstr ();
-#endif
-
 #ifdef HAVE_FTELLO
 #if !HAVE_DECL_FTELLO
 extern off_t ftello (FILE *stream);
@@ -171,10 +120,6 @@  extern int fseeko64 (FILE *stream, off64_t offset, int whence);
 #endif
 #endif
 
-#if !HAVE_DECL_STRNLEN
-size_t strnlen (const char *, size_t);
-#endif
-
 /* Define offsetof for those systems which lack it */
 
 #ifndef offsetof
diff --git a/bfd/trad-core.c b/bfd/trad-core.c
index 14627cb72ec..2473a319b13 100644
--- a/bfd/trad-core.c
+++ b/bfd/trad-core.c
@@ -25,19 +25,7 @@ 
 #include "libaout.h"	       /* BFD a.out internal data structures */
 
 #include <sys/param.h>
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# ifdef HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# ifdef HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# ifdef HAVE_NDIR_H
-#  include <ndir.h>
-# endif
-#endif
+#include <dirent.h>
 #include <signal.h>
 
 #include <sys/user.h>		/* After a.out.h  */
diff --git a/bfd/wasm-module.c b/bfd/wasm-module.c
index 6382e92d5f5..5729e059425 100644
--- a/bfd/wasm-module.c
+++ b/bfd/wasm-module.c
@@ -26,15 +26,12 @@ 
    https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md. */
 
 #include "sysdep.h"
-#include "alloca-conf.h"
 #include "bfd.h"
 #include "libiberty.h"
 #include "libbfd.h"
 #include "wasm-module.h"
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/bfd/xsym.c b/bfd/xsym.c
index cac111b521f..822cb85eb6b 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -21,7 +21,6 @@ 
 /* xSYM is the debugging format used by CodeWarrior on Mac OS classic.  */
 
 #include "sysdep.h"
-#include "alloca-conf.h"
 #include "xsym.h"
 #include "bfd.h"
 #include "libbfd.h"