public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* C99 gprof configury
@ 2021-04-05  5:50 Alan Modra
  2021-04-05  5:52 ` C99 bfd configury Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2021-04-05  5:50 UTC (permalink / raw)
  To: binutils

This series of patches is a first pass at tidying some of the obsolete
configure tests we have in support of old systems.  No doubt there are
other things that could be removed too.

Given C99 we don't need to check HAVE_SETLOCALE.  The patch also
adds setitimer checks so that they can be removed from bfd where they
aren't needed.  According to the automake manual AC_ISC_POSIX is
obsolete, so that is removed.  HAVE_SETMODE isn't checked anywhere,
so it is pointless to have a configure test for setmode.

	* configure.ac: Check for sys/time.h and setitimer.  Don't invoke
	AC_ISC_POSIX.  Don't check for setmode.
	* gprof.c: Don't test HAVE_SETLOCALE.
	* gprof.h: Include sys/time.h.
	* configure: Regenerate.
	* gconfig.in: Regenerate.

diff --git a/gprof/configure.ac b/gprof/configure.ac
index 36a40848097..25aa108ecf6 100644
--- a/gprof/configure.ac
+++ b/gprof/configure.ac
@@ -21,7 +21,6 @@ AC_INIT([gprof], BFD_VERSION)
 AC_CONFIG_SRCDIR([gprof.c])
 
 AC_CANONICAL_TARGET([])
-AC_ISC_POSIX
 
 AM_INIT_AUTOMAKE
 
@@ -39,7 +38,9 @@ AC_PROG_INSTALL
 LT_INIT
 ACX_LARGEFILE
 
-AC_CHECK_FUNCS(setmode)
+# These are in addition to what is made available in bfd/.
+AC_CHECK_HEADERS(sys/time.h)
+AC_CHECK_FUNCS(setitimer)
 
 ALL_LINGUAS="bg da de eo es fi fr ga hu id it ja ms nl pt_BR ro ru rw sr sv tr uk vi"
 ZW_GNU_GETTEXT_SISTER_DIR
diff --git a/gprof/gprof.c b/gprof/gprof.c
index 678299e7b0e..6ed88ff4776 100644
--- a/gprof/gprof.c
+++ b/gprof/gprof.c
@@ -187,12 +187,10 @@ main (int argc, char **argv)
   Sym **cg = 0;
   int ch, user_specified = 0;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
 #ifdef ENABLE_NLS
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
diff --git a/gprof/gprof.h b/gprof/gprof.h
index e1ce282437a..1c23dd83f2f 100644
--- a/gprof/gprof.h
+++ b/gprof/gprof.h
@@ -40,6 +40,10 @@
 #undef PACKAGE_VERSION
 #include "gconfig.h"
 
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
 #ifndef MIN
 #define MIN(a,b)	((a) < (b) ? (a) : (b))
 #endif
@@ -58,9 +62,7 @@
 #define	GMONNAME	"gmon.out"	/* default profile filename */
 #define	GMONSUM		"gmon.sum"	/* profile summary filename */
 
-#ifdef HAVE_LOCALE_H
-# include <locale.h>
-#endif
+#include <locale.h>
 
 #ifdef ENABLE_NLS
 /* Undefine BFD's `_' macro - it uses dgetext() and we want to use gettext().  */

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* C99 bfd configury
  2021-04-05  5:50 C99 gprof configury Alan Modra
@ 2021-04-05  5:52 ` Alan Modra
  2021-04-05  5:52   ` C99 opcodes configury Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2021-04-05  5:52 UTC (permalink / raw)
  To: binutils

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.

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"

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* C99 opcodes configury
  2021-04-05  5:52 ` C99 bfd configury Alan Modra
@ 2021-04-05  5:52   ` Alan Modra
  2021-04-05  5:54     ` C99 binutils configury Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2021-04-05  5:52 UTC (permalink / raw)
  To: binutils

	* configure.ac: Don't check for limits.h, string.h, strings.h or
	stdlib.h.
	(AC_ISC_POSIX): Don't invoke.
	* sysdep.h: Include stdlib.h and string.h unconditionally.
	* i386-opc.h: Include limits.h unconditionally.
	* wasm32-dis.c: Likewise.
	* cgen-opc.c: Don't include alloca-conf.h.
	* config.in: Regenerate.
	* configure: Regenerate.

diff --git a/opcodes/cgen-opc.c b/opcodes/cgen-opc.c
index ff86d45de13..9fdbc6e118b 100644
--- a/opcodes/cgen-opc.c
+++ b/opcodes/cgen-opc.c
@@ -19,7 +19,6 @@
    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include "sysdep.h"
-#include "alloca-conf.h"
 #include <stdio.h>
 #include "ansidecl.h"
 #include "libiberty.h"
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index c19d2f8c958..7cf0d2968b2 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -22,7 +22,6 @@ AC_INIT([opcodes], BFD_VERSION)
 AC_CONFIG_SRCDIR([z8k-dis.c])
 
 AC_CANONICAL_TARGET
-AC_ISC_POSIX
 
 AM_INIT_AUTOMAKE
 
@@ -84,9 +83,6 @@ BFD_CC_FOR_BUILD
 AC_SUBST(HDEFINES)
 AC_PROG_INSTALL
 
-AC_CHECK_HEADERS(string.h strings.h stdlib.h limits.h)
-ACX_HEADER_STRING
-
 AC_CHECK_DECLS([basename, stpcpy])
 
 # Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h
index 60c445f2b40..8f0479b937b 100644
--- a/opcodes/i386-opc.h
+++ b/opcodes/i386-opc.h
@@ -19,10 +19,7 @@
    02110-1301, USA.  */
 
 #include "opcode/i386.h"
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
-
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/opcodes/sysdep.h b/opcodes/sysdep.h
index 74fbee729f9..dc4fe446ada 100644
--- a/opcodes/sysdep.h
+++ b/opcodes/sysdep.h
@@ -32,25 +32,9 @@
 #endif
 
 #include "config.h"
-
-#include "ansidecl.h"
-
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#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>
-#endif
-#endif
-#endif
+#include "ansidecl.h"
 
 #if !HAVE_DECL_STPCPY
 extern char *stpcpy (char *__dest, const char *__src);
diff --git a/opcodes/wasm32-dis.c b/opcodes/wasm32-dis.c
index f207cb9a9c3..b701c6d56bd 100644
--- a/opcodes/wasm32-dis.c
+++ b/opcodes/wasm32-dis.c
@@ -29,9 +29,7 @@
 #include "elf/wasm32.h"
 #include <stdint.h>
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* C99 binutils configury
  2021-04-05  5:52   ` C99 opcodes configury Alan Modra
