Doxygen Book
hw_accel.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-only */
16 #include <hw_accel.h>
17 #include <errno.h>
18 
19 #if defined(__aarch64__) || defined(__arm__)
20 #if defined(__TIZEN__) || defined(__ANDROID__) || defined(__linux__)
21 #include <asm/hwcap.h>
22 #endif /* __TIZEN__ || __ANDROID__ || __linux__ */
23 #endif /* __arch64__ || __arm__ */
24 
25 #if !defined(__APPLE__)
26 #include <sys/auxv.h>
27 #else
28 #define HWCAP_ASIMD 0x1
29 #if defined(__aarch64__)
30 #define getauxval(x) (HWCAP_ASIMD)
31 #else
32 #define getauxval(x) (0x0)
33 #endif /* __aarch64__ */
34 #endif /* __APPLE__ */
35 
40 gint
42 {
43  gint neon_available = 0;
44 
45 #if defined(__aarch64__) || defined(__arm__)
46  gulong hwcap_flag;
47 
48 #if defined(__aarch64__)
49  hwcap_flag = HWCAP_ASIMD;
50 #elif defined(__arm__)
51  hwcap_flag = HWCAP_NEON;
52 #endif /* __arch64 __ */
53 
54  if (getauxval (AT_HWCAP) & hwcap_flag) {
55  neon_available = 0;
56  } else {
57  neon_available = -EINVAL;
58  }
59 #endif /* __arch64__ || __arm__ */
60 
61  return neon_available;
62 }
cpu_neon_accel_available
gint cpu_neon_accel_available(void)
Check if neon is supported.
Definition: hw_accel.c:41
hw_accel.h
Common hardware acceleration availability header.