This commit is contained in:
Justin Ethier 2015-11-10 03:08:29 -05:00
parent 23cf9bd14c
commit af3aa141f1
2 changed files with 3 additions and 1 deletions

2
gc.c
View file

@ -634,7 +634,9 @@ void gc_handshake(gc_status_type s)
void gc_post_handshake(gc_status_type s) void gc_post_handshake(gc_status_type s)
{ {
int status = ATOMIC_GET(&gc_status_col);
TODO: use atomic to change value of gc_status_col TODO: use atomic to change value of gc_status_col
while (!ATOMIC_SET_IF_EQ(&gc_status_col, status, s)){}
} }
void gc_wait_handshake() void gc_wait_handshake()

View file

@ -405,6 +405,6 @@ typedef union {
#define ATOMIC_INC(ptr) __sync_fetch_and_add((ptr),1) #define ATOMIC_INC(ptr) __sync_fetch_and_add((ptr),1)
#define ATOMIC_DEC(ptr) __sync_fetch_and_sub((ptr),1) #define ATOMIC_DEC(ptr) __sync_fetch_and_sub((ptr),1)
#define ATOMIC_GET(ptr) __sync_fetch_and_add((ptr),0) #define ATOMIC_GET(ptr) __sync_fetch_and_add((ptr),0)
#define ATOMIC_SET_IF_EQ(ptr, oldv, newv) __sync_val_compare_and_swap(ptr, oldv, newv) #define ATOMIC_SET_IF_EQ(ptr, oldv, newv) __sync_bool_compare_and_swap(ptr, oldv, newv)
#endif /* CYCLONE_TYPES_H */ #endif /* CYCLONE_TYPES_H */