[RFA] compilation warnings in bfd on Alpha/Tru64

Jerome Guitton guitton@adacore.com
Mon Apr 18 19:07:00 GMT 2005


The following patch should allow to build bfd on Tru64 with -Werrors. It fixes
two problems:

* my patch for checking for basename decl was bogus;
* on OSF5.1, fseeko/ftello are available but their declarations are not
found during the build. Apparently, they are protected by a
"#if _XOPEN_SOURCE>=500"... Setting _XOPEN_SOURCE explicitly would be looking
for troubles, so I suggest to check during the configure if a declaration
is visible for these functions and, if not, to declare them.

Opinions/Thoughts?

-- 
Jerome
-------------- next part --------------
2005-04-18  Jerome Guitton  <guitton@gnat.com>

	* configure.in: Fix the check for basename declaration. Add check
	for declarations of ftello, ftello64, fseeko, fseeko64.
	* configure: Regenerate.
	* config.in: Ditto.
	* sysdep.h: If needed, declare ftello, ftello64, fseeko, fseeko64.

Index: bfd/config.in
===================================================================
RCS file: /cvs/src/src/bfd/config.in,v
retrieving revision 1.22
diff -u -r1.22 config.in
--- bfd/config.in	31 Mar 2005 16:09:03 -0000	1.22
+++ bfd/config.in	18 Apr 2005 17:40:37 -0000
@@ -247,6 +247,18 @@
 /* Define if free is not declared in system header files. */
 #undef NEED_DECLARATION_FREE
 
+/* Define if fseeko is not declared in system header files. */
+#undef NEED_DECLARATION_FSEEKO
+
+/* Define if fseeko64 is not declared in system header files. */
+#undef NEED_DECLARATION_FSEEKO64
+
+/* Define if ftello is not declared in system header files. */
+#undef NEED_DECLARATION_FTELLO
+
+/* Define if ftello64 is not declared in system header files. */
+#undef NEED_DECLARATION_FTELLO64
+
 /* Define if getenv is not declared in system header files. */
 #undef NEED_DECLARATION_GETENV
 
