From b3dd0d4f99b447a257f6b13bc65a03e038e06cb9 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 4 Dec 2020 00:22:34 -0800 Subject: [PATCH] base: Style fixes in the CircleBuf and Fifo classes. Change-Id: Ia08548027973e2b18e09bc3f05a6498855bdd7f7 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38479 Maintainer: Gabe Black Tested-by: kokoro Reviewed-by: Daniel Carvalho --- src/base/circlebuf.hh | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/base/circlebuf.hh b/src/base/circlebuf.hh index 548e73fe0..8d7297a0e 100644 --- a/src/base/circlebuf.hh +++ b/src/base/circlebuf.hh @@ -74,7 +74,9 @@ class CircleBuf : public CircularQueue * @param len Number of elements to copy */ template - void peek(OutputIterator out, size_t len) const { + void + peek(OutputIterator out, size_t len) const + { peek(out, 0, len); } @@ -86,9 +88,11 @@ class CircleBuf : public CircularQueue * @param len Number of elements to copy */ template - void peek(OutputIterator out, off_t offset, size_t len) const { + void + peek(OutputIterator out, off_t offset, size_t len) const + { panic_if(offset + len > size(), - "Trying to read past end of circular buffer.\n"); + "Trying to read past end of circular buffer."); std::copy(begin() + offset, begin() + offset + len, out); } @@ -100,7 +104,9 @@ class CircleBuf : public CircularQueue * @param len Number of elements to read */ template - void read(OutputIterator out, size_t len) { + void + read(OutputIterator out, size_t len) + { peek(out, len); pop_front(len); } @@ -112,7 +118,9 @@ class CircleBuf : public CircularQueue * @param len Number of elements to read */ template - void write(InputIterator in, size_t len) { + void + write(InputIterator in, size_t len) + { // Writes that are larger than the backing store are allowed, // but only the last part of the buffer will be written. if (len > capacity()) { @@ -143,8 +151,7 @@ class Fifo typedef T value_type; public: - Fifo(size_t size) - : buf(size) {} + Fifo(size_t size) : buf(size) {} bool empty() const { return buf.empty(); } size_t size() const { return buf.size(); } @@ -158,9 +165,10 @@ class Fifo void read(OutputIterator out, size_t len) { buf.read(out, len); } template - void write(InputIterator in, size_t len) { - panic_if(size() + len > capacity(), - "Trying to overfill FIFO buffer.\n"); + void + write(InputIterator in, size_t len) + { + panic_if(size() + len > capacity(), "Trying to overfill FIFO buffer."); buf.write(in, len); } @@ -181,8 +189,7 @@ arrayParamOut(CheckpointOut &cp, const std::string &name, template void -arrayParamIn(CheckpointIn &cp, const std::string &name, - CircleBuf ¶m) +arrayParamIn(CheckpointIn &cp, const std::string &name, CircleBuf ¶m) { std::vector temp; arrayParamIn(cp, name, temp); @@ -193,8 +200,7 @@ arrayParamIn(CheckpointIn &cp, const std::string &name, template void -arrayParamOut(CheckpointOut &cp, const std::string &name, - const Fifo ¶m) +arrayParamOut(CheckpointOut &cp, const std::string &name, const Fifo ¶m) { std::vector temp(param.size()); param.peek(temp.begin(), temp.size()); @@ -203,14 +209,13 @@ arrayParamOut(CheckpointOut &cp, const std::string &name, template void -arrayParamIn(CheckpointIn &cp, const std::string &name, - Fifo ¶m) +arrayParamIn(CheckpointIn &cp, const std::string &name, Fifo ¶m) { std::vector temp; arrayParamIn(cp, name, temp); fatal_if(param.capacity() < temp.size(), - "Trying to unserialize data into too small FIFO\n"); + "Trying to unserialize data into too small FIFO"); param.flush(); param.write(temp.cbegin(), temp.size()); -- 2.30.2