Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion extra/zlib/zlib-1.3.1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ set(ZLIB_SRCS
zutil.c
)

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
check_c_source_compiles("
#if !defined(__x86_64__) && !defined(__amd64__)
# error not an x86_64 target
#endif
int main(void) { return 0; }" ZLIB_TARGET_X86_64)

if(ZLIB_TARGET_X86_64)
LIST(APPEND ZLIB_PRIVATE_HDRS arch_x86.h
crc32_x86.h)

Expand Down
4 changes: 2 additions & 2 deletions extra/zlib/zlib-1.3.1/arch_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#define ZLIB_X86_64_CRC32_PCLMUL 1

/* Check GCC version and only apply vpclmulqdq target attribute when compiler is GCC 8 or later */
#if defined(__GNUC__) && (__GNUC__ >= 8)
/* Apply vpclmulqdq target attribute when compiler is GCC 8 or later, or clang */
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 8))
# define HAVE_VPCLMULQDQ_ATTRIBUTE 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion extra/zlib/zlib-1.3.1/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "zutil.h" /* for Z_U4, Z_U8, z_crc_t, and FAR definitions */

#if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(__amd64__)
#include "arch_x86.h"
#endif

Expand Down
12 changes: 6 additions & 6 deletions unittest/gunit/mysys_my_checksum-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ using namespace mycrc32;

namespace mysys_my_checksum {

#if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(__amd64__)
extern "C" {
int has_crc32_x86_avx(void);
int has_crc32_x86_avx512(void);
unsigned long crc32_z_impl_x86_avx(unsigned long crc,
const unsigned char FAR *buf, z_size_t len);
#if defined(__GNUC__) && (__GNUC__ >= 8)
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 8))
unsigned long crc32_z_impl_x86_avx512(unsigned long crc,
const unsigned char FAR *buf, z_size_t len)
__attribute__((weak));
Expand Down Expand Up @@ -71,7 +71,7 @@ std::uint32_t TableCrc32Reference(std::uint32_t crc_seed,
return crc ^ 0xffffffffU;
}

#if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(__amd64__)
void VerifyAgainstTableAndZlib(
const std::vector<unsigned char> &data, std::size_t offset, std::size_t len,
std::uint32_t seed,
Expand Down Expand Up @@ -166,7 +166,7 @@ TEST(MysysMyChecksum, IntegerCrc32_64bit) {
EXPECT_EQ(IntegerCrc32(crc, value), ~zres);
}

#if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(__amd64__)
TEST(MysysMyChecksum, Crc32ZMatchesAvxImplementationWhenSupported) {
if (!has_crc32_x86_avx()) {
GTEST_SKIP() << "CPU/OS does not support AVX+PCLMUL CRC32";
Expand Down Expand Up @@ -195,7 +195,7 @@ TEST(MysysMyChecksum, Crc32ZDispatchesToAvxImplementationWhenSupported) {
if (!has_crc32_x86_avx()) {
GTEST_SKIP() << "CPU/OS does not support AVX+PCLMUL CRC32";
}
#if defined(__GNUC__) && (__GNUC__ >= 8)
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 8))
if (crc32_z_impl_x86_avx512 != nullptr && has_crc32_x86_avx512()) {
GTEST_SKIP() << "crc32_z uses AVX512 path on this CPU";
}
Expand Down Expand Up @@ -273,7 +273,7 @@ TEST(MysysMyChecksum, SixteenByteBoundaryWithVariousOffsets) {
}
}

#if defined(__GNUC__) && (__GNUC__ >= 8)
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 8))
TEST(MysysMyChecksum, Crc32ZDispatchesToAvx512ImplementationWhenSupported) {
if (crc32_z_impl_x86_avx512 == nullptr) {
GTEST_SKIP() << "AVX512 crc32 implementation is not linked in this build";
Expand Down