aboutsummaryrefslogtreecommitdiff
path: root/gold/fileread.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-09-25 17:50:26 +0000
committerIan Lance Taylor <iant@google.com>2007-09-25 17:50:26 +0000
commit9eb9fa57c2a9eec4c08491715d3341df811b7f9c (patch)
treec68eac98b999ebfb3251ab5f9851900bf8e4179b /gold/fileread.h
parent0b058123a01a282fe112ee8863bfbf0abf89f29b (diff)
downloadgdb-9eb9fa57c2a9eec4c08491715d3341df811b7f9c.zip
gdb-9eb9fa57c2a9eec4c08491715d3341df811b7f9c.tar.gz
gdb-9eb9fa57c2a9eec4c08491715d3341df811b7f9c.tar.bz2
Add cache parameter to get_view. Discard uncached views on unlock.
Fix bug this exposed in archive armap symbol name handling.
Diffstat (limited to 'gold/fileread.h')
-rw-r--r--gold/fileread.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/gold/fileread.h b/gold/fileread.h
index ef5efc0..0e5caa9 100644
--- a/gold/fileread.h
+++ b/gold/fileread.h
@@ -88,9 +88,12 @@ class File_read
// Return a view into the file starting at file offset START for
// SIZE bytes. The pointer will remain valid until the File_read is
// unlocked. It is an error if we can not read enough data from the
- // file.
+ // file. The CACHE parameter is a hint as to whether it will be
+ // useful to cache this data for later accesses--i.e., later calls
+ // to get_view, read, or get_lasting_view which retrieve the same
+ // data.
const unsigned char*
- get_view(off_t start, off_t size);
+ get_view(off_t start, off_t size, bool cache);
// Read data from the file into the buffer P starting at file offset
// START for SIZE bytes.
@@ -101,9 +104,10 @@ class File_read
// for SIZE bytes. This is allocated with new, and the caller is
// responsible for deleting it when done. The data associated with
// this view will remain valid until the view is deleted. It is an
- // error if we can not read enough data from the file.
+ // error if we can not read enough data from the file. The CACHE
+ // parameter is as in get_view.
File_view*
- get_lasting_view(off_t start, off_t size);
+ get_lasting_view(off_t start, off_t size, bool cache);
private:
// This class may not be copied.
@@ -114,8 +118,9 @@ class File_read
class View
{
public:
- View(off_t start, off_t size, const unsigned char* data)
- : start_(start), size_(size), data_(data), lock_count_(0)
+ View(off_t start, off_t size, const unsigned char* data, bool cache)
+ : start_(start), size_(size), data_(data), lock_count_(0),
+ cache_(cache)
{ }
~View();
@@ -141,6 +146,14 @@ class File_read
bool
is_locked();
+ void
+ set_cache()
+ { this->cache_ = true; }
+
+ bool
+ should_cache() const
+ { return this->cache_; }
+
private:
View(const View&);
View& operator=(const View&);
@@ -149,6 +162,7 @@ class File_read
off_t size_;
const unsigned char* data_;
int lock_count_;
+ bool cache_;
};
friend class File_view;
@@ -158,16 +172,12 @@ class File_read
find_view(off_t start, off_t size);
// Read data from the file into a buffer.
- off_t
- do_read(off_t start, off_t size, void* p);
-
- // Read an exact number of bytes into a buffer.
void
- do_read_exact(off_t start, off_t size, void* p);
+ do_read(off_t start, off_t size, void* p);
// Find or make a view into the file.
View*
- find_or_make_view(off_t start, off_t size);
+ find_or_make_view(off_t start, off_t size, bool cache);
// Clear the file views.
void