summaryrefslogtreecommitdiff
path: root/databases/mysql80-server/files/patch-storage_innobase_ut_crc32.cc
blob: 0e42c96a1843ec795f4c26bebeae259dbce2693a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
--- storage/innobase/ut/crc32.cc.orig	2021-12-17 17:07:27 UTC
+++ storage/innobase/ut/crc32.cc
@@ -111,7 +111,9 @@ external tools. */
 #endif /* CRC32_ARM64 */
 
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __FreeBSD__
 #include <asm/hwcap.h>
+#endif
 #include <sys/auxv.h>
 #endif /* CRC32_ARM64_DEFAULT */
 
@@ -360,8 +362,25 @@ bool can_use_poly_mul() { return true; }
 #endif /* CRC32_ARM64_APPLE */
 
 #ifdef CRC32_ARM64_DEFAULT
+#ifdef __FreeBSD__
+bool can_use_crc32() {
+  unsigned long capabilities;
+
+  if (elf_aux_info(AT_HWCAP, &capabilities, sizeof(unsigned long)))
+    return false;
+  return capabilities & HWCAP_CRC32;
+}
+bool can_use_poly_mul() {
+  unsigned long capabilities;
+
+  if (elf_aux_info(AT_HWCAP, &capabilities, sizeof(unsigned long)))
+    return false;
+  return capabilities & HWCAP_CRC32;
+}
+#else
 bool can_use_crc32() { return getauxval(AT_HWCAP) & HWCAP_CRC32; }
 bool can_use_poly_mul() { return getauxval(AT_HWCAP) & HWCAP_PMULL; }
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 
 /** A helper template to statically unroll a loop with a fixed number of
@@ -470,25 +489,39 @@ uint64_t crc32_impl::update(uint64_t crc, uint64_t dat
 
 #ifdef CRC32_ARM64
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __clang__
 MY_ATTRIBUTE((target("+crc")))
+#else
+MY_ATTRIBUTE((target("crc")))
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 uint32_t crc32_impl::update(uint32_t crc, unsigned char data) {
   return __crc32cb(crc, data);
 }
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __clang__
 MY_ATTRIBUTE((target("+crc")))
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 uint32_t crc32_impl::update(uint32_t crc, uint16_t data) {
   return __crc32ch(crc, data);
 }
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __clang__
 MY_ATTRIBUTE((target("+crc")))
+#else
+MY_ATTRIBUTE((target("crc")))
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 uint32_t crc32_impl::update(uint32_t crc, uint32_t data) {
   return __crc32cw(crc, data);
 }
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __clang__
 MY_ATTRIBUTE((target("+crc")))
+#else
+MY_ATTRIBUTE((target("crc")))
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 uint64_t crc32_impl::update(uint64_t crc, uint64_t data) {
   return (uint64_t)__crc32cd((uint32_t)crc, data);
@@ -534,7 +567,11 @@ static inline uint64_t less_significant_half_of_poly12
 }
 template <uint32_t w>
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __clang__
 MY_ATTRIBUTE((target("+crypto")))
+#else
+MY_ATTRIBUTE((target("crypto")))
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 uint64_t use_pclmul::polynomial_mul_rev(uint32_t rev_u) {
   constexpr uint64_t flipped_w = flip_at_32(w);
@@ -777,7 +814,11 @@ MY_ATTRIBUTE((target("sse4.2,pclmul"), flatten))
 MY_ATTRIBUTE((flatten))
 #endif /* CRC32_ARM64_APPLE */
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __clang__
 MY_ATTRIBUTE((target("+crc+crypto"), flatten))
+#else
+MY_ATTRIBUTE((target("crc,crypto")))
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 uint32_t crc32_using_pclmul(const byte *data, size_t len) {
   return crc32<use_pclmul>(0, data, len);
@@ -797,7 +838,11 @@ MY_ATTRIBUTE((target("sse4.2"), flatten))
 MY_ATTRIBUTE((flatten))
 #endif /* CRC32_ARM64_APPLE */
 #ifdef CRC32_ARM64_DEFAULT
+#ifndef __clang__
 MY_ATTRIBUTE((target("+crc"), flatten))
+#else
+MY_ATTRIBUTE((target("crc")))
+#endif
 #endif /* CRC32_ARM64_DEFAULT */
 uint32_t crc32_using_unrolled_loop_poly_mul(const byte *data, size_t len) {
   return crc32<use_unrolled_loop_poly_mul>(0, data, len);