summaryrefslogtreecommitdiff
path: root/src/mem/gems_common
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-03-10 18:33:11 -0800
committerNathan Binkert <nate@binkert.org>2010-03-10 18:33:11 -0800
commit140785d24c27f3afddbe95c9e504e27bf8274290 (patch)
treecc4d27a7d4e417a6cd0f0364cff3db67ca1825b7 /src/mem/gems_common
parent1badec39a94397397a3c918bfcc75c71efc507ea (diff)
downloadgem5-140785d24c27f3afddbe95c9e504e27bf8274290.tar.xz
ruby: get rid of std-includes.hh
Do not use "using namespace std;" in headers Include header files as needed
Diffstat (limited to 'src/mem/gems_common')
-rw-r--r--src/mem/gems_common/Map.hh37
-rw-r--r--src/mem/gems_common/PrioHeap.hh12
-rw-r--r--src/mem/gems_common/RefCnt.hh12
-rw-r--r--src/mem/gems_common/Vector.hh18
-rw-r--r--src/mem/gems_common/std-includes.hh57
-rw-r--r--src/mem/gems_common/util.cc6
-rw-r--r--src/mem/gems_common/util.hh12
7 files changed, 58 insertions, 96 deletions
diff --git a/src/mem/gems_common/Map.hh b/src/mem/gems_common/Map.hh
index 6e581d375..7b3c26279 100644
--- a/src/mem/gems_common/Map.hh
+++ b/src/mem/gems_common/Map.hh
@@ -34,12 +34,19 @@
#ifndef MAP_H
#define MAP_H
+#include <iostream>
+
#include "base/hashmap.hh"
#include "mem/gems_common/Vector.hh"
template <class KEY_TYPE, class VALUE_TYPE>
class Map
{
+ private:
+ typedef typename m5::hash_map<KEY_TYPE, VALUE_TYPE> MapType;
+ typedef typename MapType::iterator iterator;
+ typedef typename MapType::const_iterator const_iterator;
+
public:
Map() { /* empty */ }
~Map() { /* empty */ }
@@ -54,7 +61,7 @@ public:
void deleteValues();
VALUE_TYPE& lookup(const KEY_TYPE& key) const;
void clear() { m_map.clear(); }
- void print(ostream& out) const;
+ void print(std::ostream& out) const;
// Synonyms
void remove(const KEY_TYPE& key) { erase(key); }
@@ -73,7 +80,8 @@ private:
};
template <class KEY_TYPE, class VALUE_TYPE>
-ostream& operator<<(ostream& out, const Map<KEY_TYPE, VALUE_TYPE>& map);
+std::ostream&
+operator<<(std::ostream& out, const Map<KEY_TYPE, VALUE_TYPE>& map);
// *********************
@@ -94,7 +102,7 @@ template <class KEY_TYPE, class VALUE_TYPE>
VALUE_TYPE& Map<KEY_TYPE, VALUE_TYPE>::lookup(const KEY_TYPE& key) const
{
if (!exist(key))
- cerr << *this << " is looking for " << key << endl;
+ std::cerr << *this << " is looking for " << key << std::endl;
assert(exist(key));
return m_map[key];
}
@@ -103,7 +111,7 @@ template <class KEY_TYPE, class VALUE_TYPE>
Vector<KEY_TYPE> Map<KEY_TYPE, VALUE_TYPE>::keys() const
{
Vector<KEY_TYPE> keys;
- typename hash_map<KEY_TYPE, VALUE_TYPE>::const_iterator iter;
+ const_iterator iter;
for (iter = m_map.begin(); iter != m_map.end(); iter++) {
keys.insertAtBottom((*iter).first);
}
@@ -114,8 +122,8 @@ template <class KEY_TYPE, class VALUE_TYPE>
Vector<VALUE_TYPE> Map<KEY_TYPE, VALUE_TYPE>::values() const
{
Vector<VALUE_TYPE> values;
- typename hash_map<KEY_TYPE, VALUE_TYPE>::const_iterator iter;
- pair<KEY_TYPE, VALUE_TYPE> p;
+ const_iterator iter;
+ std::pair<KEY_TYPE, VALUE_TYPE> p;
for (iter = m_map.begin(); iter != m_map.end(); iter++) {
p = *iter;
@@ -127,8 +135,8 @@ Vector<VALUE_TYPE> Map<KEY_TYPE, VALUE_TYPE>::values() const
template <class KEY_TYPE, class VALUE_TYPE>
void Map<KEY_TYPE, VALUE_TYPE>::deleteKeys()
{
- typename hash_map<KEY_TYPE, VALUE_TYPE>::const_iterator iter;
- pair<KEY_TYPE, VALUE_TYPE> p;
+ const_iterator iter;
+ std::pair<KEY_TYPE, VALUE_TYPE> p;
for (iter = m_map.begin(); iter != m_map.end(); iter++) {
p = *iter;
@@ -139,8 +147,8 @@ void Map<KEY_TYPE, VALUE_TYPE>::deleteKeys()
template <class KEY_TYPE, class VALUE_TYPE>
void Map<KEY_TYPE, VALUE_TYPE>::deleteValues()
{
- typename hash_map<KEY_TYPE, VALUE_TYPE>::const_iterator iter;
- pair<KEY_TYPE, VALUE_TYPE> p;
+ const_iterator iter;
+ std::pair<KEY_TYPE, VALUE_TYPE> p;
for (iter = m_map.begin(); iter != m_map.end(); iter++) {
p = *iter;
@@ -149,10 +157,10 @@ void Map<KEY_TYPE, VALUE_TYPE>::deleteValues()
}
template <class KEY_TYPE, class VALUE_TYPE>
-void Map<KEY_TYPE, VALUE_TYPE>::print(ostream& out) const
+void Map<KEY_TYPE, VALUE_TYPE>::print(std::ostream& out) const
{
- typename hash_map<KEY_TYPE, VALUE_TYPE>::const_iterator iter;
- pair<KEY_TYPE, VALUE_TYPE> p;
+ const_iterator iter;
+ std::pair<KEY_TYPE, VALUE_TYPE> p;
out << "[";
for (iter = m_map.begin(); iter != m_map.end(); iter++) {
@@ -164,7 +172,8 @@ void Map<KEY_TYPE, VALUE_TYPE>::print(ostream& out) const
}
template <class KEY_TYPE, class VALUE_TYPE>
-ostream& operator<<(ostream& out, const Map<KEY_TYPE, VALUE_TYPE>& map)
+std::ostream&
+operator<<(std::ostream& out, const Map<KEY_TYPE, VALUE_TYPE>& map)
{
map.print(out);
return out;
diff --git a/src/mem/gems_common/PrioHeap.hh b/src/mem/gems_common/PrioHeap.hh
index acdcc0eba..d6183cf40 100644
--- a/src/mem/gems_common/PrioHeap.hh
+++ b/src/mem/gems_common/PrioHeap.hh
@@ -29,6 +29,8 @@
#ifndef PRIOHEAP_H
#define PRIOHEAP_H
+#include <iostream>
+
#include "mem/gems_common/Vector.hh"
typedef unsigned int HeapIndex;
@@ -49,7 +51,7 @@ public:
const TYPE& peekMin() const;
const TYPE& peekElement(int index) const;
TYPE extractMin();
- void print(ostream& out) const;
+ void print(std::ostream& out) const;
private:
// Private Methods
bool verifyHeap() const;
@@ -67,7 +69,7 @@ private:
// Output operator declaration
template <class TYPE>
-ostream& operator<<(ostream& out, const PrioHeap<TYPE>& obj);
+std::ostream& operator<<(std::ostream& out, const PrioHeap<TYPE>& obj);
// ******************* Helper Functions *******************
inline
@@ -210,7 +212,7 @@ void PrioHeap<TYPE>::heapify()
}
template <class TYPE>
-void PrioHeap<TYPE>::print(ostream& out) const
+void PrioHeap<TYPE>::print(std::ostream& out) const
{
Vector<TYPE> copyHeap(m_heap);
@@ -239,10 +241,10 @@ void PrioHeap<TYPE>::print(ostream& out) const
// Output operator definition
template <class TYPE>
-ostream& operator<<(ostream& out, const PrioHeap<TYPE>& obj)
+std::ostream& operator<<(std::ostream& out, const PrioHeap<TYPE>& obj)
{
obj.print(out);
- out << flush;
+ out << std::flush;
return out;
}
diff --git a/src/mem/gems_common/RefCnt.hh b/src/mem/gems_common/RefCnt.hh
index fc1ddbae9..75160fc80 100644
--- a/src/mem/gems_common/RefCnt.hh
+++ b/src/mem/gems_common/RefCnt.hh
@@ -29,6 +29,8 @@
#ifndef REFCNT_H
#define REFCNT_H
+#include <iostream>
+
template <class TYPE>
class RefCnt {
public:
@@ -44,7 +46,7 @@ public:
TYPE* ref() { return m_data_ptr; }
TYPE* mod_ref() const { return m_data_ptr; }
void freeRef();
- void print(ostream& out) const;
+ void print(std::ostream& out) const;
// Public copy constructor and assignment operator
RefCnt(const RefCnt& obj);
@@ -61,7 +63,7 @@ private:
// Output operator declaration
template <class TYPE>
inline
-ostream& operator<<(ostream& out, const RefCnt<TYPE>& obj);
+std::ostream& operator<<(std::ostream& out, const RefCnt<TYPE>& obj);
// ******************* Definitions *******************
@@ -103,7 +105,7 @@ void RefCnt<TYPE>::freeRef()
template <class TYPE>
inline
-void RefCnt<TYPE>::print(ostream& out) const
+void RefCnt<TYPE>::print(std::ostream& out) const
{
if (m_data_ptr == NULL) {
out << "[RefCnt: Null]";
@@ -150,10 +152,10 @@ RefCnt<TYPE>& RefCnt<TYPE>::operator=(const RefCnt<TYPE>& obj)
// Output operator definition
template <class TYPE>
inline
-ostream& operator<<(ostream& out, const RefCnt<TYPE>& obj)
+std::ostream& operator<<(std::ostream& out, const RefCnt<TYPE>& obj)
{
obj.print(out);
- out << flush;
+ out << std::flush;
return out;
}
diff --git a/src/mem/gems_common/Vector.hh b/src/mem/gems_common/Vector.hh
index 7e648e7c9..e10849213 100644
--- a/src/mem/gems_common/Vector.hh
+++ b/src/mem/gems_common/Vector.hh
@@ -38,7 +38,9 @@
#ifndef VECTOR_H
#define VECTOR_H
-#include "mem/gems_common/std-includes.hh"
+#include <cassert>
+#include <iostream>
+#include <vector>
template <class TYPE>
class Vector
@@ -63,7 +65,7 @@ public:
// elements and sets them to NULL, can only
// be used when the TYPE is a pointer type.
void removeFromTop(int num); // removes elements from top
- void print(ostream& out) const;
+ void print(std::ostream& out) const;
// Array Reference operator overloading
@@ -84,7 +86,7 @@ private:
};
template <class TYPE>
-ostream& operator<<(ostream& out, const Vector<TYPE>& vec);
+std::ostream& operator<<(std::ostream& out, const Vector<TYPE>& vec);
// *********************
@@ -139,7 +141,7 @@ void Vector<TYPE>::setSize(int new_size)
{
// FIXME - this should also decrease or shrink the size of the array at some point.
if (new_size > m_max_size) {
- grow(max((m_max_size+1)*2, new_size));
+ grow(std::max((m_max_size+1)*2, new_size));
}
m_size = new_size;
#ifndef NO_VECTOR_BOUNDS_CHECKS
@@ -154,7 +156,7 @@ void Vector<TYPE>::increaseSize(int new_size, const TYPE& reset)
{
assert(new_size >= m_size);
if (new_size >= m_max_size) {
- grow(max((m_max_size+1)*2, new_size));
+ grow(std::max((m_max_size+1)*2, new_size));
}
int old_size = m_size;
m_size = new_size;
@@ -243,7 +245,7 @@ void Vector<TYPE>::deletePointers()
}
template <class TYPE>
-void Vector<TYPE>::print(ostream& out) const
+void Vector<TYPE>::print(std::ostream& out) const
{
out << "[ ";
for(int i=0; i<m_size; i++) {
@@ -253,7 +255,7 @@ void Vector<TYPE>::print(ostream& out) const
out << ref(i);
}
out << " ]";
- out << flush;
+ out << std::flush;
}
// Copy constructor
@@ -325,7 +327,7 @@ void Vector<TYPE>::grow(int new_max_size)
}
template <class TYPE>
-ostream& operator<<(ostream& out, const Vector<TYPE>& vec)
+std::ostream& operator<<(std::ostream& out, const Vector<TYPE>& vec)
{
vec.print(out);
return out;
diff --git a/src/mem/gems_common/std-includes.hh b/src/mem/gems_common/std-includes.hh
deleted file mode 100644
index 0c5201d34..000000000
--- a/src/mem/gems_common/std-includes.hh
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1999-2005 Mark D. Hill and David A. Wood
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * $Id: std-includes.hh,v 3.7 2003/02/24 21:05:24 xu Exp $
- */
-
-#ifndef INCLUDES_H
-#define INCLUDES_H
-
-#include <cstring>
-#include <iomanip>
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <string>
-#include <ext/hash_map>
-#include <stdio.h>
-#include <math.h>
-#include <time.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <cassert>
-
-using namespace std;
-using namespace __gnu_cxx;
-
-typedef unsigned int uint;
-
-#endif //INCLUDES_H
diff --git a/src/mem/gems_common/util.cc b/src/mem/gems_common/util.cc
index d2ca8cb96..d7ce2e893 100644
--- a/src/mem/gems_common/util.cc
+++ b/src/mem/gems_common/util.cc
@@ -31,9 +31,13 @@
*/
#include <cassert>
+#include <iomanip>
+#include <sstream>
#include "mem/gems_common/util.hh"
+using namespace std;
+
// Split a string into a head and tail strings on the specified
// character. Return the head and the string passed in is modified by
// removing the head, leaving just the tail.
@@ -43,7 +47,7 @@ string string_split(string& str, char split_character)
string head = "";
string tail = "";
- uint counter = 0;
+ unsigned counter = 0;
while(counter < str.size()) {
if (str[counter] == split_character) {
counter++;
diff --git a/src/mem/gems_common/util.hh b/src/mem/gems_common/util.hh
index 7afe57a85..f5a86f325 100644
--- a/src/mem/gems_common/util.hh
+++ b/src/mem/gems_common/util.hh
@@ -33,13 +33,13 @@
#ifndef UTIL_H
#define UTIL_H
-#include "mem/gems_common/std-includes.hh"
+#include <string>
-string string_split(string& str, char split_character);
-string bool_to_string(bool value);
-string int_to_string(int n, bool zero_fill = false, int width = 0);
-float string_to_float(string& str);
-bool string_to_bool(const string & str);
+std::string string_split(std::string& str, char split_character);
+std::string bool_to_string(bool value);
+std::string int_to_string(int n, bool zero_fill = false, int width = 0);
+float string_to_float(std::string& str);
+bool string_to_bool(const std::string & str);
int log_int(long long n);
bool is_power_of_2(long long n);