@ 2021-04-05  5:54     ` Alan Modra
  2021-04-05  5:55       ` C99 gas configury Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2021-04-05  5:54 UTC (permalink / raw)
  To: binutils

	* configure.ac: Assume long long is available.  Don't test for
	strings.h, stdlib.h, limits.h, locale.h, or wchar.h.  Check
	inttypes.h, stdint.h, sys/stat.h and sys/types.h. Don't check for
	strcoll, setlocale, setmode or location of time_t.  Don't check
	for fprintf, getenv, snprintf, strnlen, strstr or vsnprintf decls.
	(AC_ISC_POSIX, AXC_HEADER_STRING, AC_FUNC_ALLOCA): Don't invoke.
	* sysdep.h: Don't include alloca-conf.h, include config.h instead.
	Test HAVE_SYS_TYPES_H and reorder includes.  Include limits.h,
	locale.h, string.h and stdlib.h unconditionally.  Remove various
	fallback declarations.  Assume long long is available.
	* addr2line.c: Don't test HAVE_SETLOCALE.
	* ar.c: Likewise.
	* coffdump.c: Likewise.
	* dlltool.c: Likewise.
	* dllwrap.c: Likewise.
	* elfedit.c: Likewise.
	* nm.c: Likewise.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* readelf.c: Likewise.
	* size.c: Likewise.
	* srconv.c: Likewise.
	* strings.c: Likewise.
	* sysdump.c: Likewise.
	* windmc.c: Likewise.
	* windres.c: Likewise.
	* bucomm.c: Don't test HAVE_TIME_T_IN_TIME_H or HAVE_TIME_T_IN_TYPES_H.
	* dwarf.c: Include limits.h unconditionally.  Assume long long
	is available.
	* nm.c: Don't test HAVE_STRCOLL.
	* readelf.c: Don't test HAVE_WCHAR_H.
	* strings.c: Assume long long is available.
	* syslex.l: Include string.h unconditionally.
	* aclocal.m4: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.

diff --git a/binutils/addr2line.c b/binutils/addr2line.c
index 578c64adbd1..5b02a67567b 100644
--- a/binutils/addr2line.c
+++ b/binutils/addr2line.c
@@ -425,12 +425,10 @@ main (int argc, char **argv)
   char *target;
   int c;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/ar.c b/binutils/ar.c
index 71bbde65ed6..5d6976c7027 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -723,12 +723,10 @@ main (int argc, char **argv)
   char *inarch_filename;
   int i;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/bucomm.c b/binutils/bucomm.c
index 5a3eab62f98..8ce66ab8cce 100644
--- a/binutils/bucomm.c
+++ b/binutils/bucomm.c
@@ -25,16 +25,9 @@
 #include "bfd.h"
 #include "libiberty.h"
 #include "filenames.h"
-
-#include <time.h>		/* ctime, maybe time_t */
+#include <time.h>
 #include <assert.h>
 #include "bucomm.h"
-
-#ifndef HAVE_TIME_T_IN_TIME_H
-#ifndef HAVE_TIME_T_IN_TYPES_H
-typedef long time_t;
-#endif
-#endif
 \f
 /* Error reporting.  */
 
diff --git a/binutils/coffdump.c b/binutils/coffdump.c
index dd40221b45d..37274d9d44e 100644
--- a/binutils/coffdump.c
+++ b/binutils/coffdump.c
@@ -488,12 +488,10 @@ main (int ac, char **av)
       { NULL, no_argument, 0, 0 }
     };
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/configure.ac b/binutils/configure.ac
index af24c0c9a8a..ad6d2aaefad 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -23,7 +23,6 @@ AC_INIT([binutils], BFD_VERSION)
 AC_CONFIG_SRCDIR(ar.c)
 
 AC_CANONICAL_TARGET
-AC_ISC_POSIX
 
 AM_INIT_AUTOMAKE
 
@@ -162,14 +161,18 @@ esac
 AC_SUBST(DEMANGLER_NAME)
 
 AC_CHECK_SIZEOF([long])
-AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
-
-AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h limits.h locale.h sys/param.h wchar.h)
+AC_CHECK_SIZEOF([long long])
+
+# We use headers from include/ that check various HAVE_*_H macros, thus
+# should ensure they are set by configure.  This is true even when C99
+# guarantees they are available.
+# plugin-api.h tests HAVE_STDINT_H and HAVE_INTTYPES_H
+# Besides those, we need to check anything used in binutils/ not in C99.
+AC_CHECK_HEADERS(fcntl.h inttypes.h stdint.h sys/file.h sys/param.h \
+		 sys/stat.h sys/types.h unistd.h)
 AC_HEADER_SYS_WAIT
-ACX_HEADER_STRING
-AC_FUNC_ALLOCA
 AC_FUNC_MMAP
-AC_CHECK_FUNCS(sbrk utimes setmode getc_unlocked strcoll setlocale)
+AC_CHECK_FUNCS(getc_unlocked sbrk utimes)
 AC_CHECK_FUNC([mkstemp],
 	      AC_DEFINE([HAVE_MKSTEMP], 1,
 	      [Define to 1 if you have the `mkstemp' function.]))
@@ -190,26 +193,6 @@ AC_SEARCH_LIBS(frexp, m)
 
 AM_LC_MESSAGES
 
-AC_MSG_CHECKING(for time_t in time.h)
-AC_CACHE_VAL(bu_cv_decl_time_t_time_h,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [time_t i;])],
-bu_cv_decl_time_t_time_h=yes, bu_cv_decl_time_t_time_h=no)])
-AC_MSG_RESULT($bu_cv_decl_time_t_time_h)
-if test $bu_cv_decl_time_t_time_h = yes; then
-  AC_DEFINE([HAVE_TIME_T_IN_TIME_H], 1,
-	    [Is the type time_t defined in <time.h>?])
-fi
-
-AC_MSG_CHECKING(for time_t in sys/types.h)
-AC_CACHE_VAL(bu_cv_decl_time_t_types_h,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>], [time_t i;])],
-bu_cv_decl_time_t_types_h=yes, bu_cv_decl_time_t_types_h=no)])
-AC_MSG_RESULT($bu_cv_decl_time_t_types_h)
-if test $bu_cv_decl_time_t_types_h = yes; then
-  AC_DEFINE([HAVE_TIME_T_IN_TYPES_H], 1,
-	    [Is the type time_t defined in <sys/types.h>?])
-fi
-
 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
 AC_CACHE_VAL(bu_cv_decl_getopt_unistd_h,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
@@ -236,8 +219,7 @@ if test $bu_cv_header_utime_h = yes; then
   AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
 fi
 
-AC_CHECK_DECLS([asprintf, environ, fprintf, getc_unlocked, getenv,
-		sbrk, snprintf, stpcpy, strnlen, strstr, vsnprintf])
+AC_CHECK_DECLS([asprintf, environ, getc_unlocked, sbrk, stpcpy])
 
 # Link in zlib if we can.  This allows us to read compressed debug
 # sections.  This is used only by readelf.c (objdump uses bfd for
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index b26c17852e3..e6fafb4dc84 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -3779,12 +3779,10 @@ main (int ac, char **av)
   program_name = av[0];
   oav = av;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/dllwrap.c b/binutils/dllwrap.c
index bc7104de004..698f6468d6c 100644
--- a/binutils/dllwrap.c
+++ b/binutils/dllwrap.c
@@ -630,12 +630,10 @@ main (int argc, char **argv)
 
   prog_name = argv[0];
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 293d33ec9ac..562dce5dd26 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -36,9 +36,7 @@
 #include <elfutils/debuginfod.h>
 #endif
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
@@ -215,7 +213,7 @@ get_encoded_value (unsigned char **pdata,
   return val;
 }
 
-#if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
+#if SIZEOF_LONG_LONG > SIZEOF_LONG
 # ifndef __MINGW32__
 #  define DWARF_VMA_FMT		"ll"
 #  define DWARF_VMA_FMT_LONG	"%16.16llx"
diff --git a/binutils/elfedit.c b/binutils/elfedit.c
index ddcace90f3a..e33c340d758 100644
--- a/binutils/elfedit.c
+++ b/binutils/elfedit.c
@@ -959,12 +959,10 @@ main (int argc, char ** argv)
 {
   int c, status;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/nm.c b/binutils/nm.c
index 64105ca627f..82ccec6801c 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -633,7 +633,6 @@ non_numeric_forward (const void *P_x, const void *P_y)
   if (xn == NULL)
     return -1;
 
-#ifdef HAVE_STRCOLL
   /* Solaris 2.5 has a bug in strcoll.
      strcoll returns invalid values when confronted with empty strings.  */
   if (*yn == '\0')
@@ -642,9 +641,6 @@ non_numeric_forward (const void *P_x, const void *P_y)
     return -1;
 
   return strcoll (xn, yn);
-#else
-  return strcmp (xn, yn);
-#endif
 }
 
 static int
@@ -1788,13 +1784,11 @@ main (int argc, char **argv)
   int c;
   int retval;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
   setlocale (LC_COLLATE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 6622adc5e7c..3b6a7e50169 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -6016,12 +6016,10 @@ copy_main (int argc, char *argv[])
 int
 main (int argc, char *argv[])
 {
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/objdump.c b/binutils/objdump.c
index cbbec81c026..aa1215cede8 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -5135,12 +5135,10 @@ main (int argc, char **argv)
   char *target = default_target;
   bool seenflag = false;
 
-#if defined (HAVE_SETLOCALE)
-#if defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
   setlocale (LC_CTYPE, "");
-#endif
 
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 5bc59e4c5e2..840a160ae82 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -44,9 +44,7 @@
 #include <assert.h>
 #include <time.h>
 #include <zlib.h>
-#ifdef HAVE_WCHAR_H
 #include <wchar.h>
-#endif
 
 #if __GNUC__ >= 2
 /* Define BFD64 here, even if our default architecture is 32 bit ELF
@@ -21748,12 +21746,10 @@ main (int argc, char ** argv)
 {
   int err;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/size.c b/binutils/size.c
index 294cc0b9a44..bbd79dddcfa 100644
--- a/binutils/size.c
+++ b/binutils/size.c
@@ -134,12 +134,10 @@ main (int argc, char **argv)
   int temp;
   int c;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/srconv.c b/binutils/srconv.c
index 8476e12b638..dab04e21c30 100644
--- a/binutils/srconv.c
+++ b/binutils/srconv.c
@@ -1722,12 +1722,10 @@ main (int ac, char **av)
   char *input_file;
   char *output_file;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/strings.c b/binutils/strings.c
index 3ecdb929953..44a8e1da644 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -149,9 +149,7 @@ main (int argc, char **argv)
   char *s;
   int numeric_opt = 0;
 
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_ALL, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
@@ -610,61 +608,42 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
 	switch (address_radix)
 	  {
 	  case 8:
-#ifdef HAVE_LONG_LONG
 	    if (sizeof (start) > sizeof (long))
 	      {
-# ifndef __MSVCRT__
+#ifndef __MSVCRT__
 		printf ("%7llo ", (unsigned long long) start);
-# else
+#else
 		printf ("%7I64o ", (unsigned long long) start);
-# endif
+#endif
 	      }
 	    else
-#elif !BFD_HOST_64BIT_LONG
-	      if (start != (unsigned long) start)
-		printf ("++%7lo ", (unsigned long) start);
-	      else
-#endif
-		printf ("%7lo ", (unsigned long) start);
+	      printf ("%7lo ", (unsigned long) start);
 	    break;
 
 	  case 10:
-#ifdef HAVE_LONG_LONG
 	    if (sizeof (start) > sizeof (long))
 	      {
-# ifndef __MSVCRT__
+#ifndef __MSVCRT__
 		printf ("%7llu ", (unsigned long long) start);
-# else
+#else
 		printf ("%7I64d ", (unsigned long long) start);
-# endif
+#endif
 	      }
 	    else
-#elif !BFD_HOST_64BIT_LONG
-	      if (start != (unsigned long) start)
-		printf ("++%7lu ", (unsigned long) start);
-	      else
-#endif
-		printf ("%7ld ", (long) start);
+	      printf ("%7ld ", (long) start);
 	    break;
 
 	  case 16:
-#ifdef HAVE_LONG_LONG
 	    if (sizeof (start) > sizeof (long))
 	      {
-# ifndef __MSVCRT__
+#ifndef __MSVCRT__
 		printf ("%7llx ", (unsigned long long) start);
-# else
+#else
 		printf ("%7I64x ", (unsigned long long) start);
-# endif
+#endif
 	      }
 	    else
-#elif !BFD_HOST_64BIT_LONG
-	      if (start != (unsigned long) start)
-		printf ("%lx%8.8lx ", (unsigned long) (start >> 32),
-			(unsigned long) (start & 0xffffffff));
-	      else
-#endif
-		printf ("%7lx ", (unsigned long) start);
+	      printf ("%7lx ", (unsigned long) start);
 	    break;
 	  }
 
diff --git a/binutils/sysdep.h b/binutils/sysdep.h
index 981ec025fc7..747ff4c31ff 100644
--- a/binutils/sysdep.h
+++ b/binutils/sysdep.h
@@ -20,50 +20,21 @@
 #ifndef _BIN_SYSDEP_H
 #define _BIN_SYSDEP_H
 
-#include "alloca-conf.h"
-#include "ansidecl.h"
+#include "config.h"
 #include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
-
-#include "bfdver.h"
-
-#include <stdarg.h>
-
-#ifdef USE_BINARY_FOPEN
-#include "fopen-bin.h"
-#else
-#include "fopen-same.h"
 #endif
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
 #endif
-
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #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
-#endif
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #else
@@ -72,8 +43,13 @@ extern char *strrchr ();
 #endif
 #endif
 
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
+#include "ansidecl.h"
+#include "bfdver.h"
+
+#ifdef USE_BINARY_FOPEN
+#include "fopen-bin.h"
+#else
+#include "fopen-same.h"
 #endif
 
 #include "binary-io.h"
@@ -82,40 +58,16 @@ extern char *strrchr ();
 extern char *stpcpy (char *, const char *);
 #endif
 
-#if !HAVE_DECL_STRSTR
-extern char *strstr ();
-#endif
-
 #ifdef HAVE_SBRK
 #if !HAVE_DECL_SBRK
 extern char *sbrk ();
 #endif
 #endif
 
-#if !HAVE_DECL_GETENV
-extern char *getenv ();
-#endif
-
 #if !HAVE_DECL_ENVIRON
 extern char **environ;
 #endif
 
-#if !HAVE_DECL_FPRINTF
-extern int fprintf (FILE *, const char *, ...);
-#endif
-
-#if !HAVE_DECL_SNPRINTF
-extern int snprintf(char *, size_t, const char *, ...);
-#endif
-
-#if !HAVE_DECL_VSNPRINTF
-extern int vsnprintf(char *, size_t, const char *, va_list);
-#endif
-
-#if !HAVE_DECL_STRNLEN
-size_t strnlen (const char *, size_t);
-#endif
-
 #ifndef O_RDONLY
 #define O_RDONLY 0
 #endif
@@ -134,18 +86,16 @@ size_t strnlen (const char *, size_t);
 #define SEEK_END 2
 #endif
 
-#ifdef HAVE_LOCALE_H
-# ifndef ENABLE_NLS
-   /* The Solaris version of locale.h always includes libintl.h.  If we have
-      been configured with --disable-nls then ENABLE_NLS will not be defined
-      and the dummy definitions of bindtextdomain (et al) below will conflict
-      with the defintions in libintl.h.  So we define these values to prevent
-      the bogus inclusion of libintl.h.  */
-#  define _LIBINTL_H
-#  define _LIBGETTEXT_H
-# endif
-# include <locale.h>
+#ifndef ENABLE_NLS
+  /* The Solaris version of locale.h always includes libintl.h.  If we have
+     been configured with --disable-nls then ENABLE_NLS will not be defined
+     and the dummy definitions of bindtextdomain (et al) below will conflict
+     with the defintions in libintl.h.  So we define these values to prevent
+     the bogus inclusion of libintl.h.  */
+# define _LIBINTL_H
+# define _LIBGETTEXT_H
 #endif
+#include <locale.h>
 
 #ifdef ENABLE_NLS
 # include <libintl.h>
@@ -175,9 +125,7 @@ size_t strnlen (const char *, size_t);
 #define BUFSIZE 8192
 
 /* For PATH_MAX.  */
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 
 #ifndef PATH_MAX
 /* For MAXPATHLEN.  */
@@ -193,7 +141,7 @@ size_t strnlen (const char *, size_t);
 # endif
 #endif
 
-#if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
+#if SIZEOF_LONG_LONG > SIZEOF_LONG
 /* We can't use any bfd types here since readelf may define BFD64 and
    objdump may not.  */
 #define HOST_WIDEST_INT	long long
diff --git a/binutils/sysdump.c b/binutils/sysdump.c
index f5c06504746..8993152bdd6 100644
--- a/binutils/sysdump.c
+++ b/binutils/sysdump.c
@@ -659,12 +659,10 @@ main (int ac, char **av)
     {NULL, no_argument, 0, 0}
   };
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/syslex.l b/binutils/syslex.l
index fc6ccea7ba6..d376e3b1b3a 100644
--- a/binutils/syslex.l
+++ b/binutils/syslex.l
@@ -22,14 +22,7 @@
 
 /* Note: config.h is #included via syslex_wrap.c.  */
 
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-
 #include "sysinfo.h"
 
 #ifndef YY_NO_UNPUT
diff --git a/binutils/windmc.c b/binutils/windmc.c
index af32f3bf22c..0ae4fe9b43d 100644
--- a/binutils/windmc.c
+++ b/binutils/windmc.c
@@ -941,12 +941,10 @@ main (int argc, char **argv)
   char *target, *input_filename;
   int verbose;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/binutils/windres.c b/binutils/windres.c
index 0fbf1f9fa5e..544cef6eb34 100644
--- a/binutils/windres.c
+++ b/binutils/windres.c
@@ -823,12 +823,10 @@ main (int argc, char **argv)
   rc_res_directory *resources;
   int use_temp_file;
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* C99 gas configury
  2021-04-05  5:54     ` C99 binutils configury Alan Modra
@ 2021-04-05  5:55       ` Alan Modra
  2021-04-05  5:55         ` C99 ld configury Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2021-04-05  5:55 UTC (permalink / raw)
  To: binutils

Also remove alloca stuff since we don't use alloca in gas nowadays.

	* configure.ac: Don't check for string.h, strings.h, stdlib.h,
	errno.h, limits.h, locale.h or time.h.  Don't check for unlink,
	remove, sbrk (unused) or setlocale.  Adjust gas_test_headers.
	Don't check for errno, free, malloc, realoc, sbrk, strstr, getenv
	strstr, or vsnprintf declarations.
	(AC_ISC_POSIX, AC_FUNC_ALLOCA, AC_C_INLINE): Don't invoke.
	* as.h: Don't include alloca-conf.h, include config.h instead.
	Include string.h, stdlib.h, errno.h unconditionally.  Remove
	various fallback declarations.
	* asintl.h: Don't test HAVE_LOCALE_H.
	* as.c: Don't test HAVE_SETLOCALE.
	* dwarf2dbg.c: Include limits.h unconditionally.
	* expr.c: Likewise.
	* sb.c: Likewise.
	* symbols.c: Likewise.
	* config/tc-cr16.c: Likewise.
	* config/tc-d30v.c: Likewise.
	* config/tc-i386.c: Likewise.
	* config/tc-ia64.c: Likewise.
	* config/tc-tic54x.c (tic54x_mlib): Call remove rather than unlink.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.

diff --git a/gas/as.c b/gas/as.c
index b2684fabe51..7de8af246e1 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1256,12 +1256,10 @@ main (int argc, char ** argv)
   start_time = get_run_time ();
   signal_init ();
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/gas/as.h b/gas/as.h
index 295d20ef467..6b6895479de 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -34,29 +34,15 @@
   	COMMON as "".
    If TEST is #defined, then we are testing a module: #define COMMON as "".  */
 
-#include "alloca-conf.h"
+#include "config.h"
 
 /* Now, tend to the rest of the configuration.  */
 
 /* System include files first...  */
 #include <stdio.h>
-
-#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>
-#endif
-#endif
-#endif
-
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
+
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -65,10 +51,7 @@
 #include <sys/types.h>
 #endif
 
-#ifdef HAVE_ERRNO_H
 #include <errno.h>
-#endif
-
 #include <stdarg.h>
 
 #include "getopt.h"
@@ -101,41 +84,14 @@
 #ifdef NEED_DECLARATION_ENVIRON
 extern char **environ;
 #endif
-#ifdef NEED_DECLARATION_ERRNO
-extern int errno;
-#endif
 #ifdef NEED_DECLARATION_FFS
 extern int ffs (int);
 #endif
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
-#ifdef NEED_DECLARATION_MALLOC
-extern void *malloc ();
-extern void *realloc ();
-#endif
-#ifdef NEED_DECLARATION_STRSTR
-extern char *strstr ();
-#endif
 
 #if !HAVE_DECL_MEMPCPY
 void *mempcpy(void *, const void *, size_t);
 #endif
 
-#if !HAVE_DECL_VSNPRINTF
-extern int vsnprintf(char *, size_t, const char *, va_list);
-#endif
-
-/* This is needed for VMS.  */
-#if ! defined (HAVE_UNLINK) && defined (HAVE_REMOVE)
-#define unlink remove
-#endif
-
-/* Hack to make "gcc -Wall" not complain about obstack macros.  */
-#if !defined (memcpy) && !defined (bcopy)
-#define bcopy(src,dest,size)	memcpy (dest, src, size)
-#endif
-
 #ifndef __LINE__
 #define __LINE__ "unknown"
 #endif /* __LINE__ */
diff --git a/gas/asintl.h b/gas/asintl.h
index 1bc1dd5adea..8fcbbf07ea8 100644
--- a/gas/asintl.h
+++ b/gas/asintl.h
@@ -20,18 +20,16 @@
    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
    02110-1301, USA.  */
 
-#ifdef HAVE_LOCALE_H
-# ifndef ENABLE_NLS
-   /* The Solaris version of locale.h always includes libintl.h.  If we have
-      been configured with --disable-nls then ENABLE_NLS will not be defined
-      and the dummy definitions of bindtextdomain (et al) below will conflict
-      with the definitions in libintl.h.  So we define these values to prevent
-      the bogus inclusion of libintl.h.  */
-#  define _LIBINTL_H
-#  define _LIBGETTEXT_H
-# endif
-# include <locale.h>
+#ifndef ENABLE_NLS
+  /* The Solaris version of locale.h always includes libintl.h.  If we have
+     been configured with --disable-nls then ENABLE_NLS will not be defined
+     and the dummy definitions of bindtextdomain (et al) below will conflict
+     with the definitions in libintl.h.  So we define these values to prevent
+     the bogus inclusion of libintl.h.  */
+# define _LIBINTL_H
+# define _LIBGETTEXT_H
 #endif
+#include <locale.h>
 
 #ifdef ENABLE_NLS
 # include <libintl.h>
diff --git a/gas/config/tc-cr16.c b/gas/config/tc-cr16.c
index 1f6b1fe8b6d..cbe113ef093 100644
--- a/gas/config/tc-cr16.c
+++ b/gas/config/tc-cr16.c
@@ -26,9 +26,7 @@
 #include "opcode/cr16.h"
 #include "elf/cr16.h"
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c
index 1fb078662fa..957182ac2aa 100644
--- a/gas/config/tc-d30v.c
+++ b/gas/config/tc-d30v.c
@@ -31,10 +31,7 @@ const char *md_shortopts          = "OnNcC";
 const char EXP_CHARS[]            = "eE";
 const char FLT_CHARS[]            = "dD";
 
-#if HAVE_LIMITS_H
 #include <limits.h>
-#endif
-
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 235bac075dd..b6d43b5f617 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -32,17 +32,7 @@
 #include "dw2gencfi.h"
 #include "elf/x86-64.h"
 #include "opcodes/i386-init.h"
-
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#else
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifndef INT_MAX
-#define INT_MAX (int) (((unsigned) (-1)) >> 1)
-#endif
-#endif
 
 #ifndef INFER_ADDR_PREFIX
 #define INFER_ADDR_PREFIX 1
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index c1008c2b0bd..045abaf7357 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -51,10 +51,7 @@
 #include "elf/ia64.h"
 #include "bfdver.h"
 #include <time.h>
-
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 
 #define NELEMS(a)	((int) (sizeof (a)/sizeof ((a)[0])))
 
diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index f0ac732b11e..783c3be83e1 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -2357,7 +2357,7 @@ tic54x_mlib (int ignore ATTRIBUTE_UNUSED)
       fclose (ftmp);
       free (buf);
       input_scrub_insert_file (fname);
-      unlink (fname);
+      remove (fname);
     }
 }
 
diff --git a/gas/configure.ac b/gas/configure.ac
index 6a96bb70d7d..78efba88e23 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -29,7 +29,6 @@ dnl we specify this explicitly, automake-1.7 will assume that ylwrap is in
 dnl gas/ instead of gas/../.
 AC_CONFIG_AUX_DIR(..)
 AC_CANONICAL_TARGET
-AC_ISC_POSIX
 
 AM_INIT_AUTOMAKE
 
@@ -941,8 +940,7 @@ AM_MAINTAINER_MODE
 AM_CONDITIONAL(GENINSRC_NEVER, false)
 AC_EXEEXT
 
-AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h errno.h sys/types.h limits.h locale.h time.h sys/stat.h)
-ACX_HEADER_STRING
+AC_CHECK_HEADERS(memory.h sys/stat.h sys/types.h unistd.h)
 
 # Put this here so that autoconf's "cross-compiling" message doesn't confuse
 # people who are not cross-compiling but are compiling cross-assemblers.
