action: add comparison operator for ModelAction
authorBrian Norris <banorris@uci.edu>
Mon, 14 May 2012 18:16:44 +0000 (11:16 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 14 May 2012 19:40:33 +0000 (12:40 -0700)
The operator simply compares the sequence number. Useful for some simple
model-checking tests.

action.h

index 530436d87b8465a7cb33025da42097e684d93983..9ba9c6320203c2b264a5ebf4fd13ed896e563582 100644 (file)
--- a/action.h
+++ b/action.h
@@ -29,7 +29,7 @@ public:
        action_type get_type() { return type; }
        memory_order get_mo() { return order; }
        void * get_location() { return location; }
-       int get_seq_number() { return seq_number; }
+       int get_seq_number() const { return seq_number; }
 
        TreeNode * get_treenode() { return treenode; }
        void set_node(TreeNode *n) { treenode = n; }
@@ -42,6 +42,13 @@ public:
        bool same_var(ModelAction *act);
        bool same_thread(ModelAction *act);
        bool is_dependent(ModelAction *act);
+
+       inline bool operator <(const ModelAction& act) const {
+               return get_seq_number() < act.get_seq_number();
+       }
+       inline bool operator >(const ModelAction& act) const {
+               return get_seq_number() > act.get_seq_number();
+       }
 private:
        action_type type;
        memory_order order;