Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/34177 )
Change subject: base: Minor cleanup of the ChunkGenerator.
......................................................................
base: Minor cleanup of the ChunkGenerator.
Minor style fixes, switched to Addr for some types so they'll definitely
be large enough.
Change-Id: I985004116c48ce6fb236c04e04fe54ed49a68277
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34177
Reviewed-by: Steve Reinhardt <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/base/chunk_generator.hh
1 file changed, 18 insertions(+), 21 deletions(-)
Approvals:
Steve Reinhardt: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/base/chunk_generator.hh b/src/base/chunk_generator.hh
index 994d83a..4c749b2 100644
--- a/src/base/chunk_generator.hh
+++ b/src/base/chunk_generator.hh
@@ -26,8 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __BASE__CHUNK_GENERATOR_HH__
-#define __BASE__CHUNK_GENERATOR_HH__
+#ifndef __BASE_CHUNK_GENERATOR_HH__
+#define __BASE_CHUNK_GENERATOR_HH__
/**
* @file
@@ -60,13 +60,13 @@
/** The starting address of the next chunk (after the current one). */
Addr nextAddr;
/** The size of the current chunk (in bytes). */
- unsigned curSize;
+ Addr curSize;
/** The number of bytes remaining in the region after the current
chunk. */
- unsigned sizeLeft;
+ Addr 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 unsigned chunkSize;
+ const Addr chunkSize;
public:
/**
@@ -78,8 +78,8 @@
*
* @ingroup api_chunk_generator
*/
- ChunkGenerator(Addr _startAddr, unsigned totalSize, unsigned
_chunkSize)
- : startAddr(_startAddr), chunkSize(_chunkSize)
+ ChunkGenerator(Addr _startAddr, Addr totalSize, Addr _chunkSize) :
+ startAddr(_startAddr), chunkSize(_chunkSize)
{
// chunkSize must be a power of two
assert(chunkSize == 0 || isPowerOf2(chunkSize));
@@ -87,13 +87,10 @@
// set up initial chunk.
curAddr = startAddr;
- if (chunkSize == 0) //Special Case, if we see 0, assume no
chuncking
- {
+ if (chunkSize == 0) { // Special Case, if we see 0, assume no
chunking.
nextAddr = startAddr + totalSize;
- }
- else
- {
- // nextAddr should be *next* chunk start
+ } else {
+ // nextAddr should be *next* chunk start.
nextAddr = roundUp(startAddr, chunkSize);
if (curAddr == nextAddr) {
// ... even if startAddr is already chunk-aligned
@@ -101,8 +98,8 @@
}
}
- // how many bytes are left between curAddr and the end of this
chunk?
- unsigned left_in_chunk = nextAddr - curAddr;
+ // How many bytes are left between curAddr and the end of this
chunk?
+ Addr left_in_chunk = nextAddr - curAddr;
curSize = std::min(totalSize, left_in_chunk);
sizeLeft = totalSize - curSize;
}
@@ -118,14 +115,14 @@
*
* @ingroup api_chunk_generator
*/
- unsigned size() const { return curSize; }
+ Addr size() const { return curSize; }
/**
* Number of bytes we have already chunked up.
*
* @ingroup api_chunk_generator
*/
- unsigned complete() const { return curAddr - startAddr; }
+ Addr complete() const { return curAddr - startAddr; }
/**
* Are we done? That is, did the last call to next() advance
@@ -134,7 +131,7 @@
*
* @ingroup api_chunk_generator
*/
- bool done() const { return (curSize == 0); }
+ bool done() const { return curSize == 0; }
/**
* Is this the last chunk?
@@ -142,7 +139,7 @@
*
* @ingroup api_chunk_generator
*/
- bool last() const { return (sizeLeft == 0); }
+ bool last() const { return sizeLeft == 0; }
/**
* Advance generator to next chunk.
@@ -154,7 +151,7 @@
bool
next()
{
- if (sizeLeft == 0) {
+ if (last()) {
curSize = 0;
return false;
}
@@ -167,4 +164,4 @@
}
};
-#endif // __BASE__CHUNK_GENERATOR_HH__
+#endif // __BASE_CHUNK_GENERATOR_HH__
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34177
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I985004116c48ce6fb236c04e04fe54ed49a68277
Gerrit-Change-Number: 34177
Gerrit-PatchSet: 4
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Steve Reinhardt <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s