@@ -955,14 +953,6 @@ else
 fi
 AC_MSG_RESULT($cross_gas)
 
-dnl ansidecl.h will deal with const
-dnl AC_C_CONST
-AC_FUNC_ALLOCA
-AC_C_INLINE
-
-# VMS doesn't have unlink.
-AC_CHECK_FUNCS(unlink remove, break)
-AC_CHECK_FUNCS(sbrk setlocale)
 AC_CHECK_FUNCS(strsignal)
 
 AM_LC_MESSAGES
@@ -987,29 +977,13 @@ gas_test_headers="
 #ifdef HAVE_MEMORY_H
 #include <memory.h>
 #endif
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 "
 
-# Does errno.h declare errno, or do we have to add a separate declaration
-# for it?
-GAS_CHECK_DECL_NEEDED(errno, f, int f, [
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-])
-
 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
 AC_CACHE_VAL(gas_cv_decl_getopt_unistd_h,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
@@ -1022,12 +996,8 @@ fi
 
 GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
 GAS_CHECK_DECL_NEEDED(ffs, f, int (*f)(int), $gas_test_headers)
-GAS_CHECK_DECL_NEEDED(free, f, void (*f)(), $gas_test_headers)
-GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
-GAS_CHECK_DECL_NEEDED(sbrk, f, char *(*f)(), $gas_test_headers)
-GAS_CHECK_DECL_NEEDED(strstr, f, char *(*f)(), $gas_test_headers)
 
-AC_CHECK_DECLS([free, getenv, malloc, mempcpy, realloc, stpcpy, strstr, vsnprintf, asprintf])
+AC_CHECK_DECLS([asprintf, mempcpy, stpcpy])
 
 BFD_BINARY_FOPEN
 
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 24c3560f6f4..460daaa5c0c 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -30,18 +30,7 @@
 
 #include "as.h"
 #include "safe-ctype.h"
-
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#else
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifndef INT_MAX
-#define INT_MAX (int) (((unsigned) (-1)) >> 1)
-#endif
-#endif
-
 #include "dwarf2dbg.h"
 #include <filenames.h>
 
diff --git a/gas/expr.c b/gas/expr.c
index 4d7b2ce380d..aabd33c84f9 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -28,9 +28,7 @@
 #include "as.h"
 #include "safe-ctype.h"
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/gas/sb.c b/gas/sb.c
index 44c0a16d60a..08ed8916feb 100644
--- a/gas/sb.c
+++ b/gas/sb.c
@@ -24,9 +24,7 @@
 #include "as.h"
 #include "sb.h"
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
diff --git a/gas/symbols.c b/gas/symbols.c
index f3632f13200..12216800edb 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -26,9 +26,7 @@
 #include "subsegs.h"
 #include "write.h"
 
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* C99 ld configury
  2021-04-05  5:55       ` C99 gas configury Alan Modra
@ 2021-04-05  5:55         ` Alan Modra
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Modra @ 2021-04-05  5:55 UTC (permalink / raw)
  To: binutils

	* configure.ac: Move initfini-array arg handling earlier.  Don't
	check for string.h, strings.h, stdlib.h, or locale.h.  Do check
	for inttypes.h, stdint.h, sys/types.h.  Don't check for
	setlocale, free, getev or strstr.
	(AC_ISC_POSIX): Don't invoke.
	* sysdep.h: Include string.h and stdlib.h unconditionally.  Test
	HAVE_SYS_TYPE_H and HAVE_SYS_STAT_H.  Remove strstr, free and
	getenv fallback declarations.
	* ld.h: Don't test HAVE_LOCALE_H.
	* ldmain.c: Don't test HAVE_SETLOCALE.
	* config.in: Regenerate.
	* configure: Regenerate.

diff --git a/ld/configure.ac b/ld/configure.ac
index 19a5df12c95..5429f22ac23 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -23,7 +23,6 @@ AC_CONFIG_SRCDIR(ldmain.c)
 
 AC_CANONICAL_TARGET
 AC_CANONICAL_BUILD
-AC_ISC_POSIX
 
 AM_INIT_AUTOMAKE
 AM_MAINTAINER_MODE
@@ -231,6 +230,18 @@ case "${enable_default_hash_style}" in
   *) ac_default_emit_gnu_hash=0 ;;
 esac
 
+AC_ARG_ENABLE(initfini-array,
+[  --disable-initfini-array do not use .init_array/.fini_array sections],
+[case "${enableval}" in
+ yes|no) ;;
+ *) AC_MSG_ERROR([invalid --enable-initfini-array argument]) ;;
+ esac], [enable_initfini_array=yes])
+AC_SUBST(enable_initfini_array)
+if test $enable_initfini_array = yes; then
+  AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
+    [Define .init_array/.fini_array sections are available and working.])
+fi
+
 GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
 if test "${enable_libctf}" = yes; then
     AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
@@ -280,30 +291,25 @@ ACX_PROG_CMP_IGNORE_INITIAL
 AC_SUBST(HDEFINES)
 AC_SUBST(NATIVE_LIB_DIRS)
 
-AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
-AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h)
-ACX_HEADER_STRING
-AC_CHECK_FUNCS(glob mkstemp realpath sbrk setlocale waitpid)
-AC_CHECK_FUNCS(open lseek close)
-AC_HEADER_DIRENT
+# We use headers from include/ that check various HAVE_*_H macros, thus
+# should ensure they are set by configure.  This is true even when C99
+# guarantees they are available.
+# sha1.h and md4.h test HAVE_LIMITS_H, HAVE_SYS_TYPES_H and HAVE_STDINT_H
+# plugin-api.h tests HAVE_STDINT_H and HAVE_INTTYPES_H
+# Besides those, we need to check anything used in ld/ not in C99.
+AC_CHECK_HEADERS(fcntl.h elf-hints.h limits.h inttypes.h stdint.h \
+		 sys/file.h sys/mman.h sys/param.h sys/stat.h sys/time.h \
+		 sys/types.h unistd.h)
+AC_CHECK_FUNCS(close glob lseek mkstemp open realpath sbrk waitpid)
+
+BFD_BINARY_FOPEN
+
+AC_CHECK_DECLS([asprintf, environ, sbrk])
 
-dnl AC_CHECK_HEADERS(sys/mman.h)
 AC_FUNC_MMAP
 
 AC_SEARCH_LIBS([dlopen], [dl])
 
-AC_ARG_ENABLE(initfini-array,
-[  --disable-initfini-array do not use .init_array/.fini_array sections],
-[case "${enableval}" in
- yes|no) ;;
- *) AC_MSG_ERROR([invalid --enable-initfini-array argument]) ;;
- esac], [enable_initfini_array=yes])
-AC_SUBST(enable_initfini_array)
-if test $enable_initfini_array = yes; then
-  AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
-    [Define .init_array/.fini_array sections are available and working.])
-fi
-
 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
 AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
@@ -314,10 +320,6 @@ if test $ld_cv_decl_getopt_unistd_h = yes; then
 	    [Is the prototype for getopt in <unistd.h> in the expected format?])
 fi
 
-BFD_BINARY_FOPEN
-
-AC_CHECK_DECLS([asprintf, environ, free, getenv, sbrk, strstr])
-
 # Link in zlib if we can.  This allows us to read and write
 # compressed CTF sections.
 AM_ZLIB
diff --git a/ld/ld.h b/ld/ld.h
index 1f52be9add6..35fafebfaed 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -21,8 +21,6 @@
 #ifndef LD_H
 #define LD_H
 
