changeset 2451e60d4555 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=2451e60d4555
description:
        Ruby: Use uint8_t instead of uint8 everywhere

diffstat:

 src/cpu/testers/rubytest/Check.cc   |   6 ++--
 src/cpu/testers/rubytest/Check.hh   |   2 +-
 src/mem/ruby/common/DataBlock.cc    |   8 +++---
 src/mem/ruby/common/DataBlock.hh    |  22 ++++++++++----------
 src/mem/ruby/common/SubBlock.hh     |   8 +++---
 src/mem/ruby/common/TypeDefines.hh  |   2 -
 src/mem/ruby/system/DMASequencer.hh |   2 +-
 src/mem/ruby/system/MemoryVector.hh |  40 ++++++++++++++++++------------------
 src/mem/ruby/system/RubyPort.cc     |   4 +-
 src/mem/ruby/system/System.cc       |   8 +++---
 src/mem/ruby/system/System.hh       |   4 +-
 11 files changed, 52 insertions(+), 54 deletions(-)

diffs (truncated from 385 to 300 lines):

diff -r ee27d0bf7353 -r 2451e60d4555 src/cpu/testers/rubytest/Check.cc
--- a/src/cpu/testers/rubytest/Check.cc Mon Sep 10 12:44:03 2012 -0500
+++ b/src/cpu/testers/rubytest/Check.cc Tue Sep 11 09:23:56 2012 -0500
@@ -189,7 +189,7 @@
     // }
 
     PacketPtr pkt = new Packet(req, cmd);
-    uint8_t* writeData = new uint8_t;
+    uint8_t *writeData = new uint8_t;
     *writeData = m_value + m_store_count;
     pkt->dataDynamic(writeData);
 
@@ -245,7 +245,7 @@
 
     req->setThreadContext(index, 0);
     PacketPtr pkt = new Packet(req, MemCmd::ReadReq);
-    uint8_t* dataArray = new uint8_t[CHECK_SIZE];
+    uint8_t *dataArray = new uint8_t[CHECK_SIZE];
     pkt->dataDynamicArray(dataArray);
 
     // push the subblock onto the sender state.  The sequencer will
