Changes in src/libcfa/bits/containers.h [14a61b5:de94a60]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/bits/containers.h
r14a61b5 rde94a60 191 191 //----------------------------------------------------------------------------- 192 192 #ifdef __cforall 193 trait is_db_node(dtype T) { 194 T*& get_next( T& ); 195 T*& get_prev( T& ); 196 }; 197 #endif 198 199 #ifdef __cforall 200 forall(dtype TYPE | is_db_node(TYPE)) 193 forall(dtype TYPE | sized(TYPE)) 201 194 #define T TYPE 202 195 #else … … 205 198 struct __dllist { 206 199 T * head; 200 * [T * & next, T * & prev] ( T & ) __get; 207 201 }; 208 202 #undef T … … 216 210 #ifdef __cforall 217 211 218 forall(dtype T | is_db_node(T)) 219 static inline void ?{}( __dllist(T) & this ) with( this ) { 220 head{ NULL }; 221 } 222 223 // forall(dtype T | is_db_node(T) | sized(T)) 224 // static inline void push_front( __dllist(T) & this, T & node ) with( this ) { 225 // if ( head ) { 226 // get_next( node ) = head; 227 // get_prev( node ) = get_prev( *head ); 228 // // inserted node must be consistent before it is seen 229 // // prevent code movement across barrier 230 // asm( "" : : : "memory" ); 231 // get_prev( *head ) = node; 232 // T & prev = *get_prev( node ); 233 // get_next( prev ) = node; 234 // } 235 // else { 236 // get_next( node ) = &node; 237 // get_prev( node ) = &node; 238 // } 239 240 // // prevent code movement across barrier 241 // asm( "" : : : "memory" ); 242 // head = val; 243 // } 244 245 // forall(dtype T | is_db_node(T) | sized(T)) 246 // static inline T * remove( __dllist(T) & this, T & node ) with( this ) { 247 // if ( &node == head ) { 248 // if ( get_next( *head ) == head ) { 249 // head = NULL; 250 // } 251 // else { 252 // head = get_next( *head ); 253 // } 254 // } 255 // get_prev( *get_next( node ) ) = get_prev( node ); 256 // get_next( *get_prev( node ) ) = get_next( node ); 257 // get_next( node ) = NULL; 258 // get_prev( node ) = NULL; 259 // } 212 forall(dtype T | sized(T)) 213 static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) { 214 this.head{ NULL }; 215 this.__get = __get; 216 } 217 218 #define _next .0 219 #define _prev .1 220 forall(dtype T | sized(T)) 221 static inline void push_front( __dllist(T) & this, T & node ) with( this ) { 222 if ( head ) { 223 __get( node )_next = head; 224 __get( node )_prev = __get( *head )_prev; 225 // inserted node must be consistent before it is seen 226 // prevent code movement across barrier 227 asm( "" : : : "memory" ); 228 __get( *head )_prev = &node; 229 T & prev = *__get( node )_prev; 230 __get( prev )_next = &node; 231 } 232 else { 233 __get( node )_next = &node; 234 __get( node )_prev = &node; 235 } 236 237 // prevent code movement across barrier 238 asm( "" : : : "memory" ); 239 head = &node; 240 } 241 242 forall(dtype T | sized(T)) 243 static inline void remove( __dllist(T) & this, T & node ) with( this ) { 244 if ( &node == head ) { 245 if ( __get( *head )_next == head ) { 246 head = NULL; 247 } 248 else { 249 head = __get( *head )_next; 250 } 251 } 252 __get( *__get( node )_next )_prev = __get( node )_prev; 253 __get( *__get( node )_prev )_next = __get( node )_next; 254 __get( node )_next = NULL; 255 __get( node )_prev = NULL; 256 } 257 #undef _next 258 #undef _prev 260 259 #endif 261 260
Note: See TracChangeset
for help on using the changeset viewer.