Skip to content

Commit

Permalink
don't use hardware crc with MS compilers (until we can translate it t…
Browse files Browse the repository at this point in the history
…o MS inline asm syntax)
  • Loading branch information
stevengj committed Aug 19, 2016
1 parent e8258b7 commit d1ec565
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/support/crc32c.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@

#include "crc32c.h"

#if defined(_CPU_X86_64_) && !defined(_COMPILER_MICROSOFT_)
# define HW_CRC
#endif

/* CRC-32C (iSCSI) polynomial in reversed bit order. */
#define POLY 0x82f63b78

Expand Down Expand Up @@ -111,7 +115,7 @@ static uint32_t crc32c_sw(uint32_t crci, const void *buf, size_t len)
return (uint32_t)crc ^ 0xffffffff;
}

#ifdef __x86_64__
#ifdef HW_CRC

/* Multiply a matrix times a vector over the Galois field of two elements,
GF(2). Each element is a bit in an unsigned integer. mat must have at
Expand Down Expand Up @@ -334,14 +338,14 @@ static uint32_t crc32c_hw(uint32_t crc, const void *buf, size_t len)

static int sse42 = 0;

#endif /* ifdef __x86_64__ */
#endif /* ifdef HW_CRC */

/* jl_crc32c_init must be called before jl_crc32c. Passing 1
can be used to force the use of the software implementation,
which is useful for testing purposes. */
JL_DLLEXPORT void jl_crc32c_init(int force_sw)
{
#ifdef __x86_64__
#ifdef HW_CRC
if (force_sw)
sse42 = 0; /* useful for testing purposes */
else
Expand Down

1 comment on commit d1ec565

@tkelman
Copy link
Contributor

@tkelman tkelman commented on d1ec565 Aug 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MS inline asm syntax

No such thing on 64 bit. Would have to be out-of-line in separate files, like we do for _setjmp and _longjmp

edit: intrinsics should work though, as suggested below - that can be a later optimization, no need to worry much about it now

Please sign in to comment.