really should be using a type that is big enough for all commonly used data types...
authorBrian Demsky <bdemsky@uci.edu>
Mon, 16 Jul 2012 23:14:27 +0000 (16:14 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Mon, 16 Jul 2012 23:14:27 +0000 (16:14 -0700)
added some notes on unused_value flag to specify that this value does not guarantee an unused value...

action.cc
action.h
libatomic.cc
model.cc
threads.h

index 39b0f7f6d4847207f0dc2a18da5b0edeffa5776a..adb31f8c39aaabfa06f2e954ff9b80e7ef650453 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -5,7 +5,7 @@
 #include "clockvector.h"
 #include "common.h"
 
-ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value) :
+ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, uint64_t value) :
        type(type),
        order(order),
        location(loc),
@@ -180,7 +180,7 @@ void ModelAction::print(void) const
                type_str = "unknown type";
        }
 
-       printf("(%3d) Thread: %-2d    Action: %-13s    MO: %d    Loc: %14p    Value: %-4d",
+       printf("(%3d) Thread: %-2d    Action: %-13s    MO: %d    Loc: %14p    Value: %-8u",
                        seq_number, id_to_int(tid), type_str, order, location, value);
        if (reads_from)
                printf(" Rf: %d", reads_from->get_seq_number());
index 30c8a35b80ed7681ce74bc5388c0667b9b4e4fec..36c72079b165a6a7462d5a32698e61dbdef12dbd 100644 (file)
--- a/action.h
+++ b/action.h
 #include "mymemory.h"
 #include "clockvector.h"
 
-#define VALUE_NONE -1
+/** Note that this value can be legitimately used by a program, and
+               hence by iteself does not indicate no value. */
+
+#define VALUE_NONE 1234567890
 
 /** @brief Represents an action type, identifying one of several types of
  * ModelAction */
@@ -38,7 +41,7 @@ class ClockVector;
  */
 class ModelAction {
 public:
-       ModelAction(action_type_t type, memory_order order, void *loc, int value = VALUE_NONE);
+       ModelAction(action_type_t type, memory_order order, void *loc, uint64_t value = VALUE_NONE);
        ~ModelAction();
        void print(void) const;
 
@@ -47,7 +50,7 @@ public:
        memory_order get_mo() const { return order; }
        void * get_location() const { return location; }
        modelclock_t get_seq_number() const { return seq_number; }
-       int get_value() const { return value; }
+       uint64_t get_value() const { return value; }
        const ModelAction * get_reads_from() const { return reads_from; }
 
        Node * get_node() const { return node; }
@@ -94,7 +97,7 @@ private:
 
        /** The value read or written (if RMW, then the value written). This
         * should probably be something longer. */
-       int value;
+       uint64_t value;
 
        /** The action that this action reads from. Only valid for reads */
        const ModelAction *reads_from;
index 531731966a862cacd2f704fa26163f6851cd6d52..4d2ec553fcb2cb6d61de9942d853a1e9ef39bae6 100644 (file)
@@ -13,7 +13,7 @@ int atomic_load_explicit(struct atomic_object *obj, memory_order order)
 {
        DBG();
        model->switch_to_master(new ModelAction(ATOMIC_READ, order, obj));
-       return thread_current()->get_return_value();
+       return (int) thread_current()->get_return_value();
 }
 
 void atomic_init(struct atomic_object *obj, int value)
index 0bd9b61b410f7c57f2991f9446cb74847448a55e..0c5733b543cf84899a582cdabfd6eecb1fba8b90 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -278,7 +278,7 @@ void ModelChecker::check_current_action(void)
        /* TODO: perform release/acquire synchronization here; include
         * reads_from as ModelAction member? */
        Thread *th = get_thread(curr->get_tid());
-       int value = VALUE_NONE;
+       uint64_t value = VALUE_NONE;
        if (curr->is_read()) {
                const ModelAction *reads_from = curr->get_node()->get_next_read_from();
                value = reads_from->get_value();
index 0f39a836f49efae34c63415f433e37715a43d258..e7cd792a134c4b5e223b6f9465af4eaf83753b1e 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -6,6 +6,8 @@
 #define __THREADS_H__
 
 #include <ucontext.h>
+#include <stdint.h>
+
 #include "mymemory.h"
 #include "libthreads.h"
 
@@ -55,7 +57,7 @@ public:
         * atomic read).
         * @param value The value to return
         */
-       void set_return_value(int value) { last_action_val = value; }
+       void set_return_value(uint64_t value) { last_action_val = value; }
 
        /**
         * Retrieve a return value for the last action in this thread. Used,
@@ -63,7 +65,7 @@ public:
         * be called from a user context.
         * @return The value 'returned' by the action
         */
-       int get_return_value() { return last_action_val; }
+       uint64_t get_return_value() { return last_action_val; }
 
        friend void thread_startup();
 
@@ -86,7 +88,7 @@ private:
         * @see Thread::set_return_value()
         * @see Thread::get_return_value()
         */
-       int last_action_val;
+       uint64_t last_action_val;
 };
 
 Thread * thread_current();