// add func id to reverse func map
ModelVector<const char *> * func_map_rev = history->getFuncMapRev();
- if ( func_map_rev->size() <= func_id )
- func_map_rev->resize( func_id + 1 );
+ if ( func_map_rev->size() <= func_id )
+ func_map_rev->resize( func_id + 1 );
func_map_rev->at(func_id) = funcName;
} else {
func_id = history->getFuncMap()->get(funcName);
func_id = history->getFuncMap()->get(funcName);
/* func_id not found; this could happen in the case where a function calls cds_func_entry
- * when the model has been defined yet, but then an atomic inside the function initializes
- * the model. And then cds_func_exit is called upon the function exiting.
- */
+ * when the model has been defined yet, but then an atomic inside the function initializes
+ * the model. And then cds_func_exit is called upon the function exiting.
+ */
if (func_id == 0)
return;
if (clock_may_race(currClock, thread, readClock, readThread)) {
/* Still need this read in vector */
if (copytoindex != i) {
- ASSERT(record->thread[i] >= 0);
+ ASSERT(record->thread[i] >= 0);
record->readClock[copytoindex] = record->readClock[i];
record->thread[copytoindex] = record->thread[i];
}
thrd_last_action(1),
thrd_last_fence_release(),
priv(new struct model_snapshot_members ()),
- mo_graph(new CycleGraph()),
+ mo_graph(new CycleGraph()),
fuzzer(new Fuzzer()),
thrd_func_list(),
thrd_func_inst_lists()
Thread * action_select_next_thread(const ModelAction *curr) const;
- /* thrd_func_list stores a list of function ids for each thread.
+ /* thrd_func_list stores a list of function ids for each thread.
* Each element in thrd_func_list stores the functions that
- * thread i has entered and yet to exit from
+ * thread i has entered and yet to exit from
*
* This data structure is handled by ModelHistory
*/
SnapVector< func_id_list_t * > thrd_func_list;
/* Keeps track of atomic actions that thread i has performed in some
- * function. Index of SnapVector is thread id. SnapList simulates
- * the call stack.
+ * function. Index of SnapVector is thread id. SnapList simulates
+ * the call stack.
*
* This data structure is handled by ModelHistory
*/
}
/* @param other Preceding FuncInst in the same execution trace
- * Add other to predecessors if it has been added
+ * Add other to predecessors if it has been added
*
* @return false: other is already in predecessors
* true : other is added to precedessors
bool FuncInst::add_pred(FuncInst * other)
{
func_inst_list_mt::iterator it;
- for (it = predecessors.begin(); it != predecessors.end(); it++) {
+ for (it = predecessors.begin();it != predecessors.end();it++) {
FuncInst * inst = *it;
if (inst == other)
return false;
bool FuncInst::add_succ(FuncInst * other)
{
func_inst_list_mt::iterator it;
- for (it = successors.begin(); it != successors.end(); it++) {
+ for (it = successors.begin();it != successors.end();it++) {
FuncInst * inst = *it;
if ( inst == other )
return false;
action_type type = act->get_type();
func_inst_list_mt::iterator it;
- for (it = collisions.begin(); it != collisions.end(); it++) {
+ for (it = collisions.begin();it != collisions.end();it++) {
FuncInst * inst = *it;
if ( inst->get_type() == type )
return inst;
entry_insts()
{}
-/* Check whether FuncInst with the same type, position, and location
+/* Check whether FuncInst with the same type, position, and location
* as act has been added to func_inst_map or not. If so, return it;
* if not, add it and return it.
*
func_inst = new FuncInst(act, this);
inst->get_collisions()->push_back(func_inst);
- inst_list.push_back(func_inst); // delete?
+ inst_list.push_back(func_inst); // delete?
if (func_inst->is_read())
group_reads_by_loc(func_inst);
return;
func_inst_list_mt::iterator it;
- for (it = entry_insts.begin(); it != entry_insts.end(); it++) {
+ for (it = entry_insts.begin();it != entry_insts.end();it++) {
if (inst == *it)
return;
}
reads = reads_by_loc.get(location);
func_inst_list_mt::iterator it;
- for (it = reads->begin(); it != reads->end(); it++) {
+ for (it = reads->begin();it != reads->end();it++) {
if (inst == *it)
return;
}
uint32_t func_id;
const char * func_name;
- /* Use source line number as the key of hashtable, to check if
+ /* Use source line number as the key of hashtable, to check if
* atomic operation with this line number has been added or not
*
* To do: cds_atomic_compare_exchange contains three atomic operations
cdsc::condition_variable *v = execution->getCondMap()->get( (pthread_cond_t *) __addr);
if (v == NULL)
- return; // do nothing
+ return;// do nothing
v->notify_all();
}
capacitymask = initialcapacity - 1;
threshold = (unsigned int)(initialcapacity * loadfactor);
- size = 0; // Initial number of elements in the hash
+ size = 0; // Initial number of elements in the hash
}
/** @brief Hash table destructor */
exit(EXIT_FAILURE);
}
- table = newtable; // Update the global hashtable upon resize()
+ table = newtable; // Update the global hashtable upon resize()
capacity = newsize;
capacitymask = newsize - 1;
search->val = bin->val;
}
- _free(oldtable); // Free the memory of the old hash table
+ _free(oldtable); // Free the memory of the old hash table
}
double getLoadFactor() {return loadfactor;}
unsigned int getCapacity() {return capacity;}
double loadfactor;
};
-#endif/* __HASHTABLE_H__ */
+#endif /* __HASHTABLE_H__ */
/** @brief Constructor */
ModelHistory::ModelHistory() :
- func_counter(0), /* function id starts with 0 */
+ func_counter(0), /* function id starts with 0 */
func_map(),
func_map_rev(),
func_atomics()
uint32_t id = id_to_int(tid);
SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
SnapVector< SnapList<func_inst_list_t *> *> *
- thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
+ thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
if ( thrd_func_list->size() <= id ) {
thrd_func_list->resize( id + 1 );
uint32_t id = id_to_int(tid);
SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
SnapVector< SnapList<func_inst_list_t *> *> *
- thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
+ thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
func_id_list_t * func_list = thrd_func_list->at(id);
SnapList<func_inst_list_t *> * func_inst_lists = thrd_func_inst_lists->at(id);
from all functions */
SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
SnapVector< SnapList<func_inst_list_t *> *> *
- thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
+ thrd_func_inst_lists = model->get_execution()->get_thrd_func_inst_lists();
uint32_t id = id_to_int(tid);
if ( thrd_func_list->size() <= id )
void ModelHistory::print()
{
- for (uint32_t i = 0; i < func_atomics.size(); i++ ) {
+ for (uint32_t i = 0;i < func_atomics.size();i++ ) {
FuncNode * funcNode = func_atomics[i];
if (funcNode == NULL)
continue;
model_print("function %s has entry actions\n", funcNode->get_func_name());
func_inst_list_mt::iterator it;
- for (it = entry_insts->begin(); it != entry_insts->end(); it++) {
+ for (it = entry_insts->begin();it != entry_insts->end();it++) {
FuncInst *inst = *it;
model_print("type: %d, at: %s\n", inst->get_type(), inst->get_position());
}
/*
- func_inst_list_mt * inst_list = funcNode->get_inst_list();
-
- model_print("function %s has following actions\n", funcNode->get_func_name());
- func_inst_list_mt::iterator it;
- for (it = inst_list->begin(); it != inst_list->end(); it++) {
- FuncInst *inst = *it;
- model_print("type: %d, at: %s\n", inst->get_type(), inst->get_position());
- }
-*/
+ func_inst_list_mt * inst_list = funcNode->get_inst_list();
+
+ model_print("function %s has following actions\n", funcNode->get_func_name());
+ func_inst_list_mt::iterator it;
+ for (it = inst_list->begin(); it != inst_list->end(); it++) {
+ FuncInst *inst = *it;
+ model_print("type: %d, at: %s\n", inst->get_type(), inst->get_position());
+ }
+ */
}
}
private:
uint32_t func_counter;
- /* map function names to integer ids */
+ /* map function names to integer ids */
HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> func_map;
- /* map integer ids to function names */
+ /* map integer ids to function names */
ModelVector<const char *> func_map_rev;
ModelVector<FuncNode *> func_atomics;