Skip to content

Commit

Permalink
Mac M1 build support proposal (minus rocksdb option) (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Jan 30, 2021
1 parent 52795c2 commit b124158
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/my_global.h
Expand Up @@ -152,7 +152,7 @@
# if defined(__i386__) || defined(__ppc__)
# define SIZEOF_CHARP 4
# define SIZEOF_LONG 4
# elif defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__)
# elif defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) || defined(__arm64__)
# define SIZEOF_CHARP 8
# define SIZEOF_LONG 8
# else
Expand Down
24 changes: 24 additions & 0 deletions mysys/crc32/crc32_arm64.c
Expand Up @@ -4,6 +4,29 @@

#if defined(HAVE_ARMV8_CRC)

#if defined(__APPLE__)
#include <sys/sysctl.h>

static int pmull_supported;

int crc32_aarch64_available(void)
{
int ret;
size_t len = sizeof(ret);
if (sysctlbyname("hw.optional.armv8_crc32", &ret, &len, NULL, 0) == -1)
return 0;
return ret;
}

const char *crc32c_aarch64_available(void)
{
if (crc32_aarch64_available() == 0)
return NULL;
pmull_supported = 1;
return "Using ARMv8 crc32 + pmull instructions";
}

#else
#include <sys/auxv.h>
#if defined(__FreeBSD__)
static unsigned long getauxval(unsigned int key)
Expand Down Expand Up @@ -50,6 +73,7 @@ const char *crc32c_aarch64_available(void)
return "Using ARMv8 crc32 instructions";
}

#endif /* __APPLE__ */
#endif /* HAVE_ARMV8_CRC */

#ifndef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS
Expand Down

0 comments on commit b124158

Please sign in to comment.