mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Checks for Intel CRC32 instruction for the assembler.
In OpenBSD 5.4, AS is old 2.15 and it's not supported.
This commit is contained in:
parent
ad5e6d0cc2
commit
308d1fc084
6 changed files with 49 additions and 26 deletions
17
configure.ac
17
configure.ac
|
|
@ -84,6 +84,23 @@ dnl Checks for compiler
|
|||
AC_CHECK_CC_OPT([-Wall], CFLAGS="$CFLAGS -Wall", [])
|
||||
AC_CHECK_CC_OPT([-Wextra], CFLAGS="$CFLAGS -Wextra", [])
|
||||
|
||||
dnl Checks for AS supporting the CRC instruction. In OpenBSD 5.4 it's not.
|
||||
AC_MSG_CHECKING([for crc32b])
|
||||
asmcrc=no
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
unsigned f(unsigned crc, unsigned char b)
|
||||
{
|
||||
asm volatile ("crc32b %1, %0\n" : "+r" (crc) : "rm" (b));
|
||||
return crc;
|
||||
}
|
||||
#else
|
||||
#error not x86
|
||||
#endif
|
||||
]])],
|
||||
[AC_DEFINE([HAVE_CRC32B], [1], [Define if statvfs exists.]) asmcrc=yes])
|
||||
AC_MSG_RESULT([$asmcrc])
|
||||
|
||||
dnl Checks for test environment
|
||||
AS_CASE([$host],
|
||||
[*-*-mingw*], [TESTENV="$WINE"],
|
||||
|
|
|
|||
7
mingw.h
7
mingw.h
|
|
@ -22,6 +22,13 @@
|
|||
|
||||
#include <wchar.h>
|
||||
|
||||
/**
|
||||
* Assume to always have CRC32B if running in x86
|
||||
*/
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#define HAVE_CRC32B 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Redefines PATH_MAX to allow very long paths.
|
||||
*/
|
||||
|
|
|
|||
24
murmur3.c
24
murmur3.c
|
|
@ -88,10 +88,10 @@ void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, voi
|
|||
uint32_t h4 = ((uint32_t*)seed)[3];
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
h1 = swap32(h1);
|
||||
h2 = swap32(h2);
|
||||
h3 = swap32(h3);
|
||||
h4 = swap32(h4);
|
||||
h1 = util_swap32(h1);
|
||||
h2 = util_swap32(h2);
|
||||
h3 = util_swap32(h3);
|
||||
h4 = util_swap32(h4);
|
||||
#endif
|
||||
|
||||
blocks = (const uint32_t*)data;
|
||||
|
|
@ -105,10 +105,10 @@ void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, voi
|
|||
uint32_t k4 = blocks[3];
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
k1 = swap32(k1);
|
||||
k2 = swap32(k2);
|
||||
k3 = swap32(k3);
|
||||
k4 = swap32(k4);
|
||||
k1 = util_swap32(k1);
|
||||
k2 = util_swap32(k2);
|
||||
k3 = util_swap32(k3);
|
||||
k4 = util_swap32(k4);
|
||||
#endif
|
||||
|
||||
k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; h1 ^= k1;
|
||||
|
|
@ -178,10 +178,10 @@ void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, voi
|
|||
h2 += h1; h3 += h1; h4 += h1;
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
h1 = swap32(h1);
|
||||
h2 = swap32(h2);
|
||||
h3 = swap32(h3);
|
||||
h4 = swap32(h4);
|
||||
h1 = util_swap32(h1);
|
||||
h2 = util_swap32(h2);
|
||||
h3 = util_swap32(h3);
|
||||
h4 = util_swap32(h4);
|
||||
#endif
|
||||
|
||||
((uint32_t*)out)[0] = h1;
|
||||
|
|
|
|||
2
speed.c
2
speed.c
|
|
@ -178,7 +178,7 @@ void speed(void)
|
|||
printf("%8s", "intel");
|
||||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#if HAVE_CRC32B
|
||||
if (cpu_has_sse42()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<diskmax;++j) {
|
||||
|
|
|
|||
12
spooky2.c
12
spooky2.c
|
|
@ -127,8 +127,8 @@ void SpookyHash128(const void* message, size_t length, const uint8_t* seed, uint
|
|||
h10 = ((uint64_t*)seed)[1];
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
h9 = swap64(h9);
|
||||
h10 = swap64(h10);
|
||||
h9 = util_swap64(h9);
|
||||
h10 = util_swap64(h10);
|
||||
#endif
|
||||
|
||||
h0 = h3 = h6 = h9;
|
||||
|
|
@ -143,7 +143,7 @@ void SpookyHash128(const void* message, size_t length, const uint8_t* seed, uint
|
|||
while (u.p64 < end) {
|
||||
#if WORDS_BIGENDIAN
|
||||
for(i=0;i<sc_numVars;++i)
|
||||
buf[i] = swap64(u.p64[i]);
|
||||
buf[i] = util_swap64(u.p64[i]);
|
||||
Mix(buf,h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||
#else
|
||||
Mix(u.p64,h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||
|
|
@ -161,14 +161,14 @@ void SpookyHash128(const void* message, size_t length, const uint8_t* seed, uint
|
|||
/* finalization */
|
||||
#if WORDS_BIGENDIAN
|
||||
for(i=0;i<sc_numVars;++i)
|
||||
buf[i] = swap64(buf[i]);
|
||||
buf[i] = util_swap64(buf[i]);
|
||||
#endif
|
||||
|
||||
End(buf,h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
h0 = swap64(h0);
|
||||
h1 = swap64(h1);
|
||||
h0 = util_swap64(h0);
|
||||
h1 = util_swap64(h1);
|
||||
#endif
|
||||
|
||||
((uint64_t*)digest)[0] = h0;
|
||||
|
|
|
|||
13
util.c
13
util.c
|
|
@ -1089,7 +1089,7 @@ uint32_t crc32c_gen(uint32_t crc, const unsigned char* ptr, unsigned size)
|
|||
return crc;
|
||||
}
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#if HAVE_CRC32B
|
||||
|
||||
uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size)
|
||||
{
|
||||
|
|
@ -1125,7 +1125,6 @@ uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size)
|
|||
|
||||
return crc;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
uint32_t (*crc32c)(uint32_t crc, const unsigned char* ptr, unsigned size);
|
||||
|
|
@ -1133,7 +1132,7 @@ uint32_t (*crc32c)(uint32_t crc, const unsigned char* ptr, unsigned size);
|
|||
void crc32c_init(void)
|
||||
{
|
||||
crc32c = crc32c_gen;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#if HAVE_CRC32B
|
||||
if (cpu_has_sse42()) {
|
||||
crc32c = crc32c_x86;
|
||||
}
|
||||
|
|
@ -1496,17 +1495,17 @@ inline uint64_t rotl64(uint64_t x, int8_t r)
|
|||
|
||||
#include <byteswap.h>
|
||||
|
||||
#define swap32(x) bswap_32(x)
|
||||
#define swap64(x) bswap_64(x)
|
||||
#define util_swap32(x) bswap_32(x)
|
||||
#define util_swap64(x) bswap_64(x)
|
||||
|
||||
#else
|
||||
static inline uint32_t swap32(uint32_t v)
|
||||
static inline uint32_t util_swap32(uint32_t v)
|
||||
{
|
||||
return (rotl32(v, 8) & 0x00ff00ff)
|
||||
| (rotl32(v, 24) & 0xff00ff00);
|
||||
}
|
||||
|
||||
static inline uint64_t swap64(uint64_t v)
|
||||
static inline uint64_t util_swap64(uint64_t v)
|
||||
{
|
||||
return (rotl64(v, 8) & 0x000000ff000000ffLLU)
|
||||
| (rotl64(v, 24) & 0x0000ff000000ff00LLU)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue