Changeset 1876 for trunk/src/emx/include/386/builtin.h
- Timestamp:
- Mar 20, 2005, 1:16:43 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/386/builtin.h
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r1875 r1876 126 126 * @param uAdd The value to add to *pu. 127 127 */ 128 static __inline__ void __atomic_add(__volatile__ unsigned *pu, unsigned uAdd)128 static __inline__ void __atomic_add(__volatile__ unsigned *pu, const unsigned uAdd) 129 129 { 130 130 __asm__ __volatile__("lock addl %1, %0" 131 131 : "=m" (*pu) 132 : "r" (uAdd)); 132 : "nr" (uAdd), 133 "m" (*pu)); 133 134 } 134 135 … … 139 140 * @param uAdd The value to subtract from *pu. 140 141 */ 141 static __inline__ void __atomic_sub(__volatile__ unsigned *pu, unsigned uSub)142 static __inline__ void __atomic_sub(__volatile__ unsigned *pu, const unsigned uSub) 142 143 { 143 144 __asm__ __volatile__("lock subl %1, %0" 144 145 : "=m" (*pu) 145 : "r" (uSub)); 146 : "nr" (uSub), 147 "m" (*pu)); 146 148 } 147 149 … … 155 157 { 156 158 __asm__ __volatile__("lock incl %0" 157 : "=m" (*pu)); 159 : "=m" (*pu) 160 : "m" (*pu)); 158 161 } 159 162 … … 166 169 { 167 170 __asm__ __volatile__("lock decl %0" 168 : "=m" (*pu)); 171 : "=m" (*pu) 172 : "m" (*pu)); 169 173 } 170 174 … … 177 181 * @param uMax *pu must not be above this value. 178 182 */ 179 static __inline__ int __atomic_increment_max(__volatile__ unsigned *pu, unsigned uMax)183 static __inline__ int __atomic_increment_max(__volatile__ unsigned *pu, const unsigned uMax) 180 184 { 181 185 unsigned rc; 182 __asm__ __volatile__("movl (%1), %%eax\n\t"186 __asm__ __volatile__("movl %2, %%eax\n\t" 183 187 "1:\n\t" 184 "lea 1(%%eax), %0\n\t" 185 "cmpl %2, %0\n\t" 186 "jna 2f\n\t" 187 "decl %0\n\t" 188 "movl %%eax, %0\n\t" 189 "cmpl %3, %0\n\t" 190 "jb 2f\n\t" 188 191 "jmp 4f\n" 189 192 "2:\n\t" 190 "lock cmpxchgl %0, (%1)\n\t" 193 "incl %0\n\t" 194 "lock cmpxchgl %0, %1\n\t" 191 195 "jz 3f\n\t" 192 196 "jmp 1b\n" … … 194 198 "xorl %0, %0\n\t" 195 199 "4:" 196 : "=b" (rc) 197 : "c" (pu), 198 "d" (uMax) 200 : "=b" (rc), 201 "=m" (*pu) 202 : "m" (*pu), 203 "nd" (uMax), 204 "0" (rc) 199 205 : "%eax"); 200 206 return rc; … … 210 216 * @param u16Max *pu16 must not be above this value after the incrementation. 211 217 */ 212 static inline unsigned __atomic_increment_word_max(volatile uint16_t *pu16, uint16_t u16Max) 213 { 214 unsigned rc; 215 __asm__ __volatile__("movw (%1), %%ax\n\t" 216 "xorl %%ebx, %%ebx\n\t" 218 static inline unsigned __atomic_increment_word_max(volatile uint16_t *pu16, const uint16_t u16Max) 219 { 220 unsigned rc = 0; 221 __asm__ __volatile__("movw %2, %%ax\n\t" 217 222 "1:\n\t" 218 "movw %%ax, % %bx\n\t"219 "cmpw % %dx, %%ax\n\t"223 "movw %%ax, %w0\n\t" 224 "cmpw %w3, %%ax\n\t" 220 225 "jb 2f\n\t" 221 "orl $0xffff0000, % %ebx\n\t"226 "orl $0xffff0000, %0\n\t" 222 227 "jmp 3f\n" 223 228 "2:\n\t" 224 "incw % %bx\n\t"225 "lock cmpxchgw % %bx, (%1)\n\t"229 "incw %w0\n\t" 230 "lock cmpxchgw %w0, %2\n\t" 226 231 "jz 3f\n\t" 227 232 "jmp 1b\n\t" 228 233 "3:" 229 : "=b" (rc) 230 : "r" (pu16), 231 "d" (u16Max) 234 : "=r" (rc), 235 "=m" (*pu16) 236 : "m" (*pu16), 237 "nr" (u16Max), 238 "0" (rc) 232 239 : "%eax"); 233 240 return rc; … … 243 250 * @param uMin *pu must not be below this value. 244 251 */ 245 static __inline__ int __atomic_decrement_min(__volatile__ unsigned *pu, unsigned uMin)252 static __inline__ int __atomic_decrement_min(__volatile__ unsigned *pu, const unsigned uMin) 246 253 { 247 254 unsigned rc; 248 __asm__ __volatile__("movl (%1), %%eax\n"255 __asm__ __volatile__("movl %2, %%eax\n" 249 256 "1:\n\t" 250 "lea -1(%%eax), %0\n\t" 251 "cmpl %2, %0\n\t" 252 "jnb 2f\n\t" 253 "incl %0\n\t" 257 "movl %%eax, %0\n\t" 258 "cmpl %3, %0\n\t" 259 "ja 2f\n\t" 254 260 "jmp 4f\n" 255 261 "2:\n\t" 256 "lock cmpxchgl %0, (%1)\n\t" 262 "decl %0\n\t" 263 "lock cmpxchgl %0, %1\n\t" 257 264 "jz 3f\n\t" 258 265 "jmp 1b\n" … … 260 267 "xorl %0, %0\n\t" 261 268 "4:" 262 : "=b" (rc) 263 : "c" (pu), 264 "d" (uMin) 269 : "=b" (rc), 270 "=m" (*pu) 271 : "m" (*pu), 272 "nr" (uMin), 273 "0" (rc) 265 274 : "%eax"); 266 275 return rc; … … 276 285 * @param u16Min *pu16 must not be below this value after the decrementation. 277 286 */ 278 static inline unsigned __atomic_decrement_word_min(volatile uint16_t *pu16, uint16_t u16Min) 279 { 280 unsigned rc; 281 __asm__ __volatile__("movw (%1), %%ax\n\t" 282 "xorl %%ebx, %%ebx\n\t" 287 static inline unsigned __atomic_decrement_word_min(volatile uint16_t *pu16, const uint16_t u16Min) 288 { 289 unsigned rc = 0; 290 __asm__ __volatile__("movw %2, %%ax\n\t" 283 291 "1:\n\t" 284 "movw %%ax, % %bx\n\t"285 "cmpw % %dx, %%ax\n\t"292 "movw %%ax, %w0\n\t" 293 "cmpw %w3, %%ax\n\t" 286 294 "ja 2f\n\t" 287 "orl $0xffff0000, % %ebx\n\t"295 "orl $0xffff0000, %0\n\t" 288 296 "jmp 3f\n" 289 297 "2:\n\t" 290 298 "decw %%bx\n\t" 291 "lock cmpxchgw % %bx, (%1)\n\t"299 "lock cmpxchgw %w0, %1\n\t" 292 300 "jz 3f\n\t" 293 301 "jmp 1b\n" 294 302 "3:" 295 : "=b" (rc) 296 : "r" (pu16), 297 "d" (u16Min) 303 : "=b" (rc), 304 "=m" (*pu16) 305 : "m" (*pu16), 306 "nr" (u16Min), 307 "0" (rc) 298 308 : "%eax"); 299 309 return rc; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.