PR gold/12525
authorIan Lance Taylor <ian@airs.com>
Wed, 9 Mar 2011 01:50:33 +0000 (01:50 +0000)
committerIan Lance Taylor <ian@airs.com>
Wed, 9 Mar 2011 01:50:33 +0000 (01:50 +0000)
* fileread.cc: #include <climits>.
(GOLD_IOV_MAX): Define.
(File_read::read_multiple): Limit number of entries by iov_max.
* fileread.h (class File_read): Always set max_readv_entries to
128.

gold/ChangeLog
gold/fileread.cc
gold/fileread.h

index b0e90a118d6b4e952bc1c1f57067bc9a50dcb7de..c02a174494ee382bb33112b8d0eb6020d323374a 100644 (file)
@@ -1,3 +1,12 @@
+2011-03-08  Ian Lance Taylor  <iant@google.com>
+
+       PR gold/12525
+       * fileread.cc: #include <climits>.
+       (GOLD_IOV_MAX): Define.
+       (File_read::read_multiple): Limit number of entries by iov_max.
+       * fileread.h (class File_read): Always set max_readv_entries to
+       128.
+
 2011-03-07  Ian Lance Taylor  <iant@google.com>
 
        PR gold/12525
index 14a02b2f52f9ae29274d97342d461bd5d81a8afe..654e47b42491bb8e59a653eb012838b9a41a9cd6 100644 (file)
@@ -1,6 +1,6 @@
 // fileread.cc -- read files for gold
 
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -24,6 +24,7 @@
 
 #include <cstring>
 #include <cerrno>
+#include <climits>
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/mman.h>
@@ -605,11 +606,22 @@ File_read::do_readv(off_t base, const Read_multiple& rm, size_t start,
               got, want, static_cast<long long>(base + first_offset));
 }
 
+// Portable IOV_MAX.
+
+#if !defined(HAVE_READV)
+#define GOLD_IOV_MAX 1
+#elif defined(IOV_MAX)
+#define GOLD_IOV_MAX IOV_MAX
+#else
+#define GOLD_IOV_MAX (File_read::max_readv_entries * 2)
+#endif
+
 // Read several pieces of data from the file.
 
 void
 File_read::read_multiple(off_t base, const Read_multiple& rm)
 {
+  static size_t iov_max = GOLD_IOV_MAX;
   size_t count = rm.size();
   size_t i = 0;
   while (i < count)
@@ -622,7 +634,7 @@ File_read::read_multiple(off_t base, const Read_multiple& rm)
       size_t j;
       for (j = i + 1; j < count; ++j)
        {
-         if (j - i >= File_read::max_readv_entries)
+         if (j - i >= File_read::max_readv_entries || j - i >= iov_max / 2)
            break;
          const Read_multiple_entry& j_entry(rm[j]);
          off_t j_off = j_entry.file_offset;
index a972af9ee753414d667dd2436efb3ab7763a9853..d2ac9276f3aa3b6b486a9dc2b3caf48c81c3dde7 100644 (file)
@@ -1,6 +1,6 @@
 // fileread.h -- read files for gold   -*- C++ -*-
 
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -399,13 +399,7 @@ class File_read
   { return (file_size + (page_size - 1)) & ~ (page_size - 1); }
 
   // The maximum number of entries we will pass to ::readv.
-#ifdef HAVE_READV
   static const size_t max_readv_entries = 128;
-#else
-  // On targets that don't have readv set the max to 1 so readv is not
-  // used.
-  static const size_t max_readv_entries = 1;
-#endif
 
   // Use readv to read data.
   void
This page took 0.031745 seconds and 4 git commands to generate.