Changeset 1382
- Timestamp:
- Apr 26, 2004, 2:09:44 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/386/builtin.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1381 r1382 49 49 static __inline__ int __atomic_set_bit(__volatile__ void *pv, unsigned uBit) 50 50 { 51 int rc;52 51 __asm__ __volatile__("lock btsl %2, %1\n\t" 53 52 "sbbl %0,%0" 54 : "=r" ( rc),53 : "=r" (uBit), 55 54 "=m" (*(__volatile__ unsigned *)pv) 56 : " r"(uBit)55 : "0" (uBit) 57 56 : "memory"); 58 return rc;57 return uBit; 59 58 } 60 59 … … 87 86 "sbbl %0, %0\t\n" 88 87 : "=r" (uBit) 89 : "m" (*(const __volatile__ unsigned *)pv)); 88 : "m" (*(const __volatile__ unsigned *)pv), 89 "0" (uBit)); 90 90 return uBit; 91 91 } … … 118 118 * 119 119 * @returns 0 if incremented. 120 * @returns *pu + 1when not updated.120 * @returns uMax when not updated. 121 121 * @param pu Pointer to the value to increment. 122 122 * @param uMax *pu must not be above this value. … … 125 125 { 126 126 unsigned rc; 127 __asm__ __volatile__("movl %1, %%eax\n"127 __asm__ __volatile__("movl (%1), %%eax\n\t" 128 128 "1:\n\t" 129 129 "lea 1(%%eax), %0\n\t" 130 "cmpl % 0, %2\n\t"130 "cmpl %2, %0\n\t" 131 131 "jna 2f\n\t" 132 "decl %0\n\t" 132 133 "jmp 4f\n" 133 134 "2:\n\t" 134 "lock cmpxchgl %0, %1\n\t"135 "lock cmpxchgl %0, (%1)\n\t" 135 136 "jz 3f\n\t" 136 137 "jmp 1b\n" … … 138 139 "xorl %0, %0\n\t" 139 140 "4:" 140 : "= r" (rc),141 "=m" (pu)142 : "r" (uMax)141 : "=b" (rc) 142 : "c" (pu), 143 "d" (uMax) 143 144 : "%eax"); 144 145 return rc; … … 149 150 * Atomically decrements a 32-bit unsigned value if greater than a min. 150 151 * 151 * @returns 0 if incremented.152 * @returns *pu + 1when not updated.153 * @param pu Pointer to the value to decrement.152 * @returns 0 if decremented. 153 * @returns uMin when not updated. 154 * @param pu Pointer to the value to decrement. 154 155 * @param uMin *pu must not be below this value. 155 156 */ 156 static __inline__ int __atomic_ increment_min(__volatile__ unsigned *pu, unsigned uMin)157 static __inline__ int __atomic_decrement_min(__volatile__ unsigned *pu, unsigned uMin) 157 158 { 158 159 unsigned rc; 159 __asm__ __volatile__("movl %1, %%eax\n"160 __asm__ __volatile__("movl (%1), %%eax\n" 160 161 "1:\n\t" 161 162 "lea -1(%%eax), %0\n\t" 162 "cmpl % 0, %2\n\t"163 "cmpl %2, %0\n\t" 163 164 "jnb 2f\n\t" 165 "incl %0\n\t" 164 166 "jmp 4f\n" 165 167 "2:\n\t" 166 "lock cmpxchgl %0, %1\n\t"168 "lock cmpxchgl %0, (%1)\n\t" 167 169 "jz 3f\n\t" 168 170 "jmp 1b\n" … … 170 172 "xorl %0, %0\n\t" 171 173 "4:" 172 : "= r" (rc),173 "=m" (*pu)174 : "r" (uMin)174 : "=b" (rc) 175 : "c" (pu), 176 "d" (uMin) 175 177 : "%eax"); 176 178 return rc; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.