#ifndef DEQUE_H
#define DEQUE_H
+#include <spec_lib.h>
+#include <stdlib.h>
+#include <cdsannotate.h>
+#include <specannotation.h>
+#include <model_memory.h>
+#include "common.h"
+
typedef struct {
atomic_size_t size;
atomic_int buffer[];
}
@DefineFunc:
call_id_t get_id(void *wrapper) {
- return ((tag_elem_t*) wrapper)->id;
+ tag_elem_t *res = (tag_elem_t*) wrapper;
+ if (res == NULL) {
+ //model_print("wrong id here\n");
+ return 0;
+ }
+ return res->id;
}
@DefineFunc:
int get_data(void *wrapper) {
- return ((tag_elem_t*) wrapper)->data;
+ tag_elem_t *res = (tag_elem_t*) wrapper;
+ return res->data;
}
@Happens_before:
Push -> Steal
/**
@Begin
@Interface: Take
- @Commit_point_set: Take_Point1 | Take_Point2 | Take_Point3 | Take_Point4
- @ID: size(__deque) == 0 ? DEFAULT_CALL_ID : get_id(back(__deque))
+ //@Commit_point_set: Take_Read_Bottom | Take_CAS_Top | Take_Additional_Point
+ @Commit_point_set: Take_Read_Bottom | Take_Additional_Point
+ @ID: __RET__ == EMPTY ? DEFAULT_CALL_ID : get_id(back(__deque))
@Action:
int _Old_Val = EMPTY;
- if (size(__deque) > 0) {
- _Old_Val = get_data(back(__deque));
- pop_back(__deque);
+ if (__RET__ != EMPTY) {
+ if (size(__deque) > 0) {
+ _Old_Val = get_data(back(__deque));
+ pop_back(__deque);
+ }
}
@Post_check:
_Old_Val == __RET__
/**
@Begin
@Interface: Push
- @Commit_point_set: Push_Point
+ @Commit_point_set: Push_Update_Bottom
@ID: get_and_inc(tag);
@Action:
tag_elem_t *elem = new_tag_elem(__ID__, x);
/**
@Begin
@Interface: Steal
- @Commit_point_set: Steal_Point1 | Steal_Point2 | Steal_Point3
- @ID: size(__deque) == 0 ? DEFAULT_CALL_ID : get_id(front(__deque))
+ //@Commit_point_set: Steal_Read_Bottom | Steal_CAS_Top | Steal_Additional_Point
+ @Commit_point_set: Steal_Read_Bottom | Steal_Additional_Point
+ @ID: (__RET__ == EMPTY || __RET__ == ABORT) ? DEFAULT_CALL_ID : get_id(front(__deque))
@Action:
int _Old_Val = EMPTY;
- if (size(__deque) > 0) {
- _Old_Val = get_data(front(__deque));
- pop_front(__deque);
+ if (__RET__ != EMPTY && __RET__ != ABORT) {
+ if (size(__deque) > 0) {
+ _Old_Val = get_data(front(__deque));
+ pop_front(__deque);
+ }
}
@Post_check:
- _Old_Val == __RET__
+ _Old_Val == __RET__ || __RET__ == EMPTY || __RET__ == ABORT
@End
*/
int steal(Deque *q);