summaryrefslogtreecommitdiff
path: root/src/dev/disk_image.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <Andreas.Sandberg@ARM.com>2013-02-15 17:40:10 -0500
committerAndreas Sandberg <Andreas.Sandberg@ARM.com>2013-02-15 17:40:10 -0500
commit08467a88a67c1d8b8530694b27ca04fbba8dd8d8 (patch)
tree0d1388ed62a440704c0d0a392c7e2bcb4ef164e0 /src/dev/disk_image.hh
parentca96e7bff1dfaa8e0a6d900feb88c711198b4b2b (diff)
downloadgem5-08467a88a67c1d8b8530694b27ca04fbba8dd8d8.tar.xz
dev: Use the correct return type for disk offsets
Replace the use of off_t in the various DiskImage related classes with std::streampos. off_t is a signed 32 bit integer on most 32-bit systems, whereas std::streampos is normally a 64 bit integer on most modern systems. Furthermore, std::streampos is the type used by tellg() and seekg() in the standard library, so it should have been used in the first place. This patch makes it possible to use disk images larger than 2 GiB on 32 bit systems with a modern C++ standard library.
Diffstat (limited to 'src/dev/disk_image.hh')
-rw-r--r--src/dev/disk_image.hh22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/dev/disk_image.hh b/src/dev/disk_image.hh
index 1b846522f..905879248 100644
--- a/src/dev/disk_image.hh
+++ b/src/dev/disk_image.hh
@@ -58,10 +58,12 @@ class DiskImage : public SimObject
DiskImage(const Params *p) : SimObject(p), initialized(false) {}
virtual ~DiskImage() {}
- virtual off_t size() const = 0;
+ virtual std::streampos size() const = 0;
- virtual off_t read(uint8_t *data, off_t offset) const = 0;
- virtual off_t write(const uint8_t *data, off_t offset) = 0;
+ virtual std::streampos read(uint8_t *data,
+ std::streampos offset) const = 0;
+ virtual std::streampos write(const uint8_t *data,
+ std::streampos offset) = 0;
};
/**
@@ -73,7 +75,7 @@ class RawDiskImage : public DiskImage
mutable std::fstream stream;
std::string file;
bool readonly;
- mutable off_t disk_size;
+ mutable std::streampos disk_size;
public:
typedef RawDiskImageParams Params;
@@ -83,10 +85,10 @@ class RawDiskImage : public DiskImage
void close();
void open(const std::string &filename, bool rd_only = false);
- virtual off_t size() const;
+ virtual std::streampos size() const;
- virtual off_t read(uint8_t *data, off_t offset) const;
- virtual off_t write(const uint8_t *data, off_t offset);
+ virtual std::streampos read(uint8_t *data, std::streampos offset) const;
+ virtual std::streampos write(const uint8_t *data, std::streampos offset);
};
/**
@@ -129,10 +131,10 @@ class CowDiskImage : public DiskImage
void serialize(std::ostream &os);
void unserialize(Checkpoint *cp, const std::string &section);
- virtual off_t size() const;
+ virtual std::streampos size() const;
- virtual off_t read(uint8_t *data, off_t offset) const;
- virtual off_t write(const uint8_t *data, off_t offset);
+ virtual std::streampos read(uint8_t *data, std::streampos offset) const;
+ virtual std::streampos write(const uint8_t *data, std::streampos offset);
};
#endif // __DISK_IMAGE_HH__