mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
crc32 compatibility on Windows on ARM64
This commit is contained in:
committed by
Vladislav Vaintroub
parent
6c6941c9ba
commit
9e1c1d429f
@@ -4,29 +4,36 @@
|
||||
#include <stddef.h>
|
||||
|
||||
typedef unsigned (*my_crc32_t)(unsigned, const void *, size_t);
|
||||
unsigned crc32_aarch64(unsigned, const void *, size_t);
|
||||
|
||||
#ifdef HAVE_ARMV8_CRC
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
int crc32_aarch64_available(void)
|
||||
{
|
||||
return IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
|
||||
}
|
||||
|
||||
const char *crc32c_aarch64_available(void)
|
||||
{
|
||||
if (crc32_aarch64_available() == 0)
|
||||
return NULL;
|
||||
/* TODO : pmull seems supported, but does not compile*/
|
||||
return "Using ARMv8 crc32 instructions";
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
# ifdef HAVE_ARMV8_CRYPTO
|
||||
static unsigned crc32c_aarch64_pmull(unsigned, const void *, size_t);
|
||||
# endif
|
||||
|
||||
# ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# ifdef __clang__
|
||||
# include <arm_acle.h>
|
||||
# include <arm_neon.h>
|
||||
# endif
|
||||
int crc32_aarch64_available(void)
|
||||
{
|
||||
return IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
|
||||
}
|
||||
|
||||
unsigned crc32c_aarch64(unsigned, const void *, size_t);
|
||||
|
||||
my_crc32_t crc32c_aarch64_available(void)
|
||||
{
|
||||
if (crc32_aarch64_available() == 0)
|
||||
return NULL;
|
||||
/* TODO : pmull seems supported, but does not compile*/
|
||||
return crc32c_aarch64;
|
||||
}
|
||||
|
||||
# else /* _WIN32 */
|
||||
# ifdef __APPLE__
|
||||
# include <sys/sysctl.h>
|
||||
|
||||
@@ -96,6 +103,7 @@ my_crc32_t crc32c_aarch64_available(void)
|
||||
return crc32c_aarch64;
|
||||
}
|
||||
# endif /* __APPLE__ */
|
||||
# endif /* _WIN32 */
|
||||
|
||||
const char *crc32c_aarch64_impl(my_crc32_t c)
|
||||
{
|
||||
@@ -370,7 +378,7 @@ static unsigned crc32c_aarch64_pmull(unsigned crc, const void *buf, size_t len)
|
||||
/* There are multiple approaches to calculate crc.
|
||||
Approach-1: Process 8 bytes then 4 bytes then 2 bytes and then 1 bytes
|
||||
Approach-2: Process 8 bytes and remaining workload using 1 bytes
|
||||
Apporach-3: Process 64 bytes at once by issuing 8 crc call and remaining
|
||||
Approach-3: Process 64 bytes at once by issuing 8 crc call and remaining
|
||||
using 8/1 combination.
|
||||
|
||||
Based on micro-benchmark testing we found that Approach-2 works best especially
|
||||
|
Reference in New Issue
Block a user