-#ifdef HAVE_LOCALE_H
-#endif
 #ifndef SEEK_CUR
 #define SEEK_CUR 1
 #endif
@@ -30,18 +28,16 @@
 #define SEEK_END 2
 #endif
 
-#ifdef HAVE_LOCALE_H
-# ifndef ENABLE_NLS
-   /* The Solaris version of locale.h always includes libintl.h.  If we have
-      been configured with --disable-nls then ENABLE_NLS will not be defined
-      and the dummy definitions of bindtextdomain (et al) below will conflict
-      with the defintions in libintl.h.  So we define these values to prevent
-      the bogus inclusion of libintl.h.  */
-#  define _LIBINTL_H
-#  define _LIBGETTEXT_H
-# endif
-# include <locale.h>
+#ifndef ENABLE_NLS
+  /* The Solaris version of locale.h always includes libintl.h.  If we have
+     been configured with --disable-nls then ENABLE_NLS will not be defined
+     and the dummy definitions of bindtextdomain (et al) below will conflict
+     with the defintions in libintl.h.  So we define these values to prevent
+     the bogus inclusion of libintl.h.  */
+# define _LIBINTL_H
+# define _LIBGETTEXT_H
 #endif
+#include <locale.h>
 
 #ifdef ENABLE_NLS
 # include <libintl.h>
