git: 05d0f788eb55 - main - text/ugrep: Import lzma aarch64 patch from archivers/lzma port

From: Ashish SHUKLA <ashish_at_FreeBSD.org>
Date: Thu, 25 Jan 2024 12:37:33 UTC
The branch main has been updated by ashish:

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

commit 05d0f788eb55620df08b9b82a610f20eca3c1b00
Author:     Ashish SHUKLA <ashish@FreeBSD.org>
AuthorDate: 2024-01-25 12:28:23 +0000
Commit:     Ashish SHUKLA <ashish@FreeBSD.org>
CommitDate: 2024-01-25 12:36:54 +0000

    text/ugrep: Import lzma aarch64 patch from archivers/lzma port
    
    Reported by:    jbeich
---
 textproc/ugrep/Makefile                     |  2 +-
 textproc/ugrep/files/patch-lzma_C_CpuArch.c | 41 ++++++++++++++++++++++++-----
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/textproc/ugrep/Makefile b/textproc/ugrep/Makefile
index 15eaa776c31c..48f8f6112550 100644
--- a/textproc/ugrep/Makefile
+++ b/textproc/ugrep/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	ugrep
 DISTVERSIONPREFIX=	v
 DISTVERSION=	4.5.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	textproc
 
 MAINTAINER=	ashish@FreeBSD.org
diff --git a/textproc/ugrep/files/patch-lzma_C_CpuArch.c b/textproc/ugrep/files/patch-lzma_C_CpuArch.c
index 11cb95f5d0a8..bad85faa10c3 100644
--- a/textproc/ugrep/files/patch-lzma_C_CpuArch.c
+++ b/textproc/ugrep/files/patch-lzma_C_CpuArch.c
@@ -1,15 +1,42 @@
---- lzma/C/CpuArch.c.orig	2024-01-24 11:26:34 UTC
+--- lzma/C/CpuArch.c.orig	2024-01-25 12:25:30 UTC
 +++ lzma/C/CpuArch.c
-@@ -762,10 +762,11 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYP
+@@ -762,6 +762,31 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYP
  
  #include <sys/auxv.h>
  
-+#ifdef __linux__
- #define USE_HWCAP
++#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
--
- #include <asm/hwcap.h>
+@@ -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
  
-   #define MY_HWCAP_CHECK_FUNC_2(name1, name2) \