git: 057805f28af5 - main - graphics/gegl: fix build on armv7

From: Dima Panov <fluffy_at_FreeBSD.org>
Date: Sun, 10 Jul 2022 19:16:28 UTC
The branch main has been updated by fluffy:

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

commit 057805f28af5664ae6286db371a5220de354cc9d
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2022-07-10 19:15:24 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2022-07-10 19:15:24 +0000

    graphics/gegl: fix build on armv7
    
    PR:     265092
    MFH:    2022Q3
---
 graphics/gegl/files/patch-gegl_gegl-cpuaccel.c | 41 ++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/graphics/gegl/files/patch-gegl_gegl-cpuaccel.c b/graphics/gegl/files/patch-gegl_gegl-cpuaccel.c
new file mode 100644
index 000000000000..9566e2bfd1a1
--- /dev/null
+++ b/graphics/gegl/files/patch-gegl_gegl-cpuaccel.c
@@ -0,0 +1,41 @@
+--- gegl/gegl-cpuaccel.c.orig	2022-07-07 02:35:48 UTC
++++ gegl/gegl-cpuaccel.c
+@@ -552,32 +552,18 @@ arch_accel (void)
+ #include <fcntl.h>
+ #include <string.h>
+ #include <elf.h>
++#include <sys/auxv.h>
+ 
+ #define HAVE_ACCEL 1
+ 
+ static guint32
+ arch_accel (void)
+ {
+-  /* TODO : add or hardcode the other ways it can be on arm, where
+-   *        this info comes from the system and not from running cpu
+-   *        instructions
+-   */
+-  int has_neon = 0;
+-  int fd = open ("/proc/self/auxv", O_RDONLY);
+-  Elf32_auxv_t auxv;
+-  if (fd >= 0)
+-  {
+-    while (read (fd, &auxv, sizeof (Elf32_auxv_t)) == sizeof (Elf32_auxv_t))
+-    {
+-      if (auxv.a_type == AT_HWCAP)
+-      {
+-        if (auxv.a_un.a_val & 4096)
+-          has_neon = 1;
+-      }
+-    }
+-    close (fd);
+-  }
+-  return has_neon?GEGL_CPU_ACCEL_ARM_NEON:0;
++	unsigned long hwcap = 0;
++
++	elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
++
++	return hwcap & HWCAP_NEON ? GEGL_CPU_ACCEL_ARM_NEON : 0;
+ }
+ 
+ #endif /* ARCH_ARM  */