From: Brian Norris Date: Tue, 19 Jun 2012 23:00:57 +0000 (-0700) Subject: action: add const qualifiers X-Git-Tag: pldi2013~391^2~10 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ba8e01e37619cd2003116974e681912f55f667b7;p=model-checker.git action: add const qualifiers --- diff --git a/action.cc b/action.cc index dc980db..34650c6 100644 --- a/action.cc +++ b/action.cc @@ -26,22 +26,22 @@ ModelAction::~ModelAction() delete cv; } -bool ModelAction::is_read() +bool ModelAction::is_read() const { return type == ATOMIC_READ; } -bool ModelAction::is_write() +bool ModelAction::is_write() const { return type == ATOMIC_WRITE; } -bool ModelAction::is_rmw() +bool ModelAction::is_rmw() const { return type == ATOMIC_RMW; } -bool ModelAction::is_acquire() +bool ModelAction::is_acquire() const { switch (order) { case memory_order_acquire: @@ -53,7 +53,7 @@ bool ModelAction::is_acquire() } } -bool ModelAction::is_release() +bool ModelAction::is_release() const { switch (order) { case memory_order_release: @@ -65,17 +65,17 @@ bool ModelAction::is_release() } } -bool ModelAction::is_seqcst() +bool ModelAction::is_seqcst() const { return order==memory_order_seq_cst; } -bool ModelAction::same_var(ModelAction *act) +bool ModelAction::same_var(const ModelAction *act) const { return location == act->location; } -bool ModelAction::same_thread(ModelAction *act) +bool ModelAction::same_thread(const ModelAction *act) const { return tid == act->tid; } @@ -90,7 +90,7 @@ bool ModelAction::same_thread(ModelAction *act) * @return tells whether we have to explore a reordering. */ -bool ModelAction::is_synchronizing(ModelAction *act) +bool ModelAction::is_synchronizing(const ModelAction *act) const { //Same thread can't be reordered if (same_thread(act)) diff --git a/action.h b/action.h index 976fd48..f6bc19b 100644 --- a/action.h +++ b/action.h @@ -35,24 +35,24 @@ public: ~ModelAction(); void print(void); - thread_id_t get_tid() { return tid; } - action_type get_type() { return type; } - memory_order get_mo() { return order; } - void * get_location() { return location; } + thread_id_t get_tid() const { return tid; } + action_type get_type() const { return type; } + memory_order get_mo() const { return order; } + void * get_location() const { return location; } int get_seq_number() const { return seq_number; } - Node * get_node() { return node; } + Node * get_node() const { return node; } void set_node(Node *n) { node = n; } - bool is_read(); - bool is_write(); - bool is_rmw(); - bool is_acquire(); - bool is_release(); - bool is_seqcst(); - bool same_var(ModelAction *act); - bool same_thread(ModelAction *act); - bool is_synchronizing(ModelAction *act); + bool is_read() const; + bool is_write() const; + bool is_rmw() const; + bool is_acquire() const; + bool is_release() const; + bool is_seqcst() const; + bool same_var(const ModelAction *act) const; + bool same_thread(const ModelAction *act) const; + bool is_synchronizing(const ModelAction *act) const; void create_cv(ModelAction *parent = NULL); void read_from(ModelAction *act);