Changeset 09a0bd4a in mainline for kernel/arch/abs32le/include/atomic.h
- Timestamp:
- 2010-06-24T13:00:16Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2d03471, 33c4f72
- Parents:
- e821e49
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/abs32le/include/atomic.h
re821e49 r09a0bd4a 39 39 #include <arch/barrier.h> 40 40 #include <preemption.h> 41 #include <verify.h> 41 42 42 static inline void atomic_inc(atomic_t *val) { 43 ATOMIC static inline void atomic_inc(atomic_t *val) 44 REQUIRES(val->count < ATOMIC_COUNT_MAX) 45 { 43 46 /* On real hardware the increment has to be done 44 47 as an atomic action. */ … … 47 50 } 48 51 49 static inline void atomic_dec(atomic_t *val) { 52 ATOMIC static inline void atomic_dec(atomic_t *val) 53 REQUIRES(val->count > ATOMIC_COUNT_MIN) 54 { 50 55 /* On real hardware the decrement has to be done 51 56 as an atomic action. */ 52 57 53 val->count ++;58 val->count--; 54 59 } 55 60 56 static inline atomic_count_t atomic_postinc(atomic_t *val) 61 ATOMIC static inline atomic_count_t atomic_postinc(atomic_t *val) 62 REQUIRES(val->count < ATOMIC_COUNT_MAX) 57 63 { 58 64 /* On real hardware both the storing of the previous … … 66 72 } 67 73 68 static inline atomic_count_t atomic_postdec(atomic_t *val) 74 ATOMIC static inline atomic_count_t atomic_postdec(atomic_t *val) 75 REQUIRES(val->count > ATOMIC_COUNT_MIN) 69 76 { 70 77 /* On real hardware both the storing of the previous … … 81 88 #define atomic_predec(val) (atomic_postdec(val) - 1) 82 89 83 static inline atomic_count_t test_and_set(atomic_t *val)90 ATOMIC static inline atomic_count_t test_and_set(atomic_t *val) 84 91 { 92 /* On real hardware the retrieving of the original 93 value and storing 1 have to be done as a single 94 atomic action. */ 95 85 96 atomic_count_t prev = val->count; 86 97 val->count = 1; … … 88 99 } 89 100 101 ATOMIC static inline atomic_count_t arch_atomic_get(atomic_t *val) 102 { 103 /* This function is not needed on real hardware, it just 104 duplicates the functionality of atomic_get(). It is 105 defined here because atomic_get() is an inline function 106 declared in a header file which we are included in. */ 107 108 return val->count; 109 } 110 90 111 static inline void atomic_lock_arch(atomic_t *val) 91 112 { 92 113 do { 93 while ( val->count);114 while (arch_atomic_get(val)); 94 115 } while (test_and_set(val)); 95 116 }
Note:
See TracChangeset
for help on using the changeset viewer.