X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fcpu.h;h=c636cf8639c3c4645e5a6d24894ac8e8f250dfb2;hb=983cc7da8566fcbe2647ed2d3921e7683bd8d325;hp=110815c9f87b8ec780db85ce9dde17295782be65;hpb=61f702bdd09e569bf9b3ef05d2040de5540fb8db;p=vpp.git diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h index 110815c9f87..c636cf8639c 100644 --- a/src/vppinfra/cpu.h +++ b/src/vppinfra/cpu.h @@ -190,6 +190,35 @@ clib_cpu_march_priority_avx2 () #endif #endif /* included_clib_cpu_h */ +#define CLIB_MARCH_FN_CONSTRUCTOR(fn) \ +static void __clib_constructor \ +CLIB_MARCH_SFX(fn ## _march_constructor) (void) \ +{ \ + if (CLIB_MARCH_FN_PRIORITY() > fn ## _selected_priority) \ + { \ + fn ## _selected = & CLIB_MARCH_SFX (fn ## _ma); \ + fn ## _selected_priority = CLIB_MARCH_FN_PRIORITY(); \ + } \ +} \ + +#ifndef CLIB_MARCH_VARIANT +#define CLIB_MARCH_FN(fn, rtype, _args...) \ + static rtype CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (fn ## _ma)(_args); \ + rtype (*fn ## _selected) (_args) = & CLIB_MARCH_SFX (fn ## _ma); \ + int fn ## _selected_priority = 0; \ + static inline rtype CLIB_CPU_OPTIMIZED \ + CLIB_MARCH_SFX (fn ## _ma)(_args) +#else +#define CLIB_MARCH_FN(fn, rtype, _args...) \ + static rtype CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (fn ## _ma)(_args); \ + extern int (*fn ## _selected) (_args); \ + extern int fn ## _selected_priority; \ + CLIB_MARCH_FN_CONSTRUCTOR (fn) \ + static rtype CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (fn ## _ma)(_args) +#endif + +#define CLIB_MARCH_FN_SELECT(fn) (* fn ## _selected) + format_function_t format_cpu_uarch; format_function_t format_cpu_model_name; format_function_t format_cpu_flags;