Changeset 25665 in vbox
- Timestamp:
- Jan 6, 2010 4:19:49 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56380
- Location:
- trunk
- Files:
-
- 3 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r25645 r25665 117 117 #endif 118 118 119 /** @def RT_INLINE_ASM_GCC_4_3_X_X86120 * Used to work around some 4.3.x register allocation issues in this version of121 * the compiler. */122 #ifdef __GNUC__123 # define RT_INLINE_ASM_GCC_4_3_X_X86 (__GNUC__ == 4 && __GNUC_MINOR__ == 3 && defined(__i386__))124 #endif125 #ifndef RT_INLINE_ASM_GCC_4_3_X_X86126 # define RT_INLINE_ASM_GCC_4_3_X_X86 0127 #endif128 129 130 119 131 120 /** @defgroup grp_asm ASM - Assembly Routines … … 167 156 * @{ 168 157 */ 158 159 /** @def RT_INLINE_ASM_GCC_4_3_X_X86 160 * Used to work around some 4.3.x register allocation issues in this version of 161 * the compiler. */ 162 #ifdef __GNUC__ 163 # define RT_INLINE_ASM_GCC_4_3_X_X86 (__GNUC__ == 4 && __GNUC_MINOR__ == 3 && defined(__i386__)) 164 #endif 165 #ifndef RT_INLINE_ASM_GCC_4_3_X_X86 166 # define RT_INLINE_ASM_GCC_4_3_X_X86 0 167 #endif 168 169 /** @def RT_INLINE_DONT_USE_CMPXCHG8B 170 * i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493) screws up 171 * RTSemRWRequestWrite semsemrw-lockless-generic.cpp in release builds. PIC 172 * mode, x86. 173 * 174 * Some gcc 4.3.x versions may have register allocation issues with cmpxchg8b 175 * when in PIC mode on x86. 176 */ 177 #ifndef RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC 178 # define RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC \ 179 ( (defined(PIC) || defined(__PIC__)) \ 180 && defined(RT_ARCH_X86) \ 181 && ( RT_INLINE_ASM_GCC_4_3_X_X86 \ 182 || defined(RT_OS_DARWIN)) ) 183 #endif 169 184 170 185 /** @def RT_INLINE_ASM_EXTERNAL … … 2808 2823 * @param u64 The 64-bit value to assign to *pu64. 2809 2824 */ 2810 #if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN 2825 #if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \ 2826 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC 2811 2827 DECLASM(uint64_t) ASMAtomicXchgU64(volatile uint64_t *pu64, uint64_t u64); 2812 2828 #else … … 3175 3191 */ 3176 3192 #if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \ 3177 || (RT_INLINE_ASM_GCC_4_3_X_X86 && defined(IN_RING3) && defined(__PIC__))3193 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC 3178 3194 DECLASM(bool) ASMAtomicCmpXchgU64(volatile uint64_t *pu64, const uint64_t u64New, const uint64_t u64Old); 3179 3195 #else 3180 DECLINLINE(bool) ASMAtomicCmpXchgU64(volatile uint64_t *pu64, constuint64_t u64New, uint64_t u64Old)3196 DECLINLINE(bool) ASMAtomicCmpXchgU64(volatile uint64_t *pu64, uint64_t u64New, uint64_t u64Old) 3181 3197 { 3182 3198 # if RT_INLINE_ASM_USES_INTRIN … … 3443 3459 * @param pu64Old Pointer store the old value at. 3444 3460 */ 3445 #if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN 3461 #if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \ 3462 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC 3446 3463 DECLASM(bool) ASMAtomicCmpXchgExU64(volatile uint64_t *pu64, const uint64_t u64New, const uint64_t u64Old, uint64_t *pu64Old); 3447 3464 #else … … 4222 4239 */ 4223 4240 #if (RT_INLINE_ASM_EXTERNAL && !defined(RT_ARCH_AMD64)) \ 4224 || (RT_INLINE_ASM_GCC_4_3_X_X86 && defined(IN_RING3) && defined(__PIC__))4241 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC 4225 4242 DECLASM(uint64_t) ASMAtomicReadU64(volatile uint64_t *pu64); 4226 4243 #else … … 4300 4317 * @remark This will fault if the memory is read-only! 4301 4318 */ 4302 #if RT_INLINE_ASM_EXTERNAL && !defined(RT_ARCH_AMD64) 4319 #if #if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \ 4320 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC 4303 4321 DECLASM(uint64_t) ASMAtomicUoReadU64(volatile uint64_t *pu64); 4304 4322 #else -
trunk/src/VBox/Runtime/Makefile.kmk
r25645 r25665 374 374 # Some versions of GCC might require this. 375 375 RuntimeR3_SOURCES.x86 += \ 376 common/asm/ASMAtomicXchgU64.asm \ 376 377 common/asm/ASMAtomicCmpXchgU64.asm \ 377 common/asm/ASMAtomicReadU64.asm 378 common/asm/ASMAtomicCmpXchgExU64.asm \ 379 common/asm/ASMAtomicReadU64.asm \ 380 common/asm/ASMAtomicUoReadU64.asm 378 381 379 382 ifdef IPRT_WITH_KSTUFF -
trunk/src/VBox/Runtime/common/asm/ASMAtomicCmpXchgExU64.asm
r25664 r25665 1 1 ; $Id$ 2 2 ;; @file 3 ; IPRT - ASMAtomicCmpXchg U64().3 ; IPRT - ASMAtomicCmpXchgExU64(). 4 4 ; 5 5 6 6 ; 7 ; Copyright (C) 2006-20 09Sun Microsystems, Inc.7 ; Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 37 37 38 38 ;; 39 ; Atomically compares and exchanges an unsigned 64-bit int.39 ; Atomically Exchange an unsigned 64-bit value, ordered. 40 40 ; 41 41 ; @param pu64 x86:ebp+8 gcc:rdi msc:rcx 42 42 ; @param u64New x86:ebp+c gcc:rsi msc:rdx 43 43 ; @param u64Old x86:ebp+14 gcc:rcx msc:r8 44 ; @param u64Old x86:ebp+1c gcc:rdx msc:r9 44 45 ; 45 46 ; @returns bool result: true if succesfully exchanged, false if not. 46 47 ; x86:al 47 48 ; 48 BEGINPROC_EXPORTED ASMAtomicCmpXchg U6449 BEGINPROC_EXPORTED ASMAtomicCmpXchgExU64 49 50 %ifdef RT_ARCH_AMD64 50 51 %ifdef ASM_CALL64_MSC 51 52 mov rax, r8 52 53 lock cmpxchg [rcx], rdx 54 mov [r9], rax 53 55 %else 54 56 mov rax, rcx 55 57 lock cmpxchg [rdi], rsi 58 mov [rdx], rax 56 59 %endif 57 60 setz al … … 71 74 mov edx, dword [ebp+14h + 4] 72 75 lock cmpxchg8b [edi] 76 mov edi, [ebp + 1ch] 77 mov [edi], eax 78 mov [edi + 4], edx 73 79 setz al 74 80 movzx eax, al … … 79 85 ret 80 86 %endif 81 ENDPROC ASMAtomicCmpXchg U6487 ENDPROC ASMAtomicCmpXchgExU64 82 88 -
trunk/src/VBox/Runtime/common/asm/ASMAtomicCmpXchgU64.asm
r25664 r25665 5 5 6 6 ; 7 ; Copyright (C) 2006-20 09Sun Microsystems, Inc.7 ; Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as -
trunk/src/VBox/Runtime/common/asm/ASMAtomicUoReadU64.asm
r25664 r25665 1 1 ; $Id$ 2 2 ;; @file 3 ; IPRT - ASMAtomic ReadU64().3 ; IPRT - ASMAtomicUoReadU64(). 4 4 ; 5 5 6 6 ; 7 ; Copyright (C) 2006-20 09Sun Microsystems, Inc.7 ; Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 44 44 ; 45 45 ; 46 BEGINPROC_EXPORTED ASMAtomic ReadU6446 BEGINPROC_EXPORTED ASMAtomicUoReadU64 47 47 %ifdef RT_ARCH_AMD64 48 mfence ; ASSUME its present.49 48 %ifdef ASM_CALL64_MSC 50 49 mov rax, [rcx] … … 65 64 xor ecx, ecx 66 65 xor ebx, ebx 67 lockcmpxchg8b [edi]66 cmpxchg8b [edi] 68 67 69 68 pop edi … … 72 71 ret 73 72 %endif 74 ENDPROC ASMAtomic ReadU6473 ENDPROC ASMAtomicUoReadU64 75 74 -
trunk/src/VBox/Runtime/common/asm/ASMAtomicXchgU64.asm
r25664 r25665 1 1 ; $Id$ 2 2 ;; @file 3 ; IPRT - ASMAtomic CmpXchgU64().3 ; IPRT - ASMAtomicXchgU64(). 4 4 ; 5 5 6 6 ; 7 ; Copyright (C) 2006-20 09Sun Microsystems, Inc.7 ; Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 37 37 38 38 ;; 39 ; Atomically compares and exchanges an unsigned 64-bit int.39 ; Atomically Exchange an unsigned 64-bit value, ordered. 40 40 ; 41 41 ; @param pu64 x86:ebp+8 gcc:rdi msc:rcx 42 42 ; @param u64New x86:ebp+c gcc:rsi msc:rdx 43 ; @param u64Old x86:ebp+14 gcc:rcx msc:r844 43 ; 45 44 ; @returns bool result: true if succesfully exchanged, false if not. 46 45 ; x86:al 47 46 ; 48 BEGINPROC_EXPORTED ASMAtomic CmpXchgU6447 BEGINPROC_EXPORTED ASMAtomicXchgU64 49 48 %ifdef RT_ARCH_AMD64 50 49 %ifdef ASM_CALL64_MSC 51 50 mov rax, r8 51 .try_again: 52 52 lock cmpxchg [rcx], rdx 53 53 %else 54 .try_again: 54 55 mov rax, rcx 55 56 lock cmpxchg [rdi], rsi 56 57 %endif 57 setz al 58 movzx eax, al 58 jnz .try_again 59 59 ret 60 60 %endif … … 65 65 push edi 66 66 67 .try_again: 67 68 mov ebx, dword [ebp+0ch] 68 69 mov ecx, dword [ebp+0ch + 4] 69 70 mov edi, [ebp+08h] 70 mov eax, dword [ebp+14h]71 mov edx, dword [ebp+14h + 4]72 71 lock cmpxchg8b [edi] 73 setz al 74 movzx eax, al 72 jnz .try_again 75 73 76 74 pop edi … … 79 77 ret 80 78 %endif 81 ENDPROC ASMAtomic CmpXchgU6479 ENDPROC ASMAtomicXchgU64 82 80
Note:
See TracChangeset
for help on using the changeset viewer.