numam-dpdk/lib/librte_eal/common/eal_common_cpuflags.c
Thomas Monjalon a5c9b9278c eal: fix build on FreeBSD
The auxiliary vector read is implemented only for Linux.
It could be done with procstat_getauxv() for FreeBSD.

Since the commit below, the auxiliary vector functions
are compiled for every architectures, including x86
which is tested with FreeBSD.

This patch is moving the Linux implementation in Linux directory,
and adding a fake/empty implementation for FreeBSD.

Fixes: 2ed9bf330709 ("eal: abstract away the auxiliary vector")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2018-04-27 11:13:59 +02:00

51 lines
1.0 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2014 Intel Corporation
*/
#include <stdio.h>
#include <rte_common.h>
#include <rte_cpuflags.h>
/**
* Checks if the machine is adequate for running the binary. If it is not, the
* program exits with status 1.
*/
void
rte_cpu_check_supported(void)
{
if (!rte_cpu_is_supported())
exit(1);
}
int
rte_cpu_is_supported(void)
{
/* This is generated at compile-time by the build system */
static const enum rte_cpu_flag_t compile_time_flags[] = {
RTE_COMPILE_TIME_CPUFLAGS
};
unsigned count = RTE_DIM(compile_time_flags), i;
int ret;
for (i = 0; i < count; i++) {
ret = rte_cpu_get_flag_enabled(compile_time_flags[i]);
if (ret < 0) {
fprintf(stderr,
"ERROR: CPU feature flag lookup failed with error %d\n",
ret);
return 0;
}
if (!ret) {
fprintf(stderr,
"ERROR: This system does not support \"%s\".\n"
"Please check that RTE_MACHINE is set correctly.\n",
rte_cpu_get_flag_name(compile_time_flags[i]));
return 0;
}
}
return 1;
}