Changeset 51828 in vbox
- Timestamp:
- Jul 3, 2014 3:04:39 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r49724 r51828 66 66 # pragma intrinsic(_InterlockedCompareExchange) 67 67 # pragma intrinsic(_InterlockedCompareExchange64) 68 # pragma intrinsic(_rotl) 69 # pragma intrinsic(_rotr) 70 # pragma intrinsic(_rotl64) 71 # pragma intrinsic(_rotr64) 68 72 # ifdef RT_ARCH_AMD64 69 73 # pragma intrinsic(__stosq) … … 4811 4815 4812 4816 4817 /** 4818 * Rotate 32-bit unsigned value to the left by @a cShift. 4819 * 4820 * @returns Rotated value. 4821 * @param u32 The value to rotate. 4822 * @param cShift How many bits to rotate by. 4823 */ 4824 DECLINLINE(uint32_t) ASMRotateLeftU32(uint32_t u32, uint32_t cShift) 4825 { 4826 #if RT_INLINE_ASM_USES_INTRIN 4827 return _rotl(u32, cShift); 4828 #elif RT_INLINE_ASM_GNU_STYLE && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) 4829 __asm__ __volatile__("roll %1, %0" : "=r" (u32) : "Ir" (cShift), "0" (u32)); 4830 #else 4831 cShift &= 31; 4832 return (u32 << cShift) | (u32 >> (32 - cShift)); 4833 #endif 4834 } 4835 4836 4837 /** 4838 * Rotate 32-bit unsigned value to the right by @a cShift. 4839 * 4840 * @returns Rotated value. 4841 * @param u32 The value to rotate. 4842 * @param cShift How many bits to rotate by. 4843 */ 4844 DECLINLINE(uint32_t) ASMRotateRightU32(uint32_t u32, uint32_t cShift) 4845 { 4846 #if RT_INLINE_ASM_USES_INTRIN 4847 return _rotr(u32, cShift); 4848 #elif RT_INLINE_ASM_GNU_STYLE && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) 4849 __asm__ __volatile__("rorl %1, %0" : "=r" (u32) : "Ir" (cShift), "0" (u32)); 4850 #else 4851 cShift &= 31; 4852 return (u32 >> cShift) | (u32 << (32 - cShift)); 4853 #endif 4854 } 4855 4856 4857 /** 4858 * Rotate 64-bit unsigned value to the left by @a cShift. 4859 * 4860 * @returns Rotated value. 4861 * @param u64 The value to rotate. 4862 * @param cShift How many bits to rotate by. 4863 */ 4864 DECLINLINE(uint64_t) ASMRotateLeftU64(uint64_t u64, uint32_t cShift) 4865 { 4866 #if RT_INLINE_ASM_USES_INTRIN 4867 return _rotl64(u64, cShift); 4868 #elif RT_INLINE_ASM_GNU_STYLE && defined(RT_ARCH_AMD64) 4869 __asm__ __volatile__("rolq %1, %0" : "=r" (u64) : "Ir" (cShift), "0" (u64)); 4870 #elif RT_INLINE_ASM_GNU_STYLE && defined(RT_ARCH_X86) 4871 uint32_t uSpill; 4872 __asm__ __volatile__("testb $0x20, %%cl\n\t" /* if (cShift >= 0x20) { swap(u64.hi, u64lo); cShift -= 0x20; } */ 4873 "jz 1f\n\t" 4874 "xchgl %%eax, %%edx\n\t" 4875 "1:\n\t" 4876 "andb $0x1f, %%cl\n\t" /* if (cShift & 0x1f) { */ 4877 "jz 2f\n\t" 4878 "movl %%edx, %2\n\t" /* save the hi value in %3. */ 4879 "shldl %%cl,%%eax,%%edx\n\t" /* shift the hi value left, feeding MSBits from the low value. */ 4880 "shldl %%cl,%2,%%eax\n\t" /* shift the lo value left, feeding MSBits from the saved hi value. */ 4881 "2:\n\t" /* } */ 4882 : "=A" (u64), "=c" (cShift), "=r" (uSpill) 4883 : "0" (u64), 4884 "1" (cShift)); 4885 return u64; 4886 #else 4887 cShift &= 63; 4888 return (u64 << cShift) | (u64 >> (64 - cShift)); 4889 #endif 4890 } 4891 4892 4893 /** 4894 * Rotate 64-bit unsigned value to the right by @a cShift. 4895 * 4896 * @returns Rotated value. 4897 * @param u64 The value to rotate. 4898 * @param cShift How many bits to rotate by. 4899 */ 4900 DECLINLINE(uint64_t) ASMRotateRightU64(uint64_t u64, uint32_t cShift) 4901 { 4902 #if RT_INLINE_ASM_USES_INTRIN 4903 return _rotr64(u64, cShift); 4904 #elif RT_INLINE_ASM_GNU_STYLE && defined(RT_ARCH_AMD64) 4905 __asm__ __volatile__("rorq %1, %0" : "=r" (u64) : "Ir" (cShift), "0" (u64)); 4906 #elif RT_INLINE_ASM_GNU_STYLE && defined(RT_ARCH_X86) 4907 uint32_t uSpill; 4908 __asm__ __volatile__("testb $0x20, %%cl\n\t" /* if (cShift >= 0x20) { swap(u64.hi, u64lo); cShift -= 0x20; } */ 4909 "jz 1f\n\t" 4910 "xchgl %%eax, %%edx\n\t" 4911 "1:\n\t" 4912 "andb $0x1f, %%cl\n\t" /* if (cShift & 0x1f) { */ 4913 "jz 2f\n\t" 4914 "movl %%edx, %2\n\t" /* save the hi value in %3. */ 4915 "shrdl %%cl,%%eax,%%edx\n\t" /* shift the hi value right, feeding LSBits from the low value. */ 4916 "shrdl %%cl,%2,%%eax\n\t" /* shift the lo value right, feeding LSBits from the saved hi value. */ 4917 "2:\n\t" /* } */ 4918 : "=A" (u64), "=c" (cShift), "=r" (uSpill) 4919 : "0" (u64), 4920 "1" (cShift)); 4921 return u64; 4922 #else 4923 cShift &= 63; 4924 return (u64 >> cShift) | (u64 << (64 - cShift)); 4925 #endif 4926 } 4927 4813 4928 /** @} */ 4814 4929 -
trunk/include/iprt/sha.h
r48934 r51828 46 46 typedef union RTSHA1CONTEXT 47 47 { 48 uint8_t abPadding[ARCH_BITS == 32 ? 96 : 128]; 48 uint64_t u64BetterAlignment; 49 uint8_t abPadding[8 + (5 + 80) * 4 + 4]; 49 50 #ifdef RT_SHA1_PRIVATE_CONTEXT 50 SHA_CTX Private; 51 SHA_CTX Private; 52 #endif 53 #ifdef RT_SHA1_PRIVATE_ALT_CONTEXT 54 RTSHA1ALTPRIVATECTX AltPrivate; 51 55 #endif 52 56 } RTSHA1CONTEXT; … … 149 153 typedef union RTSHA256CONTEXT 150 154 { 151 uint8_t abPadding[ARCH_BITS == 32 ? 112 : 160]; 155 uint64_t u64BetterAlignment; 156 uint8_t abPadding[ARCH_BITS == 32 ? 112 : 160]; 152 157 #ifdef RT_SHA256_PRIVATE_CONTEXT 153 SHA256_CTX Private;158 SHA256_CTX Private; 154 159 #endif 155 160 } RTSHA256CONTEXT; … … 253 258 typedef union RTSHA512CONTEXT 254 259 { 255 uint8_t abPadding[ARCH_BITS == 32 ? 216 : 256]; 260 uint64_t u64BetterAlignment; 261 uint8_t abPadding[ARCH_BITS == 32 ? 216 : 256]; 256 262 #ifdef RT_SHA512_PRIVATE_CONTEXT 257 SHA512_CTX Private;263 SHA512_CTX Private; 258 264 #endif 259 265 } RTSHA512CONTEXT; -
trunk/src/VBox/HostDrivers/Support/Makefile.kmk
r51825 r51828 269 269 $(VBOX_PATH_RUNTIME_SRC)/common/checksum/md2-alt.cpp \ 270 270 $(VBOX_PATH_RUNTIME_SRC)/common/checksum/md5.cpp \ 271 $(VBOX_PATH_RUNTIME_SRC)/common/checksum/sha1 .cpp \271 $(VBOX_PATH_RUNTIME_SRC)/common/checksum/sha1-alt.cpp \ 272 272 $(VBOX_PATH_RUNTIME_SRC)/common/checksum/sha256.cpp \ 273 273 $(VBOX_PATH_RUNTIME_SRC)/common/checksum/sha512.cpp \ -
trunk/src/VBox/Runtime/Makefile.kmk
r51821 r51828 313 313 common/checksum/RTSha1Digest.cpp \ 314 314 common/checksum/RTSha256Digest.cpp \ 315 common/checksum/sha1 .cpp \315 common/checksum/sha1-alt.cpp \ 316 316 common/checksum/sha1str.cpp \ 317 317 common/checksum/sha256.cpp \ … … 2037 2037 common/crypto/taf-sanity.cpp \ 2038 2038 common/checksum/md2-alt.cpp \ 2039 common/checksum/sha1 .cpp \2039 common/checksum/sha1-alt.cpp \ 2040 2040 common/checksum/sha256.cpp \ 2041 2041 common/checksum/sha512.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.