This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix build on Solaris 2.5.1
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: binutils at sourceware dot org
- Date: Mon, 30 Jan 2006 11:27:16 +0100
- Subject: [PATCH] Fix build on Solaris 2.5.1
Hi,
I need the attached patch to let mainline build on SPARC/Solaris 2.5.1.
Tested on SPARC/Solaris 2.5.1-2.10 and x86-64/Linux. OK for mainline?
2006-01-30 Eric Botcazou <ebotcazou@libertysurf.fr>
binutils/
* configure.in (CHECK_DECLS): Add snprintf and vsnprintf.
* configure: Regenerate.
* objdump.c (fprintf): Remove declaration.
* bucomm.h (fprintf): Declare if not already declared.
(snprintf): Likewise.
(vsnprintf): Likewise.
gas/
* configure.in (CHECK_DECLS): Add vsnprintf.
* configure: Regenerate.
* messages.c (errno.h, stdarg.h, varargs.h, va_list):
Do not include/declare here, but...
* as.h: Move code detecting VARARGS idiom to the top.
(errno.h, stdarg.h, varargs.h, va_list): ...here.
(vsnprintf): Declare if not already declared.
--
Eric Botcazou
Index: binutils/bucomm.h
===================================================================
RCS file: /cvs/src/src/binutils/bucomm.h,v
retrieving revision 1.20
diff -u -p -r1.20 bucomm.h
--- binutils/bucomm.h 30 Sep 2005 11:42:05 -0000 1.20
+++ binutils/bucomm.h 30 Jan 2006 08:27:26 -0000
@@ -90,6 +90,18 @@ extern char *getenv ();
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
+
#ifndef O_RDONLY
#define O_RDONLY 0
#endif
Index: binutils/configure.in
===================================================================
RCS file: /cvs/src/src/binutils/configure.in,v
retrieving revision 1.59
diff -u -p -r1.59 configure.in
--- binutils/configure.in 26 Jan 2006 14:43:55 -0000 1.59
+++ binutils/configure.in 30 Jan 2006 08:27:27 -0000
@@ -172,7 +172,8 @@ if test $bu_cv_header_utime_h = yes; the
AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
fi
-AC_CHECK_DECLS([fprintf, stpcpy, strstr, sbrk, getenv, environ, getc_unlocked])
+AC_CHECK_DECLS([fprintf, stpcpy, strstr, sbrk, getenv, environ, getc_unlocked,
+ snprintf, vsnprintf])
BFD_BINARY_FOPEN
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.116
diff -u -p -r1.116 objdump.c
--- binutils/objdump.c 17 Jan 2006 17:39:20 -0000 1.116
+++ binutils/objdump.c 30 Jan 2006 08:27:28 -0000
@@ -66,11 +66,6 @@
#define BYTES_IN_WORD 32
#include "aout/aout64.h"
-#if !HAVE_DECL_FPRINTF
-/* This is needed by init_disassemble_info(). */
-extern int fprintf (FILE *, const char *, ...);
-#endif
-
/* Exit status. */
static int exit_status = 0;
Index: gas/as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.50
diff -u -p -r1.50 as.h
--- gas/as.h 8 Nov 2005 15:48:26 -0000 1.50
+++ gas/as.h 30 Jan 2006 08:27:29 -0000
@@ -68,6 +68,19 @@ extern void *alloca ();
# endif /* HAVE_ALLOCA_H */
#endif /* __GNUC__ */
+/* Prefer varargs for non-ANSI compiler, since some will barf if the
+ ellipsis definition is used with a no-arguments declaration. */
+#if defined (HAVE_VARARGS_H) && !defined (__STDC__)
+#undef HAVE_STDARG_H
+#endif
+
+#if defined (HAVE_STDARG_H)
+#define USE_STDARG
+#endif
+#if !defined (USE_STDARG) && defined (HAVE_VARARGS_H)
+#define USE_VARARGS
+#endif
+
/* Now, tend to the rest of the configuration. */
/* System include files first... */
@@ -90,6 +103,27 @@ extern void *alloca ();
#include <sys/types.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifdef USE_STDARG
+#include <stdarg.h>
+#endif
+
+#ifdef USE_VARARGS
+#include <varargs.h>
+#endif
+
+#if !defined (USE_STDARG) && !defined (USE_VARARGS)
+/* Roll our own. */
+#define va_alist REST
+#define va_dcl
+typedef int * va_list;
+#define va_start(ARGS) ARGS = &REST
+#define va_end(ARGS)
+#endif
+
#include "getopt.h"
/* The first getopt value for machine-independent long options.
150 isn't special; it's just an arbitrary non-ASCII char value. */
@@ -145,6 +179,10 @@ extern PTR realloc ();
extern char *strstr ();
#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
@@ -442,19 +480,6 @@ struct _pseudo_type
typedef struct _pseudo_type pseudo_typeS;
-/* Prefer varargs for non-ANSI compiler, since some will barf if the
- ellipsis definition is used with a no-arguments declaration. */
-#if defined (HAVE_VARARGS_H) && !defined (__STDC__)
-#undef HAVE_STDARG_H
-#endif
-
-#if defined (HAVE_STDARG_H)
-#define USE_STDARG
-#endif
-#if !defined (USE_STDARG) && defined (HAVE_VARARGS_H)
-#define USE_VARARGS
-#endif
-
#ifdef USE_STDARG
#if (__GNUC__ >= 2) && !defined(VMS)
/* for use with -Wformat */
Index: gas/configure.in
===================================================================
RCS file: /cvs/src/src/gas/configure.in,v
retrieving revision 1.184
diff -u -p -r1.184 configure.in
--- gas/configure.in 16 Dec 2005 10:23:07 -0000 1.184
+++ gas/configure.in 30 Jan 2006 08:27:30 -0000
@@ -663,6 +663,8 @@ GAS_CHECK_DECL_NEEDED(malloc, f, char *(
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([vsnprintf])
+
dnl This must come last.
dnl We used to make symlinks to files in the source directory, but now
Index: gas/messages.c
===================================================================
RCS file: /cvs/src/src/gas/messages.c,v
retrieving revision 1.15
diff -u -p -r1.15 messages.c
--- gas/messages.c 11 Aug 2005 01:25:20 -0000 1.15
+++ gas/messages.c 30 Jan 2006 08:27:30 -0000
@@ -21,28 +21,6 @@
#include "as.h"
-#include <stdio.h>
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-#ifdef USE_STDARG
-#include <stdarg.h>
-#endif
-
-#ifdef USE_VARARGS
-#include <varargs.h>
-#endif
-
-#if !defined (USE_STDARG) && !defined (USE_VARARGS)
-/* Roll our own. */
-#define va_alist REST
-#define va_dcl
-typedef int * va_list;
-#define va_start(ARGS) ARGS = &REST
-#define va_end(ARGS)
-#endif
-
static void identify (char *);
static void as_show_where (void);
static void as_warn_internal (char *, unsigned int, char *);