]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* strings.c: Include config.h before bfd.h.
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Dec 2001 10:11:22 +0000 (10:11 +0000)
committerJakub Jelinek <jakub@redhat.com>
Tue, 4 Dec 2001 10:11:22 +0000 (10:11 +0000)
(file_off): New type.
(file_open): Define.
(print_strings): Use file_off instead of file_ptr.  Print addresses
which don't fit into long correctly.
(get_char): Use file_off instead of file_ptr.  Use getc_unlocked if
available.
(strings_file): Use file_off instead of file_ptr.  Use file_open.
* configure.in: Check for getc_unlocked.
Check for fopen64 and whether _LARGEFILE64_SOURCE needs to
be defined for it.
* configure: Rebuilt.
* config.h.in: Rebuilt.

binutils/ChangeLog
binutils/config.in
binutils/configure
binutils/configure.in
binutils/strings.c

index 3bb6ea2f6f0bc060b778bbc8c8447299b4a695a8..8548ec3b7153adbf3bdd7825238db9c0930c4dbd 100644 (file)
@@ -1,3 +1,19 @@
+2001-12-04  Jakub Jelinek  <jakub@redhat.com>
+
+       * strings.c: Include config.h before bfd.h.
+       (file_off): New type.
+       (file_open): Define.
+       (print_strings): Use file_off instead of file_ptr.  Print addresses
+       which don't fit into long correctly.
+       (get_char): Use file_off instead of file_ptr.  Use getc_unlocked if
+       available.
+       (strings_file): Use file_off instead of file_ptr.  Use file_open.
+       * configure.in: Check for getc_unlocked.
+       Check for fopen64 and whether _LARGEFILE64_SOURCE needs to
+       be defined for it.
+       * configure: Rebuilt.
+       * config.h.in: Rebuilt.
+
 2001-11-29  H.J. Lu <hjl@gnu.org>
 
        * bucomm.c (make_tempname): Revert the changes made on
index 8a0e1c57517921924a87f897ddc8482bbcb37ad2..1e0aa93b9c49fa7f6244007e9b78114a8dfd5fab 100644 (file)
@@ -58,6 +58,9 @@
 /* Define if you have the dcgettext function.  */
 #undef HAVE_DCGETTEXT
 
+/* Define if you have the getc_unlocked function.  */
+#undef HAVE_GETC_UNLOCKED
+
 /* Define if you have the getcwd function.  */
 #undef HAVE_GETCWD
 
 /* Define if you have the <sys/param.h> header file.  */
 #undef HAVE_SYS_PARAM_H
 
+/* Define if you have the <sys/stat.h> header file.  */
+#undef HAVE_SYS_STAT_H
+
+/* Define if you have the <sys/types.h> header file.  */
+#undef HAVE_SYS_TYPES_H
+
 /* Define if you have the <unistd.h> header file.  */
 #undef HAVE_UNISTD_H
 
 /* Suffix used for executables, if any. */
 #undef EXECUTABLE_SUFFIX
 
+/* Is fopen64 available? */
+#undef HAVE_FOPEN64
+
+/* Enable LFS */
+#undef _LARGEFILE64_SOURCE
+
 /* Is the type time_t defined in <time.h>? */
 #undef HAVE_TIME_T_IN_TIME_H
 
index 2268453ef5e42cc08104d94062bc2ac0153cd71a..68683414a9eb4fb3a6c6cdbd1e1050bac96560dc 100755 (executable)
@@ -4899,7 +4899,7 @@ EOF
 
 fi
 
-for ac_func in sbrk utimes setmode
+for ac_func in sbrk utimes setmode getc_unlocked
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:4906: checking for $ac_func" >&5
@@ -4955,6 +4955,67 @@ fi
 done
 
 
+# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
+# needs to be defined for it
+echo $ac_n "checking for fopen64""... $ac_c" 1>&6
+echo "configure:4962: checking for fopen64" >&5
+if eval "test \"`echo '$''{'bu_cv_have_fopen64'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 4967 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int main() {
+FILE *f = fopen64 ("/tmp/foo","r");
+; return 0; }
+EOF
+if { (eval echo configure:4974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  bu_cv_have_fopen64=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  saved_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
+ cat > conftest.$ac_ext <<EOF
+#line 4984 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int main() {
+FILE *f = fopen64 ("/tmp/foo","r");
+; return 0; }
+EOF
+if { (eval echo configure:4991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  bu_cv_have_fopen64=no
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+ CPPFLAGS=$saved_CPPFLAGS
+
+echo "$ac_t""$bu_cv_have_fopen64" 1>&6
+if test $bu_cv_have_fopen64 != no; then
+  cat >> confdefs.h <<\EOF
+#define HAVE_FOPEN64 1
+EOF
+
+  if test $bu_cv_have_fopen64 = "need -D_LARGEFILE64_SOURCE"; then
+    cat >> confdefs.h <<\EOF
+#define _LARGEFILE64_SOURCE 1
+EOF
+
+  fi
+fi
+
 # Some systems have frexp only in -lm, not in -lc.
 
 echo $ac_n "checking for library containing frexp""... $ac_c" 1>&6
index 23d517b4b9cd261b89f36c7d5428e6b4575d6523..05558529a9a7b31e028a9ab27284e82775da5e52 100644 (file)
@@ -100,7 +100,29 @@ AC_SUBST(DEMANGLER_NAME)
 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h)
 AC_HEADER_SYS_WAIT
 AC_FUNC_ALLOCA
-AC_CHECK_FUNCS(sbrk utimes setmode)
+AC_CHECK_FUNCS(sbrk utimes setmode getc_unlocked)
+
+# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
+# needs to be defined for it
+AC_MSG_CHECKING([for fopen64])
+AC_CACHE_VAL(bu_cv_have_fopen64,
+[AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");],
+bu_cv_have_fopen64=yes,
+[saved_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
+ AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");],
+bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
+bu_cv_have_fopen64=no)
+ CPPFLAGS=$saved_CPPFLAGS])])
+AC_MSG_RESULT($bu_cv_have_fopen64)
+if test $bu_cv_have_fopen64 != no; then
+  AC_DEFINE([HAVE_FOPEN64], 1,
+           [Is fopen64 available?])
+  if test $bu_cv_have_fopen64 = "need -D_LARGEFILE64_SOURCE"; then
+    AC_DEFINE([_LARGEFILE64_SOURCE], 1,
+             [Enable LFS])
+  fi
+fi
 
 # Some systems have frexp only in -lm, not in -lc.
 AC_SEARCH_LIBS(frexp, m)
