summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/aws-c-common/source/arch
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2025-05-12 15:51:24 +0300
committerthegeorg <[email protected]>2025-05-12 16:06:27 +0300
commitd629bb70c8773d2c0c43f5088ddbb5a86d8c37ea (patch)
tree4f678e0d65ad08c800db21c657d3b0f71fafed06 /contrib/restricted/aws/aws-c-common/source/arch
parent92c4b696d7a1c03d54e13aff7a7c20a078d90dd7 (diff)
Update contrib/restricted/aws libraries to nixpkgs 24.05
commit_hash:f8083acb039e6005e820cdee77b84e0a6b6c6d6d
Diffstat (limited to 'contrib/restricted/aws/aws-c-common/source/arch')
-rw-r--r--contrib/restricted/aws/aws-c-common/source/arch/arm/auxv/cpuid.c (renamed from contrib/restricted/aws/aws-c-common/source/arch/arm/asm/cpuid.c)8
-rw-r--r--contrib/restricted/aws/aws-c-common/source/arch/intel/cpuid.c28
-rw-r--r--contrib/restricted/aws/aws-c-common/source/arch/intel/encoding_avx2.c2
3 files changed, 36 insertions, 2 deletions
diff --git a/contrib/restricted/aws/aws-c-common/source/arch/arm/asm/cpuid.c b/contrib/restricted/aws/aws-c-common/source/arch/arm/auxv/cpuid.c
index 6a306df9809..10499da73ea 100644
--- a/contrib/restricted/aws/aws-c-common/source/arch/arm/asm/cpuid.c
+++ b/contrib/restricted/aws/aws-c-common/source/arch/arm/auxv/cpuid.c
@@ -29,7 +29,9 @@ struct cap_bits {
# if (defined(__aarch64__))
struct cap_bits s_check_cap[AWS_CPU_FEATURE_COUNT] = {
- [AWS_CPU_FEATURE_ARM_CRC] = {0, 1 << 7 /* HWCAP_CRC */},
+ [AWS_CPU_FEATURE_ARM_CRC] = {0, 1 << 7 /* HWCAP_CRC32 */},
+ [AWS_CPU_FEATURE_ARM_PMULL] = {0, 1 << 4 /* HWCAP_PMULL */},
+ [AWS_CPU_FEATURE_ARM_CRYPTO] = {0, 1 << 3 /* HWCAP_AES */},
};
# else
struct cap_bits s_check_cap[AWS_CPU_FEATURE_COUNT] = {
@@ -67,6 +69,10 @@ bool aws_cpu_has_feature(enum aws_cpu_feature_name feature_name) {
switch (feature_name) {
case AWS_CPU_FEATURE_ARM_CRC:
+# if (defined(__aarch64__))
+ case AWS_CPU_FEATURE_ARM_PMULL:
+ case AWS_CPU_FEATURE_ARM_CRYPTO:
+# endif // (defined(__aarch64__))
return s_hwcap[s_check_cap[feature_name].cap] & s_check_cap[feature_name].bit;
default:
return false;
diff --git a/contrib/restricted/aws/aws-c-common/source/arch/intel/cpuid.c b/contrib/restricted/aws/aws-c-common/source/arch/intel/cpuid.c
index 98c51b88d18..465fccd17a5 100644
--- a/contrib/restricted/aws/aws-c-common/source/arch/intel/cpuid.c
+++ b/contrib/restricted/aws/aws-c-common/source/arch/intel/cpuid.c
@@ -85,6 +85,20 @@ static bool s_has_avx2(void) {
return true;
}
+static bool s_has_avx512(void) {
+ uint32_t abcd[4];
+
+ /* Check AVX512F:
+ * CPUID.(EAX=07H, ECX=0H):EBX.AVX512[bit 16]==1 */
+ uint32_t avx512_mask = (1 << 16);
+ aws_run_cpuid(7, 0, abcd);
+ if ((abcd[1] & avx512_mask) != avx512_mask) {
+ return false;
+ }
+
+ return true;
+}
+
static bool s_has_bmi2(void) {
uint32_t abcd[4];
@@ -99,12 +113,26 @@ static bool s_has_bmi2(void) {
return true;
}
+static bool s_has_vpclmulqdq(void) {
+ uint32_t abcd[4];
+ /* Check VPCLMULQDQ:
+ * CPUID.(EAX=07H, ECX=0H):ECX.VPCLMULQDQ[bit 10]==1 */
+ uint32_t vpclmulqdq_mask = (1 << 10);
+ aws_run_cpuid(7, 0, abcd);
+ if ((abcd[2] & vpclmulqdq_mask) != vpclmulqdq_mask) {
+ return false;
+ }
+ return true;
+}
+
has_feature_fn *s_check_cpu_feature[AWS_CPU_FEATURE_COUNT] = {
[AWS_CPU_FEATURE_CLMUL] = s_has_clmul,
[AWS_CPU_FEATURE_SSE_4_1] = s_has_sse41,
[AWS_CPU_FEATURE_SSE_4_2] = s_has_sse42,
[AWS_CPU_FEATURE_AVX2] = s_has_avx2,
+ [AWS_CPU_FEATURE_AVX512] = s_has_avx512,
[AWS_CPU_FEATURE_BMI2] = s_has_bmi2,
+ [AWS_CPU_FEATURE_VPCLMULQDQ] = s_has_vpclmulqdq,
};
bool aws_cpu_has_feature(enum aws_cpu_feature_name feature_name) {
diff --git a/contrib/restricted/aws/aws-c-common/source/arch/intel/encoding_avx2.c b/contrib/restricted/aws/aws-c-common/source/arch/intel/encoding_avx2.c
index ebae8613810..439d6ddada9 100644
--- a/contrib/restricted/aws/aws-c-common/source/arch/intel/encoding_avx2.c
+++ b/contrib/restricted/aws/aws-c-common/source/arch/intel/encoding_avx2.c
@@ -179,7 +179,7 @@ static inline bool decode(const unsigned char *in, unsigned char *out) {
* so we'll just copy right out of the vector as a fallback
*/
-#ifdef HAVE_MM256_EXTRACT_EPI64
+#ifdef AWS_HAVE_MM256_EXTRACT_EPI64
uint64_t hi = _mm256_extract_epi64(vec, 2);
const uint64_t *p_hi = &hi;
#else