Skip to content
Snippets Groups Projects
Verified Commit a3be0320 authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Add ifunc demo

parent d1862b9e
No related branches found
No related tags found
No related merge requests found
Pipeline #3154 passed
#include <stdio.h>
#include <stdlib.h>
static void
func (void) __attribute__((ifunc ("resolve_func")));
static void
func_base (void)
{
puts ("Base");
}
static void
func_avx2 (void)
{
puts ("AVX2");
}
// declare resolve_func as static function (void) returning pointer to function (void) returning void
static void
(*resolve_func (void)) (void)
{
__builtin_cpu_init ();
if (__builtin_cpu_supports ("avx2"))
return func_avx2;
else
return func_base;
}
int
main (void)
{
func ();
return 0;
}
......@@ -33,6 +33,10 @@ if has_endian_h
executable('bytedouble', 'bytedouble.c')
endif
if host_machine.cpu_family() == 'x86_64' and cc.has_function_attribute('ifunc')
executable('ifunc', 'ifunc.c')
endif
if openmp_dep.found()
subdir('openmp')
endif
......
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