summaryrefslogtreecommitdiff
path: root/src/base/chunk_generator.hh
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
committerNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
commit6faf377b5305f9dcc3c7b013c4d67f5accb92617 (patch)
tree0e437fb49a32dd3d2d2bec95a8dc3bdb4ddf05b0 /src/base/chunk_generator.hh
parent4e3426624557b555c354035ee3961eab7554d81d (diff)
downloadgem5-6faf377b5305f9dcc3c7b013c4d67f5accb92617.tar.xz
types: clean up types, especially signed vs unsigned
Diffstat (limited to 'src/base/chunk_generator.hh')
-rw-r--r--src/base/chunk_generator.hh25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/base/chunk_generator.hh b/src/base/chunk_generator.hh
index d2ae45d1e..bc71a0569 100644
--- a/src/base/chunk_generator.hh
+++ b/src/base/chunk_generator.hh
@@ -37,8 +37,9 @@
*/
#include <algorithm>
+
#include "base/intmath.hh"
-#include "arch/isa_traits.hh" // for Addr
+#include "base/types.hh"
/**
* This class takes an arbitrary memory region (address/length pair)
@@ -61,13 +62,13 @@ class ChunkGenerator
/** The starting address of the next chunk (after the current one). */
Addr nextAddr;
/** The size of the current chunk (in bytes). */
- int curSize;
+ unsigned curSize;
/** The number of bytes remaining in the region after the current chunk. */
- int sizeLeft;
+ unsigned sizeLeft;
/** The start address so we can calculate offset in writing block. */
const Addr startAddr;
/** The maximum chunk size, e.g., the cache block size or page size. */
- const int chunkSize;
+ const unsigned chunkSize;
public:
/**
@@ -77,7 +78,7 @@ class ChunkGenerator
* @param _chunkSize The size/alignment of chunks into which
* the region should be decomposed.
*/
- ChunkGenerator(Addr _startAddr, int totalSize, int _chunkSize)
+ ChunkGenerator(Addr _startAddr, unsigned totalSize, unsigned _chunkSize)
: startAddr(_startAddr), chunkSize(_chunkSize)
{
// chunkSize must be a power of two
@@ -102,31 +103,33 @@ class ChunkGenerator
}
// how many bytes are left between curAddr and the end of this chunk?
- int left_in_chunk = nextAddr - curAddr;
+ unsigned left_in_chunk = nextAddr - curAddr;
curSize = std::min(totalSize, left_in_chunk);
sizeLeft = totalSize - curSize;
}
/** Return starting address of current chunk. */
- Addr addr() { return curAddr; }
+ Addr addr() const { return curAddr; }
/** Return size in bytes of current chunk. */
- int size() { return curSize; }
+ unsigned size() const { return curSize; }
/** Number of bytes we have already chunked up. */
- int complete() { return curAddr - startAddr; }
+ unsigned complete() const { return curAddr - startAddr; }
+
/**
* Are we done? That is, did the last call to next() advance
* past the end of the region?
* @return True if yes, false if more to go.
*/
- bool done() { return (curSize == 0); }
+ bool done() const { return (curSize == 0); }
/**
* Advance generator to next chunk.
* @return True if successful, false if unsuccessful
* (because we were at the last chunk).
*/
- bool next()
+ bool
+ next()
{
if (sizeLeft == 0) {
curSize = 0;