Changeset 1888 in vbox for trunk/include/iprt
- Timestamp:
- Apr 3, 2007 2:48:08 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r1228 r1888 2871 2871 2872 2872 /** 2873 * Multiple a 64-bit by a 32-bit integer and divide the result by a 32-bit integer 2874 * using a 96 bit intermediate result. 2875 * 2876 * @returns (u64A * u32B) / u32C. 2877 * @param u64A The 64-bit value. 2878 * @param u32B The 32-bit value to multiple by A. 2879 * @param u32C The 32-bit value to divide A*B by. 2880 */ 2881 #if RT_INLINE_ASM_EXTERNAL 2882 DECLASM(uint64_t) ASMMultU64ByU32DivByU32(uint64_t u64A, uint32_t u32B, uint32_t u32C); 2883 #else 2884 DECLINLINE(uint64_t) ASMMultU64ByU32DivByU32(uint64_t u64A, uint32_t u32B, uint32_t u32C) 2885 { 2886 # if RT_INLINE_ASM_GNU_STYLE && defined(__AMD64__) 2887 uint64_t u64Result, u64Spill; 2888 __asm__ __volatile__("mulq %2\n\t" 2889 "divq %3\n\t" 2890 : "=a" (u64Result), 2891 "=d" (u64Spill) 2892 : "r" ((uint64_t)u32B), 2893 "r" ((uint64_t)u32C), 2894 "0" (u64A), 2895 "1" (0)); 2896 return u64Result; 2897 # else 2898 RTUINT64U u; 2899 uint64_t u64Low = (uint64_t)(u64A & 0xffffffff) * u32B; 2900 uint64_t u64Hi = (uint64_t)(u64A >> 32) * u32B; 2901 u64Hi += (u64Low >> 32); 2902 u.s.Hi = (uint32_t)(u64Hi / u32C); 2903 u.s.Lo = (uint32_t)((((u64Hi % u32C) << 32) + (u64Low & 0xffffffff)) / u32C); 2904 return u.u; 2905 # endif 2906 } 2907 #endif 2908 2909 2910 /** 2873 2911 * Probes a byte pointer for read access. 2874 2912 *
Note:
See TracChangeset
for help on using the changeset viewer.