mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-04-05 18:27:02 +00:00
Update cpu_features to Dec24
This commit is contained in:
parent
58c2178f98
commit
c29b85a82a
@ -3,12 +3,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
# option() honors normal variables.
|
||||
# see: https://cmake.org/cmake/help/git-stage/policy/CMP0077.html
|
||||
if(POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
|
||||
project(CpuFeatures VERSION 0.9.0 LANGUAGES C)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
@ -151,7 +145,7 @@ if(UNIX)
|
||||
add_library(unix_based_hardware_detection OBJECT
|
||||
${PROJECT_SOURCE_DIR}/include/internal/hwcaps.h
|
||||
${PROJECT_SOURCE_DIR}/src/hwcaps_linux_or_android.c
|
||||
${PROJECT_SOURCE_DIR}/src/hwcaps_freebsd.c
|
||||
${PROJECT_SOURCE_DIR}/src/hwcaps_freebsd_or_openbsd.c
|
||||
${PROJECT_SOURCE_DIR}/src/hwcaps.c
|
||||
)
|
||||
setup_include_and_definitions(unix_based_hardware_detection)
|
||||
|
@ -4,7 +4,6 @@
|
||||
#ifndef CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_
|
||||
#define CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Architectures
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -85,6 +84,10 @@
|
||||
#define CPU_FEATURES_OS_FREEBSD
|
||||
#endif
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#define CPU_FEATURES_OS_OPENBSD
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#define CPU_FEATURES_OS_ANDROID
|
||||
#endif
|
||||
@ -226,14 +229,15 @@
|
||||
|
||||
#endif // defined(CPU_FEATURES_ARCH_X86)
|
||||
|
||||
#if defined(CPU_FEATURES_ARCH_ANY_ARM)
|
||||
// Note: MSVC targeting ARM does not define `__ARM_NEON` but Windows on ARM
|
||||
// requires it. In that case we force NEON detection.
|
||||
#if defined(__ARM_NEON) || \
|
||||
(defined(CPU_FEATURES_COMPILER_MSC) && defined(CPU_FEATURES_ARCH_ANY_ARM))
|
||||
#if defined(__ARM_NEON) || defined(CPU_FEATURES_COMPILER_MSC)
|
||||
#define CPU_FEATURES_COMPILED_ANY_ARM_NEON 1
|
||||
#else
|
||||
#define CPU_FEATURES_COMPILED_ANY_ARM_NEON 0
|
||||
#endif
|
||||
#endif // defined(__ARM_NEON) || defined(CPU_FEATURES_COMPILER_MSC)
|
||||
#endif // defined(CPU_FEATURES_ARCH_ANY_ARM)
|
||||
|
||||
#if defined(CPU_FEATURES_ARCH_MIPS)
|
||||
#if defined(__mips_msa)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
#ifdef CPU_FEATURES_OS_FREEBSD
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD)
|
||||
|
||||
#include "internal/hwcaps.h"
|
||||
|
||||
@ -38,8 +38,8 @@ const char *CpuFeatures_GetPlatformPointer(void) { return NULL; }
|
||||
const char *CpuFeatures_GetBasePlatformPointer(void) { return NULL; }
|
||||
|
||||
#else
|
||||
#error "FreeBSD needs support for elf_aux_info"
|
||||
#error "FreeBSD / OpenBSD needs support for elf_aux_info"
|
||||
#endif // HAVE_STRONG_ELF_AUX_INFO
|
||||
|
||||
#endif // CPU_FEATURES_TEST
|
||||
#endif // CPU_FEATURES_OS_FREEBSD
|
||||
#endif // CPU_FEATURES_OS_FREEBSD || CPU_FEATURES_OS_OPENBSD
|
@ -4,8 +4,8 @@
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
#ifdef CPU_FEATURES_ARCH_AARCH64
|
||||
#if (defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX) || \
|
||||
defined(CPU_FEATURES_OS_ANDROID))
|
||||
#if (defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD) || \
|
||||
defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID))
|
||||
#if (defined(CPU_FEATURES_COMPILER_GCC) || defined(CPU_FEATURES_COMPILER_CLANG))
|
||||
|
||||
#include "internal/cpuid_aarch64.h"
|
||||
@ -16,9 +16,7 @@
|
||||
uint64_t GetMidrEl1(void)
|
||||
{
|
||||
uint64_t midr_el1;
|
||||
// clang-format off
|
||||
__asm("mrs %0, MIDR_EL1" : "=r"(midr_el1));
|
||||
// clang-format on
|
||||
return midr_el1;
|
||||
}
|
||||
#endif // CPU_FEATURES_MOCK_CPUID_AARCH64
|
||||
@ -27,6 +25,6 @@ uint64_t GetMidrEl1(void)
|
||||
#error "Unsupported compiler, aarch64 cpuid requires either GCC or Clang."
|
||||
#endif // (defined(CPU_FEATURES_COMPILER_GCC) ||
|
||||
// defined(CPU_FEATURES_COMPILER_CLANG))
|
||||
#endif // (defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
// || defined(CPU_FEATURES_OS_ANDROID))
|
||||
#endif // (defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD)
|
||||
// || defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID))
|
||||
#endif // CPU_FEATURES_ARCH_AARCH64
|
@ -4,7 +4,7 @@
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
#ifdef CPU_FEATURES_ARCH_AARCH64
|
||||
#ifdef CPU_FEATURES_OS_FREEBSD
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD)
|
||||
|
||||
#include "cpuinfo_aarch64.h"
|
||||
#include "internal/cpuid_aarch64.h"
|
||||
@ -35,5 +35,5 @@ Aarch64Info GetAarch64Info(void)
|
||||
return info;
|
||||
}
|
||||
|
||||
#endif // CPU_FEATURES_OS_FREEBSD
|
||||
#endif // CPU_FEATURES_ARCH_AARCH64
|
||||
#endif // CPU_FEATURES_OS_FREEBSD || CPU_FEATURES_OS_OPENBSD
|
||||
#endif // CPU_FEATURES_ARCH_AARCH64
|
@ -148,7 +148,11 @@ static Node* CreatePrintfString(const char* format, ...)
|
||||
const int written = vsnprintf(ptr, gBumpAllocator.size, format, arglist);
|
||||
va_end(arglist);
|
||||
if (written < 0 || written >= (int)gBumpAllocator.size) internal_error();
|
||||
return CreateConstantString((char*)BA_Bump(written));
|
||||
// `vsnprintf` does not set `\0` when no characters are to be written.
|
||||
if (written == 0) *ptr = '\0';
|
||||
// `vsnprintf` returns the number of printed characters excluding `\0`.
|
||||
const int null_terminated_written = written + 1;
|
||||
return CreateConstantString((char*)BA_Bump(null_terminated_written));
|
||||
}
|
||||
|
||||
// Adds a string node.
|
||||
|
@ -28,7 +28,7 @@ target_link_libraries(stack_line_reader_for_test string_view filesystem_for_test
|
||||
add_library(all_libraries
|
||||
../src/hwcaps.c
|
||||
../src/hwcaps_linux_or_android.c
|
||||
../src/hwcaps_freebsd.c
|
||||
../src/hwcaps_freebsd_or_openbsd.c
|
||||
../src/stack_line_reader.c)
|
||||
target_link_libraries(all_libraries hwcaps_for_testing stack_line_reader string_view)
|
||||
|
||||
@ -84,7 +84,7 @@ if(PROCESSOR_IS_AARCH64)
|
||||
../src/impl_aarch64_linux_or_android.c
|
||||
../src/impl_aarch64_windows.c
|
||||
../src/impl_aarch64_macos_or_iphone.c
|
||||
../src/impl_aarch64_freebsd.c
|
||||
../src/impl_aarch64_freebsd_or_openbsd.c
|
||||
)
|
||||
if(APPLE)
|
||||
target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_SYSCTL_AARCH64)
|
||||
|
@ -9,15 +9,15 @@
|
||||
#if defined(CPU_FEATURES_OS_WINDOWS)
|
||||
#include "internal/windows_utils.h"
|
||||
#endif // CPU_FEATURES_OS_WINDOWS
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
#include "internal/cpuid_aarch64.h"
|
||||
#endif // defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
#endif // defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
|
||||
namespace cpu_features
|
||||
{
|
||||
class FakeCpuAarch64
|
||||
{
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
public:
|
||||
uint64_t GetMidrEl1() const { return _midr_el1; }
|
||||
|
||||
@ -87,11 +87,8 @@ static FakeCpuAarch64& cpu()
|
||||
}
|
||||
|
||||
// Define OS dependent mock functions
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
extern "C" uint64_t GetMidrEl1(void)
|
||||
{
|
||||
return cpu().GetMidrEl1();
|
||||
}
|
||||
#if defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD) || defined(CPU_FEATURES_OS_LINUX)
|
||||
extern "C" uint64_t GetMidrEl1(void) { return cpu().GetMidrEl1(); }
|
||||
#elif defined(CPU_FEATURES_OS_MACOS)
|
||||
extern "C" bool GetDarwinSysCtlByName(const char* name)
|
||||
{
|
||||
@ -148,7 +145,7 @@ TEST_F(CpuidAarch64Test, Aarch64FeaturesEnum)
|
||||
}
|
||||
|
||||
// AT_HWCAP tests
|
||||
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_FREEBSD)
|
||||
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD)
|
||||
TEST_F(CpuidAarch64Test, FromHardwareCap)
|
||||
{
|
||||
ResetHwcaps();
|
||||
@ -218,7 +215,7 @@ TEST_F(CpuidAarch64Test, FromHardwareCap2)
|
||||
EXPECT_FALSE(info.features.dgh);
|
||||
EXPECT_FALSE(info.features.rng);
|
||||
}
|
||||
#endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_FREEBSD)
|
||||
#endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD)
|
||||
|
||||
// OS dependent tests
|
||||
#if defined(CPU_FEATURES_OS_LINUX)
|
||||
@ -431,7 +428,7 @@ TEST_F(CpuidAarch64Test, WINDOWS_AARCH64_RPI4)
|
||||
EXPECT_FALSE(info.features.jscvt);
|
||||
EXPECT_FALSE(info.features.lrcpc);
|
||||
}
|
||||
#elif defined(CPU_FEATURES_OS_FREEBSD)
|
||||
#elif defined(CPU_FEATURES_OS_FREEBSD) || defined(CPU_FEATURES_OS_OPENBSD)
|
||||
TEST_F(CpuidAarch64Test, MrsMidrEl1_RPI4)
|
||||
{
|
||||
ResetHwcaps();
|
||||
@ -465,4 +462,4 @@ TEST_F(CpuidAarch64Test, MrsMidrEl1_RPI4)
|
||||
}
|
||||
#endif // CPU_FEATURES_OS_FREEBSD
|
||||
} // namespace
|
||||
} // namespace cpu_features
|
||||
} // namespace cpu_features
|
Loading…
x
Reference in New Issue
Block a user