changes to ms-queue spec
[cdsspec-compiler.git] / benchmark / ms-queue / my_queue.h
index ff3d42d4697354fa96985e9f457425a1957d3fdc..714be4f83d71daeb98b68a9f1681fd3076d5a39d 100644 (file)
@@ -3,6 +3,13 @@
 
 #include <stdatomic.h>
 
+#include <spec_lib.h>
+#include <stdlib.h>
+#include <cdsannotate.h>
+#include <specannotation.h>
+#include <model_memory.h>
+#include "common.h" 
+
 #define MAX_NODES                      0xf
 
 typedef unsigned long long pointer;
@@ -60,6 +67,8 @@ void init_queue(queue_t *q, int num_threads);
                        }
                @DefineFunc:
                        call_id_t get_id(void *wrapper) {
+                               if (wrapper == NULL)
+                                       return 0;
                                return ((tag_elem_t*) wrapper)->id;
                        }
                @DefineFunc:
@@ -79,8 +88,8 @@ void init_queue(queue_t *q, int num_threads);
 /**
        @Begin
        @Interface: Enqueue
-       @Commit_point_set: Enqueue_Success_Point
-       @ID: get_and_inc(tag);
+       @Commit_point_set: Enqueue_Read_Tail | Enqueue_UpdateNext | Enqueue_UpdateOrLoad_Tail
+       @ID: get_and_inc(tag)
        @Action:
                # __ID__ is an internal macro that refers to the id of the current
                # interface call
@@ -93,16 +102,21 @@ void enqueue(queue_t *q, unsigned int val);
 /**
        @Begin
        @Interface: Dequeue
-       @Commit_point_set: Dequeue_Success_Point | Dequeue_Empty_Point
-       @ID: get_id(back(__queue))
+       @Commit_point_set: Dequeue_Read_Head | Dequeue_Read_Tail | Dequeue_LoadNext
+       @ID: get_id(front(__queue))
        @Action:
-               unsigned int _Old_Val = get_data(front(__queue));
-               pop_front(__queue);
+               unsigned int _Old_Val = 0;
+               if (size(__queue) > 0) {
+                       _Old_Val = get_data(front(__queue));
+                       pop_front(__queue);
+               } else {
+                       _Old_Val = 0;
+               }
        @Post_check:
-               _Old_Val == __RET__
+               __RET__ ? *output == _Old_Val : _Old_Val == 0
        @End
 */
-unsigned int dequeue(queue_t *q);
+bool dequeue(queue_t *q, int *output);
 int get_thread_num();
 
 #endif