Changeset 14a61b5 for src/libcfa/bits
- Timestamp:
- May 8, 2018, 11:55:33 AM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 5fec3f6
- Parents:
- 10cfad9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/bits/containers.h
r10cfad9 r14a61b5 186 186 #endif 187 187 188 189 //----------------------------------------------------------------------------- 190 // Doubly Linked List 191 //----------------------------------------------------------------------------- 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)) 201 #define T TYPE 202 #else 203 #define T void 204 #endif 205 struct __dllist { 206 T * head; 207 }; 208 #undef T 209 210 #ifdef __cforall 211 #define __dllist_t(T) __dllist(T) 212 #else 213 #define __dllist_t(T) struct __dllist 214 #endif 215 216 #ifdef __cforall 217 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 // } 260 #endif 261 188 262 //----------------------------------------------------------------------------- 189 263 // Tools
Note: See TracChangeset
for help on using the changeset viewer.