Changeset c53e813 in mainline
- Timestamp:
- 2018-09-07T16:18:10Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e90cfa6
- Parents:
- 3cfe2b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/atomic.h
r3cfe2b8 rc53e813 40 40 #include <stdatomic.h> 41 41 42 // TODO: Remove. 43 // Before <stdatomic.h> was available, there was only one atomic type 44 // equivalent to atomic_size_t. This means that in some places, atomic_t can 45 // be replaced with a more appropriate type (e.g. atomic_bool for flags or 46 // a signed type for potentially signed values). 47 // So atomic_t should be replaced with the most appropriate type on a case by 48 // case basis, and after there are no more uses, remove this type. 42 49 typedef atomic_size_t atomic_t; 43 50 44 static inline size_t atomic_predec(atomic_t *val) 45 { 46 return atomic_fetch_sub(val, 1) - 1; 47 } 51 #define atomic_predec(val) \ 52 (atomic_fetch_sub((val), 1) - 1) 48 53 49 static inline size_t atomic_preinc(atomic_t *val) 50 { 51 return atomic_fetch_add(val, 1) + 1; 52 } 54 #define atomic_preinc(val) \ 55 (atomic_fetch_add((val), 1) + 1) 53 56 54 static inline size_t atomic_postdec(atomic_t *val) 55 { 56 return atomic_fetch_sub(val, 1); 57 } 57 #define atomic_postdec(val) \ 58 atomic_fetch_sub((val), 1) 58 59 59 static inline size_t atomic_postinc(atomic_t *val) 60 { 61 return atomic_fetch_add(val, 1); 62 } 60 #define atomic_postinc(val) \ 61 atomic_fetch_add((val), 1) 63 62 64 static inline void atomic_dec(atomic_t *val) 65 { 66 atomic_fetch_sub(val, 1); 67 } 63 #define atomic_dec(val) \ 64 ((void) atomic_fetch_sub(val, 1)) 68 65 69 static inline void atomic_inc(atomic_t *val) 70 { 71 atomic_fetch_add(val, 1); 72 } 66 #define atomic_inc(val) \ 67 ((void) atomic_fetch_add(val, 1)) 73 68 74 69 #define local_atomic_exchange(var_addr, new_val) \
Note:
See TracChangeset
for help on using the changeset viewer.