git: db8997fb59bc - main - archivers/unarr: unbreak build on aarch64 after 29c8a5787507

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Wed, 13 Sep 2023 23:26:21 UTC
The branch main has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=db8997fb59bc3a976c87f6c4b02974928aa43638

commit db8997fb59bc3a976c87f6c4b02974928aa43638
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2023-09-13 23:01:59 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-09-13 23:25:40 +0000

    archivers/unarr: unbreak build on aarch64 after 29c8a5787507
    
    lzmasdk/CpuArch.c:769:10: fatal error: 'asm/hwcap.h' file not found
     #include <asm/hwcap.h>
              ^~~~~~~~~~~~~
    
    Reported by:    pkg-fallout
---
 archivers/unarr/files/patch-lzmasdk_CpuArch.c | 44 +++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/archivers/unarr/files/patch-lzmasdk_CpuArch.c b/archivers/unarr/files/patch-lzmasdk_CpuArch.c
new file mode 100644
index 000000000000..e0c13d3b8d8b
--- /dev/null
+++ b/archivers/unarr/files/patch-lzmasdk_CpuArch.c
@@ -0,0 +1,44 @@
+Copied from archivers/7-zip/files/patch-C_CpuArch.c
+
+--- lzmasdk/CpuArch.c.orig	2023-09-03 15:06:37 UTC
++++ lzmasdk/CpuArch.c
+@@ -762,6 +762,31 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYP
+ 
+ #include <sys/auxv.h>
+ 
++#if defined(__FreeBSD__)
++static unsigned long get_hwcap(int aux) {
++  unsigned long hwcap;
++  if (elf_aux_info(aux, &hwcap, sizeof hwcap) != 0) {
++        return 0;
++  }
++  return hwcap;
++}
++
++#ifdef MY_CPU_ARM64
++BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap(AT_HWCAP) & HWCAP_CRC32; }
++BoolInt CPU_IsSupported_NEON(void) { return 1; }
++BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap(AT_HWCAP) & HWCAP_SHA1; }
++BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap(AT_HWCAP) & HWCAP_SHA2; }
++BoolInt CPU_IsSupported_AES(void) { return get_hwcap(AT_HWCAP) & HWCAP_AES; }
++#else /* MY_CPU_ARM */
++BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_CRC32; }
++BoolInt CPU_IsSupported_NEON(void) { return get_hwcap(AT_HWCAP) & HWCAP_NEON; }
++BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap(AT_HWCAP2) & HWCAP2_SHA1; }
++BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_SHA2; }
++BoolInt CPU_IsSupported_AES(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_AES; }
++#endif
++
++#else // __FreeBSD__
++
+ #define USE_HWCAP
+ 
+ #ifdef USE_HWCAP
+@@ -795,6 +820,7 @@ MY_HWCAP_CHECK_FUNC (AES)
+ MY_HWCAP_CHECK_FUNC (SHA2)
+ MY_HWCAP_CHECK_FUNC (AES)
+ 
++#endif // FreeBSD
+ #endif // __APPLE__
+ #endif // _WIN32
+