summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/cpu.h29
1 files changed, 29 insertions, 0 deletions
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;