Line 0
Link Here
|
|
|
1 |
--- third_party/zlib/cpu_features.c.orig 2020-05-18 20:40:28 UTC |
2 |
+++ third_party/zlib/cpu_features.c |
3 |
@@ -24,11 +24,20 @@ int ZLIB_INTERNAL x86_cpu_enable_simd = 0; |
4 |
|
5 |
#ifndef CPU_NO_SIMD |
6 |
|
7 |
-#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) |
8 |
+#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(ARMV8_OS_FREEBSD) |
9 |
#include <pthread.h> |
10 |
#endif |
11 |
|
12 |
-#if defined(ARMV8_OS_ANDROID) |
13 |
+#if defined(ARMV8_OS_FREEBSD) |
14 |
+#include <machine/armreg.h> |
15 |
+#include <sys/types.h> |
16 |
+#ifndef ID_AA64ISAR0_AES_VAL |
17 |
+#define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES |
18 |
+#endif |
19 |
+#ifndef ID_AA64ISAR0_CRC32_VAL |
20 |
+#define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32 |
21 |
+#endif |
22 |
+#elif defined(ARMV8_OS_ANDROID) |
23 |
#include <cpu-features.h> |
24 |
#elif defined(ARMV8_OS_LINUX) |
25 |
#include <asm/hwcap.h> |
26 |
@@ -49,7 +58,7 @@ int ZLIB_INTERNAL x86_cpu_enable_simd = 0; |
27 |
static void _cpu_check_features(void); |
28 |
#endif |
29 |
|
30 |
-#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) |
31 |
+#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) || defined(ARMV8_OS_FREEBSD) |
32 |
static pthread_once_t cpu_check_inited_once = PTHREAD_ONCE_INIT; |
33 |
void ZLIB_INTERNAL cpu_check_features(void) |
34 |
{ |
35 |
@@ -108,6 +117,13 @@ static void _cpu_check_features(void) |
36 |
#elif defined(ARMV8_OS_WINDOWS) |
37 |
arm_cpu_enable_crc32 = IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE); |
38 |
arm_cpu_enable_pmull = IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE); |
39 |
+#elif defined(ARMV8_OS_FREEBSD) |
40 |
+ uint64_t id_aa64isar0; |
41 |
+ id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1); |
42 |
+ if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL) |
43 |
+ arm_cpu_enable_pmull = 1; |
44 |
+ if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE) |
45 |
+ arm_cpu_enable_crc32 = 1; |
46 |
#endif |
47 |
} |
48 |
#endif |
49 |
@@ -145,4 +161,4 @@ static void _cpu_check_features(void) |
50 |
} |
51 |
#endif |
52 |
#endif |
53 |
-#endif |
54 |
\ No newline at end of file |
55 |
+#endif |