From 1667e1f8017bd3f4bf5b1ef5712e3156577f99a2 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 5 Jul 2012 17:33:08 -0700 Subject: [PATCH] trivial changes * remove unnecessary 'class' keyword * add ASSERT() in the 'thread_current()' function * move #include into .cc file * remove more end-of-line spaces --- action.h | 2 +- cyclegraph.cc | 13 +++++++------ cyclegraph.h | 10 +++++----- model.cc | 4 ++-- model.h | 6 +++--- nodestack.h | 2 +- threads.cc | 1 + 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/action.h b/action.h index c84381d..4903f37 100644 --- a/action.h +++ b/action.h @@ -101,6 +101,6 @@ private: ClockVector *cv; }; -typedef std::list action_list_t; +typedef std::list action_list_t; #endif /* __ACTION_H__ */ diff --git a/cyclegraph.cc b/cyclegraph.cc index c1fea4f..8788bfe 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -1,4 +1,5 @@ #include "cyclegraph.h" +#include "action.h" CycleGraph::CycleGraph() { hasCycles=false; @@ -24,17 +25,17 @@ void CycleGraph::addEdge(ModelAction *from, ModelAction *to) { } bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) { - std::vector queue; - HashTable discovered; - + std::vector queue; + HashTable discovered; + queue.push_back(from); discovered.put(from, from); while(!queue.empty()) { - class CycleNode * node=queue.back(); + CycleNode * node=queue.back(); queue.pop_back(); if (node==to) return true; - + for(unsigned int i=0;igetEdges()->size();i++) { CycleNode *next=(*node->getEdges())[i]; if (!discovered.contains(next)) { @@ -50,7 +51,7 @@ CycleNode::CycleNode(ModelAction *modelaction) { action=modelaction; } -std::vector * CycleNode::getEdges() { +std::vector * CycleNode::getEdges() { return &edges; } diff --git a/cyclegraph.h b/cyclegraph.h index 818a3e8..df9d46c 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -2,11 +2,11 @@ #define CYCLEGRAPH_H #include "hashtable.h" -#include "action.h" #include #include class CycleNode; +class ModelAction; /** @brief A graph of Model Actions for tracking cycles. */ class CycleGraph { @@ -17,9 +17,9 @@ class CycleGraph { private: CycleNode * getNode(ModelAction *); - HashTable actionToNode; + HashTable actionToNode; bool checkReachable(CycleNode *from, CycleNode *to); - + bool hasCycles; }; @@ -28,11 +28,11 @@ class CycleNode { public: CycleNode(ModelAction *action); void addEdge(CycleNode * node); - std::vector * getEdges(); + std::vector * getEdges(); private: ModelAction *action; - std::vector edges; + std::vector edges; }; #endif diff --git a/model.cc b/model.cc index 4e2bb02..3e25dc6 100644 --- a/model.cc +++ b/model.cc @@ -26,7 +26,7 @@ ModelChecker::ModelChecker() diverge(NULL), nextThread(THREAD_ID_T_NONE), action_trace(new action_list_t()), - thread_map(new std::map), + thread_map(new std::map), obj_thrd_map(new std::map >()), thrd_last_action(new std::vector(1)), node_stack(new NodeStack()), @@ -37,7 +37,7 @@ ModelChecker::ModelChecker() /** @brief Destructor */ ModelChecker::~ModelChecker() { - std::map::iterator it; + std::map::iterator it; for (it = thread_map->begin(); it != thread_map->end(); it++) delete (*it).second; delete thread_map; diff --git a/model.h b/model.h index 4ea5590..fbf1b3f 100644 --- a/model.h +++ b/model.h @@ -30,7 +30,7 @@ public: ~ModelChecker(); /** The scheduler to use: tracks the running/ready Threads */ - class Scheduler *scheduler; + Scheduler *scheduler; /** Stores the context for the main model-checking system thread (call * once) @@ -88,10 +88,10 @@ private: ucontext_t *system_context; action_list_t *action_trace; - std::map *thread_map; + std::map *thread_map; std::map > *obj_thrd_map; std::vector *thrd_last_action; - class NodeStack *node_stack; + NodeStack *node_stack; ModelAction *next_backtrack; }; diff --git a/nodestack.h b/nodestack.h index 37f9261..59e5457 100644 --- a/nodestack.h +++ b/nodestack.h @@ -64,7 +64,7 @@ private: action_set_t may_read_from; }; -typedef std::list > node_list_t; +typedef std::list< Node *, MyAlloc< Node * > > node_list_t; /** * @brief A stack of nodes diff --git a/threads.cc b/threads.cc index 37b0f1a..6d290a9 100644 --- a/threads.cc +++ b/threads.cc @@ -19,6 +19,7 @@ static void stack_free(void *stack) Thread * thread_current(void) { + ASSERT(model); return model->scheduler->get_current_thread(); } -- 2.34.1