Skip to content
Snippets Groups Projects
Commit 379dee3d authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Fix Bug#1130846 "cpu_feature.m and crc32.c do not compile if a target arch is..."

parent f7e8d056
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@
*/
bool sse42_enabled_cpu();
#if defined (__x86_64__) || defined (__i386__)
/* Hardware-calculate CRC32 for the given data buffer.
*
* @param crc initial CRC
......@@ -50,7 +50,7 @@ bool sse42_enabled_cpu();
* @return CRC32 value
*/
u_int32_t crc32c_hw(u_int32_t crc, const unsigned char *buf, unsigned int len);
#endif
#endif /* TARANTOOL_CPU_FEATURES_H */
......@@ -30,17 +30,17 @@
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <stdbool.h>
#if !defined (__x86_64__) && !defined (__i386__)
#error "Only x86 and x86_64 architectures supported"
#endif
#include "cpu_feature.h"
#if defined (__x86_64__) || defined (__i386__)
#ifdef HAVE_CPUID_H
#include <cpuid.h>
#else
#include <third_party/compat/sys/cpuid.h>
#endif
#include "cpu_feature.h"
#define SCALE_F sizeof(unsigned long)
......@@ -48,8 +48,6 @@
#define REX_PRE "0x48, "
#elif defined (__i386__)
#define REX_PRE
#else
#error "Only x86 and x86_64 architectures supported"
#endif
......@@ -87,13 +85,12 @@ crc32c_hw(u_int32_t crc, const unsigned char *buf, unsigned int len)
if (iremainder) {
crc = crc32c_hw_byte(crc, (unsigned char const*)ptmp,
iremainder);
iremainder);
}
return crc;
}
bool
sse42_enabled_cpu()
{
......@@ -105,4 +102,12 @@ sse42_enabled_cpu()
return (cx & (1 << 20)) != 0;
}
#else /* !(defined (__x86_64__) || defined (__i386__)) */
bool
sse42_enabled_cpu()
{
return false;
}
#endif
......@@ -38,6 +38,9 @@ crc32_func crc32_calc = NULL;
void
crc32_init()
{
#if defined (__x86_64__) || defined (__i386__)
crc32_calc = sse42_enabled_cpu() ? &crc32c_hw : &crc32c;
#else
crc32_calc = &crc32c;
#endif
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment