Changeset 52345 in vbox for trunk/include
- Timestamp:
- Aug 11, 2014 3:29:24 PM (10 years ago)
- Location:
- trunk/include/iprt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r51834 r52345 3266 3266 3267 3267 3268 /** 3269 * Atomically increment an unsigned 32-bit value, unordered. 3270 * 3271 * @returns the new value. 3272 * @param pu32 Pointer to the variable to increment. 3273 */ 3274 #if RT_INLINE_ASM_EXTERNAL 3275 DECLASM(uint32_t) ASMAtomicUoIncU32(uint32_t volatile *pu32); 3276 #else 3277 DECLINLINE(uint32_t) ASMAtomicUoIncU32(uint32_t volatile *pu32) 3278 { 3279 uint32_t u32; 3280 # if RT_INLINE_ASM_GNU_STYLE 3281 __asm__ __volatile__("xaddl %0, %1\n\t" 3282 : "=r" (u32), 3283 "=m" (*pu32) 3284 : "0" (1), 3285 "m" (*pu32) 3286 : "memory"); 3287 return u32 + 1; 3288 # else 3289 __asm 3290 { 3291 mov eax, 1 3292 # ifdef RT_ARCH_AMD64 3293 xadd [rdx], eax 3294 # else 3295 xadd [edx], eax 3296 # endif 3297 mov u32, eax 3298 } 3299 return u32 + 1; 3300 # endif 3301 } 3302 #endif 3303 3304 3305 /** 3306 * Atomically decrement an unsigned 32-bit value, unordered. 3307 * 3308 * @returns the new value. 3309 * @param pu32 Pointer to the variable to decrement. 3310 */ 3311 #if RT_INLINE_ASM_EXTERNAL 3312 DECLASM(uint32_t) ASMAtomicUoDecU32(uint32_t volatile *pu32); 3313 #else 3314 DECLINLINE(uint32_t) ASMAtomicUoDecU32(uint32_t volatile *pu32) 3315 { 3316 uint32_t u32; 3317 # if RT_INLINE_ASM_GNU_STYLE 3318 __asm__ __volatile__("lock; xaddl %0, %1\n\t" 3319 : "=r" (u32), 3320 "=m" (*pu32) 3321 : "0" (-1), 3322 "m" (*pu32) 3323 : "memory"); 3324 return u32 - 1; 3325 # else 3326 __asm 3327 { 3328 mov eax, -1 3329 # ifdef RT_ARCH_AMD64 3330 mov rdx, [pu32] 3331 xadd [rdx], eax 3332 # else 3333 mov edx, [pu32] 3334 xadd [edx], eax 3335 # endif 3336 mov u32, eax 3337 } 3338 return u32 - 1; 3339 # endif 3340 } 3341 #endif 3342 3268 3343 3269 3344 /** @def RT_ASM_PAGE_SIZE -
trunk/include/iprt/mangling.h
r52341 r52345 54 54 # define ASMAtomicReadU64 RT_MANGLER(ASMAtomicReadU64) /* not-some-systems... */ 55 55 # define ASMAtomicReadU64_EndProc RT_MANGLER(ASMAtomicReadU64_EndProc) 56 # define ASMAtomicUoAndU32 RT_MANGLER(ASMAtomicUoAndU32) /* not-some-systems... */ 57 # define ASMAtomicUoAndU32_EndProc RT_MANGLER(ASMAtomicUoAndU32_EndProc) 58 # define ASMAtomicUoAndU64 RT_MANGLER(ASMAtomicUoAndU64) /* not-some-systems... */ 59 # define ASMAtomicUoAndU64_EndProc RT_MANGLER(ASMAtomicUoAndU64_EndProc) 60 # define ASMAtomicUoDecU32 RT_MANGLER(ASMAtomicUoDecU32) /* not-some-systems... */ 61 # define ASMAtomicUoDecU32_EndProc RT_MANGLER(ASMAtomicUoDecU32_EndProc) 62 # define ASMAtomicUoIncU32 RT_MANGLER(ASMAtomicUoIncU32) /* not-some-systems... */ 63 # define ASMAtomicUoIncU32_EndProc RT_MANGLER(ASMAtomicUoIncU32_EndProc) 64 # define ASMAtomicUoOrU32 RT_MANGLER(ASMAtomicUoOrU32) /* not-some-systems... */ 65 # define ASMAtomicUoOrU32_EndProc RT_MANGLER(ASMAtomicUoOrU32_EndProc) 66 # define ASMAtomicUoOrU64 RT_MANGLER(ASMAtomicUoOrU64) /* not-some-systems... */ 67 # define ASMAtomicUoOrU64_EndProc RT_MANGLER(ASMAtomicUoOrU64_EndProc) 56 68 # define ASMAtomicUoReadU64 RT_MANGLER(ASMAtomicUoReadU64) /* not-some-systems... */ 57 69 # define ASMAtomicUoReadU64_EndProc RT_MANGLER(ASMAtomicUoReadU64_EndProc) 58 # define ASMAtomicUoAndU64 RT_MANGLER(ASMAtomicUoAndU64) /* not-some-systems... */59 # define ASMAtomicUoAndU64_EndProc RT_MANGLER(ASMAtomicUoAndU64_EndProc)60 # define ASMAtomicUoAndU32 RT_MANGLER(ASMAtomicUoAndU32) /* not-some-systems... */61 # define ASMAtomicUoAndU32_EndProc RT_MANGLER(ASMAtomicUoAndU32_EndProc)62 # define ASMAtomicUoOrU64 RT_MANGLER(ASMAtomicUoOrU64) /* not-some-systems... */63 # define ASMAtomicUoOrU64_EndProc RT_MANGLER(ASMAtomicUoOrU64_EndProc)64 # define ASMAtomicUoOrU32 RT_MANGLER(ASMAtomicUoOrU32) /* not-some-systems... */65 # define ASMAtomicUoOrU32_EndProc RT_MANGLER(ASMAtomicUoOrU32_EndProc)66 70 # define ASMAtomicXchgU64 RT_MANGLER(ASMAtomicXchgU64) /* not-some-systems... */ 67 71 # define ASMAtomicXchgU64_EndProc RT_MANGLER(ASMAtomicXchgU64_EndProc)
Note:
See TracChangeset
for help on using the changeset viewer.