Changes in kernel/arch/ia64/include/atomic.h [e86a849a:7038f55] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/include/atomic.h
re86a849a r7038f55 27 27 */ 28 28 29 /** @addtogroup ia64 29 /** @addtogroup ia64 30 30 * @{ 31 31 */ … … 36 36 #define KERN_ia64_ATOMIC_H_ 37 37 38 /** Atomic addition. 39 * 40 * @param val Atomic value. 41 * @param imm Value to add. 42 * 43 * @return Value before addition. 44 */ 45 static inline long atomic_add(atomic_t *val, int imm) 46 { 47 long v; 48 49 asm volatile ("fetchadd8.rel %0 = %1, %2\n" : "=r" (v), 50 "+m" (val->count) : "i" (imm)); 51 52 return v; 53 } 54 38 55 static inline uint64_t test_and_set(atomic_t *val) 39 56 { … … 41 58 42 59 asm volatile ( 43 "movl %[v] = 0x1;;\n" 44 "xchg8 %[v] = %[count], %[v];;\n" 45 : [v] "=r" (v), 46 [count] "+m" (val->count) 60 "movl %0 = 0x1;;\n" 61 "xchg8 %0 = %1, %0;;\n" 62 : "=r" (v), "+m" (val->count) 47 63 ); 48 64 … … 60 76 static inline void atomic_inc(atomic_t *val) 61 77 { 62 long v; 63 64 asm volatile ( 65 "fetchadd8.rel %[v] = %[count], 1\n" 66 : [v] "=r" (v), 67 [count] "+m" (val->count) 68 ); 78 atomic_add(val, 1); 69 79 } 70 80 71 81 static inline void atomic_dec(atomic_t *val) 72 82 { 73 long v; 74 75 asm volatile ( 76 "fetchadd8.rel %[v] = %[count], -1\n" 77 : [v] "=r" (v), 78 [count] "+m" (val->count) 79 ); 83 atomic_add(val, -1); 80 84 } 81 85 82 86 static inline long atomic_preinc(atomic_t *val) 83 87 { 84 long v; 85 86 asm volatile ( 87 "fetchadd8.rel %[v] = %[count], 1\n" 88 : [v] "=r" (v), 89 [count] "+m" (val->count) 90 ); 91 92 return (v + 1); 88 return atomic_add(val, 1) + 1; 93 89 } 94 90 95 91 static inline long atomic_predec(atomic_t *val) 96 92 { 97 long v; 98 99 asm volatile ( 100 "fetchadd8.rel %[v] = %[count], -1\n" 101 : [v] "=r" (v), 102 [count] "+m" (val->count) 103 ); 104 105 return (v - 1); 93 return atomic_add(val, -1) - 1; 106 94 } 107 95 108 96 static inline long atomic_postinc(atomic_t *val) 109 97 { 110 long v; 111 112 asm volatile ( 113 "fetchadd8.rel %[v] = %[count], 1\n" 114 : [v] "=r" (v), 115 [count] "+m" (val->count) 116 ); 117 118 return v; 98 return atomic_add(val, 1); 119 99 } 120 100 121 101 static inline long atomic_postdec(atomic_t *val) 122 102 { 123 long v; 124 125 asm volatile ( 126 "fetchadd8.rel %[v] = %[count], -1\n" 127 : [v] "=r" (v), 128 [count] "+m" (val->count) 129 ); 130 131 return v; 103 return atomic_add(val, -1); 132 104 } 133 105
Note:
See TracChangeset
for help on using the changeset viewer.