Commit 5b9f337c authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Changed the ipassign METIS assigner source to allow compilation under gcc 3.*....

Changed the ipassign METIS assigner source to allow compilation under gcc 3.*. This should be enough for compilation under FreeBSD 5.* and 6.*
parent ace7963e
......@@ -61,7 +61,8 @@ public:
bestCount = partitionCount;
bestScore = currentScore;
partitions = current;
cerr << "NewBest: " << i << ":" << partitionCount << endl;
std::cerr << "NewBest: " << i << ":" << partitionCount
<< std::endl;
}
}
m_finalCount = bestCount;
......
......@@ -20,6 +20,7 @@ public:
: message(error)
{
}
virtual ~StringException() throw() {}
virtual char const * what() const throw()
{
return message.c_str();
......@@ -28,12 +29,12 @@ public:
{
message += addend;
}
virtual void addToMessage(string const & addend)
virtual void addToMessage(std::string const & addend)
{
addToMessage(addend.c_str());
}
private:
string message;
std::string message;
};
// Can be thrown during IP assignment
......
......@@ -60,8 +60,8 @@ Framework & Framework::operator=(Framework const & right)
// This is a cool exception-safe way to do copy. See
// Herb Sutter's 'Exceptional C++' book.
Framework temp(right);
swap(m_assign, temp.m_assign);
swap(m_partition, temp.m_partition);
swap_auto_ptr(m_assign, temp.m_assign);
swap_auto_ptr(m_partition, temp.m_partition);
return *this;
}
......
......@@ -33,7 +33,7 @@ public:
void ipAssign(void);
// Print IP addresses.
void printIP(ostream & output) const;
void printIP(std::ostream & output) const;
private:
// These constants are used to store the module options before the
// modules themselves are created according to the specification.
......
......@@ -53,8 +53,8 @@ namespace ptree
virtual Node * getChild(void)=0;
virtual Node * getSibling(void)=0;
virtual void setParent(Node * newParent)=0;
virtual void addChild(auto_ptr<Node> newChild)=0;
virtual void addSibling(auto_ptr<Node> newSibling)=0;
virtual void addChild(std::auto_ptr<Node> newChild)=0;
virtual void addSibling(std::auto_ptr<Node> newSibling)=0;
IPAddress getPrefix(void) const
{
......@@ -114,7 +114,7 @@ namespace ptree
virtual void accept(Visitor & target)=0;
void logStructure(ostream & output, vector<bool> & table)
void logStructure(std::ostream & output, std::vector<bool> & table)
{
// print out the current node
output << "PARSE_TREE: ";
......@@ -158,7 +158,7 @@ namespace ptree
}
}
virtual void printCustomDebug(ostream & output)=0;
virtual void printCustomDebug(std::ostream & output)=0;
protected:
void copyTo(Node & dest) const
{
......@@ -241,7 +241,7 @@ namespace ptree
m_parent = newParent;
}
virtual void addChild(auto_ptr<Node> newChild)
virtual void addChild(std::auto_ptr<Node> newChild)
{
if (newChild.get() != NULL)
{
......@@ -253,13 +253,13 @@ namespace ptree
else
{
// The new child goes at the front of the list.
swap(m_child, newChild);
swap_auto_ptr(m_child, newChild);
m_child->addSibling(newChild);
}
}
}
virtual void addSibling(auto_ptr<Node> newSibling)
virtual void addSibling(std::auto_ptr<Node> newSibling)
{
if (newSibling.get() != NULL)
{
......@@ -279,7 +279,7 @@ namespace ptree
{
target.visitBranch(*this);
}
virtual void printCustomDebug(ostream & output)
virtual void printCustomDebug(std::ostream & output)
{
output << "Branch";
}
......@@ -343,12 +343,12 @@ namespace ptree
m_parent = newParent;
}
virtual void addChild(auto_ptr<Node> newChild)
virtual void addChild(std::auto_ptr<Node> newChild)
{
throw AddChildToLeafException();
}
virtual void addSibling(auto_ptr<Node> newSibling)
virtual void addSibling(std::auto_ptr<Node> newSibling)
{
if (newSibling.get() != NULL)
{
......@@ -378,7 +378,7 @@ namespace ptree
{
target.visitLeaf(*this);
}
virtual void printCustomDebug(ostream & output)
virtual void printCustomDebug(std::ostream & output)
{
output << "Leaf: " << m_lanIndex;
}
......@@ -436,7 +436,7 @@ namespace ptree
class SiblingListVisitor : public Visitor
{
public:
SiblingListVisitor(list<Node *> & newSiblingList)
SiblingListVisitor(std::list<Node *> & newSiblingList)
: siblingList(newSiblingList) {}
virtual ~SiblingListVisitor() {}
virtual void visitBranch(Branch & target)
......@@ -459,7 +459,7 @@ namespace ptree
}
private:
list<Node *> & siblingList;
std::list<Node *> & siblingList;
};
/**************************************************/
......
......@@ -143,12 +143,12 @@ public:
std::vector<int> & partitions)
{
// breadth first search.
queue<size_t> nextConnection;
std::queue<size_t> nextConnection;
size_t first = 0;
size_t numInPartition = 0;
size_t i = 0;
bool hasFirst = false;
vector<bool> connected;
std::vector<bool> connected;
connected.resize(partitions.size());
// Set all LANs in whichPartition to false. All others to true.
......
......@@ -496,7 +496,8 @@ private:
size_t i = 0;
for (i = 0; i < vertexCount; ++i)
{
maxDegree = max(maxDegree, (*m_indexes)[i + 1] - (*m_indexes)[i]);
maxDegree = std::max(maxDegree,
(*m_indexes)[i + 1] - (*m_indexes)[i]);
}
anchorDeltaOrigin[SOURCE] = maxDegree;
anchorDeltaOrigin[SINK] = maxDegree;
......@@ -619,8 +620,9 @@ private:
+ anchorDeltaOrigin[currentAnchor];
anchorDelta[currentAnchor][index].push_front(vertex);
info[vertex].pos = anchorDelta[currentAnchor][index].begin();
anchorMinIndex[currentAnchor] = min(anchorMinIndex[currentAnchor],
index);
anchorMinIndex[currentAnchor]
= std::min(anchorMinIndex[currentAnchor],
index);
}
}
......@@ -674,8 +676,9 @@ private:
// destList.splice(destList.begin(), originList, info[vertex].pos);
info[vertex].pos = destList.begin();
info[vertex].delta = newDelta;
anchorMinIndex[newPartition] = min(anchorMinIndex[newPartition],
newIndex);
anchorMinIndex[newPartition]
= std::min(anchorMinIndex[newPartition],
newIndex);
normalizeDelta(oldPartition);
}
}
......
......@@ -55,7 +55,8 @@ public:
bestCount = partitionCount;
bestScore = currentScore;
partitions = current;
cerr << "NewBest: " << i << ":" << partitionCount << endl;
std::cerr << "NewBest: " << i << ":" << partitionCount
<< std::endl;
}
}
m_finalCount = bestCount;
......
......@@ -9,11 +9,7 @@
#include "lib.h"
#include "bitmath.h"
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2003 University of Utah and the Flux Group.
* All rights reserved.
*/
using namespace std;
string ipToString(IPAddress ip)
{
......
......@@ -18,7 +18,7 @@ typedef unsigned int IPAddress;
class BadStringToIPConversionException : public StringException
{
public:
explicit BadStringToIPConversionException(string const & error)
explicit BadStringToIPConversionException(std::string const & error)
: StringException("Bad String to IP conversion: " + error)
{
}
......@@ -37,8 +37,8 @@ public:
// take an unsigned int and produce a dotted quadruplet based on it.
// can throw bad_alloc
string ipToString(IPAddress ip);
IPAddress stringToIP(string const & source);
std::string ipToString(IPAddress ip);
IPAddress stringToIP(std::string const & source);
// take a count and return the smallest block that is large enough
// to contain count hosts.
......
......@@ -11,6 +11,8 @@
#include "lib.h"
#include "coprocess.h"
using namespace std;
FileWrapper coprocess(string const & command)
{
FileWrapper temp(popen(command.c_str(), "r+"));
......
......@@ -32,7 +32,7 @@ public:
FileWrapper & operator=(FileWrapper & right)
{
FileWrapper temp(right);
swap(data, temp.data);
std::swap(data, temp.data);
return *this;
}
......@@ -65,7 +65,7 @@ private:
FILE * data;
};
FileWrapper coprocess(string const & command);
FileWrapper coprocess(std::string const & command);
int read(FileWrapper & file, int & source, int & dest, int & firstHop,
int & distance);
void write(FileWrapper & file, char command);
......
......@@ -35,6 +35,14 @@ extern "C"
#include "Exception.h"
#include "bitmath.h"
template <class T>
void swap_auto_ptr(std::auto_ptr<T> & left, std::auto_ptr<T> & right)
{
std::auto_ptr<T> temp = left;
left = right;
right = temp;
}
extern const int totalBits;
extern const int prefixBits;
extern const int postfixBits;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment