View | Details | Raw Unified | Return to bug 264942
Collapse All | Expand All

(-)b/x11/babl/files/patch-babl_babl-cpuaccel.c (-1 / +43 lines)
Added Link Here
0
- 
1
--- babl/babl-cpuaccel.c.orig	2022-06-28 12:20:06 UTC
2
+++ babl/babl-cpuaccel.c
3
@@ -556,33 +556,19 @@ arch_accel (void)
4
 #include <fcntl.h>
5
 #include <string.h>
6
 #include <elf.h>
7
+#include <sys/auxv.h>
8
 
9
 #define HAVE_ACCEL 1
10
 
11
 static guint32
12
 arch_accel (void)
13
 {
14
-  /* TODO : add or hardcode the other ways it can be on arm, where
15
-   *        this info comes from the system and not from running cpu
16
-   *        instructions
17
-   */
18
-  int has_neon = 0;
19
-  int fd = open ("/proc/self/auxv", O_RDONLY);
20
-  Elf32_auxv_t auxv;
21
-  if (fd >= 0)
22
-  {
23
-    while (read (fd, &auxv, sizeof (Elf32_auxv_t)) == sizeof (Elf32_auxv_t))
24
-    {
25
-      if (auxv.a_type == AT_HWCAP)
26
-      {
27
-        if (auxv.a_un.a_val & 4096)
28
-          has_neon = 1;
29
-      }
30
-    }
31
-    close (fd);
32
-  }
33
-  return has_neon?BABL_CPU_ACCEL_ARM_NEON:0;
34
-}
35
+	unsigned long hwcap = 0;
36
+
37
+	elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
38
+
39
+	return hwcap & HWCAP_NEON ? BABL_CPU_ACCEL_ARM_NEON : 0;
40
+}	
41
 
42
 #endif /* ARCH_ARM  */
43
 

Return to bug 264942