1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // atomic.hfa -- simpler macros to access atomic instructions |
---|
8 | // |
---|
9 | // Author : Peter A. Buhr |
---|
10 | // Created On : Thu May 25 15:22:46 2023 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Thu May 25 15:24:45 2023 |
---|
13 | // Update Count : 1 |
---|
14 | // |
---|
15 | |
---|
16 | #define LOAD( lock ) (__atomic_load_n( &(lock), __ATOMIC_SEQ_CST )) |
---|
17 | #define LOADM( lock, memorder ) (__atomic_load_n( &(lock), memorder )) |
---|
18 | #define STORE( lock, assn ) (__atomic_store_n( &(lock), assn, __ATOMIC_SEQ_CST )) |
---|
19 | #define STOREM( lock, assn, memorder ) (__atomic_store_n( &(lock), assn, memorder )) |
---|
20 | #define CLR( lock ) (__atomic_clear( &(lock), __ATOMIC_RELEASE )) |
---|
21 | #define CLRM( lock, memorder ) (__atomic_clear( &(lock), memorder )) |
---|
22 | #define TAS( lock ) (__atomic_test_and_set( &(lock), __ATOMIC_ACQUIRE )) |
---|
23 | #define TASM( lock, memorder ) (__atomic_test_and_set( &(lock), memorder )) |
---|
24 | #define CAS( change, comp, assn ) ({typeof(comp) __temp = (comp); __atomic_compare_exchange_n( &(change), &(__temp), (assn), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ); }) |
---|
25 | #define CASM( change, comp, assn, memorder... ) ({typeof(comp) * __temp = &(comp); __atomic_compare_exchange_n( &(change), &(__temp), (assn), false, memorder, memorder ); }) |
---|
26 | #define CASV( change, comp, assn ) (__atomic_compare_exchange_n( &(change), &(comp), (assn), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST )) |
---|
27 | #define CASVM( change, comp, assn, memorder... ) (__atomic_compare_exchange_n( &(change), &(comp), (assn), false, memorder, memorder )) |
---|
28 | #define FAS( change, assn ) (__atomic_exchange_n( &(change), (assn), __ATOMIC_SEQ_CST )) |
---|
29 | #define FASM( change, assn, memorder ) (__atomic_exchange_n( &(change), (assn), memorder )) |
---|
30 | #define FAI( change, Inc ) (__atomic_fetch_add( &(change), (Inc), __ATOMIC_SEQ_CST )) |
---|
31 | #define FAIM( change, Inc, memorder ) (__atomic_fetch_add( &(change), (Inc), memorder )) |
---|