From ebb69e5e3765c0a65f92d4eb5e4ae8ba56c23f94 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 27 Dec 2018 11:25:30 +0100 Subject: Add CPU feature detection. Will be used for dynamically dispatching future asm functions. --- meson.build | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 2e034b2..5bcfb02 100644 --- a/meson.build +++ b/meson.build @@ -4,6 +4,7 @@ project('libmg2d', 'c', add_project_arguments('-D_XOPEN_SOURCE=700', language : 'c') lib_src = [ + 'cpu.c', 'ell_relax.c', 'log.c', 'mg2d.c', @@ -17,15 +18,28 @@ dep_tp = declare_dependency(link_args : '-lthreadpool') deps = [dep_tp] -# x86 SIMD +cdata = configuration_data() +cdata.set10('ARCH_X86', false) +cdata.set10('ARCH_X86_64', false) +cdata.set10('HAVE_EXTERNAL_ASM', false) + arch = host_machine.cpu_family() -if arch == 'x86_64' - nasm = find_program('nasm', required : false) - if not nasm.found() - warning('nasm not found, no SIMD will be built') +if arch.startswith('x86') + cdata.set10('ARCH_X86', true) + + if arch == 'x86_64' + cdata.set10('ARCH_X86_64', true) + nasm = find_program('nasm', required : get_option('nasm')) + if nasm.found() + cdata.set10('HAVE_EXTERNAL_ASM', true) + else + warning('nasm not found, no SIMD will be built') + endif endif endif +configure_file(output : 'config.h', output_format : 'c', configuration : cdata) + if nasm.found() cdata_asm = configuration_data() cdata_asm.set10('ARCH_X86', true) @@ -57,6 +71,7 @@ if nasm.found() ) nasm_sources = files( + 'cpuid.asm', ) lib_obj += nasm_gen.process(nasm_sources) -- cgit v1.2.3