aboutsummaryrefslogtreecommitdiff
path: root/gold/fileread.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-09-25 00:27:29 +0000
committerIan Lance Taylor <iant@google.com>2007-09-25 00:27:29 +0000
commitba45d2478b259454e5b4c2d7dcaa7a35ecbf329c (patch)
treee9d069c39988c400a7f41583978372080b661a92 /gold/fileread.cc
parent5f67a19ce6e7ddd10473df8e2754d9d229c884fe (diff)
downloadgdb-ba45d2478b259454e5b4c2d7dcaa7a35ecbf329c.zip
gdb-ba45d2478b259454e5b4c2d7dcaa7a35ecbf329c.tar.gz
gdb-ba45d2478b259454e5b4c2d7dcaa7a35ecbf329c.tar.bz2
Break out default pbytes argument to read and get_view routines,
adding new routines.
Diffstat (limited to 'gold/fileread.cc')
-rw-r--r--gold/fileread.cc33
1 files changed, 29 insertions, 4 deletions
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 8fad789..a39d530 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -202,8 +202,25 @@ File_read::do_read(off_t start, off_t size, void* p, off_t* pbytes)
return bytes;
}
+// Read data from the file.
+
void
-File_read::read(off_t start, off_t size, void* p, off_t* pbytes)
+File_read::read(off_t start, off_t size, void* p)
+{
+ gold_assert(this->lock_count_ > 0);
+
+ File_read::View* pv = this->find_view(start, size);
+ if (pv != NULL)
+ {
+ memcpy(p, pv->data() + (start - pv->start()), size);
+ return;
+ }
+
+ this->do_read(start, size, p, NULL);
+}
+
+void
+File_read::read_up_to(off_t start, off_t size, void* p, off_t* pbytes)
{
gold_assert(this->lock_count_ > 0);
@@ -286,7 +303,15 @@ File_read::find_or_make_view(off_t start, off_t size, off_t* pbytes)
// mmap.
const unsigned char*
-File_read::get_view(off_t start, off_t size, off_t* pbytes)
+File_read::get_view(off_t start, off_t size)
+{
+ gold_assert(this->lock_count_ > 0);
+ File_read::View* pv = this->find_or_make_view(start, size, NULL);
+ return pv->data() + (start - pv->start());
+}
+
+const unsigned char*
+File_read::get_view_and_size(off_t start, off_t size, off_t* pbytes)
{
gold_assert(this->lock_count_ > 0);
File_read::View* pv = this->find_or_make_view(start, size, pbytes);
@@ -294,10 +319,10 @@ File_read::get_view(off_t start, off_t size, off_t* pbytes)
}
File_view*
-File_read::get_lasting_view(off_t start, off_t size, off_t* pbytes)
+File_read::get_lasting_view(off_t start, off_t size)
{
gold_assert(this->lock_count_ > 0);
- File_read::View* pv = this->find_or_make_view(start, size, pbytes);
+ File_read::View* pv = this->find_or_make_view(start, size, NULL);
pv->lock();
return new File_view(*this, pv, pv->data() + (start - pv->start()));
}