[checksum] switch to 7-zip's SHA-256 algorithm

* That's more like it! When compiled in 64-bit we get about the same speed as 7-zip
  (slower when 32-bit, but shhh, or people will ask for a 64-bit version of Rufus...)
* Looks like what was holding us back was the sha256_write() from Brad Conte's
* Also fix WDK compilation and harmonize the BE->LE conversions
This commit is contained in:
Pete Batard 2016-03-02 18:51:43 +00:00
parent 07114edc6f
commit 00ffbae61f
4 changed files with 106 additions and 78 deletions

View file

@ -52,21 +52,29 @@
#define PREFETCH64(m) do { _m_prefetch(m); _m_prefetch(m+32); } while(0)
#endif
#if defined(_MSC_VER)
#if defined (_MSC_VER) && (_MSC_VER >= 1300)
#include <stdlib.h>
#pragma intrinsic(_byteswap_ushort)
#pragma intrinsic(_byteswap_ulong)
#pragma intrinsic(_byteswap_uint64)
#define bswap_uint64 _byteswap_uint64
#define bswap_uint32 _byteswap_ulong
#define bswap_uint16 _byteswap_ushort
#else
#define get_be32(p) bswap_uint32(*(const uint32_t *)(const uint8_t *)(p))
#define get_be64(p) bswap_uint64(*(const uint64_t *)(const uint8_t *)(p))
#elif defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
#define bswap_uint64 __builtin_bswap64
#define bswap_uint32 __builtin_bswap32
#define bswap_uint16 __builtin_bswap16
#define get_be32(p) bswap_uint32(*(const uint32_t *)(const uint8_t *)(p))
#define get_be64(p) bswap_uint64(*(const uint32_t *)(const uint8_t *)(p))
#endif
/*
* Nibbled from https://github.com/hanji/popcnt/blob/master/populationcount.cpp
* Since MSVC x86_32 does not have intrinsic popcount64 and I don't have all day
*/
static inline int popcnt64(register uint64_t u)
static __inline int popcnt64(register uint64_t u)
{
u = (u & 0x5555555555555555) + ((u >> 1) & 0x5555555555555555);
u = (u & 0x3333333333333333) + ((u >> 2) & 0x3333333333333333);