unify style for returning pointers
authorBrian Norris <banorris@uci.edu>
Tue, 24 Apr 2012 00:34:06 +0000 (17:34 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 24 Apr 2012 00:34:06 +0000 (17:34 -0700)
When returning a pointer from a function, always put a space between the type,
the '*', and the function name. E.g.:

  type * func(args);

common.h
malloc.c
model.cc
model.h
schedule.cc
threads.cc
threads.h
tree.cc
tree.h

index f262720..1570a32 100644 (file)
--- a/common.h
+++ b/common.h
@@ -13,7 +13,7 @@
 #define DBG()
 #endif
 
-void *myMalloc(size_t size);
+void * myMalloc(size_t size);
 void myFree(void *ptr);
 
 #endif /* __COMMON_H__ */
index 82fdd04..f20c4e7 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -22,7 +22,7 @@ static void __my_alloc_init(void)
        }
 }
 
-void *myMalloc(size_t size)
+void * myMalloc(size_t size)
 {
        if (real_malloc == NULL)
                __my_alloc_init();
index 914ae3d..f3844f0 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -40,7 +40,7 @@ void ModelChecker::add_system_thread(Thread *t)
        this->system_thread = t;
 }
 
-Thread *ModelChecker::schedule_next_thread()
+Thread * ModelChecker::schedule_next_thread()
 {
        Thread *t;
        if (nextThread == THREAD_ID_T_NONE)
@@ -96,10 +96,15 @@ thread_id_t ModelChecker::advance_backtracking_state()
 
 bool ModelChecker::next_execution()
 {
-       return false;
+       num_executions++;
+       if ((exploring = model->get_next_backtrack()) == NULL)
+               return false;
+       model->reset_to_initial_state();
+       nextThread = get_next_replay_thread();
+       return true;
 }
 
-ModelAction *ModelChecker::get_last_conflict(ModelAction *act)
+ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
 {
        void *loc = act->get_location();
        action_type type = act->get_type();
diff --git a/model.h b/model.h
index 44979ab..7dbd9ab 100644 (file)
--- a/model.h
+++ b/model.h
@@ -31,9 +31,9 @@ public:
        thread_id_t get_tid() { return tid; }
        action_type get_type() { return type; }
        memory_order get_mo() { return order; }
-       void *get_location() { return location; }
+       void * get_location() { return location; }
 
-       TreeNode *get_node() { return node; }
+       TreeNode * get_node() { return node; }
        void set_node(TreeNode *n) { node = n; }
 private:
        action_type type;
@@ -51,10 +51,10 @@ public:
                actionTrace = t;
                iter = actionTrace->begin();
        }
-       ModelAction *get_diverge() { return diverge; }
-       action_list_t *get_trace() { return actionTrace; }
+       ModelAction * get_diverge() { return diverge; }
+       action_list_t * get_trace() { return actionTrace; }
        void advance_state() { iter++; }
-       ModelAction *get_state() {
+       ModelAction * get_state() {
                return iter == actionTrace->end() ? NULL : *iter;
        }
 private:
@@ -76,10 +76,10 @@ public:
        void set_current_action(ModelAction *act) { current_action = act; }
        void check_current_action(void);
        void print_trace(void);
-       Thread *schedule_next_thread();
+       Thread * schedule_next_thread();
 
        int add_thread(Thread *t);
-       Thread *get_thread(thread_id_t tid) { return thread_map[tid]; }
+       Thread * get_thread(thread_id_t tid) { return thread_map[tid]; }
 
        void assign_id(Thread *t);
 
@@ -90,7 +90,7 @@ private:
        int used_thread_id;
        int num_executions;
 
-       ModelAction *get_last_conflict(ModelAction *act);
+       ModelAction * get_last_conflict(ModelAction *act);
        void set_backtracking(ModelAction *act);
        thread_id_t advance_backtracking_state();
        thread_id_t get_next_replay_thread();
index 0f550c4..67b40ec 100644 (file)
@@ -9,7 +9,7 @@ void Scheduler::add_thread(Thread *t)
        readyList.push_back(t);
 }
 
-Thread *Scheduler::next_thread(void)
+Thread * Scheduler::next_thread(void)
 {
        Thread *t = model->schedule_next_thread();
 
@@ -29,7 +29,7 @@ Thread *Scheduler::next_thread(void)
        return t;
 }
 
-Thread *Scheduler::get_current_thread(void)
+Thread * Scheduler::get_current_thread(void)
 {
        return current;
 }
index 830ea1a..be384fb 100644 (file)
@@ -10,7 +10,7 @@
 
 #define STACK_SIZE (1024 * 1024)
 
-static void *stack_allocate(size_t size)
+static void * stack_allocate(size_t size)
 {
        return malloc(size);
 }
@@ -20,7 +20,7 @@ static void stack_free(void *stack)
        free(stack);
 }
 
-Thread *thread_current(void)
+Thread * thread_current(void)
 {
        return model->scheduler->get_current_thread();
 }
index 9787c3f..8e0c3b0 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -37,7 +37,7 @@ private:
        thread_state state;
 };
 
-Thread *thread_current();
+Thread * thread_current();
 
 static inline thread_id_t thrd_to_id(thrd_t t)
 {
diff --git a/tree.cc b/tree.cc
index 3a7f5c4..16a0b69 100644 (file)
--- a/tree.cc
+++ b/tree.cc
@@ -15,7 +15,7 @@ TreeNode::~TreeNode() {
                delete it->second;
 }
 
-TreeNode *TreeNode::exploreChild(tree_t id)
+TreeNode * TreeNode::exploreChild(tree_t id)
 {
        TreeNode *n;
        std::set<tree_t >::iterator it;
@@ -47,7 +47,7 @@ tree_t TreeNode::getNextBacktrack()
        return *backtrack.begin();
 }
 
-TreeNode *TreeNode::getRoot()
+TreeNode * TreeNode::getRoot()
 {
        if (parent)
                return parent->getRoot();
diff --git a/tree.h b/tree.h
index 676cbe4..1c9f74c 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -16,12 +16,12 @@ public:
        TreeNode(TreeNode *par);
        ~TreeNode();
        bool hasBeenExplored(tree_t id) { return children.find(id) != children.end(); }
-       TreeNode *exploreChild(tree_t id);
+       TreeNode * exploreChild(tree_t id);
        tree_t getNextBacktrack();
 
        /* Return 1 if already in backtrack, 0 otherwise */
        int setBacktrack(tree_t id);
-       TreeNode *getRoot();
+       TreeNode * getRoot();
        static int getTotalNodes() { return TreeNode::totalNodes; }
 private:
        TreeNode *parent;