Index: bfd/configure
===================================================================
RCS file: /cvs/src/src/bfd/configure,v
retrieving revision 1.203
diff -u -r1.203 configure
--- bfd/configure	14 Apr 2005 05:26:18 -0000	1.203
+++ bfd/configure	18 Apr 2005 17:40:39 -0000
@@ -9556,8 +9556,7 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include "sysdep.h"
-
+$ac_includes_default
 int
 main ()
 {
@@ -10085,6 +10084,310 @@
 
 fi
 
+echo "$as_me:$LINENO: checking whether ftello must be declared" >&5
+echo $ECHO_N "checking whether ftello must be declared... $ECHO_C" >&6
+if test "${bfd_cv_decl_needed_ftello+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#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
+int
+main ()
+{
+char *(*pfn) = (char *(*)) ftello
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  bfd_cv_decl_needed_ftello=no
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+bfd_cv_decl_needed_ftello=yes
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+echo "$as_me:$LINENO: result: $bfd_cv_decl_needed_ftello" >&5
+echo "${ECHO_T}$bfd_cv_decl_needed_ftello" >&6
+if test $bfd_cv_decl_needed_ftello = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define NEED_DECLARATION_FTELLO 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking whether ftello64 must be declared" >&5
+echo $ECHO_N "checking whether ftello64 must be declared... $ECHO_C" >&6
+if test "${bfd_cv_decl_needed_ftello64+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#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
+int
+main ()
+{
+char *(*pfn) = (char *(*)) ftello64
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  bfd_cv_decl_needed_ftello64=no
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+bfd_cv_decl_needed_ftello64=yes
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+echo "$as_me:$LINENO: result: $bfd_cv_decl_needed_ftello64" >&5
+echo "${ECHO_T}$bfd_cv_decl_needed_ftello64" >&6
+if test $bfd_cv_decl_needed_ftello64 = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define NEED_DECLARATION_FTELLO64 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking whether fseeko must be declared" >&5
+echo $ECHO_N "checking whether fseeko must be declared... $ECHO_C" >&6
+if test "${bfd_cv_decl_needed_fseeko+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#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
+int
+main ()
+{
+char *(*pfn) = (char *(*)) fseeko
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  bfd_cv_decl_needed_fseeko=no
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+bfd_cv_decl_needed_fseeko=yes
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+echo "$as_me:$LINENO: result: $bfd_cv_decl_needed_fseeko" >&5
+echo "${ECHO_T}$bfd_cv_decl_needed_fseeko" >&6
+if test $bfd_cv_decl_needed_fseeko = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define NEED_DECLARATION_FSEEKO 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking whether fseeko64 must be declared" >&5
+echo $ECHO_N "checking whether fseeko64 must be declared... $ECHO_C" >&6
+if test "${bfd_cv_decl_needed_fseeko64+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#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
+int
+main ()
+{
+char *(*pfn) = (char *(*)) fseeko64
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  bfd_cv_decl_needed_fseeko64=no
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+bfd_cv_decl_needed_fseeko64=yes
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+echo "$as_me:$LINENO: result: $bfd_cv_decl_needed_fseeko64" >&5
+echo "${ECHO_T}$bfd_cv_decl_needed_fseeko64" >&6
+if test $bfd_cv_decl_needed_fseeko64 = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define NEED_DECLARATION_FSEEKO64 1
+_ACEOF
+
+fi
+
 
 # If we are configured native, pick a core file support file.
 COREFILE=
Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.175
diff -u -r1.175 configure.in
--- bfd/configure.in	14 Apr 2005 05:26:17 -0000	1.175
+++ bfd/configure.in	18 Apr 2005 17:40:39 -0000
@@ -127,7 +127,7 @@
 AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid)
 AC_CHECK_FUNCS(strtoull)
 
-AC_CHECK_DECLS(basename, , , [#include "sysdep.h"])
+AC_CHECK_DECLS(basename)
 
 BFD_BINARY_FOPEN
 
@@ -137,6 +137,10 @@
 BFD_NEED_DECLARATION(malloc)
 BFD_NEED_DECLARATION(realloc)
 BFD_NEED_DECLARATION(strstr)
+BFD_NEED_DECLARATION(ftello)
+BFD_NEED_DECLARATION(ftello64)
+BFD_NEED_DECLARATION(fseeko)
+BFD_NEED_DECLARATION(fseeko64)
 
 # If we are configured native, pick a core file support file.
 COREFILE=
Index: bfd/sysdep.h
===================================================================
RCS file: /cvs/src/src/bfd/sysdep.h,v
retrieving revision 1.8
diff -u -r1.8 sysdep.h
--- bfd/sysdep.h	30 Mar 2005 02:46:25 -0000	1.8
+++ bfd/sysdep.h	18 Apr 2005 17:40:40 -0000
@@ -129,6 +129,30 @@
 extern char *strstr ();
 #endif
 
+#ifdef HAVE_FTELLO
+#ifdef NEED_DECLARATION_FTELLO
+extern off_t ftello (FILE *stream);
+#endif
+#endif
+
+#ifdef HAVE_FTELLO64
+#ifdef NEED_DECLARATION_FTELLO64
+extern off64_t ftello64 (FILE *stream);
+#endif
+#endif
+
+#ifdef HAVE_FSEEKO
+#ifdef NEED_DECLARATION_FSEEKO
+extern int fseeko (FILE *stream, off_t offset, int whence);
+#endif
+#endif
+
+#ifdef HAVE_FSEEKO64
+#ifdef NEED_DECLARATION_FSEEKO64
+extern int fseeko64 (FILE *stream, off64_t offset, int whence);
+#endif
+#endif
+
 /* Define offsetof for those systems which lack it */
 
 #ifndef offsetof


More information about the Binutils mailing list