git: 8eb8cfb22a93 - 2023Q4 - multimedia/ringrtc: fix build on armv7

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Fri, 27 Oct 2023 06:35:37 UTC
The branch 2023Q4 has been updated by fuz:

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

commit 8eb8cfb22a934a283d6ff5a99710c1b2b175adbe
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-10-25 17:03:09 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-10-27 06:35:10 +0000

    multimedia/ringrtc: fix build on armv7
    
    Add missing CPU feature detection logic to bundled opus.
    
    Approved by:    portmgr (build fix blanket)
    MFH:            2023Q4
    
    (cherry picked from commit 9ce9fc372c730db46ec32d48d63d08a5005ac2ac)
---
 ...c_webrtc_src_ringrtc_opus_src_celt_arm_armcpu.c | 40 ++++++++++++++++++++++
 ...rtc_src_third__party_opus_src_celt_arm_armcpu.c | 40 ++++++++++++++++++++++
 2 files changed, 80 insertions(+)

diff --git a/multimedia/ringrtc/files/patch-src_webrtc_src_ringrtc_opus_src_celt_arm_armcpu.c b/multimedia/ringrtc/files/patch-src_webrtc_src_ringrtc_opus_src_celt_arm_armcpu.c
new file mode 100644
index 000000000000..07d04b8750f2
--- /dev/null
+++ b/multimedia/ringrtc/files/patch-src_webrtc_src_ringrtc_opus_src_celt_arm_armcpu.c
@@ -0,0 +1,40 @@
+--- ../../src/webrtc/src/ringrtc/opus/src/celt/arm/armcpu.c.orig	2023-10-25 18:24:55 UTC
++++ ../../src/webrtc/src/ringrtc/opus/src/celt/arm/armcpu.c
+@@ -148,6 +148,37 @@
+   }
+   return flags;
+ }
++#elif defined(__FreeBSD__)
++#include <sys/auxv.h>
++
++opus_uint32 opus_cpu_capabilities(void)
++{
++	long hwcap = 0;
++	opus_uint32 flags = 0;
++
++	elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
++
++# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \
++ || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
++	if (hwcap & HWCAP_EDSP)
++		flags |= OPUS_CPU_ARM_EDSP_FLAG;
++
++#  if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
++	if (hwcap & HWCAP_NEON)
++		flags |= OPUS_CPU_ARM_NEON_FLAG;
++#  endif
++# endif
++
++# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \
++ || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
++
++#  if __ARM_ARCH >= 6
++	flags |= OPUS_CPU_ARM_MEDIA_FLAG;
++#  endif
++# endif
++
++	return (flags);
++}
+ #else
+ /* The feature registers which can tell us what the processor supports are
+  * accessible in priveleged modes only, so we can't have a general user-space
diff --git a/multimedia/ringrtc/files/patch-src_webrtc_src_third__party_opus_src_celt_arm_armcpu.c b/multimedia/ringrtc/files/patch-src_webrtc_src_third__party_opus_src_celt_arm_armcpu.c
new file mode 100644
index 000000000000..e5d59c3fc889
--- /dev/null
+++ b/multimedia/ringrtc/files/patch-src_webrtc_src_third__party_opus_src_celt_arm_armcpu.c
@@ -0,0 +1,40 @@
+--- ../../src/webrtc/src/third_party/opus/src/celt/arm/armcpu.c.orig	2023-10-25 18:00:46 UTC
++++ ../../src/webrtc/src/third_party/opus/src/celt/arm/armcpu.c
+@@ -148,6 +148,37 @@
+   }
+   return flags;
+ }
++#elif defined(__FreeBSD__)
++#include <sys/auxv.h>
++
++opus_uint32 opus_cpu_capabilities(void)
++{
++	long hwcap = 0;
++	opus_uint32 flags = 0;
++
++	elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
++
++# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \
++ || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
++	if (hwcap & HWCAP_EDSP)
++		flags |= OPUS_CPU_ARM_EDSP_FLAG;
++
++#  if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
++	if (hwcap & HWCAP_NEON)
++		flags |= OPUS_CPU_ARM_NEON_FLAG;
++#  endif
++# endif
++
++# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \
++ || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
++
++#  if __ARM_ARCH >= 6
++	flags |= OPUS_CPU_ARM_MEDIA_FLAG;
++#  endif
++# endif
++
++	return (flags);
++}
+ #else
+ /* The feature registers which can tell us what the processor supports are
+  * accessible in priveleged modes only, so we can't have a general user-space