diff --git a/ld/ldmain.c b/ld/ldmain.c
index b99d518ea31..be33b6943c6 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -246,12 +246,10 @@ main (int argc, char **argv)
   char *emulation;
   long start_time = get_run_time ();
 
-#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+#ifdef HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
-#if defined (HAVE_SETLOCALE)
   setlocale (LC_CTYPE, "");
-#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
diff --git a/ld/sysdep.h b/ld/sysdep.h
index 27bce0adf38..a80ac133ade 100644
--- a/ld/sysdep.h
+++ b/ld/sysdep.h
@@ -28,30 +28,15 @@
 #include "config.h"
 
 #include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-
-#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_STAT_H
+#include <sys/stat.h>
 #endif
-
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
-
+#include <string.h>
+#include <stdarg.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -107,18 +92,6 @@ extern char *strrchr ();
 #define SEEK_END 2
 #endif
 
-#if !HAVE_DECL_STRSTR
-extern char *strstr ();
-#endif
-
-#if !HAVE_DECL_FREE
-extern void free ();
-#endif
-
-#if !HAVE_DECL_GETENV
-extern char *getenv ();
-#endif
-
 #if !HAVE_DECL_ENVIRON
 extern char **environ;
 #endif

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-05  5:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-05  5:50 C99 gprof configury Alan Modra
2021-04-05  5:52 ` C99 bfd configury Alan Modra
2021-04-05  5:52   ` C99 opcodes configury Alan Modra
2021-04-05  5:54     ` C99 binutils configury Alan Modra
2021-04-05  5:55       ` C99 gas configury Alan Modra
2021-04-05  5:55         ` C99 ld configury Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).