@@ -306,7 +306,7 @@
         DPRINTF(RubyTest, "Check callback\n");
         // Perform load/check
         for (int byte_number=0; byte_number<CHECK_SIZE; byte_number++) {
-            if (uint8(m_value + byte_number) != data->getByte(byte_number)) {
+            if (uint8_t(m_value + byte_number) != data->getByte(byte_number)) {
                 panic("Action/check failure: proc: %d address: %s data: %s "
                       "byte_number: %d m_value+byte_number: %d byte: %d %s"
                       "Time: %d\n",
diff -r ee27d0bf7353 -r 2451e60d4555 src/cpu/testers/rubytest/Check.hh
--- a/src/cpu/testers/rubytest/Check.hh Mon Sep 10 12:44:03 2012 -0500
+++ b/src/cpu/testers/rubytest/Check.hh Tue Sep 11 09:23:56 2012 -0500
@@ -68,7 +68,7 @@
     void debugPrint();
 
     TesterStatus m_status;
-    uint8 m_value;
+    uint8_t m_value;
     int m_store_count;
     NodeID m_initiatingNode;
     Address m_address;
diff -r ee27d0bf7353 -r 2451e60d4555 src/mem/ruby/common/DataBlock.cc
--- a/src/mem/ruby/common/DataBlock.cc  Mon Sep 10 12:44:03 2012 -0500
+++ b/src/mem/ruby/common/DataBlock.cc  Tue Sep 11 09:23:56 2012 -0500
@@ -31,7 +31,7 @@
 
 DataBlock::DataBlock(const DataBlock &cp)
 {
-    m_data = new uint8[RubySystem::getBlockSizeBytes()];
+    m_data = new uint8_t[RubySystem::getBlockSizeBytes()];
     memcpy(m_data, cp.m_data, RubySystem::getBlockSizeBytes());
     m_alloc = true;
 }
@@ -39,7 +39,7 @@
 void
 DataBlock::alloc()
 {
-    m_data = new uint8[RubySystem::getBlockSizeBytes()];
+    m_data = new uint8_t[RubySystem::getBlockSizeBytes()];
     m_alloc = true;
     clear();
 }
@@ -70,7 +70,7 @@
     out << dec << "]" << flush;
 }
 
-const uint8*
+const uint8_t*
 DataBlock::getData(int offset, int len) const
 {
     assert(offset + len <= RubySystem::getBlockSizeBytes());
@@ -78,7 +78,7 @@
 }
 
 void
-DataBlock::setData(uint8* data, int offset, int len)
+DataBlock::setData(uint8_t *data, int offset, int len)
 {
     assert(offset + len <= RubySystem::getBlockSizeBytes());
     memcpy(&m_data[offset], data, len);
diff -r ee27d0bf7353 -r 2451e60d4555 src/mem/ruby/common/DataBlock.hh
--- a/src/mem/ruby/common/DataBlock.hh  Mon Sep 10 12:44:03 2012 -0500
+++ b/src/mem/ruby/common/DataBlock.hh  Tue Sep 11 09:23:56 2012 -0500
@@ -29,12 +29,12 @@
 #ifndef __MEM_RUBY_COMMON_DATABLOCK_HH__
 #define __MEM_RUBY_COMMON_DATABLOCK_HH__
 
+#include <inttypes.h>
+
 #include <cassert>
 #include <iomanip>
 #include <iostream>
 
-#include "mem/ruby/common/TypeDefines.hh"
-
 class DataBlock
 {
   public:
@@ -53,25 +53,25 @@
 
     DataBlock& operator=(const DataBlock& obj);
 
-    void assign(uint8* data);
+    void assign(uint8_t *data);
 
     void clear();
-    uint8 getByte(int whichByte) const;
-    const uint8* getData(int offset, int len) const;
-    void setByte(int whichByte, uint8 data);
-    void setData(uint8* data, int offset, int len);
+    uint8_t getByte(int whichByte) const;
+    const uint8_t *getData(int offset, int len) const;
+    void setByte(int whichByte, uint8_t data);
+    void setData(uint8_t *data, int offset, int len);
     void copyPartial(const DataBlock & dblk, int offset, int len);
     bool equal(const DataBlock& obj) const;
     void print(std::ostream& out) const;
 
   private:
     void alloc();
-    uint8* m_data;
+    uint8_t *m_data;
     bool m_alloc;
 };
 
 inline void
-DataBlock::assign(uint8* data)
+DataBlock::assign(uint8_t *data)
 {
     assert(data != NULL);
     if (m_alloc) {
@@ -81,14 +81,14 @@
     m_alloc = false;
 }
 
-inline uint8
+inline uint8_t
 DataBlock::getByte(int whichByte) const
 {
     return m_data[whichByte];
 }
 
 inline void
-DataBlock::setByte(int whichByte, uint8 data)
+DataBlock::setByte(int whichByte, uint8_t data)
 {
     m_data[whichByte] = data;
 }
diff -r ee27d0bf7353 -r 2451e60d4555 src/mem/ruby/common/SubBlock.hh
--- a/src/mem/ruby/common/SubBlock.hh   Mon Sep 10 12:44:03 2012 -0500
+++ b/src/mem/ruby/common/SubBlock.hh   Tue Sep 11 09:23:56 2012 -0500
@@ -48,12 +48,12 @@
 
     int getSize() const { return m_data.size(); }
     void resize(int size) {  m_data.resize(size); }
-    uint8 getByte(int offset) const { return m_data[offset]; }
-    void setByte(int offset, uint8 data) { m_data[offset] = data; }
+    uint8_t getByte(int offset) const { return m_data[offset]; }
+    void setByte(int offset, uint8_t data) { m_data[offset] = data; }
 
     // Shorthands
-    uint8 readByte() const { return getByte(0); }
-    void writeByte(uint8 data) { setByte(0, data); }
+    uint8_t readByte() const { return getByte(0); }
+    void writeByte(uint8_t data) { setByte(0, data); }
 
     // Merging to and from DataBlocks - We only need to worry about
     // updates when we are using DataBlocks
diff -r ee27d0bf7353 -r 2451e60d4555 src/mem/ruby/common/TypeDefines.hh
--- a/src/mem/ruby/common/TypeDefines.hh        Mon Sep 10 12:44:03 2012 -0500
+++ b/src/mem/ruby/common/TypeDefines.hh        Tue Sep 11 09:23:56 2012 -0500
@@ -30,8 +30,6 @@
 #ifndef TYPEDEFINES_H
 #define TYPEDEFINES_H
 
-
-typedef unsigned char uint8;
 typedef unsigned int uint32;
 typedef unsigned long long uint64;
 
diff -r ee27d0bf7353 -r 2451e60d4555 src/mem/ruby/system/DMASequencer.hh
--- a/src/mem/ruby/system/DMASequencer.hh       Mon Sep 10 12:44:03 2012 -0500
+++ b/src/mem/ruby/system/DMASequencer.hh       Tue Sep 11 09:23:56 2012 -0500
@@ -43,7 +43,7 @@
     bool write;
     int bytes_completed;
     int bytes_issued;
-    uint8* data;
+    uint8_t *data;
     PacketPtr pkt;
 };
 
diff -r ee27d0bf7353 -r 2451e60d4555 src/mem/ruby/system/MemoryVector.hh
--- a/src/mem/ruby/system/MemoryVector.hh       Mon Sep 10 12:44:03 2012 -0500
+++ b/src/mem/ruby/system/MemoryVector.hh       Tue Sep 11 09:23:56 2012 -0500
@@ -48,16 +48,16 @@
 
     void resize(uint64 size);  // destructive
 
-    void write(const Address & paddr, uint8* data, int len);
-    uint8* read(const Address & paddr, uint8* data, int len);
-    uint32 collatePages(uint8* &raw_data);
-    void populatePages(uint8* raw_data);
+    void write(const Address & paddr, uint8_t *data, int len);
+    uint8_t *read(const Address & paddr, uint8_t *data, int len);
+    uint32 collatePages(uint8_t *&raw_data);
+    void populatePages(uint8_t *raw_data);
 
   private:
-    uint8* getBlockPtr(const PhysAddress & addr);
+    uint8_t *getBlockPtr(const PhysAddress & addr);
 
     uint64 m_size;
-    uint8** m_pages;
+    uint8_t **m_pages;
     uint32 m_num_pages;
     const uint32 m_page_offset_mask;
     static const uint32 PAGE_SIZE = 4096;
@@ -104,12 +104,12 @@
     m_size = size;
     assert(size%PAGE_SIZE == 0);
     m_num_pages = size >> 12;
-    m_pages = new uint8*[m_num_pages];
-    memset(m_pages, 0, m_num_pages * sizeof(uint8*));
+    m_pages = new uint8_t*[m_num_pages];
+    memset(m_pages, 0, m_num_pages * sizeof(uint8_t*));
 }
 
 inline void
-MemoryVector::write(const Address & paddr, uint8* data, int len)
+MemoryVector::write(const Address & paddr, uint8_t *data, int len)
 {
     assert(paddr.getAddress() + len <= m_size);
     uint32 page_num = paddr.getAddress() >> 12;
@@ -123,7 +123,7 @@
         }
         if (all_zeros)
             return;
-        m_pages[page_num] = new uint8[PAGE_SIZE];
+        m_pages[page_num] = new uint8_t[PAGE_SIZE];
         memset(m_pages[page_num], 0, PAGE_SIZE);
         uint32 offset = paddr.getAddress() & m_page_offset_mask;
         memcpy(&m_pages[page_num][offset], data, len);
@@ -133,8 +133,8 @@
     }
 }
 
-inline uint8*
-MemoryVector::read(const Address & paddr, uint8* data, int len)
+inline uint8_t*
+MemoryVector::read(const Address & paddr, uint8_t *data, int len)
 {
     assert(paddr.getAddress() + len <= m_size);
     uint32 page_num = paddr.getAddress() >> 12;
@@ -147,12 +147,12 @@
     return data;
 }
 
-inline uint8*
+inline uint8_t*
 MemoryVector::getBlockPtr(const PhysAddress & paddr)
 {
     uint32 page_num = paddr.getAddress() >> 12;
     if (m_pages[page_num] == 0) {
-        m_pages[page_num] = new uint8[PAGE_SIZE];
+        m_pages[page_num] = new uint8_t[PAGE_SIZE];
         memset(m_pages[page_num], 0, PAGE_SIZE);
     }
     return &m_pages[page_num][paddr.getAddress()&m_page_offset_mask];
@@ -167,7 +167,7 @@
  */
 
 inline uint32
-MemoryVector::collatePages(uint8* &raw_data)
+MemoryVector::collatePages(uint8_t *&raw_data)
 {
     uint32 num_zero_pages = 0;
     uint32 data_size = 0;
@@ -177,9 +177,9 @@
         if (m_pages[i] == 0) num_zero_pages++;
     }
 
-    raw_data = new uint8[  sizeof(uint32) /* number of pages*/
-                         + m_num_pages /* whether the page is all zeros */
-                         + PAGE_SIZE * (m_num_pages - num_zero_pages)];
+    raw_data = new uint8_t[sizeof(uint32) /* number of pages*/ +
+                           m_num_pages /* whether the page is all zeros */ +
+                           PAGE_SIZE * (m_num_pages - num_zero_pages)];
 
     /* Write the number of pages to be stored. */
     memcpy(raw_data, &m_num_pages, sizeof(uint32));
@@ -210,7 +210,7 @@
  * in the checkpoint.
  */
 inline void
-MemoryVector::populatePages(uint8* raw_data)
+MemoryVector::populatePages(uint8_t *raw_data)
 {
     uint32 data_size = 0;
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to