Move options files from <build_dir>/build_options to build_options/<build_dir>.
[gem5.git] / dev / pktfifo.hh
index 0b2e95e2ab32a1afd268e2ed13193f5de55cbc23..a8b6266184c36dfa78916c488f56c95b9f0cde2b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002-2004 The Regents of The University of Michigan
+ * Copyright (c) 2004-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -46,15 +46,16 @@ class PacketFifo
     int _reserved;
 
   public:
-    explicit PacketFifo(int max) : _maxsize(max), _size(0) {}
+    explicit PacketFifo(int max) : _maxsize(max), _size(0), _reserved(0) {}
     virtual ~PacketFifo() {}
 
-    int maxsize() const { return _maxsize; }
     int packets() const { return fifo.size(); }
-    int size() const { return _size + _reserved; }
-    int avail() const { return maxsize() - size(); }
-    bool empty() const { return size() == 0; }
-    bool full() const { return size() >= maxsize(); }
+    int maxsize() const { return _maxsize; }
+    int size() const { return _size; }
+    int reserved() const { return _reserved; }
+    int avail() const { return _maxsize - _size - _reserved; }
+    bool empty() const { return size() <= 0; }
+    bool full() const { return avail() <= 0; }
 
     int reserve(int len = 0)
     {
@@ -91,6 +92,7 @@ class PacketFifo
     {
         fifo.clear();
         _size = 0;
+        _reserved = 0;
     }
 
 /**