index dec77dfc20dc1328c73bd9c72bbc780affaeba91..89e322bc8e59bd65bafa066a9d169a0fe0a1ba6a 100644 (file)
@@ -56,6 +56,9 @@
    Written by Richard Stallman <rms@gnu.ai.mit.edu>
    and David MacKenzie <djm@gnu.ai.mit.edu>.  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include "bfd.h"
 #include <stdio.h>
 #include <getopt.h>
@@ -90,6 +93,14 @@ extern int errno;
 /* The BFD section flags that identify an initialized data section.  */
 #define DATA_FLAGS (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS)
 
+#ifdef HAVE_FOPEN64
+typedef off64_t file_off;
+#define file_open(s,m) fopen64(s,m)
+#else
+typedef off_t file_off;
+#define file_open(s,m) fopen(s,m)
+#endif
+
 /* Radix for printing addresses (must be 8, 10 or 16).  */
 static int address_radix;
 
@@ -133,10 +144,10 @@ static boolean strings_object_file PARAMS ((const char *));
 static boolean strings_file PARAMS ((char *file));
 static int integer_arg PARAMS ((char *s));
 static void print_strings PARAMS ((const char *filename, FILE *stream,
-                                 file_ptr address, int stop_point,
+                                 file_off address, int stop_point,
                                  int magiccount, char *magic));
 static void usage PARAMS ((FILE *stream, int status));
-static long get_char PARAMS ((FILE *stream, file_ptr *address,
+static long get_char PARAMS ((FILE *stream, file_off *address,
                              int *magiccount, char **magic));
 \f
 int
@@ -371,10 +382,7 @@ strings_file (file)
     {
       FILE *stream;
 
-      stream = fopen (file, "rb");
-      /* Not all systems permit "rb", so try "r" if it failed.  */
-      if (stream == NULL)
-       stream = fopen (file, "r");
+      stream = file_open (file, FOPEN_RB);
       if (stream == NULL)
        {
          fprintf (stderr, "%s: ", program_name);
@@ -382,7 +390,7 @@ strings_file (file)
          return false;
        }
 
-      print_strings (file, stream, (file_ptr) 0, 0, 0, (char *) 0);
+      print_strings (file, stream, (file_off) 0, 0, 0, (char *) 0);
 
       if (fclose (stream) == EOF)
        {
@@ -408,7 +416,7 @@ strings_file (file)
 static long
 get_char (stream, address, magiccount, magic)
      FILE *stream;
-     file_ptr *address;
+     file_off *address;
      int *magiccount;
      char **magic;
 {
@@ -427,7 +435,11 @@ get_char (stream, address, magiccount, magic)
        {
          if (stream == NULL)
            return EOF;
+#ifdef HAVE_GETC_UNLOCKED
+         c = getc_unlocked (stream);
+#else
          c = getc (stream);
+#endif
          if (c == EOF)
            return EOF;
        }
@@ -479,7 +491,7 @@ static void
 print_strings (filename, stream, address, stop_point, magiccount, magic)
      const char *filename;
      FILE *stream;
-     file_ptr address;
+     file_off address;
      int stop_point;
      int magiccount;
      char *magic;
@@ -488,7 +500,7 @@ print_strings (filename, stream, address, stop_point, magiccount, magic)
 
   while (1)
     {
-      file_ptr start;
+      file_off start;
       int i;
       long c;
 
@@ -517,15 +529,48 @@ print_strings (filename, stream, address, stop_point, magiccount, magic)
        switch (address_radix)
          {
          case 8:
-           printf ("%7lo ", (unsigned long) start);
+#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+           if (sizeof (start) > sizeof (long))
+             printf ("%7Lo ", (unsigned long long) start);
+           else
+#else
+# if !BFD_HOST_64BIT_LONG
+           if (start != (unsigned long) start)
+             printf ("++%7lo ", (unsigned long) start);
+           else
+# endif
+#endif
+             printf ("%7lo ", (unsigned long) start);
            break;
 
          case 10:
-           printf ("%7ld ", (long) start);
+#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+           if (sizeof (start) > sizeof (long))
+             printf ("%7Ld ", (unsigned long long) start);
+           else
+#else
+# if !BFD_HOST_64BIT_LONG
+           if (start != (unsigned long) start)
+             printf ("++%7ld ", (unsigned long) start);
+           else
+# endif
+#endif
+             printf ("%7ld ", (long) start);
            break;
 
          case 16:
-           printf ("%7lx ", (unsigned long) start);
+#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+           if (sizeof (start) > sizeof (long))
+             printf ("%7Lx ", (unsigned long long) start);
+           else
+#else
+# if !BFD_HOST_64BIT_LONG
+           if (start != (unsigned long) start)
+             printf ("%lx%8.8lx ", start >> 32, start & 0xffffffff);
+           else
+# endif
+#endif
+             printf ("%7lx ", (unsigned long) start);
            break;
          }