Skip to content
Snippets Groups Projects
Commit 7b61d4ec authored by Janne Grunau's avatar Janne Grunau Committed by Jean-Baptiste Kempf
Browse files

arm: add cpu flag detection

For Linux (and Android) use getauxval(). For ios and windows on arm
assume NEON is available.
parent 2689dfb5
No related branches found
No related tags found
1 merge request!275fix arm build with asm disabled and add cpu flag detection for linux, android and ios
......@@ -132,6 +132,12 @@ elif cc.has_function('_aligned_malloc', prefix : '#include <malloc.h>', args : t
cdata.set('HAVE_ALIGNED_MALLOC', 1)
endif
if (host_machine.cpu_family() == 'aarch64' or
host_machine.cpu_family().startswith('arm'))
if cc.has_function('getauxval', prefix : '#include <sys/auxv.h>', args : test_args)
cdata.set('HAVE_GETAUXVAL', 1)
endif
endif
# Compiler flag tests
......
......@@ -25,8 +25,30 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "src/arm/cpu.h"
#if HAVE_GETAUXVAL
#include <sys/auxv.h>
#if ARCH_AARCH64
#define NEON_HWCAP HWCAP_ASIMD
#elif ARCH_ARM
#define NEON_HWCAP HWCAP_ARM_NEON
#endif
#endif
unsigned dav1d_get_cpu_flags_arm(void) {
return DAV1D_ARM_CPU_FLAG_NEON;
unsigned flags = 0;
#if HAVE_GETAUXVAL
unsigned long hw_cap = getauxval(AT_HWCAP);
flags |= (hw_cap & NEON_HWCAP) ? DAV1D_ARM_CPU_FLAG_NEON : 0;
#elif __APPLE__
flags |= DAV1D_ARM_CPU_FLAG_NEON;
#elif defined(_WIN32)
flags |= DAV1D_ARM_CPU_FLAG_NEON;
#endif
return flags;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment