net/mlx5: fix ARM build
[dpdk.git] / lib / librte_eal / common / eal_common_cpuflags.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #include <stdio.h>
6
7 #include <rte_common.h>
8 #include <rte_cpuflags.h>
9
10 /**
11  * Checks if the machine is adequate for running the binary. If it is not, the
12  * program exits with status 1.
13  */
14 void
15 rte_cpu_check_supported(void)
16 {
17         if (!rte_cpu_is_supported())
18                 exit(1);
19 }
20
21 int
22 rte_cpu_is_supported(void)
23 {
24         /* This is generated at compile-time by the build system */
25         static const enum rte_cpu_flag_t compile_time_flags[] = {
26                         RTE_COMPILE_TIME_CPUFLAGS
27         };
28         unsigned count = RTE_DIM(compile_time_flags), i;
29         int ret;
30
31         for (i = 0; i < count; i++) {
32                 ret = rte_cpu_get_flag_enabled(compile_time_flags[i]);
33
34                 if (ret < 0) {
35                         fprintf(stderr,
36                                 "ERROR: CPU feature flag lookup failed with error %d\n",
37                                 ret);
38                         return 0;
39                 }
40                 if (!ret) {
41                         fprintf(stderr,
42                                 "ERROR: This system does not support \"%s\".\n"
43                                 "Please check that RTE_MACHINE is set correctly.\n",
44                                 rte_cpu_get_flag_name(compile_time_flags[i]));
45                         return 0;
46                 }
47         }
48
49         return 1;
50 }