Changeset bb3ba51 in mainline
- Timestamp:
- 2017-08-22T18:10:29Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 295ee02
- Parents:
- b93ea46a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/riscv64/include/arch/atomic.h
rb93ea46a rbb3ba51 40 40 NO_TRACE static inline void atomic_inc(atomic_t *val) 41 41 { 42 // FIXME 42 asm volatile ( 43 "amoadd.d zero, %[inc], %[addr]\n" 44 : [addr] "+A" (val->count) 45 : [inc] "r" (1) 46 ); 43 47 } 44 48 45 49 NO_TRACE static inline void atomic_dec(atomic_t *val) 46 50 { 47 // FIXME 51 asm volatile ( 52 "amoadd.d zero, %[inc], %[addr]\n" 53 : [addr] "+A" (val->count) 54 : [inc] "r" (-1) 55 ); 48 56 } 49 57 50 58 NO_TRACE static inline atomic_count_t atomic_postinc(atomic_t *val) 51 59 { 52 atomic_inc(val); 53 return val->count - 1; 60 atomic_count_t orig; 61 62 asm volatile ( 63 "amoadd.d %[orig], %[inc], %[addr]\n" 64 : [orig] "=r" (orig), [addr] "+A" (val->count) 65 : [inc] "r" (1) 66 ); 67 68 return orig; 54 69 } 55 70 56 71 NO_TRACE static inline atomic_count_t atomic_postdec(atomic_t *val) 57 72 { 58 atomic_dec(val); 59 return val->count + 1; 73 atomic_count_t orig; 74 75 asm volatile ( 76 "amoadd.d %[orig], %[inc], %[addr]\n" 77 : [orig] "=r" (orig), [addr] "+A" (val->count) 78 : [inc] "r" (-1) 79 ); 80 81 return orig; 60 82 } 61 83 62 84 NO_TRACE static inline atomic_count_t atomic_preinc(atomic_t *val) 63 85 { 64 atomic_inc(val); 65 return val->count; 86 atomic_count_t orig; 87 88 asm volatile ( 89 "amoadd.d %[orig], %[inc], %[addr]\n" 90 : [orig] "=r" (orig), [addr] "+A" (val->count) 91 : [inc] "r" (1) 92 ); 93 94 return orig - 1; 66 95 } 67 96 68 97 NO_TRACE static inline atomic_count_t atomic_predec(atomic_t *val) 69 98 { 70 atomic_dec(val); 71 return val->count; 99 atomic_count_t orig; 100 101 asm volatile ( 102 "amoadd.d %[orig], %[inc], %[addr]\n" 103 : [orig] "=r" (orig), [addr] "+A" (val->count) 104 : [inc] "r" (-1) 105 ); 106 107 return orig + 1; 72 108 } 73 109
Note:
See TracChangeset
for help on using the changeset viewer.