1 // AUTOMATICALLY GENERATED -- DO NOT EDIT! -*- c++ -*-
7 // INTERFACE definition follows
10 #line 2 "template.cpp"
14 #line 5 "template.cpp"
20 friend class stack_t<T>;
22 // Dont change the layout !!, comp_and_swap2 expects
23 // version and _next next to each other, in that order
28 #line 46 "template.cpp"
35 // stack_top_t<T>::operator=(const stack_top_t& _copy){
36 // _version = _copy._version;
37 // _next = _copy._next;
43 stack_top_t (int version, T *next);
45 #line 67 "template.cpp"
48 #line 17 "template.cpp"
57 #line 72 "template.cpp"
66 #line 84 "template.cpp"
70 #line 103 "template.cpp"
74 #line 132 "template.cpp"
75 // This version of dequeue only returns a value
76 // if it is equal to the one passed as top
82 #line 164 "template.cpp"
86 #line 172 "template.cpp"
91 #line 27 "template.cpp"
93 // atomic-manipulation functions
98 template <class I> bool compare_and_swap(I *ptr, I oldval, I newval);
100 #line 41 "template.cpp"
101 template <class I> bool test_and_set(I *l);
103 #line 180 "template.cpp"
104 template<class T> stack_t<T>*
107 #line 187 "template.cpp"
108 template <> stack_t<int>*
111 #line 195 "template.cpp"
112 template <> inline stack_t<bool>*
115 #line 238 "template.cpp"
116 template<typename FOO,
117 typename = typename cxx::enable_if<!cxx::is_same<SPACE, Mem_space>::value>::type> void
118 template_with_dfl_arg1();
120 #line 244 "template.cpp"
121 template<typename FOO,
122 typename = typename cxx::enable_if<!cxx::is_same<SPACE, Mem_space>::value>::type,
124 template_with_dfl_arg2();
127 // IMPLEMENTATION of inline functions (and needed classes)
131 #line 192 "template.cpp"
135 template <> inline stack_t<bool>*
138 return new stack<bool>();
142 // IMPLEMENTATION of function templates
146 #line 26 "template.cpp"
149 // atomic-manipulation functions
154 template <class I> bool compare_and_swap(I *ptr, I oldval, I newval)
156 return compare_and_swap(reinterpret_cast<unsigned*>(ptr),
157 *reinterpret_cast<unsigned*>(&oldval),
158 *reinterpret_cast<unsigned*>(&newval));
161 #line 39 "template.cpp"
164 template <class I> bool test_and_set(I *l)
166 return test_and_set(reinterpret_cast<unsigned*>(l));
169 #line 45 "template.cpp"
177 // stack_top_t<T>::operator=(const stack_top_t& _copy){
178 // _version = _copy._version;
179 // _next = _copy._next;
185 template<class T> stack_top_t<T>::stack_top_t (int version, T *next)
186 : _version (version),
190 #line 64 "template.cpp"
194 template<class T> stack_top_t<T>::stack_top_t ()
199 #line 71 "template.cpp"
207 template<class T> stack_t<T>::stack_t()
211 #line 81 "template.cpp"
215 template<class T> int
216 stack_t<T>::insert(T *e)
218 stack_top_t<T> old_head,
222 e->set_next(_head._next);
224 new_head._version = _head._version+1;
226 } while (! compare_and_swap2((int *) &_head,
229 return new_head._version;
232 #line 100 "template.cpp"
237 stack_t<T>::dequeue()
239 stack_top_t<T> old_head,
252 new_head._next = first->get_next();
253 new_head._version = _head._version + 1;
254 } while (! compare_and_swap2((int *) &_head,
257 // XXX Why did the old implementation test on e ?
258 // while (e && ! compare_and_swap(&_first, e, e->list_property.next));
259 // This is necessary to handle the case of a empty stack.
261 // return old_head._next;
265 #line 131 "template.cpp"
267 // This version of dequeue only returns a value
268 // if it is equal to the one passed as top
272 stack_t<T>::dequeue(T *top)
274 stack_top_t<T> old_head,
276 // stack_elem_t *first;
278 old_head._version = _head._version; // version doesnt matter
279 old_head._next = top; // cas will fail, if top aint at top
280 if(!_head._next){ // empty stack
283 new_head._version = _head._version + 1;
284 new_head._next = top->get_next();
287 if(! compare_and_swap2((int *) &_head,
293 // top was on top , so we dequeued it
297 #line 161 "template.cpp"
307 #line 169 "template.cpp"
311 template<class T> void
318 #line 178 "template.cpp"
321 template<class T> stack_t<T>*
324 return new stack_t<T>();
327 #line 236 "template.cpp"
330 template<typename FOO,
332 template_with_dfl_arg1()
335 #line 242 "template.cpp"
338 template<typename FOO,
341 template_with_dfl_arg2()