1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-31 11:19:18 +00:00

Merge release0017 branch

This commit is contained in:
Carles Fernandez 2022-04-20 14:24:28 +02:00
commit bba80cb920
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
94 changed files with 3076 additions and 1857 deletions

View File

@ -17,13 +17,13 @@ Contact Information
CTTC Homepage CTTC Homepage
---------------------------- ----------------------------
http://www.cttc.cat https://www.cttc.cat
Mailing List Mailing List
---------------------------- ----------------------------
gnss-sdr-developers@lists.sourceforge.net gnss-sdr-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers https://sourceforge.net/projects/gnss-sdr/lists/gnss-sdr-developers
Email Email
@ -64,4 +64,4 @@ Stefan van der Linden spvdlinden@gmail.com Contributor
Carlos Paniego carpanie@hotmail.com Artwork Carlos Paniego carpanie@hotmail.com Artwork
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades <carles.fernandez@cttc.es> # SPDX-FileCopyrightText: 2011-2022 Carles Fernandez-Prades <carles.fernandez@cttc.es>

View File

@ -1,7 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2022 C. Fernandez-Prades carles.fernandez(at)cttc.es # SPDX-FileCopyrightText: 2022 C. Fernandez-Prades carles.fernandez(at)cttc.es
--- ---
abstract: "An open-source Global Navigation Satellite Systems software-defined receiver."
authors: authors:
- affiliation: "Centre Tecnològic de Telecomunicacions de Catalunya (CTTC)" - affiliation: "Centre Tecnològic de Telecomunicacions de Catalunya (CTTC)"
alias: carlesfernandez alias: carlesfernandez
@ -102,7 +101,7 @@ authors:
family-names: "van der Linden" family-names: "van der Linden"
given-names: Stefan given-names: Stefan
cff-version: "1.2.0" cff-version: "1.2.0"
date-released: "2022-02-14" date-released: "2022-04-20"
identifiers: identifiers:
- description: "The concept DOI of the work. This is a DOI always pointing to the latest stable release." - description: "The concept DOI of the work. This is a DOI always pointing to the latest stable release."
type: doi type: doi
@ -326,4 +325,4 @@ repository-code: "https://github.com/gnss-sdr/gnss-sdr"
title: GNSS-SDR title: GNSS-SDR
type: software type: software
url: "https://gnss-sdr.org" url: "https://gnss-sdr.org"
version: "0.0.16" version: "0.0.17"

View File

@ -16,7 +16,7 @@ endif()
# Build type can still be overridden by setting -DCMAKE_BUILD_TYPE= # Build type can still be overridden by setting -DCMAKE_BUILD_TYPE=
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
cmake_minimum_required(VERSION 2.8.12...3.22) cmake_minimum_required(VERSION 2.8.12...3.23)
project(gnss-sdr CXX C) project(gnss-sdr CXX C)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
@ -101,7 +101,7 @@ option(ENABLE_SYSTEM_TESTING_EXTRA "Download external tools and build extra syst
option(ENABLE_GNSS_SIM_INSTALL "Enable the installation of gnss_sim on the fly" ON) option(ENABLE_GNSS_SIM_INSTALL "Enable the installation of gnss_sim on the fly" ON)
option(ENABLE_OWN_CPUFEATURES "Force the building of the cpu_features library even if it is already installed" ON) option(ENABLE_CPUFEATURES "Make use of the cpu_features library" ON)
if(NOT (ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)) if(NOT (ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA))
set(ENABLE_GNSS_SIM_INSTALL OFF) set(ENABLE_GNSS_SIM_INSTALL OFF)
@ -166,9 +166,9 @@ endif()
set(VERSION_INFO_MAJOR_VERSION 0) set(VERSION_INFO_MAJOR_VERSION 0)
set(VERSION_INFO_API_COMPAT 0) set(VERSION_INFO_API_COMPAT 0)
if(${THIS_IS_A_RELEASE}) if(${THIS_IS_A_RELEASE})
set(VERSION_INFO_MINOR_VERSION 16) set(VERSION_INFO_MINOR_VERSION 17)
else() else()
set(VERSION_INFO_MINOR_VERSION 16.git-${GIT_BRANCH}-${GIT_COMMIT_HASH}) set(VERSION_INFO_MINOR_VERSION 17.git-${GIT_BRANCH}-${GIT_COMMIT_HASH})
endif() endif()
set(VERSION ${VERSION_INFO_MAJOR_VERSION}.${VERSION_INFO_API_COMPAT}.${VERSION_INFO_MINOR_VERSION}) set(VERSION ${VERSION_INFO_MAJOR_VERSION}.${VERSION_INFO_API_COMPAT}.${VERSION_INFO_MINOR_VERSION})
@ -320,7 +320,7 @@ set(GNSSSDR_PROTOBUF_MIN_VERSION "3.0.0")
# Versions to download and build (but not installed) if not found # Versions to download and build (but not installed) if not found
################################################################################ ################################################################################
set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2")
set(GNSSSDR_GLOG_LOCAL_VERSION "0.5.0") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0")
set(GNSSSDR_ARMADILLO_LOCAL_VERSION "10.8.x") set(GNSSSDR_ARMADILLO_LOCAL_VERSION "10.8.x")
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) OR if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
@ -330,12 +330,16 @@ else()
endif() endif()
set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master")
set(GNSSSDR_GPSTK_LOCAL_VERSION "8.0.0") set(GNSSSDR_GPSTK_LOCAL_VERSION "8.0.0")
set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.21") set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23")
set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.12") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.12")
set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.19.4") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.20.0")
set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.6.1") set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.6.1")
set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7") set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7")
if(CMAKE_VERSION VERSION_LESS "3.16")
set(GNSSSDR_GLOG_LOCAL_VERSION "0.5.0")
endif()
if(CMAKE_VERSION VERSION_LESS "3.3") if(CMAKE_VERSION VERSION_LESS "3.3")
set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") # Fix for Debian 8 set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") # Fix for Debian 8
endif() endif()
@ -1156,7 +1160,6 @@ if(NOT VOLKGNSSSDR_FOUND)
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_COMPILER} set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_COMPILER}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install
-DENABLE_STATIC_LIBS=ON -DENABLE_STATIC_LIBS=ON
-DENABLE_OWN_CPUFEATURES=${ENABLE_OWN_CPUFEATURES}
-DENABLE_PROFILING=${ENABLE_PROFILING} -DENABLE_PROFILING=${ENABLE_PROFILING}
-DENABLE_ORC=${ORC_ENABLED} -DENABLE_ORC=${ORC_ENABLED}
${STRIP_VOLK_GNSSSDR_PROFILE} ${STRIP_VOLK_GNSSSDR_PROFILE}
@ -1193,15 +1196,8 @@ if(NOT VOLKGNSSSDR_FOUND)
endif() endif()
include(GNUInstallDirs) include(GNUInstallDirs)
set(SUPPORTED_CPU_FEATURES_ARCH FALSE) set(SUPPORTED_CPU_FEATURES_ARCH FALSE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") if(CMAKE_SYSTEM_PROCESSOR MATCHES
set(SUPPORTED_CPU_FEATURES_ARCH TRUE) "(^mips)|(^arm)|(^aarch64)|(x86_64)|(AMD64|amd64)|(^i.86$)|(^powerpc)|(^ppc)")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
set(SUPPORTED_CPU_FEATURES_ARCH TRUE) set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
endif() endif()
if(${CMAKE_INSTALL_LIBDIR} MATCHES lib64) if(${CMAKE_INSTALL_LIBDIR} MATCHES lib64)
@ -1227,22 +1223,27 @@ if(NOT VOLKGNSSSDR_FOUND)
${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile
) )
if(NOT ENABLE_OWN_CPUFEATURES) if(ENABLE_CPUFEATURES)
find_package(CpuFeatures QUIET) find_package(CPUFEATURES)
set_package_properties(CpuFeatures PROPERTIES set_package_properties(CPUFEATURES PROPERTIES
URL "https://github.com/google/cpu_features" URL "https://github.com/google/cpu_features"
PURPOSE "Used by the volk_gnsssdr library." PURPOSE "Used by the volk_gnsssdr library."
TYPE REQUIRED TYPE REQUIRED
) )
endif() endif()
if(CpuFeatures_FOUND) if(CPUFEATURES_FOUND)
message(STATUS "Found CpuFeatures: (found version ${CpuFeatures_VERSION})") message(STATUS "Found CpuFeatures: (found version ${CPUFEATURES_VERSION})")
set_package_properties(CpuFeatures PROPERTIES set_package_properties(CPUFEATURES PROPERTIES
DESCRIPTION "A cross platform C99 library to get CPU features at runtime (found: v${CpuFeatures_VERSION})" DESCRIPTION "A cross platform C99 library to get CPU features at runtime (version: ${CPUFEATURES_VERSION})"
) )
else() else()
set_package_properties(CpuFeatures PROPERTIES set_package_properties(CPUFEATURES PROPERTIES
DESCRIPTION "A cross platform C99 library to get CPU features at runtime" DESCRIPTION "A cross platform C99 library to get CPU features at runtime"
)
if(VOLK_VERSION AND VOLK_VERSION VERSION_GREATER "2.3" AND VOLK_VERSION VERSION_LESS "2.5.2") # detect "hidden" cpu_features 0.6.0
set(ENABLE_CPUFEATURES OFF)
else()
set_package_properties(CPUFEATURES PROPERTIES
PURPOSE "CpuFeatures will be built when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'." PURPOSE "CpuFeatures will be built when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'."
) )
set(VOLK_GNSSSDR_BUILD_BYPRODUCTS set(VOLK_GNSSSDR_BUILD_BYPRODUCTS
@ -1250,6 +1251,10 @@ if(NOT VOLKGNSSSDR_FOUND)
${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX}
) )
endif() endif()
endif()
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS}
-DVOLK_CPU_FEATURES=${ENABLE_CPUFEATURES}
)
ExternalProject_Add(volk_gnsssdr_module ExternalProject_Add(volk_gnsssdr_module
PREFIX ${CMAKE_BINARY_DIR}/volk_gnsssdr_module PREFIX ${CMAKE_BINARY_DIR}/volk_gnsssdr_module
SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr
@ -1265,6 +1270,10 @@ if(NOT VOLKGNSSSDR_FOUND)
INSTALL_DIR ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install INSTALL_DIR ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install
) )
else() else()
set(ENABLE_CPUFEATURES OFF)
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS}
-DVOLK_CPU_FEATURES=${ENABLE_CPUFEATURES}
)
ExternalProject_Add(volk_gnsssdr_module ExternalProject_Add(volk_gnsssdr_module
PREFIX ${CMAKE_BINARY_DIR}/volk_gnsssdr_module PREFIX ${CMAKE_BINARY_DIR}/volk_gnsssdr_module
SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr
@ -1292,8 +1301,8 @@ if(NOT VOLKGNSSSDR_FOUND)
set_property(TARGET volk_gnsssdr PROPERTY IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}) set_property(TARGET volk_gnsssdr PROPERTY IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX})
set(VOLK_GNSSSDR_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/volk_gnsssdr_module/build/include/;${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include;${ORC_INCLUDE_DIRS}") set(VOLK_GNSSSDR_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/volk_gnsssdr_module/build/include/;${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include;${ORC_INCLUDE_DIRS}")
set(VOLK_GNSSSDR_LIBRARIES volk_gnsssdr ${ORC_LIBRARIES_STATIC}) set(VOLK_GNSSSDR_LIBRARIES volk_gnsssdr ${ORC_LIBRARIES_STATIC})
if(CpuFeatures_FOUND) if(CPUFEATURES_FOUND)
set(VOLK_GNSSSDR_LIBRARIES ${VOLK_GNSSSDR_LIBRARIES} CpuFeatures::cpu_features) set(VOLK_GNSSSDR_LIBRARIES ${VOLK_GNSSSDR_LIBRARIES} CpuFeature::cpu_features)
endif() endif()
if(NOT TARGET Volkgnsssdr::volkgnsssdr) if(NOT TARGET Volkgnsssdr::volkgnsssdr)
@ -1308,7 +1317,7 @@ if(NOT VOLKGNSSSDR_FOUND)
INTERFACE_LINK_LIBRARIES "${VOLK_GNSSSDR_LIBRARIES}" INTERFACE_LINK_LIBRARIES "${VOLK_GNSSSDR_LIBRARIES}"
) )
if(CMAKE_VERSION VERSION_GREATER 3.0 AND SUPPORTED_CPU_FEATURES_ARCH) if(CMAKE_VERSION VERSION_GREATER 3.0 AND SUPPORTED_CPU_FEATURES_ARCH)
if(NOT CpuFeatures_FOUND) if(NOT CPUFEATURES_FOUND AND ENABLE_CPUFEATURES)
set_target_properties(Volkgnsssdr::volkgnsssdr PROPERTIES set_target_properties(Volkgnsssdr::volkgnsssdr PROPERTIES
INTERFACE_LINK_LIBRARIES ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX} INTERFACE_LINK_LIBRARIES ${CMAKE_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX}
) )
@ -1338,7 +1347,6 @@ if(NOT VOLKGNSSSDR_FOUND)
PURPOSE "volk_gnsssdr will be built when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'." PURPOSE "volk_gnsssdr will be built when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'."
) )
else() else()
set(ENABLE_OWN_CPUFEATURES OFF)
set(ENABLE_ORC OFF) set(ENABLE_ORC OFF)
endif() endif()
@ -1674,9 +1682,12 @@ ${CMAKE_BINARY_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure
${CMAKE_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}glogd${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}glogd${CMAKE_STATIC_LIBRARY_SUFFIX}
) )
endif() endif()
if((CMAKE_VERSION VERSION_GREATER 3.12.0) AND NOT (CMAKE_GENERATOR STREQUAL Xcode)) if((CMAKE_VERSION VERSION_GREATER 3.12.0) AND NOT (CMAKE_GENERATOR STREQUAL Xcode) AND NOT CMAKE_CROSSCOMPILING)
set(PARALLEL_BUILD "--parallel 2") set(PARALLEL_BUILD "--parallel 2")
endif() endif()
if(GNSSSDR_GLOG_LOCAL_VERSION VERSION_GREATER 0.5.0)
set(GLOG_GTEST -DWITH_GTEST=FALSE)
endif()
ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION} ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION}
DEPENDS ${TARGET_GFLAGS} DEPENDS ${TARGET_GFLAGS}
PREFIX ${CMAKE_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} PREFIX ${CMAKE_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
@ -1689,6 +1700,7 @@ ${CMAKE_BINARY_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure
${GLOG_TOOLCHAIN_FILE} ${GLOG_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:NoOptWithASM>:Debug>$<$<CONFIG:Coverage>:Debug>$<$<CONFIG:O2WithASM>:RelWithDebInfo>$<$<CONFIG:O3WithASM>:RelWithDebInfo>$<$<CONFIG:ASAN>:Debug> -DCMAKE_BUILD_TYPE=$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:NoOptWithASM>:Debug>$<$<CONFIG:Coverage>:Debug>$<$<CONFIG:O2WithASM>:RelWithDebInfo>$<$<CONFIG:O3WithASM>:RelWithDebInfo>$<$<CONFIG:ASAN>:Debug>
-DBUILD_SHARED_LIBS=OFF -DBUILD_SHARED_LIBS=OFF
${GLOG_GTEST}
-DBUILD_TESTING=OFF -DBUILD_TESTING=OFF
BUILD_COMMAND "${GLOG_MAKE_PROGRAM} ${PARALLEL_BUILD}" BUILD_COMMAND "${GLOG_MAKE_PROGRAM} ${PARALLEL_BUILD}"
BUILD_BYPRODUCTS ${GLOG_BUILD_BYPRODUCTS} BUILD_BYPRODUCTS ${GLOG_BUILD_BYPRODUCTS}
@ -3353,7 +3365,7 @@ add_feature_info(ENABLE_GNSS_SIM_INSTALL ENABLE_GNSS_SIM_INSTALL "Enables downlo
add_feature_info(ENABLE_INSTALL_TESTS ENABLE_INSTALL_TESTS "Install test binaries when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} install'.") add_feature_info(ENABLE_INSTALL_TESTS ENABLE_INSTALL_TESTS "Install test binaries when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} install'.")
add_feature_info(ENABLE_BENCHMARKS ENABLE_BENCHMARKS "Enables building of code snippet benchmarks.") add_feature_info(ENABLE_BENCHMARKS ENABLE_BENCHMARKS "Enables building of code snippet benchmarks.")
add_feature_info(ENABLE_EXTERNAL_MATHJAX ENABLE_EXTERNAL_MATHJAX "Use MathJax from an external CDN in HTML docs when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} doc'.") add_feature_info(ENABLE_EXTERNAL_MATHJAX ENABLE_EXTERNAL_MATHJAX "Use MathJax from an external CDN in HTML docs when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} doc'.")
add_feature_info(ENABLE_OWN_CPUFEATURES ENABLE_OWN_CPUFEATURES "Force building own local version of the cpu_features library, even if it is already installed.") add_feature_info(ENABLE_CPUFEATURES ENABLE_CPUFEATURES "Make use of the cpu_features library.")
add_feature_info(Boost_USE_STATIC_LIBS Boost_USE_STATIC_LIBS "Use Boost static libraries.") add_feature_info(Boost_USE_STATIC_LIBS Boost_USE_STATIC_LIBS "Use Boost static libraries.")
message(STATUS "") message(STATUS "")

View File

@ -170,6 +170,9 @@ Please note that the required files from `libgtest-dev` were moved to
again to `libgtest-dev` in Debian 10 "buster" and Ubuntu 18.10 "cosmic" (and again to `libgtest-dev` in Debian 10 "buster" and Ubuntu 18.10 "cosmic" (and
above). above).
Since Ubuntu 21.04 Hirsute / Debian 11, the package `libcpu-features-dev` is
also required.
**Note for Ubuntu 14.04 LTS "trusty" users:** you will need to build from source **Note for Ubuntu 14.04 LTS "trusty" users:** you will need to build from source
and install GNU Radio manually, as explained below, since GNSS-SDR requires and install GNU Radio manually, as explained below, since GNSS-SDR requires
`gnuradio-dev` >= 3.7.3, and Ubuntu 14.04 came with 3.7.2. Install all the `gnuradio-dev` >= 3.7.3, and Ubuntu 14.04 came with 3.7.2. Install all the
@ -470,9 +473,9 @@ your GNU/Linux distribution, GNSS-SDR can also work well with OpenSSL.
#### Install [Matio](https://github.com/tbeu/matio "Matio's Homepage"), MATLAB MAT file I/O library: #### Install [Matio](https://github.com/tbeu/matio "Matio's Homepage"), MATLAB MAT file I/O library:
``` ```
$ wget https://github.com/tbeu/matio/releases/download/v1.5.21/matio-1.5.21.tar.gz $ wget https://github.com/tbeu/matio/releases/download/v1.5.23/matio-1.5.23.tar.gz
$ tar xvfz matio-1.5.21.tar.gz $ tar xvfz matio-1.5.23.tar.gz
$ cd matio-1.5.21 $ cd matio-1.5.23
$ ./configure $ ./configure
$ make $ make
$ sudo make install $ sudo make install
@ -493,9 +496,9 @@ $ sudo apt-get install autoconf automake libtool curl make g++ unzip
and then: and then:
``` ```
$ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protobuf-cpp-3.19.4.tar.gz $ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.0/protobuf-cpp-3.20.0.tar.gz
$ tar xvfz protobuf-cpp-3.19.4.tar.gz $ tar xvfz protobuf-cpp-3.20.0.tar.gz
$ cd protobuf-3.19.4 $ cd protobuf-3.20.0
$ ./autogen.sh $ ./autogen.sh
$ ./configure $ ./configure
$ make $ make
@ -2128,7 +2131,7 @@ if you reference the following article to credit the GNSS-SDR project:
- C. Fern&aacute;ndez-Prades, J. Arribas, P. Closas, C. Avil&eacute;s, and L. - C. Fern&aacute;ndez-Prades, J. Arribas, P. Closas, C. Avil&eacute;s, and L.
Esteve, Esteve,
[GNSS-SDR: an open source tool for researchers and developers](http://www.cttc.es/publication/gnss-sdr-an-open-source-tool-for-researchers-and-developers/), [GNSS-SDR: an open source tool for researchers and developers](https://www.researchgate.net/publication/233380791_GNSS-SDR_An_open_source_tool_for_researchers_and_developers),
in Proceedings of the 24th International Technical Meeting of The Satellite in Proceedings of the 24th International Technical Meeting of The Satellite
Division of the Institute of Navigation (ION GNSS), Portland, Oregon, Sept. Division of the Institute of Navigation (ION GNSS), Portland, Oregon, Sept.
19-23, 2011, pp. 780-794. 19-23, 2011, pp. 780-794.

View File

@ -0,0 +1,91 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
set(FPHSA_NAME_MISMATCHED ON)
find_library(CPUFEATURES_LIBRARIES
NAMES cpu_features
PATHS /usr/lib
/usr/lib64
/usr/lib/x86_64-linux-gnu
/usr/lib/i386-linux-gnu
/usr/lib/arm-linux-gnueabihf
/usr/lib/arm-linux-gnueabi
/usr/lib/aarch64-linux-gnu
/usr/lib/mipsel-linux-gnu
/usr/lib/mips-linux-gnu
/usr/lib/mips64el-linux-gnuabi64
/usr/lib/powerpc-linux-gnu
/usr/lib/powerpc64-linux-gnu
/usr/lib/powerpc64le-linux-gnu
/usr/lib/powerpc-linux-gnuspe
/usr/lib/hppa-linux-gnu
/usr/lib/s390x-linux-gnu
/usr/lib/i386-gnu
/usr/lib/hppa-linux-gnu
/usr/lib/x86_64-kfreebsd-gnu
/usr/lib/i386-kfreebsd-gnu
/usr/lib/m68k-linux-gnu
/usr/lib/sh4-linux-gnu
/usr/lib/sparc64-linux-gnu
/usr/lib/x86_64-linux-gnux32
/usr/lib/alpha-linux-gnu
/usr/lib/riscv64-linux-gnu
/usr/local/lib
/usr/local/lib64
/opt/local/lib
)
find_path(CPUFEATURES_INCLUDE_DIR cpu_features_macros.h
PATHS $ENV{CPUFEATURES_DIR}/include
$ENV{CPUFEATURES_DIR}
/usr/include
/usr/local/include
~/Library/Frameworks
/Library/Frameworks
/sw/include # Fink
/opt/local/include # MacPorts
/opt/csw/include # Blastwave
PATH_SUFFIXES cpu_features
)
if(CPUFEATURES_INCLUDE_DIR AND CPUFEATURES_LIBRARIES)
if(NOT PACKAGE_VERSION)
set(PACKAGE_VERSION "")
endif()
set(OLD_PACKAGE_VERSION ${PACKAGE_VERSION})
unset(PACKAGE_VERSION)
list(GET CPUFEATURES_LIBRARIES 0 FIRST_DIR)
get_filename_component(CPUFEATURES_LIBRARIES_PATH ${FIRST_DIR} DIRECTORY)
if(EXISTS ${CPUFEATURES_LIBRARIES_PATH}/cmake/CpuFeatures/CpuFeaturesConfigVersion.cmake)
include(${CPUFEATURES_LIBRARIES_PATH}/cmake/CpuFeatures/CpuFeaturesConfigVersion.cmake)
endif()
if(PACKAGE_VERSION)
set(CPUFEATURES_VERSION ${PACKAGE_VERSION})
else()
set(CPUFEATURES_VERSION "Unknown")
endif()
set(PACKAGE_VERSION ${OLD_PACKAGE_VERSION})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CPUFEATURES
DEFAULT_MSG
CPUFEATURES_LIBRARIES
CPUFEATURES_INCLUDE_DIR
)
if(CPUFEATURES_FOUND AND NOT TARGET CpuFeature::cpu_features)
add_library(CpuFeature::cpu_features STATIC IMPORTED)
set_target_properties(CpuFeature::cpu_features PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${CPUFEATURES_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${CPUFEATURES_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${CPUFEATURES_LIBRARIES}"
)
endif()
mark_as_advanced(CPUFEATURES_LIBRARIES)

View File

@ -12,7 +12,7 @@
;######### GLOBAL OPTIONS ################## ;######### GLOBAL OPTIONS ##################
;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [sps]. ;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [sps].
;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE ;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE
; i.e. using front-end-cal as reported here:http://www.cttc.es/publication/turning-a-television-into-a-gnss-receiver/ ; i.e. using front-end-cal as reported here: https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
GNSS-SDR.internal_fs_sps=4000000 GNSS-SDR.internal_fs_sps=4000000
GNSS-SDR.use_acquisition_resampler=true GNSS-SDR.use_acquisition_resampler=true

View File

@ -12,7 +12,8 @@
;######### GLOBAL OPTIONS ################## ;######### GLOBAL OPTIONS ##################
;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. ;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second].
;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE ;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE
; i.e. using front-end-cal as reported here:http://www.cttc.es/publication/turning-a-television-into-a-gnss-receiver/ ; i.e. using front-end-cal as reported here: https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
; i.e. using front-end-cal as reported here: https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
GNSS-SDR.internal_fs_sps=1200000 GNSS-SDR.internal_fs_sps=1200000
@ -80,7 +81,7 @@ InputFilter.grid_density=16
;#The following options are used only in Freq_Xlating_Fir_Filter implementation. ;#The following options are used only in Freq_Xlating_Fir_Filter implementation.
;#InputFilter.IF is the intermediate frequency (in Hz) shifted down to zero Hz ;#InputFilter.IF is the intermediate frequency (in Hz) shifted down to zero Hz
;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE ;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE
; i.e. using front-end-cal as reported here:http://www.cttc.es/publication/turning-a-television-into-a-gnss-receiver/ ; i.e. using front-end-cal as reported here: https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
InputFilter.sampling_frequency=1200000 InputFilter.sampling_frequency=1200000
InputFilter.IF=80558 InputFilter.IF=80558

View File

@ -12,7 +12,7 @@
;######### GLOBAL OPTIONS ################## ;######### GLOBAL OPTIONS ##################
;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. ;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second].
;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE ;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE
; i.e. using front-end-cal as reported here:http://www.cttc.es/publication/turning-a-television-into-a-gnss-receiver/ ; i.e. using front-end-cal as reported here: https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
GNSS-SDR.internal_fs_sps=1999898 GNSS-SDR.internal_fs_sps=1999898
@ -34,7 +34,7 @@ GNSS-SDR.SUPL_CI=0x31b0
SignalSource.implementation=Osmosdr_Signal_Source SignalSource.implementation=Osmosdr_Signal_Source
SignalSource.item_type=gr_complex SignalSource.item_type=gr_complex
; FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE ; FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE
; i.e. using front-end-cal as reported here:http://www.cttc.es/publication/turning-a-television-into-a-gnss-receiver/ ; i.e. using front-end-cal as reported here: https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
SignalSource.sampling_frequency=2000000 SignalSource.sampling_frequency=2000000
SignalSource.freq=1575420000 SignalSource.freq=1575420000
SignalSource.gain=40 SignalSource.gain=40
@ -88,7 +88,7 @@ InputFilter.band2_error=1.0
InputFilter.filter_type=bandpass InputFilter.filter_type=bandpass
InputFilter.grid_density=16 InputFilter.grid_density=16
;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE ;FOR USE GNSS-SDR WITH RTLSDR DONGLES USER MUST SET THE CALIBRATED SAMPLE RATE HERE
; i.e. using front-end-cal as reported here:http://www.cttc.es/publication/turning-a-television-into-a-gnss-receiver/ ; i.e. using front-end-cal as reported here: https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
InputFilter.sampling_frequency=1999898 InputFilter.sampling_frequency=1999898
InputFilter.IF=80558 ; IF deviation due to front-end LO inaccuracies [Hz] InputFilter.IF=80558 ; IF deviation due to front-end LO inaccuracies [Hz]

View File

@ -12,8 +12,39 @@ SPDX-FileCopyrightText: 2011-2022 Carles Fernandez-Prades <carles.fernandez@cttc
All notable changes to GNSS-SDR will be documented in this file. All notable changes to GNSS-SDR will be documented in this file.
## [GNSS-SDR v0.0.17](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.17) - 2022-04-20
### Improvements in Availability:
- Compute PVT solutions when using GPS L5 signals even if the satellite is
reported as not healthy in the CNAV message.
### Improvements in Portability:
- Updated `cpu_features` library to v0.7.0. The building option
`ENABLE_OWN_CPUFEATURES` has been replaced by `ENABLE_CPUFEATURES`, defaulting
to `ON`.
- Fixed building against GNU Radio v3.10.2.0.
### Improvements in Reliability:
- Fix some defects detected by Coverity Scan 2021.12.1.
### Improvements in Usability:
- Added a script at `src/utils/scripts/download-galileo-almanac.sh` that
downloads an XML file with the latest Galileo almanac published by the
European GNSS Service Centre at https://www.gsc-europa.eu/product-almanacs
See the definitions of concepts and metrics at
https://gnss-sdr.org/design-forces/
&nbsp;
## [GNSS-SDR v0.0.16](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.16) - 2022-02-15 ## [GNSS-SDR v0.0.16](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.16) - 2022-02-15
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6090349.svg)](https://doi.org/10.5281/zenodo.6090349)
### Improvements in Availability: ### Improvements in Availability:
- Added the Galileo E5b receiving chain. The software is now able to compute PVT - Added the Galileo E5b receiving chain. The software is now able to compute PVT
@ -120,6 +151,8 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.15](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.15) - 2021-08-23 ## [GNSS-SDR v0.0.15](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.15) - 2021-08-23
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5242839.svg)](https://doi.org/10.5281/zenodo.5242839)
### Improvements in Availability: ### Improvements in Availability:
- Added the reading of reduced clock and ephemeris data (CED) in the Galileo E1B - Added the reading of reduced clock and ephemeris data (CED) in the Galileo E1B
@ -244,6 +277,8 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.14](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.14) - 2021-01-08 ## [GNSS-SDR v0.0.14](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.14) - 2021-01-08
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4428100.svg)](https://doi.org/10.5281/zenodo.4428100)
### Improvements in Availability: ### Improvements in Availability:
- Fixed bug in acquisition detection when the configuration parameter - Fixed bug in acquisition detection when the configuration parameter
@ -353,6 +388,8 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.13](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.13) - 2020-07-29 ## [GNSS-SDR v0.0.13](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.13) - 2020-07-29
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3965566.svg)](https://doi.org/10.5281/zenodo.3965566)
### Improvements in Efficiency: ### Improvements in Efficiency:
- Faster internal handling of `Gnss_Synchro` objects by reducing the amount of - Faster internal handling of `Gnss_Synchro` objects by reducing the amount of
@ -467,6 +504,8 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.12](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.12) - 2020-03-13 ## [GNSS-SDR v0.0.12](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.12) - 2020-03-13
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3709089.svg)](https://doi.org/10.5281/zenodo.3709089)
### Improvements in Accuracy: ### Improvements in Accuracy:
- Improved accuracy of the C/N0 estimator. - Improved accuracy of the C/N0 estimator.
@ -661,6 +700,8 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.11](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.11) - 2019-08-04 ## [GNSS-SDR v0.0.11](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.11) - 2019-08-04
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3359989.svg)](https://doi.org/10.5281/zenodo.3359989)
This release has several improvements in different dimensions, addition of new This release has several improvements in different dimensions, addition of new
features and bug fixes: features and bug fixes:
@ -814,6 +855,8 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.10](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.10) - 2018-12-14 ## [GNSS-SDR v0.0.10](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.10) - 2018-12-14
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2279988.svg)](https://doi.org/10.5281/zenodo.2279988)
This release has several improvements in different dimensions, addition of new This release has several improvements in different dimensions, addition of new
features and bug fixes: features and bug fixes:
@ -892,8 +935,7 @@ features and bug fixes:
- Improvements in the RTCM server stability. - Improvements in the RTCM server stability.
- Improvements in the correctness of generated RINEX files. - Improvements in the correctness of generated RINEX files.
- The receiver can read and make use of Galileo almanac XML files published by - The receiver can read and make use of Galileo almanac XML files published by
the European GNSS Service Centre at the European GNSS Service Centre at https://www.gsc-europa.eu/product-almanacs
https://www.gsc-europa.eu/system-status/almanac-data
- Own-defined XML schemas for navigation data published at - Own-defined XML schemas for navigation data published at
https://github.com/gnss-sdr/gnss-sdr/tree/next/docs/xml-schemas https://github.com/gnss-sdr/gnss-sdr/tree/next/docs/xml-schemas
- Added program `rinex2assist` to convert RINEX navigation files into XML files - Added program `rinex2assist` to convert RINEX navigation files into XML files
@ -1046,7 +1088,7 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.9](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.9) - 2017-02-13 ## [GNSS-SDR v0.0.9](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.9) - 2017-02-13
DOI: https://doi.org/10.5281/zenodo.291371 [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.291371.svg)](https://doi.org/10.5281/zenodo.291371)
This release has several improvements, addition of new features and bug fixes in This release has several improvements, addition of new features and bug fixes in
many dimensions: many dimensions:
@ -1167,7 +1209,7 @@ https://gnss-sdr.org/design-forces/
## [GNSS-SDR v0.0.8](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.8) - 2016-07-04 ## [GNSS-SDR v0.0.8](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.8) - 2016-07-04
DOI: https://doi.org/10.5281/zenodo.57022 [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.57022.svg)](http://dx.doi.org/10.5281/zenodo.57022)
This is a maintenance and bug fix release with no relevant new features with This is a maintenance and bug fix release with no relevant new features with
respect to v0.0.7. The main changes are: respect to v0.0.7. The main changes are:
@ -1193,7 +1235,7 @@ respect to v0.0.7. The main changes are:
## [GNSS-SDR v0.0.7](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.7) - 2016-05-15 ## [GNSS-SDR v0.0.7](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.7) - 2016-05-15
DOI: https://doi.org/10.5281/zenodo.51521 [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.51521.svg)](https://doi.org/10.5281/zenodo.51521)
This release has several improvements, addition of new features and bug fixes: This release has several improvements, addition of new features and bug fixes:
@ -1285,6 +1327,8 @@ This release has several improvements, addition of new features and bug fixes:
## [GNSS-SDR v0.0.6](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.6) - 2015-09-02 ## [GNSS-SDR v0.0.6](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.6) - 2015-09-02
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.30104.svg)](https://doi.org/10.5281/zenodo.30104)
This release has several improvements and bug fixes: This release has several improvements and bug fixes:
- Added initial support to multi-band, multi-source configurations (multiple - Added initial support to multi-band, multi-source configurations (multiple
@ -1335,6 +1379,8 @@ This release has several improvements and bug fixes:
## [GNSS-SDR v0.0.5](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.5) - 2015-01-13 ## [GNSS-SDR v0.0.5](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.5) - 2015-01-13
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13920.svg)](https://doi.org/10.5281/zenodo.13920)
This release has several improvements and bug fixes: This release has several improvements and bug fixes:
- Now GNSS-SDR can be installed on the system with the usual - Now GNSS-SDR can be installed on the system with the usual
@ -1362,6 +1408,8 @@ This release has several improvements and bug fixes:
## [GNSS-SDR v0.0.4](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.4) - 2014-09-08 ## [GNSS-SDR v0.0.4](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.4) - 2014-09-08
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11628.svg)](https://doi.org/10.5281/zenodo.11628)
This release has several improvements and bug fixes: This release has several improvements and bug fixes:
- Added hybrid processing GPS L1 C/A and Galileo E1B, providing position fixes - Added hybrid processing GPS L1 C/A and Galileo E1B, providing position fixes
@ -1399,6 +1447,8 @@ This release has several improvements and bug fixes:
## [GNSS-SDR v0.0.3](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.3) - 2014-06-30 ## [GNSS-SDR v0.0.3](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.3) - 2014-06-30
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10708.svg)](https://doi.org/10.5281/zenodo.10708)
This release has several improvements and bug fixes, completing the transition This release has several improvements and bug fixes, completing the transition
from Subversion to Git. The main changes are: from Subversion to Git. The main changes are:

View File

@ -89,7 +89,7 @@ dependencies and build process. Mainly, it consists on installing <a href="https
\li <a href="https://www.libvolk.org" target="_blank">Volk</a>, a Vector-Optimized Library of Kernels which provides an abstraction of optimized math routines targeting several SIMD processors, \li <a href="https://www.libvolk.org" target="_blank">Volk</a>, a Vector-Optimized Library of Kernels which provides an abstraction of optimized math routines targeting several SIMD processors,
and, optionally, and, optionally,
\li GNU Radio modules for hardware interface (<a href="https://github.com/gnuradio/gnuradio/tree/master/gr-uhd" target="_blank">gr-uhd</a>, <a href="http://git.osmocom.org/gr-osmosdr" target="_blank">gr-osmosdr</a>, <a href="https://github.com/analogdevicesinc/gr-iio" target="_blank">gr-iio</a>), \li GNU Radio modules for hardware interface (<a href="https://github.com/gnuradio/gnuradio/tree/main/gr-uhd" target="_blank">gr-uhd</a>, <a href="http://git.osmocom.org/gr-osmosdr" target="_blank">gr-osmosdr</a>, <a href="https://github.com/analogdevicesinc/gr-iio" target="_blank">gr-iio</a>),
\li <a href="https://github.com/google/benchmark" target="_blank">Benchmark</a>, a library to benchmark code snippets, \li <a href="https://github.com/google/benchmark" target="_blank">Benchmark</a>, a library to benchmark code snippets,
\li <a href="https://github.com/gperftools/gperftools" target="_blank">Gperftools</a>, which provides fast, multi-threaded malloc() and performance analysis tools. \li <a href="https://github.com/gperftools/gperftools" target="_blank">Gperftools</a>, which provides fast, multi-threaded malloc() and performance analysis tools.
@ -584,10 +584,10 @@ but if you distribute the code, it has to remain under GPL.
If you use GNSS-SDR to produce a research paper or Thesis, we would appreciate If you use GNSS-SDR to produce a research paper or Thesis, we would appreciate
if you reference any of these articles to credit the GNSS-SDR project: if you reference any of these articles to credit the GNSS-SDR project:
\li \anchor Navitec2012 C. Fern&aacute;ndez-Prades, J. Arribas, L. Esteve, D. Pubill, P. Closas, <a href="http://www.cttc.es/publication/an-open-source-galileo-e1-software-receiver/" target="_blank"><i>An Open Source Galileo E1 Software Receiver</i></a>, in Proc. of the 6th ESA Workshop on Satellite Navigation Technologies (NAVITEC 2012), ESTEC, Noordwijk, The Netherlands, Dec. 2012. \li \anchor Navitec2012 C. Fern&aacute;ndez-Prades, J. Arribas, L. Esteve, D. Pubill, P. Closas, <a href="https://www.researchgate.net/publication/233859838_An_Open_Source_Galileo_E1_Software_Receiver/" target="_blank"><i>An Open Source Galileo E1 Software Receiver</i></a>, in Proc. of the 6th ESA Workshop on Satellite Navigation Technologies (NAVITEC 2012), ESTEC, Noordwijk, The Netherlands, Dec. 2012.
\li J. Arribas, <a href="https://theses.eurasip.org/theses/449/gnss-array-based-acquisition-theory-and/" target="_blank"><i>GNSS Array-based Acquisition: Theory and Implementation</i></a>, PhD Thesis, Universitat Polit&egrave;cnica de Catalunya, Barcelona, Spain, June 2012. \li J. Arribas, <a href="https://theses.eurasip.org/theses/449/gnss-array-based-acquisition-theory-and/" target="_blank"><i>GNSS Array-based Acquisition: Theory and Implementation</i></a>, PhD Thesis, Universitat Polit&egrave;cnica de Catalunya, Barcelona, Spain, June 2012.
\li C. Fern&aacute;ndez-Prades, J. Arribas, P. Closas, C. Avil&eacute;s, and L. Esteve, <a href="http://www.cttc.es/publication/gnss-sdr-an-open-source-tool-for-researchers-and-developers/" target="_blank"><i>GNSS-SDR: an open source tool for researchers and developers</i></a>, in Proc. of the ION GNSS 2011 Conference, Portland, Oregon, Sept. 19-23, 2011. \li C. Fern&aacute;ndez-Prades, J. Arribas, P. Closas, C. Avil&eacute;s, and L. Esteve, <a href="https://www.researchgate.net/publication/233380791_GNSS-SDR_An_open_source_tool_for_researchers_and_developers" target="_blank"><i>GNSS-SDR: an open source tool for researchers and developers</i></a>, in Proc. of the ION GNSS 2011 Conference, Portland, Oregon, Sept. 19-23, 2011.
\li C. Fern&aacute;ndez-Prades, C. Avil&eacute;s, L. Esteve, J. Arribas, and P. Closas, <a href="http://www.cttc.es/publication/design-patterns-for-gnss-software-receivers/" target="_blank"><i>Design patterns for GNSS software receivers</i></a>, in Proc. of the 5th ESA Workshop on Satellite Navigation Technologies (NAVITEC'2010), ESTEC, Noordwijk, The Netherlands, Dec. 2010. DOI:10.1109/NAVITEC.2010.5707981 \li C. Fern&aacute;ndez-Prades, C. Avil&eacute;s, L. Esteve, J. Arribas, and P. Closas, <a href="https://www.researchgate.net/publication/228624103_Design_Patterns_for_GNSS_Software_Receivers" target="_blank"><i>Design patterns for GNSS software receivers</i></a>, in Proc. of the 5th ESA Workshop on Satellite Navigation Technologies (NAVITEC'2010), ESTEC, Noordwijk, The Netherlands, Dec. 2010. DOI:10.1109/NAVITEC.2010.5707981
For LaTeX users, these are the BibTeX cites for your convenience: For LaTeX users, these are the BibTeX cites for your convenience:

View File

@ -32,7 +32,7 @@ The crystal oscillator that ships with the RTL2832U family devices exhibits limi
\.TP \.TP
Example of configuration file available at: ${prefix}/share/gnss\-sdr/conf/front\-end\-cal.conf, where ${prefix}$ uses to be /usr or /usr/local. This will be the configuration file used by default if the \fB\-config_file\fR option is not set. Example of configuration file available at: ${prefix}/share/gnss\-sdr/conf/front\-end\-cal.conf, where ${prefix}$ uses to be /usr or /usr/local. This will be the configuration file used by default if the \fB\-config_file\fR option is not set.
\.TP \.TP
[1] C. Fernandez\-Prades, J. Arribas, P. Closas, \fITurning a Television into a GNSS Receiver\fR, in Proceedings of ION GNSS+, 15\-16 September 2013, Nashville, Tennessee (USA). A draft copy is freely available at http://www.cttc.es/publication/turning\-a\-television\-into\-a\-gnss\-receiver/ [1] C. Fernandez\-Prades, J. Arribas, P. Closas, \fITurning a Television into a GNSS Receiver\fR, in Proceedings of ION GNSS+, 15\-16 September 2013, Nashville, Tennessee (USA). A draft copy is freely available at https://www.researchgate.net/publication/257137427_Turning_a_Television_into_a_GNSS_Receiver
\.TP \.TP
Check https://gnss\-sdr.org for more information. Check https://gnss\-sdr.org for more information.
.SH BUGS .SH BUGS
@ -40,4 +40,4 @@ No known bugs.
.SH AUTHOR .SH AUTHOR
Javier Arribas (javier.arribas@cttc.es) Javier Arribas (javier.arribas@cttc.es)
\.TP \.TP
This software has been developed at CTTC (Centre Tecnologic de Telecomunicacions de Catalunya, http://www.cttc.es) with contributions from around the world. This software has been developed at CTTC (Centre Tecnologic de Telecomunicacions de Catalunya, https://www.cttc.cat) with contributions from around the world.

View File

@ -2,7 +2,7 @@
.\" SPDX-License-Identifier: GPL-3.0-or-later .\" SPDX-License-Identifier: GPL-3.0-or-later
.\" SPDX-FileCopyrightText: Carles Fernandez-Prades <carles.fernandez(at)cttc.es> .\" SPDX-FileCopyrightText: Carles Fernandez-Prades <carles.fernandez(at)cttc.es>
.\" Contact carles.fernandez@cttc.es to correct errors or typos. .\" Contact carles.fernandez@cttc.es to correct errors or typos.
.TH gnss\-sdr 1 "15 Feb 2022" "0.0.16" "gnss\-sdr man page" .TH gnss\-sdr 1 "20 Apr 2022" "0.0.17" "gnss\-sdr man page"
.SH NAME .SH NAME
\fBgnss\-sdr\fR \- GNSS Software Defined Receiver. \fBgnss\-sdr\fR \- GNSS Software Defined Receiver.
.SH SYNOPSIS .SH SYNOPSIS
@ -78,4 +78,4 @@ Please report bugs at https://github.com/gnss-sdr/gnss-sdr/issues
.SH AUTHOR .SH AUTHOR
Carles Fernandez\-Prades (carles.fernandez@cttc.es) Carles Fernandez\-Prades (carles.fernandez@cttc.es)
\.TP \.TP
This software package has been developed at CTTC (Centre Tecnologic de Telecomunicacions de Catalunya, http://www.cttc.es) with contributions from around the world. This software package has been developed at CTTC (Centre Tecnologic de Telecomunicacions de Catalunya, https://www.cttc.cat) with contributions from around the world.

View File

@ -1254,8 +1254,9 @@ void rtklib_pvt_gs::msg_handler_telemetry(const pmt::pmt_t& msg)
} }
if (gps_cnav_ephemeris->signal_health != 0) if (gps_cnav_ephemeris->signal_health != 0)
{ {
std::cout << TEXT_RED << "Satellite " << Gnss_Satellite(std::string("GPS"), gps_cnav_ephemeris->PRN) std::cout << "Satellite " << Gnss_Satellite(std::string("GPS"), gps_cnav_ephemeris->PRN)
<< " is not healthy, not used for navigation" << TEXT_RESET << '\n'; << " does not report a healthy status in the CNAV message,"
<< " use PVT solutions at your own risk.\n";
} }
DLOG(INFO) << "New GPS CNAV ephemeris record has arrived "; DLOG(INFO) << "New GPS CNAV ephemeris record has arrived ";
} }
@ -2023,7 +2024,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item
if (tmp_eph_iter_cnav != d_internal_pvt_solver->gps_cnav_ephemeris_map.cend()) if (tmp_eph_iter_cnav != d_internal_pvt_solver->gps_cnav_ephemeris_map.cend())
{ {
const uint32_t prn_aux = tmp_eph_iter_cnav->second.PRN; const uint32_t prn_aux = tmp_eph_iter_cnav->second.PRN;
if ((prn_aux == in[i][epoch].PRN) && (((std::string(in[i][epoch].Signal) == std::string("2S")) || (std::string(in[i][epoch].Signal) == std::string("L5"))) && (tmp_eph_iter_cnav->second.signal_health == 0))) if ((prn_aux == in[i][epoch].PRN) && (((std::string(in[i][epoch].Signal) == std::string("2S")) || (std::string(in[i][epoch].Signal) == std::string("L5")))))
{ {
store_valid_observable = true; store_valid_observable = true;
} }

View File

@ -216,7 +216,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items,
d_state = 1; d_state = 1;
} }
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
break; break;
@ -368,7 +368,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += d_fft_size * ninput_items[0]; // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 1; acquisition_message = 1;
@ -403,7 +403,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 2; acquisition_message = 2;

View File

@ -226,7 +226,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items,
d_state = 1; d_state = 1;
} }
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
break; break;
@ -389,7 +389,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 1; acquisition_message = 1;
@ -424,7 +424,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 2; acquisition_message = 2;

View File

@ -680,7 +680,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items,
d_state = 1; d_state = 1;
} }
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
break; break;
} }
@ -710,7 +710,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items,
{ {
// We already have d_max_dwells consecutive blocks in the internal buffer, // We already have d_max_dwells consecutive blocks in the internal buffer,
// just skip input blocks. // just skip input blocks.
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0];
} }
// We create a new thread to process next block if the following // We create a new thread to process next block if the following
@ -754,7 +754,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
acquisition_message = 1; acquisition_message = 1;
this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message));
@ -788,7 +788,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
acquisition_message = 2; acquisition_message = 2;
this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message));

View File

@ -256,7 +256,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
d_state = 1; d_state = 1;
} }
d_sample_counter += static_cast<uint64_t>(d_sampled_ms * d_samples_per_ms * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_sampled_ms) * d_samples_per_ms * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
// DLOG(INFO) << "END CASE 0"; // DLOG(INFO) << "END CASE 0";
break; break;
@ -290,7 +290,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
d_test_statistics = 0.0; d_test_statistics = 0.0;
d_noise_floor_power = 0.0; d_noise_floor_power = 0.0;
d_sample_counter += static_cast<uint64_t>(d_sampled_ms * d_samples_per_ms); // sample counter d_sample_counter += static_cast<uint64_t>(d_sampled_ms) * d_samples_per_ms; // sample counter
d_well_count++; d_well_count++;
@ -495,7 +495,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_sampled_ms * d_samples_per_ms * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_sampled_ms) * d_samples_per_ms * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 1; acquisition_message = 1;
@ -538,7 +538,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_sampled_ms * d_samples_per_ms * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_sampled_ms) * d_samples_per_ms * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 2; acquisition_message = 2;

View File

@ -251,7 +251,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items,
d_state = 1; d_state = 1;
} }
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
break; break;
@ -390,7 +390,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 1; acquisition_message = 1;
@ -425,7 +425,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items,
d_active = false; d_active = false;
d_state = 0; d_state = 0;
d_sample_counter += static_cast<uint64_t>(d_fft_size * ninput_items[0]); // sample counter d_sample_counter += static_cast<uint64_t>(d_fft_size) * ninput_items[0]; // sample counter
consume_each(ninput_items[0]); consume_each(ninput_items[0]);
acquisition_message = 2; acquisition_message = 2;

View File

@ -8,7 +8,7 @@
######################################################################## ########################################################################
# Project setup # Project setup
######################################################################## ########################################################################
cmake_minimum_required(VERSION 2.8.12...3.22) cmake_minimum_required(VERSION 2.8.12...3.23)
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() endif()
@ -209,7 +209,7 @@ message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.")
set(VERSION_INFO_MAJOR_VERSION 0) set(VERSION_INFO_MAJOR_VERSION 0)
set(VERSION_INFO_MINOR_VERSION 0) set(VERSION_INFO_MINOR_VERSION 0)
set(VERSION_INFO_MAINT_VERSION 16) set(VERSION_INFO_MAINT_VERSION 17)
include(VolkGnsssdrVersion) # setup version info include(VolkGnsssdrVersion) # setup version info
@ -250,43 +250,42 @@ endif()
######################################################################## ########################################################################
# cpu_features # cpu_features
option(ENABLE_OWN_CPUFEATURES "Force the building of the cpu_features library even if it is already installed" OFF)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^cortex") if(CMAKE_SYSTEM_PROCESSOR MATCHES "^cortex")
set(CMAKE_SYSTEM_PROCESSOR arm-${CMAKE_SYSTEM_PROCESSOR}) set(CMAKE_SYSTEM_PROCESSOR arm-${CMAKE_SYSTEM_PROCESSOR})
endif() endif()
set(SUPPORTED_CPU_FEATURES_ARCH FALSE) # cpu_features - sensible defaults, user settable option
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") if(CMAKE_SYSTEM_PROCESSOR MATCHES
set(SUPPORTED_CPU_FEATURES_ARCH TRUE) "(^mips)|(^arm)|(^aarch64)|(x86_64)|(AMD64|amd64)|(^i.86$)|(^powerpc)|(^ppc)")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(arm64)") option(VOLK_CPU_FEATURES "volk-gnsssdr uses cpu_features" ON)
set(SUPPORTED_CPU_FEATURES_ARCH TRUE) else()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") option(VOLK_CPU_FEATURES "volk-gnsssdr uses cpu_features" OFF)
set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
endif() endif()
if(CMAKE_VERSION VERSION_GREATER 3.0 AND SUPPORTED_CPU_FEATURES_ARCH) if(CMAKE_VERSION VERSION_GREATER 3.0 AND VOLK_CPU_FEATURES)
find_package(CPUFEATURES)
set(USE_CPU_FEATURES ON)
if(NOT CPUFEATURES_FOUND)
message(STATUS "Building volk-gnsssdr with cpu_features")
set(BUILD_TESTING OFF CACHE BOOL "Build cpu_features without tests." FORCE)
set(BUILD_PIC ON CACHE BOOL
"Build cpu_features with Position Independent Code (PIC)."
FORCE
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL
"Build cpu_features with Position Independent Code (PIC)." "Build cpu_features with Position Independent Code (PIC)."
FORCE FORCE
) )
set(USE_CPU_FEATURES ON)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
if(NOT ENABLE_OWN_CPUFEATURES)
find_package(CPUFEATURES QUIET)
endif()
if(CPUFEATURES_FOUND)
message(STATUS "Found CpuFeatures: (found version ${CPUFEATURES_VERSION})")
else()
add_subdirectory(cpu_features) add_subdirectory(cpu_features)
endif()
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}") set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
endif() endif()
else()
message(STATUS "Building volk-gnsssdr without cpu_features")
endif()
# Python # Python
include(VolkPython) # sets PYTHON_EXECUTABLE include(VolkPython) # sets PYTHON_EXECUTABLE

View File

@ -203,4 +203,4 @@ by Carles Fern&aacute;ndez-Prades and Javier Arribas. This software is released
under the GNU General Public License version 3, see the file COPYING. under the GNU General Public License version 3, see the file COPYING.
This project is managed by This project is managed by
[Centre Tecnol&ograve;gic de Telecomunicacions de Catalunya](http://www.cttc.es "CTTC webpage"). [Centre Tecnol&ograve;gic de Telecomunicacions de Catalunya](https://www.cttc.cat "CTTC webpage").

View File

@ -86,7 +86,6 @@ if(CPUFEATURES_FOUND AND NOT TARGET CpuFeature::cpu_features)
INTERFACE_INCLUDE_DIRECTORIES "${CPUFEATURES_INCLUDE_DIR}" INTERFACE_INCLUDE_DIRECTORIES "${CPUFEATURES_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${CPUFEATURES_LIBRARIES}" INTERFACE_LINK_LIBRARIES "${CPUFEATURES_LIBRARIES}"
) )
add_library(cpu_features ALIAS CpuFeature::cpu_features)
endif() endif()
mark_as_advanced(CPUFEATURES_LIBRARIES) mark_as_advanced(CPUFEATURES_LIBRARIES)

View File

@ -2,7 +2,7 @@
.\" SPDX-License-Identifier: GPL-3.0-or-later .\" SPDX-License-Identifier: GPL-3.0-or-later
.\" SPDX-FileCopyrightText: Carles Fernandez-Prades <carles.fernandez(at)cttc.es> .\" SPDX-FileCopyrightText: Carles Fernandez-Prades <carles.fernandez(at)cttc.es>
.\" Contact carles.fernandez@cttc.es to correct errors or typos. .\" Contact carles.fernandez@cttc.es to correct errors or typos.
.TH volk_gnsssdr\-config\-info 1 "15 Feb 2022" "0.0.16" "volk_gnsssdr\-config\-info man page" .TH volk_gnsssdr\-config\-info 1 "20 Apr 2022" "0.0.17" "volk_gnsssdr\-config\-info man page"
.SH NAME .SH NAME
\fBvolk_gnsssdr\-config\-info\fR \- Prints configuration information of libvolk_gnsssdr functions. \fBvolk_gnsssdr\-config\-info\fR \- Prints configuration information of libvolk_gnsssdr functions.
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -2,7 +2,7 @@
.\" SPDX-License-Identifier: GPL-3.0-or-later .\" SPDX-License-Identifier: GPL-3.0-or-later
.\" SPDX-FileCopyrightText: Carles Fernandez-Prades <carles.fernandez(at)cttc.es> .\" SPDX-FileCopyrightText: Carles Fernandez-Prades <carles.fernandez(at)cttc.es>
.\" Contact carles.fernandez@cttc.es to correct errors or typos. .\" Contact carles.fernandez@cttc.es to correct errors or typos.
.TH volk_gnsssdr_profile 1 "15 Feb 2022" "0.0.16" "volk_gnsssdr_profile man page" .TH volk_gnsssdr_profile 1 "20 Apr 2022" "0.0.17" "volk_gnsssdr_profile man page"
.SH NAME .SH NAME
\fBvolk_gnsssdr_profile\fR \- Profiler application for libvolk_gnsssdr functions. \fBvolk_gnsssdr_profile\fR \- Profiler application for libvolk_gnsssdr functions.
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -9,7 +9,7 @@ if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) cmake_policy(SET CMP0077 NEW)
endif() endif()
project(CpuFeatures VERSION 0.6.0 LANGUAGES C) project(CpuFeatures VERSION 0.7.0 LANGUAGES C)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
if(CMAKE_VERSION LESS "3.1") if(CMAKE_VERSION LESS "3.1")
@ -23,9 +23,6 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE) FORCE)
endif() endif()
# BUILD_TESTING is a standard CMake variable, but we declare it here to make it
# prominent in the GUI.
option(BUILD_TESTING "Enable test (depends on googletest)." OFF)
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
# it prominent in the GUI. # it prominent in the GUI.
# cpu_features uses bit-fields which are - to some extends - implementation-defined (see https://en.cppreference.com/w/c/language/bit_field). # cpu_features uses bit-fields which are - to some extends - implementation-defined (see https://en.cppreference.com/w/c/language/bit_field).
@ -61,7 +58,7 @@ set(PROCESSOR_IS_POWER FALSE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
set(PROCESSOR_IS_MIPS TRUE) set(PROCESSOR_IS_MIPS TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(arm64)") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
set(PROCESSOR_IS_AARCH64 TRUE) set(PROCESSOR_IS_AARCH64 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(PROCESSOR_IS_ARM TRUE) set(PROCESSOR_IS_ARM TRUE)
@ -74,22 +71,19 @@ endif()
macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME) macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpu_features_macros.h) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpu_features_macros.h)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpu_features_cache_info.h) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpu_features_cache_info.h)
file(GLOB IMPL_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/impl_*.c")
list(APPEND ${SRCS_LIST_NAME} ${IMPL_SOURCES})
if(PROCESSOR_IS_MIPS) if(PROCESSOR_IS_MIPS)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_mips.h) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_mips.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/src/cpuinfo_mips.c)
elseif(PROCESSOR_IS_ARM) elseif(PROCESSOR_IS_ARM)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_arm.h) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_arm.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/src/cpuinfo_arm.c)
elseif(PROCESSOR_IS_AARCH64) elseif(PROCESSOR_IS_AARCH64)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_aarch64.h) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_aarch64.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/src/cpuinfo_aarch64.c)
elseif(PROCESSOR_IS_X86) elseif(PROCESSOR_IS_X86)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_x86.h) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_x86.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/cpuid_x86.h) list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/cpuid_x86.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/src/cpuinfo_x86.c)
elseif(PROCESSOR_IS_POWER) elseif(PROCESSOR_IS_POWER)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_ppc.h) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_ppc.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/src/cpuinfo_ppc.c)
else() else()
message(FATAL_ERROR "Unsupported architectures ${CMAKE_SYSTEM_PROCESSOR}") message(FATAL_ERROR "Unsupported architectures ${CMAKE_SYSTEM_PROCESSOR}")
endif() endif()
@ -147,9 +141,11 @@ target_link_libraries(cpu_features PUBLIC ${CMAKE_DL_LIBS})
target_include_directories(cpu_features target_include_directories(cpu_features
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpu_features> PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpu_features>
) )
if(APPLE AND (PROCESSOR_IS_X86 OR PROCESSOR_IS_AARCH64)) if(PROCESSOR_IS_X86)
if(APPLE)
target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME) target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME)
endif() endif()
endif()
add_library(CpuFeature::cpu_features ALIAS cpu_features) add_library(CpuFeature::cpu_features ALIAS cpu_features)
# #

View File

@ -16,7 +16,7 @@ For API / ABI compatibility reasons, it is recommended to build and use
cpu_features in a subdirectory of your project or as an embedded dependency. cpu_features in a subdirectory of your project or as an embedded dependency.
This is similar to the recommended usage of the googletest framework ( This is similar to the recommended usage of the googletest framework (
https://github.com/google/googletest/blob/master/googletest/README.md ) https://github.com/google/googletest/blob/main/googletest/README.md )
Build and use step-by-step Build and use step-by-step
@ -29,11 +29,11 @@ cpu_features directly and use the `cpu_features` target in your project.
3- Add the `cpu_features` target to the `target_link_libraries()` section of 3- Add the `cpu_features` target to the `target_link_libraries()` section of
your executable or of your library. your executable or of your library.
## Enabling tests ## Disabling tests
CMake default options for cpu_features is Release built type with tests CMake default options for cpu_features is `Release` built type with tests
disabled. To enable testing set cmake `BUILD_TESTING` variable to `ON`, enabled. To disable testing set cmake `BUILD_TESTING` variable to `OFF`. e.g.
[.travis.yml](https://github.com/google/cpu_features/blob/master/.travis.yml)
and ```sh
[appveyor.yml](https://github.com/google/cpu_features/blob/master/appveyor.yml) cmake -S. -Bbuild -DBUILD_TESTING=OFF
have up to date examples. ```

View File

@ -8,7 +8,7 @@ project(googletest-download NONE)
include(ExternalProject) include(ExternalProject)
ExternalProject_Add(googletest ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master GIT_TAG main
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ #ifndef CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_
#define CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ #define CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_
@ -29,7 +28,7 @@
#define CPU_FEATURES_ARCH_ARM #define CPU_FEATURES_ARCH_ARM
#endif #endif
#if (defined(__aarch64__) || (defined(__APPLE__) && defined(__arm64__))) #if defined(__aarch64__)
#define CPU_FEATURES_ARCH_AARCH64 #define CPU_FEATURES_ARCH_AARCH64
#endif #endif
@ -57,24 +56,33 @@
// Os // Os
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#if defined(__linux__) #if (defined(__freebsd__) || defined(__FreeBSD__))
#define CPU_FEATURES_OS_LINUX_OR_ANDROID #define CPU_FEATURES_OS_FREEBSD
#endif #endif
#if defined(__ANDROID__) #if defined(__ANDROID__)
#define CPU_FEATURES_OS_ANDROID #define CPU_FEATURES_OS_ANDROID
#endif #endif
#if defined(__linux__) && !defined(CPU_FEATURES_OS_FREEBSD) && \
!defined(CPU_FEATURES_OS_ANDROID)
#define CPU_FEATURES_OS_LINUX
#endif
#if (defined(_WIN64) || defined(_WIN32)) #if (defined(_WIN64) || defined(_WIN32))
#define CPU_FEATURES_OS_WINDOWS #define CPU_FEATURES_OS_WINDOWS
#endif #endif
#if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__)) #if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__))
#define CPU_FEATURES_OS_DARWIN // From https://stackoverflow.com/a/49560690
#include "TargetConditionals.h"
#if defined(TARGET_OS_OSX)
#define CPU_FEATURES_OS_MACOS
#endif
#if defined(TARGET_OS_IPHONE)
// This is set for any non-Mac Apple products (IOS, TV, WATCH)
#define CPU_FEATURES_OS_IPHONE
#endif #endif
#if (defined(__freebsd__) || defined(__FreeBSD__))
#define CPU_FEATURES_OS_FREEBSD
#endif #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -215,11 +223,18 @@
// Communicates to the compiler that the block is unreachable // Communicates to the compiler that the block is unreachable
#if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC) #if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC)
#define UNREACHABLE() __builtin_unreachable() #define CPU_FEATURES_UNREACHABLE() __builtin_unreachable()
#elif defined(CPU_FEATURES_COMPILER_MSC) #elif defined(CPU_FEATURES_COMPILER_MSC)
#define UNREACHABLE() __assume(0) #define CPU_FEATURES_UNREACHABLE() __assume(0)
#else #else
#define UNREACHABLE() #define CPU_FEATURES_UNREACHABLE()
#endif
// Communicates to the compiler that the function is now deprecated
#if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC)
#define CPU_FEATURES_DEPRECATED(message) __attribute__((deprecated(message)))
#else
#define CPU_FEATURES_DEPRECATED(message)
#endif #endif
#endif // CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ #endif // CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ #ifndef CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_
#define CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ #define CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_ #ifndef CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_
#define CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_ #define CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_ #ifndef CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_
#define CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_ #define CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ #ifndef CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_
#define CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ #define CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_
@ -62,7 +61,6 @@ typedef struct
PPCFeatures features; PPCFeatures features;
} PPCInfo; } PPCInfo;
// This function is guaranteed to be malloc, memset and memcpy free.
PPCInfo GetPPCInfo(void); PPCInfo GetPPCInfo(void);
typedef struct typedef struct

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_X86_H_ #ifndef CPU_FEATURES_INCLUDE_CPUINFO_X86_H_
#define CPU_FEATURES_INCLUDE_CPUINFO_X86_H_ #define CPU_FEATURES_INCLUDE_CPUINFO_X86_H_
@ -14,6 +13,8 @@ CPU_FEATURES_START_CPP_NAMESPACE
#define CPU_FEATURES_VENDOR_GENUINE_INTEL "GenuineIntel" #define CPU_FEATURES_VENDOR_GENUINE_INTEL "GenuineIntel"
#define CPU_FEATURES_VENDOR_AUTHENTIC_AMD "AuthenticAMD" #define CPU_FEATURES_VENDOR_AUTHENTIC_AMD "AuthenticAMD"
#define CPU_FEATURES_VENDOR_HYGON_GENUINE "HygonGenuine" #define CPU_FEATURES_VENDOR_HYGON_GENUINE "HygonGenuine"
#define CPU_FEATURES_VENDOR_CENTAUR_HAULS "CentaurHauls"
#define CPU_FEATURES_VENDOR_SHANGHAI " Shanghai "
// See https://en.wikipedia.org/wiki/CPUID for a list of x86 cpu features. // See https://en.wikipedia.org/wiki/CPUID for a list of x86 cpu features.
// The field names are based on the short name provided in the wikipedia tables. // The field names are based on the short name provided in the wikipedia tables.
@ -95,21 +96,27 @@ typedef struct
int model; int model;
int stepping; int stepping;
char vendor[13]; // 0 terminated string char vendor[13]; // 0 terminated string
char brand_string[49]; // 0 terminated string
} X86Info; } X86Info;
// Calls cpuid and returns an initialized X86info. // Calls cpuid and returns an initialized X86info.
// This function is guaranteed to be malloc, memset and memcpy free.
X86Info GetX86Info(void); X86Info GetX86Info(void);
// Returns cache hierarchy informations. // Returns cache hierarchy informations.
// Can call cpuid multiple times. // Can call cpuid multiple times.
// Only works on Intel CPU at the moment. // Only works on Intel CPU at the moment.
// This function is guaranteed to be malloc, memset and memcpy free.
CacheInfo GetX86CacheInfo(void); CacheInfo GetX86CacheInfo(void);
typedef enum typedef enum
{ {
X86_UNKNOWN, X86_UNKNOWN,
ZHAOXIN_ZHANGJIANG, // ZhangJiang
ZHAOXIN_WUDAOKOU, // WuDaoKou
ZHAOXIN_LUJIAZUI, // LuJiaZui
ZHAOXIN_YONGFENG, // YongFeng
INTEL_80486, // 80486
INTEL_P5, // P5
INTEL_LAKEMONT, // LAKEMONT
INTEL_CORE, // CORE INTEL_CORE, // CORE
INTEL_PNR, // PENRYN INTEL_PNR, // PENRYN
INTEL_NHM, // NEHALEM INTEL_NHM, // NEHALEM
@ -129,6 +136,13 @@ typedef enum
INTEL_ICL, // ICE LAKE INTEL_ICL, // ICE LAKE
INTEL_TGL, // TIGER LAKE INTEL_TGL, // TIGER LAKE
INTEL_SPR, // SAPPHIRE RAPIDS INTEL_SPR, // SAPPHIRE RAPIDS
INTEL_ADL, // ALDER LAKE
INTEL_RCL, // ROCKET LAKE
INTEL_KNIGHTS_M, // KNIGHTS MILL
INTEL_KNIGHTS_L, // KNIGHTS LANDING
INTEL_KNIGHTS_F, // KNIGHTS FERRY
INTEL_KNIGHTS_C, // KNIGHTS CORNER
INTEL_NETBURST, // NETBURST
AMD_HAMMER, // K8 HAMMER AMD_HAMMER, // K8 HAMMER
AMD_K10, // K10 AMD_K10, // K10
AMD_K11, // K11 AMD_K11, // K11
@ -144,6 +158,7 @@ typedef enum
AMD_ZEN_PLUS, // K17 ZEN+ AMD_ZEN_PLUS, // K17 ZEN+
AMD_ZEN2, // K17 ZEN 2 AMD_ZEN2, // K17 ZEN 2
AMD_ZEN3, // K19 ZEN 3 AMD_ZEN3, // K19 ZEN 3
X86_MICROARCHITECTURE_LAST_,
} X86Microarchitecture; } X86Microarchitecture;
// Returns the underlying microarchitecture by looking at X86Info's vendor, // Returns the underlying microarchitecture by looking at X86Info's vendor,
@ -153,7 +168,7 @@ X86Microarchitecture GetX86Microarchitecture(const X86Info* info);
// Calls cpuid and fills the brand_string. // Calls cpuid and fills the brand_string.
// - brand_string *must* be of size 49 (beware of array decaying). // - brand_string *must* be of size 49 (beware of array decaying).
// - brand_string will be zero terminated. // - brand_string will be zero terminated.
// - This function calls memcpy. CPU_FEATURES_DEPRECATED("brand_string is now embedded in X86Info by default")
void FillX86BrandString(char brand_string[49]); void FillX86BrandString(char brand_string[49]);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -237,4 +252,4 @@ CPU_FEATURES_END_CPP_NAMESPACE
#error "Including cpuinfo_x86.h from a non-x86 target." #error "Including cpuinfo_x86.h from a non-x86 target."
#endif #endif
#endif // CPU_FEATURES_INCLUDE_CPUINFO_X86_H #endif // CPU_FEATURES_INCLUDE_CPUINFO_X86_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_ #ifndef CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_
#define CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_ #define CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_ #ifndef CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_
#define CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_ #define CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// An interface for the filesystem that allows mocking the filesystem in // An interface for the filesystem that allows mocking the filesystem in
// unittests. // unittests.
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_ #ifndef CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// Interface to retrieve hardware capabilities. It relies on Linux's getauxval // Interface to retrieve hardware capabilities. It relies on Linux's getauxval
// or `/proc/self/auxval` under the hood. // or `/proc/self/auxval` under the hood.
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_ #ifndef CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// Reads a file line by line and stores the data on the stack. This allows // Reads a file line by line and stores the data on the stack. This allows
// parsing files in one go without allocating. // parsing files in one go without allocating.
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_ #ifndef CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_

View File

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// A view over a piece of string. The view is not 0 terminated. // A view over a piece of string. The view is not 0 terminated.
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_ #ifndef CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_
#define CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_ #define CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_

View File

@ -3,210 +3,365 @@
# SPDX-FileCopyrightText: 2017 Google LLC # SPDX-FileCopyrightText: 2017 Google LLC
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
readonly SCRIPT_FOLDER=$(cd -P -- "$(dirname -- "$0")" && pwd -P) set -eo pipefail
readonly PROJECT_FOLDER="${SCRIPT_FOLDER}/.."
readonly ARCHIVE_FOLDER=~/cpu_features_archives
readonly QEMU_INSTALL=${ARCHIVE_FOLDER}/qemu
readonly DEFAULT_CMAKE_ARGS=" -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON"
function extract() { function extract() {
echo "Extracting ${1}..."
case $1 in case $1 in
*.tar.bz2) tar xjf "$1" ;; *.tar.bz2) tar xjf "$1" ;;
*.tar.xz) tar xJf "$1" ;; *.tar.xz) tar xJf "$1" ;;
*.tar.gz) tar xzf "$1" ;; *.tar.gz) tar xzf "$1" ;;
*) *)
echo "don't know how to extract '$1'..." >&2 echo "don't know how to extract '$1'..."
exit 1 exit 1
esac esac
} }
function unpackifnotexists() { function unpack() {
mkdir -p "${ARCHIVE_FOLDER}" mkdir -p "${ARCHIVE_DIR}"
cd "${ARCHIVE_FOLDER}" || exit cd "${ARCHIVE_DIR}" || exit 2
local URL=$1 local -r URL=$1
local RELATIVE_FOLDER=$2 local -r RELATIVE_DIR=$2
local DESTINATION="${ARCHIVE_FOLDER}/${RELATIVE_FOLDER}" local -r DESTINATION="${ARCHIVE_DIR}/${RELATIVE_DIR}"
if [[ ! -d "${DESTINATION}" ]] ; then if [[ ! -d "${DESTINATION}" ]] ; then
local ARCHIVE_NAME=$(echo ${URL} | sed 's/.*\///') echo "Downloading ${URL}..."
test -f "${ARCHIVE_NAME}" || wget -q "${URL}" local -r ARCHIVE_NAME=$(basename "${URL}")
test -f "${ARCHIVE_NAME}" || wget --no-verbose "${URL}"
extract "${ARCHIVE_NAME}" extract "${ARCHIVE_NAME}"
rm -f "${ARCHIVE_NAME}" rm -f "${ARCHIVE_NAME}"
fi fi
} }
function installqemuifneeded() { function install_qemu() {
local VERSION=${QEMU_VERSION:=2.11.1} if [[ "${QEMU_ARCH}" == "DISABLED" ]]; then
local ARCHES=${QEMU_ARCHES:=arm aarch64 i386 x86_64 mips mipsel mips64 mips64el} >&2 echo 'QEMU is disabled !'
local TARGETS=${QEMU_TARGETS:=$(echo "$ARCHES" | sed 's#$# #;s#\([^ ]*\) #\1-linux-user #g')} return 0
fi
local -r QEMU_VERSION=${QEMU_VERSION:=5.2.0}
local -r QEMU_TARGET=${QEMU_ARCH}-linux-user
if echo "${VERSION} ${TARGETS}" | cmp --silent ${QEMU_INSTALL}/.build -; then if echo "${QEMU_VERSION} ${QEMU_TARGET}" | cmp --silent "${QEMU_INSTALL}/.build" -; then
echo "qemu ${VERSION} up to date!" echo "qemu ${QEMU_VERSION} up to date!"
return 0 return 0
fi fi
echo "VERSION: ${VERSION}" echo "QEMU_VERSION: ${QEMU_VERSION}"
echo "TARGETS: ${TARGETS}" echo "QEMU_TARGET: ${QEMU_TARGET}"
rm -rf ${QEMU_INSTALL} rm -rf "${QEMU_INSTALL}"
# Checking for a tarball before downloading makes testing easier :-) # Checking for a tarball before downloading makes testing easier :-)
local QEMU_URL="http://wiki.qemu-project.org/download/qemu-${VERSION}.tar.xz" local -r QEMU_URL="http://wiki.qemu-project.org/download/qemu-${QEMU_VERSION}.tar.xz"
local QEMU_FOLDER="qemu-${VERSION}" local -r QEMU_DIR="qemu-${QEMU_VERSION}"
unpackifnotexists ${QEMU_URL} ${QEMU_FOLDER} unpack ${QEMU_URL} ${QEMU_DIR}
cd ${QEMU_FOLDER} || exit cd ${QEMU_DIR} || exit 2
# Qemu (meson based build) depends on: pkgconf, libglib2.0, python3, ninja
./configure \ ./configure \
--prefix="${QEMU_INSTALL}" \ --prefix="${QEMU_INSTALL}" \
--target-list="${TARGETS}" \ --target-list="${QEMU_TARGET}" \
--disable-docs \ --audio-drv-list= \
--disable-sdl \ --disable-brlapi \
--disable-gtk \ --disable-curl \
--disable-gnutls \
--disable-gcrypt \
--disable-nettle \
--disable-curses \ --disable-curses \
--static --disable-docs \
--disable-gcrypt \
--disable-gnutls \
--disable-gtk \
--disable-libnfs \
--disable-libssh \
--disable-nettle \
--disable-opengl \
--disable-sdl \
--disable-virglrenderer \
--disable-vte \
--enable-modules
make -j4 # --static Not supported on Archlinux
# so we use --enable-modules
# wrapper on ninja
make -j8
make install make install
echo "$VERSION $TARGETS" > ${QEMU_INSTALL}/.build echo "$QEMU_VERSION $QEMU_TARGET" > "${QEMU_INSTALL}/.build"
} }
function assert_defined(){ function assert_defined(){
local VALUE=${1} if [[ -z "${!1}" ]]; then
: "${VALUE?"${1} needs to be defined"}" >&2 echo "Variable '${1}' must be defined"
exit 1
fi
} }
function integrate() { function clean_build() {
cd "${PROJECT_FOLDER}" # Cleanup previous build
case "${OS}" in rm -rf "${BUILD_DIR}"
"Windows_NT") CMAKE_BUILD_ARGS="--config Debug --target ALL_BUILD" mkdir -p "${BUILD_DIR}"
CMAKE_TEST_FILES="${BUILD_DIR}/test/Debug/*_test.exe"
DEMO=${BUILD_DIR}/Debug/list_cpu_features.exe
;;
*) CMAKE_BUILD_ARGS="--target all"
CMAKE_TEST_FILES="${BUILD_DIR}/test/*_test"
DEMO=${BUILD_DIR}/list_cpu_features
;;
esac
# Generating CMake configuration
cmake -H. -B"${BUILD_DIR}" ${DEFAULT_CMAKE_ARGS} "${CMAKE_ADDITIONAL_ARGS[@]}" -G"${CMAKE_GENERATOR:-Unix Makefiles}"
# Building
cmake --build "${BUILD_DIR}" ${CMAKE_BUILD_ARGS}
# Running tests if needed
if [[ "${QEMU_ARCH}" == "DISABLED" ]]; then
return
fi
RUN_CMD=""
if [[ -n "${QEMU_ARCH}" ]]; then
installqemuifneeded
RUN_CMD="${QEMU_INSTALL}/bin/qemu-${QEMU_ARCH} ${QEMU_ARGS[@]}"
fi
for test_binary in ${CMAKE_TEST_FILES}; do
${RUN_CMD} ${test_binary}
done
${RUN_CMD} ${DEMO}
} }
function expand_linaro_config() { function expand_linaro_config() {
assert_defined TARGET #ref: https://releases.linaro.org/components/toolchain/binaries/
local LINARO_ROOT_URL=https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11 local -r LINARO_VERSION=7.5-2019.12
local -r LINARO_ROOT_URL=https://releases.linaro.org/components/toolchain/binaries/${LINARO_VERSION}
local GCC_URL=${LINARO_ROOT_URL}/${TARGET}/gcc-linaro-7.2.1-2017.11-x86_64_${TARGET}.tar.xz local -r GCC_VERSION=7.5.0-2019.12
local GCC_RELATIVE_FOLDER="gcc-linaro-7.2.1-2017.11-x86_64_${TARGET}" local -r GCC_URL=${LINARO_ROOT_URL}/${TARGET}/gcc-linaro-${GCC_VERSION}-x86_64_${TARGET}.tar.xz
unpackifnotexists "${GCC_URL}" "${GCC_RELATIVE_FOLDER}" local -r GCC_RELATIVE_DIR="gcc-linaro-${GCC_VERSION}-x86_64_${TARGET}"
unpack "${GCC_URL}" "${GCC_RELATIVE_DIR}"
local SYSROOT_URL=${LINARO_ROOT_URL}/${TARGET}/sysroot-glibc-linaro-2.25-2017.11-${TARGET}.tar.xz local -r SYSROOT_VERSION=2.25-2019.12
local SYSROOT_RELATIVE_FOLDER=sysroot-glibc-linaro-2.25-2017.11-${TARGET} local -r SYSROOT_URL=${LINARO_ROOT_URL}/${TARGET}/sysroot-glibc-linaro-${SYSROOT_VERSION}-${TARGET}.tar.xz
unpackifnotexists "${SYSROOT_URL}" "${SYSROOT_RELATIVE_FOLDER}" local -r SYSROOT_RELATIVE_DIR=sysroot-glibc-linaro-${SYSROOT_VERSION}-${TARGET}
unpack "${SYSROOT_URL}" "${SYSROOT_RELATIVE_DIR}"
local SYSROOT_FOLDER=${ARCHIVE_FOLDER}/${SYSROOT_RELATIVE_FOLDER} local -r SYSROOT_DIR=${ARCHIVE_DIR}/${SYSROOT_RELATIVE_DIR}
local GCC_FOLDER=${ARCHIVE_FOLDER}/${GCC_RELATIVE_FOLDER} local -r STAGING_DIR=${ARCHIVE_DIR}/${SYSROOT_RELATIVE_DIR}-stage
local -r GCC_DIR=${ARCHIVE_DIR}/${GCC_RELATIVE_DIR}
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_SYSTEM_NAME=Linux) # Write a Toolchain file
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_SYSTEM_PROCESSOR=${TARGET}) # note: This is manadatory to use a file in order to have the CMake variable
# 'CMAKE_CROSSCOMPILING' set to TRUE.
# ref: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-linux
cat >"$TOOLCHAIN_FILE" <<EOL
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ${TARGET})
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_SYSROOT=${SYSROOT_FOLDER}) set(CMAKE_SYSROOT ${SYSROOT_DIR})
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_C_COMPILER=${GCC_FOLDER}/bin/${TARGET}-gcc) set(CMAKE_STAGING_PREFIX ${STAGING_DIR})
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_CXX_COMPILER=${GCC_FOLDER}/bin/${TARGET}-g++)
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER) set(tools ${GCC_DIR})
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY) set(CMAKE_C_COMPILER \${tools}/bin/${TARGET}-gcc)
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY) set(CMAKE_CXX_COMPILER \${tools}/bin/${TARGET}-g++)
QEMU_ARGS+=(-L ${SYSROOT_FOLDER}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
EOL
CMAKE_ADDITIONAL_ARGS+=( -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" )
QEMU_ARGS+=( -L "${SYSROOT_DIR}" )
QEMU_ARGS+=( -E LD_LIBRARY_PATH=/lib ) QEMU_ARGS+=( -E LD_LIBRARY_PATH=/lib )
} }
function expand_codescape_config() { function expand_codescape_config() {
assert_defined TARGET # ref: https://codescape.mips.com/components/toolchain/2020.06-01/downloads.html
local DATE=2017.10-08 # ref: https://codescape.mips.com/components/toolchain/2019.02-04/downloads.html
local CODESCAPE_URL=https://codescape.mips.com/components/toolchain/${DATE}/Codescape.GNU.Tools.Package.${DATE}.for.MIPS.MTI.Linux.CentOS-5.x86_64.tar.gz local -r DATE=2020.06-01
local GCC_URL=${CODESCAPE_URL} #local -r DATE=2019.02-04
local GCC_RELATIVE_FOLDER="mips-mti-linux-gnu/${DATE}" local -r CODESCAPE_URL=https://codescape.mips.com/components/toolchain/${DATE}/Codescape.GNU.Tools.Package.${DATE}.for.MIPS.MTI.Linux.CentOS-6.x86_64.tar.gz
unpackifnotexists "${GCC_URL}" "${GCC_RELATIVE_FOLDER}" #local -r CODESCAPE_URL=https://codescape.mips.com/components/toolchain/${DATE}/Codescape.GNU.Tools.Package.${DATE}.for.MIPS.IMG.Linux.CentOS-6.x86_64.tar.gz
local -r GCC_URL=${CODESCAPE_URL}
local -r GCC_RELATIVE_DIR="mips-mti-linux-gnu/${DATE}"
#local -r GCC_RELATIVE_DIR="mips-img-linux-gnu/${DATE}"
unpack "${GCC_URL}" "${GCC_RELATIVE_DIR}"
local GCC_FOLDER=${ARCHIVE_FOLDER}/${GCC_RELATIVE_FOLDER} local -r GCC_DIR=${ARCHIVE_DIR}/${GCC_RELATIVE_DIR}
local MIPS_FLAGS="" local MIPS_FLAGS=""
local LIBC_FOLDER_SUFFIX="" local LIBC_DIR_SUFFIX=""
local FLAVOUR="" local FLAVOUR=""
case "${TARGET}" in case "${TARGET}" in
"mips32") MIPS_FLAGS="-EB -mabi=32"; FLAVOUR="mips-r2-hard"; LIBC_FOLDER_SUFFIX="lib" ;; "mips32")
"mips32el") MIPS_FLAGS="-EL -mabi=32"; FLAVOUR="mipsel-r2-hard"; LIBC_FOLDER_SUFFIX="lib" ;; MIPS_FLAGS="-EB -mips32r6 -mabi=32"
"mips64") MIPS_FLAGS="-EB -mabi=64"; FLAVOUR="mips-r2-hard"; LIBC_FOLDER_SUFFIX="lib64" ;; FLAVOUR="mips-r6-hard"
"mips64el") MIPS_FLAGS="-EL -mabi=64"; FLAVOUR="mipsel-r2-hard"; LIBC_FOLDER_SUFFIX="lib64" ;; #MIPS_FLAGS="-EB -mips32r2 -mabi=32"
*) echo 'unknown mips platform'; exit 1;; #FLAVOUR="mips-r2-hard"
LIBC_DIR_SUFFIX="lib"
;;
"mips32el")
MIPS_FLAGS="-EL -mips32r6 -mabi=32"
FLAVOUR="mipsel-r6-hard"
#MIPS_FLAGS="-EL -mips32r2 -mabi=32"
#FLAVOUR="mipsel-r2-hard"
LIBC_DIR_SUFFIX="lib"
;;
"mips64")
MIPS_FLAGS="-EB -mips64r6 -mabi=64"
FLAVOUR="mips-r6-hard"
#FLAVOUR="mips-r2-hard"
LIBC_DIR_SUFFIX="lib64"
;;
"mips64el")
MIPS_FLAGS="-EL -mips64r6 -mabi=64"
FLAVOUR="mipsel-r6-hard"
#FLAVOUR="mipsel-r2-hard"
LIBC_DIR_SUFFIX="lib64"
;;
*)
>&2 echo 'unknown mips platform'
exit 1 ;;
esac esac
local -r SYSROOT_DIR=${GCC_DIR}/sysroot
local -r STAGING_DIR=${SYSROOT_DIR}-stage
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_FIND_ROOT_PATH=${GCC_FOLDER}) # Write a Toolchain file
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_SYSTEM_NAME=Linux) # note: This is manadatory to use a file in order to have the CMake variable
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_SYSTEM_PROCESSOR=${TARGET}) # 'CMAKE_CROSSCOMPILING' set to TRUE.
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_C_COMPILER=mips-mti-linux-gnu-gcc) # ref: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-linux
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_CXX_COMPILER=mips-mti-linux-gnu-g++) cat >"${TOOLCHAIN_FILE}" <<EOL
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_C_COMPILER_ARG1="${MIPS_FLAGS}") set(CMAKE_SYSTEM_NAME Linux)
CMAKE_ADDITIONAL_ARGS+=(-DCMAKE_CXX_COMPILER_ARG1="${MIPS_FLAGS}") set(CMAKE_SYSTEM_PROCESSOR ${TARGET})
local SYSROOT_FOLDER=${GCC_FOLDER}/sysroot/${FLAVOUR} set(CMAKE_SYSROOT ${SYSROOT_DIR})
set(CMAKE_STAGING_PREFIX ${STAGING_DIR})
# Keeping only the sysroot of interest to save on travis cache. set(tools ${GCC_DIR})
if [[ "${CONTINUOUS_INTEGRATION}" = "true" ]]; then
for folder in ${GCC_FOLDER}/sysroot/*; do
if [[ "${folder}" != "${SYSROOT_FOLDER}" ]]; then
rm -rf ${folder}
fi
done
fi
local LIBC_FOLDER=${GCC_FOLDER}/mips-mti-linux-gnu/lib/${FLAVOUR}/${LIBC_FOLDER_SUFFIX} set(CMAKE_C_COMPILER \${tools}/bin/mips-mti-linux-gnu-gcc)
QEMU_ARGS+=(-L ${SYSROOT_FOLDER}) #set(CMAKE_C_COMPILER \${tools}/bin/mips-img-linux-gnu-gcc)
QEMU_ARGS+=(-E LD_PRELOAD=${LIBC_FOLDER}/libstdc++.so.6:${LIBC_FOLDER}/libgcc_s.so.1) set(CMAKE_C_FLAGS "${MIPS_FLAGS}")
set(CMAKE_CXX_COMPILER \${tools}/bin/mips-mti-linux-gnu-g++)
#set(CMAKE_CXX_COMPILER \${tools}/bin/mips-img-linux-gnu-g++)
set(CMAKE_CXX_FLAGS "${MIPS_FLAGS}")
set(CMAKE_FIND_ROOT_PATH ${GCC_DIR})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
EOL
CMAKE_ADDITIONAL_ARGS+=( -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" )
QEMU_ARGS+=( -L "${SYSROOT_DIR}/${FLAVOUR}" )
local -r LIBC_DIR=${GCC_DIR}/mips-mti-linux-gnu/lib/${FLAVOUR}/${LIBC_DIR_SUFFIX}
#local -r LIBC_DIR=${GCC_DIR}/mips-img-linux-gnu/lib/${FLAVOUR}/${LIBC_DIR_SUFFIX}
QEMU_ARGS+=( -E LD_PRELOAD="${LIBC_DIR}/libstdc++.so.6:${LIBC_DIR}/libgcc_s.so.1" )
} }
function expand_environment_and_integrate() { function build() {
assert_defined PROJECT_FOLDER cd "${PROJECT_DIR}" || exit 2
set -x
clean_build
cmake -S. -B"${BUILD_DIR}" "${CMAKE_DEFAULT_ARGS[@]}" "${CMAKE_ADDITIONAL_ARGS[@]}"
cmake --build "${BUILD_DIR}" --target all -j8 -v
set +x
}
function run_test() {
assert_defined QEMU_ARCH
if [[ "${QEMU_ARCH}" == "DISABLED" ]]; then
>&2 echo "QEMU is disabled for ${TARGET}"
return
fi
install_qemu
RUN_CMD="${QEMU_INSTALL}/bin/qemu-${QEMU_ARCH} ${QEMU_ARGS[*]}"
cd "${BUILD_DIR}" || exit 2
set -x
for test_binary in "${BUILD_DIR}"/list_cpu_feature* ; do
${RUN_CMD} "${test_binary}"
done
set +x
}
function usage() {
local -r NAME=$(basename "$0")
echo -e "$NAME - Build using a cross toolchain.
SYNOPSIS
\t$NAME [-h|--help] [toolchain|build|qemu|test|all]
DESCRIPTION
\tCross compile using a cross toolchain.
\tYou MUST define the following variables before running this script:
\t* TARGET:
\t\tx86_64
\t\taarch64-linux-gnu aarch64_be-linux-gnu
\t\tarm-linux-gnueabihf armv8l-linux-gnueabihf arm-linux-gnueabi
\t\tarmeb-linux-gnueabihf armeb-linux-gnueabi
\t\tmips32 mips32el
\t\tmips64 mips64el
OPTIONS
\t-h --help: show this help text
\ttoolchain: download, unpack toolchain and generate CMake toolchain file
\tbuild: toolchain + build the project using the toolchain file (note: remove previous build dir)
\tqemu: download, unpack and build qemu
\ttest: qemu + run all executable using qemu (note: don't build !)
\tall: build + test (default)
EXAMPLES
* Using export:
export TARGET=aarch64-linux-gnu
$0
* One-liner:
TARGET=aarch64-linux-gnu $0"
}
# Main
function main() {
case ${1} in
-h | --help)
usage; exit ;;
esac
assert_defined TARGET assert_defined TARGET
BUILD_DIR="${PROJECT_FOLDER}/cmake_build/${TARGET}" declare -r PROJECT_DIR="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
mkdir -p "${BUILD_DIR}" declare -r ARCHIVE_DIR="${PROJECT_DIR}/build_cross/archives"
declare -r BUILD_DIR="${PROJECT_DIR}/build_cross/${TARGET}"
declare -r TOOLCHAIN_FILE=${ARCHIVE_DIR}/toolchain_${TARGET}.cmake
declare -a CONFIG_NAMES=() echo "Target: '${TARGET}'"
declare -a QEMU_ARGS=()
echo "Project dir: '${PROJECT_DIR}'"
echo "Archive dir: '${ARCHIVE_DIR}'"
echo "Build dir: '${BUILD_DIR}'"
echo "toolchain file: '${TOOLCHAIN_FILE}'"
declare -a CMAKE_DEFAULT_ARGS=( -G ${CMAKE_GENERATOR:-"Ninja"} )
declare -a CMAKE_ADDITIONAL_ARGS=() declare -a CMAKE_ADDITIONAL_ARGS=()
case ${TOOLCHAIN} in declare -a QEMU_ARGS=()
LINARO) expand_linaro_config ;; case ${TARGET} in
CODESCAPE) expand_codescape_config ;; x86_64)
NATIVE) QEMU_ARCH="" ;; declare -r QEMU_ARCH=x86_64 ;;
*) echo "Unknown toolchain '${TOOLCHAIN}'..."; exit 1;; arm-linux-gnueabihf | armv8l-linux-gnueabihf | arm-linux-gnueabi)
expand_linaro_config
declare -r QEMU_ARCH=arm ;;
armeb-linux-gnueabihf | armeb-linux-gnueabi)
expand_linaro_config
declare -r QEMU_ARCH=DISABLED ;;
aarch64-linux-gnu)
expand_linaro_config
declare -r QEMU_ARCH=aarch64 ;;
aarch64_be-linux-gnu)
expand_linaro_config
declare -r QEMU_ARCH=DISABLED ;;
mips32)
expand_codescape_config
declare -r QEMU_ARCH=mips ;;
mips32el)
expand_codescape_config
declare -r QEMU_ARCH=mipsel ;;
mips64)
expand_codescape_config
declare -r QEMU_ARCH=mips64 ;;
mips64el)
expand_codescape_config
declare -r QEMU_ARCH=mips64el ;;
*)
>&2 echo "Unknown TARGET '${TARGET}'..."
exit 1 ;;
esac
declare -r QEMU_INSTALL=${ARCHIVE_DIR}/qemu-${QEMU_ARCH}
case ${1} in
toolchain)
exit ;;
build)
build ;;
qemu)
install_qemu ;;
test)
run_test ;;
*)
build
run_test ;;
esac esac
integrate
} }
if [ "${CONTINUOUS_INTEGRATION}" = "true" ]; then main "${1:-all}"
QEMU_ARCHES=${QEMU_ARCH}
expand_environment_and_integrate
fi

View File

@ -3,85 +3,59 @@
# SPDX-FileCopyrightText: 2017 Google LLC # SPDX-FileCopyrightText: 2017 Google LLC
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
source "$(dirname -- "$0")"/run_integration.sh
# Toolchains for little-endian, 64-bit ARMv8 for GNU/Linux systems # Toolchains for little-endian, 64-bit ARMv8 for GNU/Linux systems
function set_aarch64-linux-gnu() { function set_aarch64-linux-gnu() {
TOOLCHAIN=LINARO export TARGET=aarch64-linux-gnu
TARGET=aarch64-linux-gnu
QEMU_ARCH=aarch64
} }
# Toolchains for little-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems # Toolchains for little-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems
function set_arm-linux-gnueabihf() { function set_arm-linux-gnueabihf() {
TOOLCHAIN=LINARO export TARGET=arm-linux-gnueabihf
TARGET=arm-linux-gnueabihf
QEMU_ARCH=arm
} }
# Toolchains for little-endian, 32-bit ARMv8 for GNU/Linux systems # Toolchains for little-endian, 32-bit ARMv8 for GNU/Linux systems
function set_armv8l-linux-gnueabihf() { function set_armv8l-linux-gnueabihf() {
TOOLCHAIN=LINARO export TARGET=armv8l-linux-gnueabihf
TARGET=armv8l-linux-gnueabihf
QEMU_ARCH=arm
} }
# Toolchains for little-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems # Toolchains for little-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems
function set_arm-linux-gnueabi() { function set_arm-linux-gnueabi() {
TOOLCHAIN=LINARO export TARGET=arm-linux-gnueabi
TARGET=arm-linux-gnueabi
QEMU_ARCH=arm
} }
# Toolchains for big-endian, 64-bit ARMv8 for GNU/Linux systems # Toolchains for big-endian, 64-bit ARMv8 for GNU/Linux systems
function set_aarch64_be-linux-gnu() { function set_aarch64_be-linux-gnu() {
TOOLCHAIN=LINARO export TARGET=aarch64_be-linux-gnu
TARGET=aarch64_be-linux-gnu
QEMU_ARCH=DISABLED
} }
# Toolchains for big-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems # Toolchains for big-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems
function set_armeb-linux-gnueabihf() { function set_armeb-linux-gnueabihf() {
TOOLCHAIN=LINARO export TARGET=armeb-linux-gnueabihf
TARGET=armeb-linux-gnueabihf
QEMU_ARCH=DISABLED
} }
# Toolchains for big-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems # Toolchains for big-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems
function set_armeb-linux-gnueabi() { function set_armeb-linux-gnueabi() {
TOOLCHAIN=LINARO export TARGET=armeb-linux-gnueabi
TARGET=armeb-linux-gnueabi
QEMU_ARCH=DISABLED
} }
function set_mips32() { function set_mips32() {
TOOLCHAIN=CODESCAPE export TARGET=mips32
TARGET=mips32
QEMU_ARCH=mips
} }
function set_mips32el() { function set_mips32el() {
TOOLCHAIN=CODESCAPE export TARGET=mips32el
TARGET=mips32el
QEMU_ARCH=mipsel
} }
function set_mips64() { function set_mips64() {
TOOLCHAIN=CODESCAPE export TARGET=mips64
TARGET=mips64
QEMU_ARCH=mips64
} }
function set_mips64el() { function set_mips64el() {
TOOLCHAIN=CODESCAPE export TARGET=mips64el
TARGET=mips64el
QEMU_ARCH=mips64el
} }
function set_native() { function set_x86_64() {
TOOLCHAIN=NATIVE export TARGET=x86_64
TARGET=native
QEMU_ARCH=""
} }
ENVIRONMENTS=" ENVIRONMENTS="
@ -96,14 +70,13 @@ ENVIRONMENTS="
set_mips32el set_mips32el
set_mips64 set_mips64
set_mips64el set_mips64el
set_native set_x86_64
" "
set -e set -e
CMAKE_GENERATOR="Ninja"
for SET_ENVIRONMENT in ${ENVIRONMENTS}; do for SET_ENVIRONMENT in ${ENVIRONMENTS}; do
echo "testing ${SET_ENVIRONMENT}"
${SET_ENVIRONMENT} ${SET_ENVIRONMENT}
expand_environment_and_integrate ./"$(dirname -- "$0")"/run_integration.sh
done done

View File

@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include <stddef.h>
static void copy(char *__restrict dst, const char *src, size_t count)
{
for (size_t i = 0; i < count; ++i) dst[i] = src[i];
}

View File

@ -1,210 +0,0 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "cpuinfo_aarch64.h"
#include "internal/filesystem.h"
#include "internal/hwcaps.h"
#include "internal/stack_line_reader.h"
#include "internal/string_view.h"
#include <assert.h>
#include <ctype.h>
#if defined(CPU_FEATURES_OS_DARWIN)
#if !defined(HAVE_SYSCTLBYNAME)
#error "Darwin needs support for sysctlbyname"
#endif
#include <sys/sysctl.h>
#if defined(CPU_FEATURES_MOCK_CPUID_ARM64)
extern bool GetDarwinSysCtlByName(const char*);
extern int GetDarwinSysCtlByNameValue(const char*);
#else // CPU_FEATURES_MOCK_CPUID_ARM64
static bool GetDarwinSysCtlByName(const char* name)
{
int enabled;
size_t enabled_len = sizeof(enabled);
const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0);
return failure ? false : enabled;
}
static int GetDarwinSysCtlByNameValue(const char* name)
{
int enabled;
size_t enabled_len = sizeof(enabled);
const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0);
return failure ? 0 : enabled;
}
#endif
#endif // CPU_FEATURES_OS_DARWIN
// Generation of feature's getters/setters functions and kGetters, kSetters,
// kCpuInfoFlags and kHardwareCapabilities global tables.
#define DEFINE_TABLE_FEATURES \
FEATURE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \
FEATURE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \
FEATURE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \
FEATURE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \
FEATURE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \
FEATURE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \
FEATURE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \
FEATURE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \
FEATURE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \
FEATURE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \
FEATURE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \
FEATURE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \
FEATURE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \
FEATURE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \
FEATURE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \
FEATURE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \
FEATURE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \
FEATURE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \
FEATURE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \
FEATURE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \
FEATURE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \
FEATURE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \
FEATURE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \
FEATURE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \
FEATURE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \
FEATURE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \
FEATURE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \
FEATURE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \
FEATURE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \
FEATURE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \
FEATURE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \
FEATURE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \
FEATURE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \
FEATURE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \
FEATURE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \
FEATURE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \
FEATURE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \
AARCH64_HWCAP2_SVEBITPERM) \
FEATURE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \
FEATURE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \
FEATURE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \
FEATURE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \
FEATURE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \
FEATURE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \
FEATURE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \
FEATURE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \
FEATURE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \
FEATURE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \
FEATURE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \
FEATURE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \
FEATURE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \
FEATURE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE)
#define DEFINE_TABLE_FEATURE_TYPE Aarch64Features
#include "define_tables.h"
#if !defined(CPU_FEATURES_OS_DARWIN)
static bool HandleAarch64Line(const LineResult result,
Aarch64Info* const info)
{
StringView line = result.line;
StringView key, value;
if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value))
{
if (CpuFeatures_StringView_IsEquals(key, str("Features")))
{
for (size_t i = 0; i < AARCH64_LAST_; ++i)
{
kSetters[i](&info->features, CpuFeatures_StringView_HasWord(
value, kCpuInfoFlags[i], ' '));
}
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU implementer")))
{
info->implementer = CpuFeatures_StringView_ParsePositiveNumber(value);
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU variant")))
{
info->variant = CpuFeatures_StringView_ParsePositiveNumber(value);
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU part")))
{
info->part = CpuFeatures_StringView_ParsePositiveNumber(value);
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU revision")))
{
info->revision = CpuFeatures_StringView_ParsePositiveNumber(value);
}
}
return !result.eof;
}
static void FillProcCpuInfoData(Aarch64Info* const info)
{
const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
if (fd >= 0)
{
StackLineReader reader;
StackLineReader_Initialize(&reader, fd);
for (;;)
{
if (!HandleAarch64Line(StackLineReader_NextLine(&reader), info))
{
break;
}
}
CpuFeatures_CloseFile(fd);
}
}
#endif /* !CPU_FEATURES_OS_DARWIN */
static const Aarch64Info kEmptyAarch64Info;
Aarch64Info GetAarch64Info(void)
{
// capabilities are fetched from both getauxval and /proc/cpuinfo so we can
// have some information if the executable is sandboxed (aka no access to
// /proc/cpuinfo).
Aarch64Info info = kEmptyAarch64Info;
#if defined(CPU_FEATURES_OS_DARWIN)
// Handling Darwin platform through sysctlbyname
info.implementer = GetDarwinSysCtlByNameValue("hw.cputype");
info.variant = GetDarwinSysCtlByNameValue("hw.cpusubtype");
info.part = GetDarwinSysCtlByNameValue("hw.cpufamily");
info.revision = GetDarwinSysCtlByNameValue("hw.cpusubfamily");
info.features.fp = GetDarwinSysCtlByName("hw.optional.floatingpoint");
info.features.fphp = GetDarwinSysCtlByName("hw.optional.neon_hpfp");
info.features.sha512 = GetDarwinSysCtlByName("hw.optional.armv8_2_sha512");
info.features.atomics = GetDarwinSysCtlByName("hw.optional.armv8_1_atomics");
info.features.asimdfhm = GetDarwinSysCtlByName("hw.optional.armv8_2_fhm");
info.features.sha3 = GetDarwinSysCtlByName("hw.optional.armv8_2_sha3");
info.features.crc32 = GetDarwinSysCtlByName("hw.optional.armv8_crc32");
#else
FillProcCpuInfoData(&info);
const HardwareCapabilities hwcaps = CpuFeatures_GetHardwareCapabilities();
for (size_t i = 0; i < AARCH64_LAST_; ++i)
{
if (CpuFeatures_IsHwCapsSet(kHardwareCapabilities[i], hwcaps))
{
kSetters[i](&info.features, true);
}
}
#endif
return info;
}
////////////////////////////////////////////////////////////////////////////////
// Introspection functions
int GetAarch64FeaturesEnumValue(const Aarch64Features* features,
Aarch64FeaturesEnum value)
{
if (value >= AARCH64_LAST_) return false;
return kGetters[value](features);
}
const char* GetAarch64FeaturesEnumName(Aarch64FeaturesEnum value)
{
if (value >= AARCH64_LAST_) return "unknown feature";
return kCpuInfoFlags[value];
}

View File

@ -1,175 +0,0 @@
// SPDX-FileCopyrightText: 2018 IBM.
// SPDX-License-Identifier: Apache-2.0
#include "cpuinfo_ppc.h"
#include "internal/bit_utils.h"
#include "internal/filesystem.h"
#include "internal/hwcaps.h"
#include "internal/stack_line_reader.h"
#include "internal/string_view.h"
#include <assert.h>
#include <stdbool.h>
#include <string.h>
// Generation of feature's getters/setters functions and kGetters, kSetters,
// kCpuInfoFlags and kHardwareCapabilities global tables.
#define DEFINE_TABLE_FEATURES \
FEATURE(PPC_32, ppc32, "ppc32", PPC_FEATURE_32, 0) \
FEATURE(PPC_64, ppc64, "ppc64", PPC_FEATURE_64, 0) \
FEATURE(PPC_601_INSTR, ppc601, "ppc601", PPC_FEATURE_601_INSTR, 0) \
FEATURE(PPC_HAS_ALTIVEC, altivec, "altivec", PPC_FEATURE_HAS_ALTIVEC, 0) \
FEATURE(PPC_HAS_FPU, fpu, "fpu", PPC_FEATURE_HAS_FPU, 0) \
FEATURE(PPC_HAS_MMU, mmu, "mmu", PPC_FEATURE_HAS_MMU, 0) \
FEATURE(PPC_HAS_4xxMAC, mac_4xx, "4xxmac", PPC_FEATURE_HAS_4xxMAC, 0) \
FEATURE(PPC_UNIFIED_CACHE, unifiedcache, "ucache", \
PPC_FEATURE_UNIFIED_CACHE, 0) \
FEATURE(PPC_HAS_SPE, spe, "spe", PPC_FEATURE_HAS_SPE, 0) \
FEATURE(PPC_HAS_EFP_SINGLE, efpsingle, "efpsingle", \
PPC_FEATURE_HAS_EFP_SINGLE, 0) \
FEATURE(PPC_HAS_EFP_DOUBLE, efpdouble, "efpdouble", \
PPC_FEATURE_HAS_EFP_DOUBLE, 0) \
FEATURE(PPC_NO_TB, no_tb, "notb", PPC_FEATURE_NO_TB, 0) \
FEATURE(PPC_POWER4, power4, "power4", PPC_FEATURE_POWER4, 0) \
FEATURE(PPC_POWER5, power5, "power5", PPC_FEATURE_POWER5, 0) \
FEATURE(PPC_POWER5_PLUS, power5plus, "power5+", PPC_FEATURE_POWER5_PLUS, 0) \
FEATURE(PPC_CELL, cell, "cellbe", PPC_FEATURE_CELL, 0) \
FEATURE(PPC_BOOKE, booke, "booke", PPC_FEATURE_BOOKE, 0) \
FEATURE(PPC_SMT, smt, "smt", PPC_FEATURE_SMT, 0) \
FEATURE(PPC_ICACHE_SNOOP, icachesnoop, "ic_snoop", PPC_FEATURE_ICACHE_SNOOP, \
0) \
FEATURE(PPC_ARCH_2_05, arch205, "arch_2_05", PPC_FEATURE_ARCH_2_05, 0) \
FEATURE(PPC_PA6T, pa6t, "pa6t", PPC_FEATURE_PA6T, 0) \
FEATURE(PPC_HAS_DFP, dfp, "dfp", PPC_FEATURE_HAS_DFP, 0) \
FEATURE(PPC_POWER6_EXT, power6ext, "power6x", PPC_FEATURE_POWER6_EXT, 0) \
FEATURE(PPC_ARCH_2_06, arch206, "arch_2_06", PPC_FEATURE_ARCH_2_06, 0) \
FEATURE(PPC_HAS_VSX, vsx, "vsx", PPC_FEATURE_HAS_VSX, 0) \
FEATURE(PPC_PSERIES_PERFMON_COMPAT, pseries_perfmon_compat, "archpmu", \
PPC_FEATURE_PSERIES_PERFMON_COMPAT, 0) \
FEATURE(PPC_TRUE_LE, truele, "true_le", PPC_FEATURE_TRUE_LE, 0) \
FEATURE(PPC_PPC_LE, ppcle, "ppcle", PPC_FEATURE_PPC_LE, 0) \
FEATURE(PPC_ARCH_2_07, arch207, "arch_2_07", 0, PPC_FEATURE2_ARCH_2_07) \
FEATURE(PPC_HTM, htm, "htm", 0, PPC_FEATURE2_HTM) \
FEATURE(PPC_DSCR, dscr, "dscr", 0, PPC_FEATURE2_DSCR) \
FEATURE(PPC_EBB, ebb, "ebb", 0, PPC_FEATURE2_EBB) \
FEATURE(PPC_ISEL, isel, "isel", 0, PPC_FEATURE2_ISEL) \
FEATURE(PPC_TAR, tar, "tar", 0, PPC_FEATURE2_TAR) \
FEATURE(PPC_VEC_CRYPTO, vcrypto, "vcrypto", 0, PPC_FEATURE2_VEC_CRYPTO) \
FEATURE(PPC_HTM_NOSC, htm_nosc, "htm-nosc", 0, PPC_FEATURE2_HTM_NOSC) \
FEATURE(PPC_ARCH_3_00, arch300, "arch_3_00", 0, PPC_FEATURE2_ARCH_3_00) \
FEATURE(PPC_HAS_IEEE128, ieee128, "ieee128", 0, PPC_FEATURE2_HAS_IEEE128) \
FEATURE(PPC_DARN, darn, "darn", 0, PPC_FEATURE2_DARN) \
FEATURE(PPC_SCV, scv, "scv", 0, PPC_FEATURE2_SCV) \
FEATURE(PPC_HTM_NO_SUSPEND, htm_no_suspend, "htm-no-suspend", 0, \
PPC_FEATURE2_HTM_NO_SUSPEND)
#define DEFINE_TABLE_FEATURE_TYPE PPCFeatures
#include "define_tables.h"
static bool HandlePPCLine(const LineResult result,
PPCPlatformStrings* const strings)
{
StringView line = result.line;
StringView key, value;
if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value))
{
if (CpuFeatures_StringView_HasWord(key, "platform", ' '))
{
CpuFeatures_StringView_CopyString(value, strings->platform,
sizeof(strings->platform));
}
else if (CpuFeatures_StringView_IsEquals(key, str("model")))
{
CpuFeatures_StringView_CopyString(value, strings->model,
sizeof(strings->platform));
}
else if (CpuFeatures_StringView_IsEquals(key, str("machine")))
{
CpuFeatures_StringView_CopyString(value, strings->machine,
sizeof(strings->platform));
}
else if (CpuFeatures_StringView_IsEquals(key, str("cpu")))
{
CpuFeatures_StringView_CopyString(value, strings->cpu,
sizeof(strings->platform));
}
}
return !result.eof;
}
static void FillProcCpuInfoData(PPCPlatformStrings* const strings)
{
const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
if (fd >= 0)
{
StackLineReader reader;
StackLineReader_Initialize(&reader, fd);
for (;;)
{
if (!HandlePPCLine(StackLineReader_NextLine(&reader), strings))
{
break;
}
}
CpuFeatures_CloseFile(fd);
}
}
static const PPCInfo kEmptyPPCInfo;
PPCInfo GetPPCInfo(void)
{
/*
* On Power feature flags aren't currently in cpuinfo so we only look at
* the auxilary vector.
*/
PPCInfo info = kEmptyPPCInfo;
const HardwareCapabilities hwcaps = CpuFeatures_GetHardwareCapabilities();
for (size_t i = 0; i < PPC_LAST_; ++i)
{
if (CpuFeatures_IsHwCapsSet(kHardwareCapabilities[i], hwcaps))
{
kSetters[i](&info.features, true);
}
}
return info;
}
static const PPCPlatformStrings kEmptyPPCPlatformStrings;
PPCPlatformStrings GetPPCPlatformStrings(void)
{
PPCPlatformStrings strings = kEmptyPPCPlatformStrings;
const char* platform = CpuFeatures_GetPlatformPointer();
const char* base_platform = CpuFeatures_GetBasePlatformPointer();
FillProcCpuInfoData(&strings);
if (platform != NULL)
{
CpuFeatures_StringView_CopyString(str(platform), strings.type.platform,
sizeof(strings.type.platform));
}
if (base_platform != NULL)
{
CpuFeatures_StringView_CopyString(str(base_platform),
strings.type.base_platform,
sizeof(strings.type.base_platform));
}
return strings;
}
////////////////////////////////////////////////////////////////////////////////
// Introspection functions
int GetPPCFeaturesEnumValue(const PPCFeatures* features,
PPCFeaturesEnum value)
{
if (value >= PPC_LAST_) return false;
return kGetters[value](features);
}
const char* GetPPCFeaturesEnumName(PPCFeaturesEnum value)
{
if (value >= PPC_LAST_) return "unknown feature";
return kCpuInfoFlags[value];
}

View File

@ -0,0 +1,79 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#ifndef INTROSPECTION_PREFIX
#error "missing INTROSPECTION_PREFIX"
#endif
#ifndef INTROSPECTION_ENUM_PREFIX
#error "missing INTROSPECTION_ENUM_PREFIX"
#endif
#ifndef INTROSPECTION_TABLE
#error "missing INTROSPECTION_TABLE"
#endif
#include <stdbool.h>
#define STRINGIZE_(s) #s
#define STRINGIZE(s) STRINGIZE_(s)
#define FEAT_TYPE_NAME__(X) X##Features
#define FEAT_TYPE_NAME_(X) FEAT_TYPE_NAME__(X)
#define FEAT_TYPE_NAME FEAT_TYPE_NAME_(INTROSPECTION_PREFIX)
#define FEAT_ENUM_NAME__(X) X##FeaturesEnum
#define FEAT_ENUM_NAME_(X) FEAT_ENUM_NAME__(X)
#define FEAT_ENUM_NAME FEAT_ENUM_NAME_(INTROSPECTION_PREFIX)
#define GET_FEAT_ENUM_VALUE__(X) Get##X##FeaturesEnumValue
#define GET_FEAT_ENUM_VALUE_(X) GET_FEAT_ENUM_VALUE__(X)
#define GET_FEAT_ENUM_VALUE GET_FEAT_ENUM_VALUE_(INTROSPECTION_PREFIX)
#define GET_FEAT_ENUM_NAME__(X) Get##X##FeaturesEnumName
#define GET_FEAT_ENUM_NAME_(X) GET_FEAT_ENUM_NAME__(X)
#define GET_FEAT_ENUM_NAME GET_FEAT_ENUM_NAME_(INTROSPECTION_PREFIX)
#define FEAT_ENUM_LAST__(X) X##_LAST_
#define FEAT_ENUM_LAST_(X) FEAT_ENUM_LAST__(X)
#define FEAT_ENUM_LAST FEAT_ENUM_LAST_(INTROSPECTION_ENUM_PREFIX)
// Generate individual getters and setters.
#define LINE(ENUM, NAME, A, B, C) \
static void set_##ENUM(FEAT_TYPE_NAME* features, bool value) \
{ \
features->NAME = value; \
} \
static int get_##ENUM(const FEAT_TYPE_NAME* features) \
{ \
return features->NAME; \
}
INTROSPECTION_TABLE
#undef LINE
// Generate getters table
#define LINE(ENUM, NAME, A, B, C) [ENUM] = get_##ENUM,
static int (*const kGetters[])(const FEAT_TYPE_NAME*) = {INTROSPECTION_TABLE};
#undef LINE
// Generate setters table
#define LINE(ENUM, NAME, A, B, C) [ENUM] = set_##ENUM,
static void (*const kSetters[])(FEAT_TYPE_NAME*, bool) = {INTROSPECTION_TABLE};
#undef LINE
// Implements the `GetXXXFeaturesEnumValue` API.
int GET_FEAT_ENUM_VALUE(const FEAT_TYPE_NAME* features, FEAT_ENUM_NAME value)
{
if (value >= FEAT_ENUM_LAST) return false;
return kGetters[value](features);
}
// Generate feature name table.
#define LINE(ENUM, NAME, A, B, C) [ENUM] = STRINGIZE(NAME),
static const char* kFeatureNames[] = {INTROSPECTION_TABLE};
#undef LINE
// Implements the `GetXXXFeaturesEnumName` API.
const char* GET_FEAT_ENUM_NAME(FEAT_ENUM_NAME value)
{
if (value >= FEAT_ENUM_LAST) return "unknown_feature";
return kFeatureNames[value];
}

View File

@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "internal/hwcaps.h"
#include "define_introspection.inl"
#define LINE(ENUM, NAME, CPUINFO_FLAG, HWCAP, HWCAP2) \
[ENUM] = (HardwareCapabilities){HWCAP, HWCAP2},
static const HardwareCapabilities kHardwareCapabilities[] = {
INTROSPECTION_TABLE};
#undef LINE
#define LINE(ENUM, NAME, CPUINFO_FLAG, HWCAP, HWCAP2) [ENUM] = CPUINFO_FLAG,
static const char* kCpuInfoFlags[] = {INTROSPECTION_TABLE};
#undef LINE

View File

@ -1,58 +0,0 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
// The following preprocessor constants must be defined before including this
// file:
// - DEFINE_TABLE_FEATURE_TYPE, the underlying type (e.g. X86Features)
// - DEFINE_TABLE_FEATURES, the list of FEATURE macros to be inserted.
// This file is to be included once per `cpuinfo_XXX.c` in order to construct
// feature getters and setters functions as well as several enum indexed tables
// from the db file.
// - `kGetters` a table of getters function pointers from feature enum to
// retrieve a feature,
// - `kSetters` a table of setters function pointers from feature enum to set a
// feature,
// - `kCpuInfoFlags` a table of strings from feature enum to /proc/cpuinfo
// flags,
// - `kHardwareCapabilities` a table of HardwareCapabilities structs indexed by
// their feature enum.
#ifndef SRC_DEFINE_TABLES_H_
#define SRC_DEFINE_TABLES_H_
#define FEATURE(ENUM, NAME, CPUINFO_FLAG, HWCAP, HWCAP2) [ENUM] = CPUINFO_FLAG,
static const char* kCpuInfoFlags[] = {DEFINE_TABLE_FEATURES};
#undef FEATURE
#ifndef DEFINE_TABLE_DONT_GENERATE_HWCAPS
#define FEATURE(ENUM, NAME, CPUINFO_FLAG, HWCAP, HWCAP2) \
[ENUM] = (HardwareCapabilities){HWCAP, HWCAP2},
static const HardwareCapabilities kHardwareCapabilities[] = {
DEFINE_TABLE_FEATURES};
#undef FEATURE
#endif // DEFINE_TABLE_DONT_GENERATE_HWCAPS
#define FEATURE(ENUM, NAME, CPUINFO_FLAG, HWCAP, HWCAP2) \
static void set_##ENUM(DEFINE_TABLE_FEATURE_TYPE* features, bool value) \
{ \
features->NAME = value; \
} \
static int get_##ENUM(const DEFINE_TABLE_FEATURE_TYPE* features) \
{ \
return features->NAME; \
}
DEFINE_TABLE_FEATURES
#undef FEATURE
#define FEATURE(ENUM, NAME, CPUINFO_FLAG, HWCAP, HWCAP2) [ENUM] = set_##ENUM,
static void (*const kSetters[])(DEFINE_TABLE_FEATURE_TYPE*,
bool) = {DEFINE_TABLE_FEATURES};
#undef FEATURE
#define FEATURE(ENUM, NAME, CPUINFO_FLAG, HWCAP, HWCAP2) [ENUM] = get_##ENUM,
static int (*const kGetters[])(const DEFINE_TABLE_FEATURE_TYPE*) = {
DEFINE_TABLE_FEATURES};
#undef FEATURE
#endif // SRC_DEFINE_TABLES_H_

View File

@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include <stdbool.h>
#include <stddef.h>
static bool equals(const char *lhs, const char *rhs, size_t count)
{
for (size_t i = 0; i < count; ++i)
if (lhs[i] != rhs[i]) return false;
return true;
}

View File

@ -60,13 +60,7 @@ static unsigned long GetElfHwcapFromGetauxval(uint32_t hwcap_type)
#elif defined(HAVE_DLFCN_H) #elif defined(HAVE_DLFCN_H)
// On Android we probe the system's C library for a 'getauxval' function and // On Android we probe the system's C library for a 'getauxval' function and
// call it if it exits, or return 0 for failure. This function is available // call it if it exits, or return 0 for failure. This function is available
// since API level 20. // since API level 18.
//
// This code does *NOT* check for '__ANDROID_API__ >= 20' to support the edge
// case where some NDK developers use headers for a platform that is newer than
// the one really targetted by their application. This is typically done to use
// newer native APIs only when running on more recent Android versions, and
// requires careful symbol management.
// //
// Note that getauxval() can't really be re-implemented here, because its // Note that getauxval() can't really be re-implemented here, because its
// implementation does not parse /proc/self/auxv. Instead it depends on values // implementation does not parse /proc/self/auxv. Instead it depends on values

View File

@ -0,0 +1,157 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_AARCH64
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
#include "cpuinfo_aarch64.h"
////////////////////////////////////////////////////////////////////////////////
// Definitions for introspection.
////////////////////////////////////////////////////////////////////////////////
#define INTROSPECTION_TABLE \
LINE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \
LINE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \
LINE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \
LINE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \
LINE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \
LINE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \
LINE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \
LINE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \
LINE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \
LINE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \
LINE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \
LINE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \
LINE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \
LINE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \
LINE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \
LINE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \
LINE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \
LINE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \
LINE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \
LINE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \
LINE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \
LINE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \
LINE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \
LINE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \
LINE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \
LINE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \
LINE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \
LINE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \
LINE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \
LINE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \
LINE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \
LINE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \
LINE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \
LINE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \
LINE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \
LINE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \
LINE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \
AARCH64_HWCAP2_SVEBITPERM) \
LINE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \
LINE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \
LINE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \
LINE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \
LINE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \
LINE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \
LINE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \
LINE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \
LINE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \
LINE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \
LINE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \
LINE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \
LINE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \
LINE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE)
#define INTROSPECTION_PREFIX Aarch64
#define INTROSPECTION_ENUM_PREFIX AARCH64
#include "define_introspection_and_hwcaps.inl"
////////////////////////////////////////////////////////////////////////////////
// Implementation.
////////////////////////////////////////////////////////////////////////////////
#include "internal/bit_utils.h"
#include "internal/filesystem.h"
#include "internal/stack_line_reader.h"
#include "internal/string_view.h"
#include <stdbool.h>
static bool HandleAarch64Line(const LineResult result,
Aarch64Info* const info)
{
StringView line = result.line;
StringView key, value;
if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value))
{
if (CpuFeatures_StringView_IsEquals(key, str("Features")))
{
for (size_t i = 0; i < AARCH64_LAST_; ++i)
{
kSetters[i](&info->features, CpuFeatures_StringView_HasWord(
value, kCpuInfoFlags[i], ' '));
}
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU implementer")))
{
info->implementer = CpuFeatures_StringView_ParsePositiveNumber(value);
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU variant")))
{
info->variant = CpuFeatures_StringView_ParsePositiveNumber(value);
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU part")))
{
info->part = CpuFeatures_StringView_ParsePositiveNumber(value);
}
else if (CpuFeatures_StringView_IsEquals(key, str("CPU revision")))
{
info->revision = CpuFeatures_StringView_ParsePositiveNumber(value);
}
}
return !result.eof;
}
static void FillProcCpuInfoData(Aarch64Info* const info)
{
const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
if (fd >= 0)
{
StackLineReader reader;
StackLineReader_Initialize(&reader, fd);
for (;;)
{
if (!HandleAarch64Line(StackLineReader_NextLine(&reader), info))
{
break;
}
}
CpuFeatures_CloseFile(fd);
}
}
static const Aarch64Info kEmptyAarch64Info;
Aarch64Info GetAarch64Info(void)
{
// capabilities are fetched from both getauxval and /proc/cpuinfo so we can
// have some information if the executable is sandboxed (aka no access to
// /proc/cpuinfo).
Aarch64Info info = kEmptyAarch64Info;
FillProcCpuInfoData(&info);
const HardwareCapabilities hwcaps = CpuFeatures_GetHardwareCapabilities();
for (size_t i = 0; i < AARCH64_LAST_; ++i)
{
if (CpuFeatures_IsHwCapsSet(kHardwareCapabilities[i], hwcaps))
{
kSetters[i](&info.features, true);
}
}
return info;
}
#endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
#endif // CPU_FEATURES_ARCH_AARCH64

View File

@ -1,47 +1,58 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_ARM
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
#include "cpuinfo_arm.h" #include "cpuinfo_arm.h"
////////////////////////////////////////////////////////////////////////////////
// Definitions for introspection.
////////////////////////////////////////////////////////////////////////////////
#define INTROSPECTION_TABLE \
LINE(ARM_SWP, swp, "swp", ARM_HWCAP_SWP, 0) \
LINE(ARM_HALF, half, "half", ARM_HWCAP_HALF, 0) \
LINE(ARM_THUMB, thumb, "thumb", ARM_HWCAP_THUMB, 0) \
LINE(ARM_26BIT, _26bit, "26bit", ARM_HWCAP_26BIT, 0) \
LINE(ARM_FASTMULT, fastmult, "fastmult", ARM_HWCAP_FAST_MULT, 0) \
LINE(ARM_FPA, fpa, "fpa", ARM_HWCAP_FPA, 0) \
LINE(ARM_VFP, vfp, "vfp", ARM_HWCAP_VFP, 0) \
LINE(ARM_EDSP, edsp, "edsp", ARM_HWCAP_EDSP, 0) \
LINE(ARM_JAVA, java, "java", ARM_HWCAP_JAVA, 0) \
LINE(ARM_IWMMXT, iwmmxt, "iwmmxt", ARM_HWCAP_IWMMXT, 0) \
LINE(ARM_CRUNCH, crunch, "crunch", ARM_HWCAP_CRUNCH, 0) \
LINE(ARM_THUMBEE, thumbee, "thumbee", ARM_HWCAP_THUMBEE, 0) \
LINE(ARM_NEON, neon, "neon", ARM_HWCAP_NEON, 0) \
LINE(ARM_VFPV3, vfpv3, "vfpv3", ARM_HWCAP_VFPV3, 0) \
LINE(ARM_VFPV3D16, vfpv3d16, "vfpv3d16", ARM_HWCAP_VFPV3D16, 0) \
LINE(ARM_TLS, tls, "tls", ARM_HWCAP_TLS, 0) \
LINE(ARM_VFPV4, vfpv4, "vfpv4", ARM_HWCAP_VFPV4, 0) \
LINE(ARM_IDIVA, idiva, "idiva", ARM_HWCAP_IDIVA, 0) \
LINE(ARM_IDIVT, idivt, "idivt", ARM_HWCAP_IDIVT, 0) \
LINE(ARM_VFPD32, vfpd32, "vfpd32", ARM_HWCAP_VFPD32, 0) \
LINE(ARM_LPAE, lpae, "lpae", ARM_HWCAP_LPAE, 0) \
LINE(ARM_EVTSTRM, evtstrm, "evtstrm", ARM_HWCAP_EVTSTRM, 0) \
LINE(ARM_AES, aes, "aes", 0, ARM_HWCAP2_AES) \
LINE(ARM_PMULL, pmull, "pmull", 0, ARM_HWCAP2_PMULL) \
LINE(ARM_SHA1, sha1, "sha1", 0, ARM_HWCAP2_SHA1) \
LINE(ARM_SHA2, sha2, "sha2", 0, ARM_HWCAP2_SHA2) \
LINE(ARM_CRC32, crc32, "crc32", 0, ARM_HWCAP2_CRC32)
#define INTROSPECTION_PREFIX Arm
#define INTROSPECTION_ENUM_PREFIX ARM
#include "define_introspection_and_hwcaps.inl"
////////////////////////////////////////////////////////////////////////////////
// Implementation.
////////////////////////////////////////////////////////////////////////////////
#include "internal/bit_utils.h" #include "internal/bit_utils.h"
#include "internal/filesystem.h" #include "internal/filesystem.h"
#include "internal/hwcaps.h"
#include "internal/stack_line_reader.h" #include "internal/stack_line_reader.h"
#include "internal/string_view.h" #include "internal/string_view.h"
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <stdbool.h>
// Generation of feature's getters/setters functions and kGetters, kSetters,
// kCpuInfoFlags and kHardwareCapabilities global tables.
#define DEFINE_TABLE_FEATURES \
FEATURE(ARM_SWP, swp, "swp", ARM_HWCAP_SWP, 0) \
FEATURE(ARM_HALF, half, "half", ARM_HWCAP_HALF, 0) \
FEATURE(ARM_THUMB, thumb, "thumb", ARM_HWCAP_THUMB, 0) \
FEATURE(ARM_26BIT, _26bit, "26bit", ARM_HWCAP_26BIT, 0) \
FEATURE(ARM_FASTMULT, fastmult, "fastmult", ARM_HWCAP_FAST_MULT, 0) \
FEATURE(ARM_FPA, fpa, "fpa", ARM_HWCAP_FPA, 0) \
FEATURE(ARM_VFP, vfp, "vfp", ARM_HWCAP_VFP, 0) \
FEATURE(ARM_EDSP, edsp, "edsp", ARM_HWCAP_EDSP, 0) \
FEATURE(ARM_JAVA, java, "java", ARM_HWCAP_JAVA, 0) \
FEATURE(ARM_IWMMXT, iwmmxt, "iwmmxt", ARM_HWCAP_IWMMXT, 0) \
FEATURE(ARM_CRUNCH, crunch, "crunch", ARM_HWCAP_CRUNCH, 0) \
FEATURE(ARM_THUMBEE, thumbee, "thumbee", ARM_HWCAP_THUMBEE, 0) \
FEATURE(ARM_NEON, neon, "neon", ARM_HWCAP_NEON, 0) \
FEATURE(ARM_VFPV3, vfpv3, "vfpv3", ARM_HWCAP_VFPV3, 0) \
FEATURE(ARM_VFPV3D16, vfpv3d16, "vfpv3d16", ARM_HWCAP_VFPV3D16, 0) \
FEATURE(ARM_TLS, tls, "tls", ARM_HWCAP_TLS, 0) \
FEATURE(ARM_VFPV4, vfpv4, "vfpv4", ARM_HWCAP_VFPV4, 0) \
FEATURE(ARM_IDIVA, idiva, "idiva", ARM_HWCAP_IDIVA, 0) \
FEATURE(ARM_IDIVT, idivt, "idivt", ARM_HWCAP_IDIVT, 0) \
FEATURE(ARM_VFPD32, vfpd32, "vfpd32", ARM_HWCAP_VFPD32, 0) \
FEATURE(ARM_LPAE, lpae, "lpae", ARM_HWCAP_LPAE, 0) \
FEATURE(ARM_EVTSTRM, evtstrm, "evtstrm", ARM_HWCAP_EVTSTRM, 0) \
FEATURE(ARM_AES, aes, "aes", 0, ARM_HWCAP2_AES) \
FEATURE(ARM_PMULL, pmull, "pmull", 0, ARM_HWCAP2_PMULL) \
FEATURE(ARM_SHA1, sha1, "sha1", 0, ARM_HWCAP2_SHA1) \
FEATURE(ARM_SHA2, sha2, "sha2", 0, ARM_HWCAP2_SHA2) \
FEATURE(ARM_CRC32, crc32, "crc32", 0, ARM_HWCAP2_CRC32)
#define DEFINE_TABLE_FEATURE_TYPE ArmFeatures
#include "define_tables.h"
typedef struct typedef struct
{ {
@ -155,13 +166,15 @@ static void FixErrors(ArmInfo* const info,
// https://crbug.com/341598. // https://crbug.com/341598.
info->features.neon = false; info->features.neon = false;
break; break;
case 0x510006F2: }
case 0x510006F3:
// The Nexus 4 (Qualcomm Krait) kernel configuration forgets to report // Some Qualcomm Krait kernels forget to report IDIV support.
// IDIV support. // https://github.com/torvalds/linux/commit/120ecfafabec382c4feb79ff159ef42a39b6d33b
if (info->implementer == 0x51 && info->architecture == 7 &&
(info->part == 0x4d || info->part == 0x6f))
{
info->features.idiva = true; info->features.idiva = true;
info->features.idivt = true; info->features.idivt = true;
break;
} }
// Propagate cpu features. // Propagate cpu features.
@ -217,18 +230,5 @@ ArmInfo GetArmInfo(void)
return info; return info;
} }
//////////////////////////////////////////////////////////////////////////////// #endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
// Introspection functions #endif // CPU_FEATURES_ARCH_ARM
int GetArmFeaturesEnumValue(const ArmFeatures* features,
ArmFeaturesEnum value)
{
if (value >= ARM_LAST_) return false;
return kGetters[value](features);
}
const char* GetArmFeaturesEnumName(ArmFeaturesEnum value)
{
if (value >= ARM_LAST_) return "unknown feature";
return kCpuInfoFlags[value];
}

View File

@ -1,21 +1,32 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_MIPS
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
#include "cpuinfo_mips.h" #include "cpuinfo_mips.h"
////////////////////////////////////////////////////////////////////////////////
// Definitions for introspection.
////////////////////////////////////////////////////////////////////////////////
#define INTROSPECTION_TABLE \
LINE(MIPS_MSA, msa, "msa", MIPS_HWCAP_MSA, 0) \
LINE(MIPS_EVA, eva, "eva", 0, 0) \
LINE(MIPS_R6, r6, "r6", MIPS_HWCAP_R6, 0)
#define INTROSPECTION_PREFIX Mips
#define INTROSPECTION_ENUM_PREFIX MIPS
#include "define_introspection_and_hwcaps.inl"
////////////////////////////////////////////////////////////////////////////////
// Implementation.
////////////////////////////////////////////////////////////////////////////////
#include "internal/filesystem.h" #include "internal/filesystem.h"
#include "internal/hwcaps.h" #include "internal/hwcaps.h"
#include "internal/stack_line_reader.h" #include "internal/stack_line_reader.h"
#include "internal/string_view.h" #include "internal/string_view.h"
#include <assert.h>
// Generation of feature's getters/setters functions and kGetters, kSetters,
// kCpuInfoFlags and kHardwareCapabilities global tables.
#define DEFINE_TABLE_FEATURES \
FEATURE(MIPS_MSA, msa, "msa", MIPS_HWCAP_MSA, 0) \
FEATURE(MIPS_EVA, eva, "eva", 0, 0) \
FEATURE(MIPS_R6, r6, "r6", MIPS_HWCAP_R6, 0)
#define DEFINE_TABLE_FEATURE_TYPE MipsFeatures
#include "define_tables.h"
static bool HandleMipsLine(const LineResult result, static bool HandleMipsLine(const LineResult result,
MipsFeatures* const features) MipsFeatures* const features)
@ -75,18 +86,5 @@ MipsInfo GetMipsInfo(void)
return info; return info;
} }
//////////////////////////////////////////////////////////////////////////////// #endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
// Introspection functions #endif // CPU_FEATURES_ARCH_MIPS
int GetMipsFeaturesEnumValue(const MipsFeatures* features,
MipsFeaturesEnum value)
{
if (value >= MIPS_LAST_) return false;
return kGetters[value](features);
}
const char* GetMipsFeaturesEnumName(MipsFeaturesEnum value)
{
if (value >= MIPS_LAST_) return "unknown feature";
return kCpuInfoFlags[value];
}

View File

@ -0,0 +1,167 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_PPC
#ifdef CPU_FEATURES_OS_LINUX
#include "cpuinfo_ppc.h"
////////////////////////////////////////////////////////////////////////////////
// Definitions for introspection.
////////////////////////////////////////////////////////////////////////////////
#define INTROSPECTION_TABLE \
LINE(PPC_32, ppc32, "ppc32", PPC_FEATURE_32, 0) \
LINE(PPC_64, ppc64, "ppc64", PPC_FEATURE_64, 0) \
LINE(PPC_601_INSTR, ppc601, "ppc601", PPC_FEATURE_601_INSTR, 0) \
LINE(PPC_HAS_ALTIVEC, altivec, "altivec", PPC_FEATURE_HAS_ALTIVEC, 0) \
LINE(PPC_HAS_FPU, fpu, "fpu", PPC_FEATURE_HAS_FPU, 0) \
LINE(PPC_HAS_MMU, mmu, "mmu", PPC_FEATURE_HAS_MMU, 0) \
LINE(PPC_HAS_4xxMAC, mac_4xx, "4xxmac", PPC_FEATURE_HAS_4xxMAC, 0) \
LINE(PPC_UNIFIED_CACHE, unifiedcache, "ucache", PPC_FEATURE_UNIFIED_CACHE, \
0) \
LINE(PPC_HAS_SPE, spe, "spe", PPC_FEATURE_HAS_SPE, 0) \
LINE(PPC_HAS_EFP_SINGLE, efpsingle, "efpsingle", PPC_FEATURE_HAS_EFP_SINGLE, \
0) \
LINE(PPC_HAS_EFP_DOUBLE, efpdouble, "efpdouble", PPC_FEATURE_HAS_EFP_DOUBLE, \
0) \
LINE(PPC_NO_TB, no_tb, "notb", PPC_FEATURE_NO_TB, 0) \
LINE(PPC_POWER4, power4, "power4", PPC_FEATURE_POWER4, 0) \
LINE(PPC_POWER5, power5, "power5", PPC_FEATURE_POWER5, 0) \
LINE(PPC_POWER5_PLUS, power5plus, "power5+", PPC_FEATURE_POWER5_PLUS, 0) \
LINE(PPC_CELL, cell, "cellbe", PPC_FEATURE_CELL, 0) \
LINE(PPC_BOOKE, booke, "booke", PPC_FEATURE_BOOKE, 0) \
LINE(PPC_SMT, smt, "smt", PPC_FEATURE_SMT, 0) \
LINE(PPC_ICACHE_SNOOP, icachesnoop, "ic_snoop", PPC_FEATURE_ICACHE_SNOOP, 0) \
LINE(PPC_ARCH_2_05, arch205, "arch_2_05", PPC_FEATURE_ARCH_2_05, 0) \
LINE(PPC_PA6T, pa6t, "pa6t", PPC_FEATURE_PA6T, 0) \
LINE(PPC_HAS_DFP, dfp, "dfp", PPC_FEATURE_HAS_DFP, 0) \
LINE(PPC_POWER6_EXT, power6ext, "power6x", PPC_FEATURE_POWER6_EXT, 0) \
LINE(PPC_ARCH_2_06, arch206, "arch_2_06", PPC_FEATURE_ARCH_2_06, 0) \
LINE(PPC_HAS_VSX, vsx, "vsx", PPC_FEATURE_HAS_VSX, 0) \
LINE(PPC_PSERIES_PERFMON_COMPAT, pseries_perfmon_compat, "archpmu", \
PPC_FEATURE_PSERIES_PERFMON_COMPAT, 0) \
LINE(PPC_TRUE_LE, truele, "true_le", PPC_FEATURE_TRUE_LE, 0) \
LINE(PPC_PPC_LE, ppcle, "ppcle", PPC_FEATURE_PPC_LE, 0) \
LINE(PPC_ARCH_2_07, arch207, "arch_2_07", 0, PPC_FEATURE2_ARCH_2_07) \
LINE(PPC_HTM, htm, "htm", 0, PPC_FEATURE2_HTM) \
LINE(PPC_DSCR, dscr, "dscr", 0, PPC_FEATURE2_DSCR) \
LINE(PPC_EBB, ebb, "ebb", 0, PPC_FEATURE2_EBB) \
LINE(PPC_ISEL, isel, "isel", 0, PPC_FEATURE2_ISEL) \
LINE(PPC_TAR, tar, "tar", 0, PPC_FEATURE2_TAR) \
LINE(PPC_VEC_CRYPTO, vcrypto, "vcrypto", 0, PPC_FEATURE2_VEC_CRYPTO) \
LINE(PPC_HTM_NOSC, htm_nosc, "htm-nosc", 0, PPC_FEATURE2_HTM_NOSC) \
LINE(PPC_ARCH_3_00, arch300, "arch_3_00", 0, PPC_FEATURE2_ARCH_3_00) \
LINE(PPC_HAS_IEEE128, ieee128, "ieee128", 0, PPC_FEATURE2_HAS_IEEE128) \
LINE(PPC_DARN, darn, "darn", 0, PPC_FEATURE2_DARN) \
LINE(PPC_SCV, scv, "scv", 0, PPC_FEATURE2_SCV) \
LINE(PPC_HTM_NO_SUSPEND, htm_no_suspend, "htm-no-suspend", 0, \
PPC_FEATURE2_HTM_NO_SUSPEND)
#define INTROSPECTION_PREFIX PPC
#define INTROSPECTION_ENUM_PREFIX PPC
#include "define_introspection_and_hwcaps.inl"
////////////////////////////////////////////////////////////////////////////////
// Implementation.
////////////////////////////////////////////////////////////////////////////////
#include "internal/bit_utils.h"
#include "internal/filesystem.h"
#include "internal/hwcaps.h"
#include "internal/stack_line_reader.h"
#include "internal/string_view.h"
#include <stdbool.h>
static bool HandlePPCLine(const LineResult result,
PPCPlatformStrings* const strings)
{
StringView line = result.line;
StringView key, value;
if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value))
{
if (CpuFeatures_StringView_HasWord(key, "platform", ' '))
{
CpuFeatures_StringView_CopyString(value, strings->platform,
sizeof(strings->platform));
}
else if (CpuFeatures_StringView_IsEquals(key, str("model")))
{
CpuFeatures_StringView_CopyString(value, strings->model,
sizeof(strings->platform));
}
else if (CpuFeatures_StringView_IsEquals(key, str("machine")))
{
CpuFeatures_StringView_CopyString(value, strings->machine,
sizeof(strings->platform));
}
else if (CpuFeatures_StringView_IsEquals(key, str("cpu")))
{
CpuFeatures_StringView_CopyString(value, strings->cpu,
sizeof(strings->platform));
}
}
return !result.eof;
}
static void FillProcCpuInfoData(PPCPlatformStrings* const strings)
{
const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
if (fd >= 0)
{
StackLineReader reader;
StackLineReader_Initialize(&reader, fd);
for (;;)
{
if (!HandlePPCLine(StackLineReader_NextLine(&reader), strings))
{
break;
}
}
CpuFeatures_CloseFile(fd);
}
}
static const PPCInfo kEmptyPPCInfo;
PPCInfo GetPPCInfo(void)
{
/*
* On Power feature flags aren't currently in cpuinfo so we only look at
* the auxilary vector.
*/
PPCInfo info = kEmptyPPCInfo;
const HardwareCapabilities hwcaps = CpuFeatures_GetHardwareCapabilities();
for (size_t i = 0; i < PPC_LAST_; ++i)
{
if (CpuFeatures_IsHwCapsSet(kHardwareCapabilities[i], hwcaps))
{
kSetters[i](&info.features, true);
}
}
return info;
}
static const PPCPlatformStrings kEmptyPPCPlatformStrings;
PPCPlatformStrings GetPPCPlatformStrings(void)
{
PPCPlatformStrings strings = kEmptyPPCPlatformStrings;
const char* platform = CpuFeatures_GetPlatformPointer();
const char* base_platform = CpuFeatures_GetBasePlatformPointer();
FillProcCpuInfoData(&strings);
if (platform != NULL)
CpuFeatures_StringView_CopyString(str(platform), strings.type.platform,
sizeof(strings.type.platform));
if (base_platform != NULL)
CpuFeatures_StringView_CopyString(str(base_platform),
strings.type.base_platform,
sizeof(strings.type.base_platform));
return strings;
}
#endif // CPU_FEATURES_OS_LINUX
#endif // CPU_FEATURES_ARCH_PPC

View File

@ -0,0 +1,61 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_X86
#ifdef CPU_FEATURES_OS_FREEBSD
#include "impl_x86__base_implementation.inl"
static void OverrideOsPreserves(OsPreserves* os_preserves)
{
(void)os_preserves;
// No override
}
#include "internal/filesystem.h"
#include "internal/stack_line_reader.h"
#include "internal/string_view.h"
static void DetectFeaturesFromOs(X86Info* info, X86Features* features)
{
(void)info;
// Handling FreeBSD platform through parsing /var/run/dmesg.boot.
const int fd = CpuFeatures_OpenFile("/var/run/dmesg.boot");
if (fd >= 0)
{
StackLineReader reader;
StackLineReader_Initialize(&reader, fd);
for (bool stop = false; !stop;)
{
const LineResult result = StackLineReader_NextLine(&reader);
if (result.eof) stop = true;
const StringView line = result.line;
if (!CpuFeatures_StringView_StartsWith(line, str(" Features"))) continue;
// Lines of interests are of the following form:
// " Features=0x1783fbff<PSE36,MMX,FXSR,SSE,SSE2,HTT>"
// We first extract the comma separated values between angle brackets.
StringView csv = result.line;
int index = CpuFeatures_StringView_IndexOfChar(csv, '<');
if (index >= 0) csv = CpuFeatures_StringView_PopFront(csv, index + 1);
if (csv.size > 0 && CpuFeatures_StringView_Back(csv) == '>')
csv = CpuFeatures_StringView_PopBack(csv, 1);
if (CpuFeatures_StringView_HasWord(csv, "SSE", ',')) features->sse = true;
if (CpuFeatures_StringView_HasWord(csv, "SSE2", ','))
features->sse2 = true;
if (CpuFeatures_StringView_HasWord(csv, "SSE3", ','))
features->sse3 = true;
if (CpuFeatures_StringView_HasWord(csv, "SSSE3", ','))
features->ssse3 = true;
if (CpuFeatures_StringView_HasWord(csv, "SSE4.1", ','))
features->sse4_1 = true;
if (CpuFeatures_StringView_HasWord(csv, "SSE4.2", ','))
features->sse4_2 = true;
}
CpuFeatures_CloseFile(fd);
}
}
#endif // CPU_FEATURES_OS_FREEBSD
#endif // CPU_FEATURES_ARCH_X86

View File

@ -0,0 +1,51 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_X86
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
#include "impl_x86__base_implementation.inl"
static void OverrideOsPreserves(OsPreserves* os_preserves)
{
(void)os_preserves;
// No override
}
#include "internal/filesystem.h"
#include "internal/stack_line_reader.h"
#include "internal/string_view.h"
static void DetectFeaturesFromOs(X86Info* info, X86Features* features)
{
(void)info;
// Handling Linux platform through /proc/cpuinfo.
const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
if (fd >= 0)
{
StackLineReader reader;
StackLineReader_Initialize(&reader, fd);
for (bool stop = false; !stop;)
{
const LineResult result = StackLineReader_NextLine(&reader);
if (result.eof) stop = true;
const StringView line = result.line;
StringView key, value;
if (!CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value))
continue;
if (!CpuFeatures_StringView_IsEquals(key, str("flags"))) continue;
features->sse = CpuFeatures_StringView_HasWord(value, "sse", ' ');
features->sse2 = CpuFeatures_StringView_HasWord(value, "sse2", ' ');
features->sse3 = CpuFeatures_StringView_HasWord(value, "pni", ' ');
features->ssse3 = CpuFeatures_StringView_HasWord(value, "ssse3", ' ');
features->sse4_1 = CpuFeatures_StringView_HasWord(value, "sse4_1", ' ');
features->sse4_2 = CpuFeatures_StringView_HasWord(value, "sse4_2", ' ');
break;
}
CpuFeatures_CloseFile(fd);
}
}
#endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
#endif // CPU_FEATURES_ARCH_X86

View File

@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_X86
#ifdef CPU_FEATURES_OS_MACOS
#include "impl_x86__base_implementation.inl"
#if !defined(HAVE_SYSCTLBYNAME)
#error "Darwin needs support for sysctlbyname"
#endif
#include <sys/sysctl.h>
#if defined(CPU_FEATURES_MOCK_CPUID_X86)
extern bool GetDarwinSysCtlByName(const char*);
#else // CPU_FEATURES_MOCK_CPUID_X86
static bool GetDarwinSysCtlByName(const char* name)
{
int enabled;
size_t enabled_len = sizeof(enabled);
const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0);
return failure ? false : enabled;
}
#endif
static void OverrideOsPreserves(OsPreserves* os_preserves)
{
// On Darwin AVX512 support is On-demand.
// We have to query the OS instead of querying the Zmm save/restore state.
// https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/osfmk/i386/fpu.c#L173-L199
os_preserves->avx512_registers = GetDarwinSysCtlByName("hw.optional.avx512f");
}
static void DetectFeaturesFromOs(X86Info* info, X86Features* features)
{
(void)info;
// Handling Darwin platform through sysctlbyname.
features->sse = GetDarwinSysCtlByName("hw.optional.sse");
features->sse2 = GetDarwinSysCtlByName("hw.optional.sse2");
features->sse3 = GetDarwinSysCtlByName("hw.optional.sse3");
features->ssse3 = GetDarwinSysCtlByName("hw.optional.supplementalsse3");
features->sse4_1 = GetDarwinSysCtlByName("hw.optional.sse4_1");
features->sse4_2 = GetDarwinSysCtlByName("hw.optional.sse4_2");
}
#endif // CPU_FEATURES_OS_MACOS
#endif // CPU_FEATURES_ARCH_X86

View File

@ -0,0 +1,51 @@
// SPDX-FileCopyrightText: 2017 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include "cpu_features_macros.h"
#ifdef CPU_FEATURES_ARCH_X86
#ifdef CPU_FEATURES_OS_WINDOWS
#include "impl_x86__base_implementation.inl"
static void OverrideOsPreserves(OsPreserves* os_preserves)
{
(void)os_preserves;
// No override
}
#include <windows.h> // IsProcessorFeaturePresent
#if defined(CPU_FEATURES_MOCK_CPUID_X86)
extern bool GetWindowsIsProcessorFeaturePresent(DWORD);
#else // CPU_FEATURES_MOCK_CPUID_X86
static bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature)
{
return IsProcessorFeaturePresent(ProcessorFeature);
}
#endif
static void DetectFeaturesFromOs(X86Info* info, X86Features* features)
{
// Handling Windows platform through IsProcessorFeaturePresent.
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
features->sse =
GetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE);
features->sse2 =
GetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
features->sse3 =
GetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE);
// https://github.com/google/cpu_features/issues/200
#if (_WIN32_WINNT >= 0x0601) // Win7+
if (GetX86Microarchitecture(info) == INTEL_WSM)
{
features->ssse3 = true;
features->sse4_1 = true;
features->sse4_2 = true;
}
#endif
}
#endif // CPU_FEATURES_OS_WINDOWS
#endif // CPU_FEATURES_ARCH_X86

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 Google LLC // SPDX-FileCopyrightText: 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// This program dumps current host data to the standard output. // This program dumps current host data to the standard output.
@ -363,7 +363,7 @@ static Node* GetCacheTypeString(CacheType cache_type)
case CPU_FEATURE_CACHE_PREFETCH: case CPU_FEATURE_CACHE_PREFETCH:
return CreateConstantString("prefetch"); return CreateConstantString("prefetch");
} }
UNREACHABLE(); CPU_FEATURES_UNREACHABLE();
} }
static void AddCacheInfo(Node* root, const CacheInfo* cache_info) static void AddCacheInfo(Node* root, const CacheInfo* cache_info)

View File

@ -50,7 +50,13 @@ add_test(NAME stack_line_reader_test COMMAND stack_line_reader_test)
##------------------------------------------------------------------------------ ##------------------------------------------------------------------------------
## cpuinfo_x86_test ## cpuinfo_x86_test
if(PROCESSOR_IS_X86) if(PROCESSOR_IS_X86)
add_executable(cpuinfo_x86_test cpuinfo_x86_test.cc ../src/cpuinfo_x86.c) add_executable(cpuinfo_x86_test
cpuinfo_x86_test.cc
../src/impl_x86_freebsd.c
../src/impl_x86_linux_or_android.c
../src/impl_x86_macos.c
../src/impl_x86_windows.c
)
target_compile_definitions(cpuinfo_x86_test PUBLIC CPU_FEATURES_MOCK_CPUID_X86) target_compile_definitions(cpuinfo_x86_test PUBLIC CPU_FEATURES_MOCK_CPUID_X86)
if(APPLE) if(APPLE)
target_compile_definitions(cpuinfo_x86_test PRIVATE HAVE_SYSCTLBYNAME) target_compile_definitions(cpuinfo_x86_test PRIVATE HAVE_SYSCTLBYNAME)
@ -61,32 +67,28 @@ endif()
##------------------------------------------------------------------------------ ##------------------------------------------------------------------------------
## cpuinfo_arm_test ## cpuinfo_arm_test
if(PROCESSOR_IS_ARM) if(PROCESSOR_IS_ARM)
add_executable(cpuinfo_arm_test cpuinfo_arm_test.cc ../src/cpuinfo_arm.c) add_executable(cpuinfo_arm_test cpuinfo_arm_test.cc ../src/impl_arm_linux_or_android.c)
target_link_libraries(cpuinfo_arm_test all_libraries) target_link_libraries(cpuinfo_arm_test all_libraries)
add_test(NAME cpuinfo_arm_test COMMAND cpuinfo_arm_test) add_test(NAME cpuinfo_arm_test COMMAND cpuinfo_arm_test)
endif() endif()
##------------------------------------------------------------------------------ ##------------------------------------------------------------------------------
## cpuinfo_aarch64_test ## cpuinfo_aarch64_test
if(PROCESSOR_IS_AARCH64) if(PROCESSOR_IS_AARCH64)
add_executable(cpuinfo_aarch64_test cpuinfo_aarch64_test.cc ../src/cpuinfo_aarch64.c) add_executable(cpuinfo_aarch64_test cpuinfo_aarch64_test.cc ../src/impl_aarch64_linux_or_android.c)
if(APPLE)
target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_CPUID_ARM64)
target_compile_definitions(cpuinfo_aarch64_test PRIVATE HAVE_SYSCTLBYNAME)
endif()
target_link_libraries(cpuinfo_aarch64_test all_libraries) target_link_libraries(cpuinfo_aarch64_test all_libraries)
add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test) add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test)
endif() endif()
##------------------------------------------------------------------------------ ##------------------------------------------------------------------------------
## cpuinfo_mips_test ## cpuinfo_mips_test
if(PROCESSOR_IS_MIPS) if(PROCESSOR_IS_MIPS)
add_executable(cpuinfo_mips_test cpuinfo_mips_test.cc ../src/cpuinfo_mips.c) add_executable(cpuinfo_mips_test cpuinfo_mips_test.cc ../src/impl_mips_linux_or_android.c)
target_link_libraries(cpuinfo_mips_test all_libraries) target_link_libraries(cpuinfo_mips_test all_libraries)
add_test(NAME cpuinfo_mips_test COMMAND cpuinfo_mips_test) add_test(NAME cpuinfo_mips_test COMMAND cpuinfo_mips_test)
endif() endif()
##------------------------------------------------------------------------------ ##------------------------------------------------------------------------------
## cpuinfo_ppc_test ## cpuinfo_ppc_test
if(PROCESSOR_IS_POWER) if(PROCESSOR_IS_POWER)
add_executable(cpuinfo_ppc_test cpuinfo_ppc_test.cc ../src/cpuinfo_ppc.c) add_executable(cpuinfo_ppc_test cpuinfo_ppc_test.cc ../src/impl_ppc_linux.c)
target_link_libraries(cpuinfo_ppc_test all_libraries) target_link_libraries(cpuinfo_ppc_test all_libraries)
add_test(NAME cpuinfo_ppc_test COMMAND cpuinfo_ppc_test) add_test(NAME cpuinfo_ppc_test COMMAND cpuinfo_ppc_test)
endif() endif()

View File

@ -103,7 +103,6 @@ CPU architecture: 7
CPU variant : 0x0 CPU variant : 0x0
CPU part : 0xb76 CPU part : 0xb76
CPU revision : 7 CPU revision : 7
Hardware : BCM2835 Hardware : BCM2835
Revision : 9000c1 Revision : 9000c1
Serial : 000000006cd946f3)"); Serial : 000000006cd946f3)");
@ -156,7 +155,6 @@ CPU architecture: 7
CPU variant : 0x4 CPU variant : 0x4
CPU part : 0xc09 CPU part : 0xc09
CPU revision : 1 CPU revision : 1
processor : 1 processor : 1
model name : ARMv7 Processor rev 1 (v7l) model name : ARMv7 Processor rev 1 (v7l)
BogoMIPS : 50.00 BogoMIPS : 50.00
@ -166,7 +164,6 @@ CPU architecture: 7
CPU variant : 0x4 CPU variant : 0x4
CPU part : 0xc09 CPU part : 0xc09
CPU revision : 1 CPU revision : 1
Hardware : Marvell Armada 380/385 (Device Tree) Hardware : Marvell Armada 380/385 (Device Tree)
Revision : 0000 Revision : 0000
Serial : 0000000000000000)"); Serial : 0000000000000000)");
@ -221,7 +218,6 @@ CPU architecture: 7
CPU variant : 0x0 CPU variant : 0x0
CPU part : 0xb76 CPU part : 0xb76
CPU revision : 6 CPU revision : 6
Hardware : SPICA Hardware : SPICA
Revision : 0020 Revision : 0020
Serial : 33323613546d00ec )"); Serial : 33323613546d00ec )");
@ -267,17 +263,14 @@ TEST(CpuinfoArmTest, InvalidNeon)
R"(Processor: ARMv7 Processory rev 0 (v71) R"(Processor: ARMv7 Processory rev 0 (v71)
processor: 0 processor: 0
BogoMIPS: 13.50 BogoMIPS: 13.50
Processor: 1 Processor: 1
BogoMIPS: 13.50 BogoMIPS: 13.50
Features: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt Features: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
CPU implementer : 0x51 CPU implementer : 0x51
CPU architecture: 7 CPU architecture: 7
CPU variant: 0x1 CPU variant: 0x1
CPU part: 0x04d CPU part: 0x04d
CPU revision: 0 CPU revision: 0
Hardware: SAMSUNG M2 Hardware: SAMSUNG M2
Revision: 0010 Revision: 0010
Serial: 00001e030000354e)"); Serial: 00001e030000354e)");
@ -324,6 +317,25 @@ CPU revision : 3)");
EXPECT_EQ(GetArmCpuId(&info), 0x510006f3); EXPECT_EQ(GetArmCpuId(&info), 0x510006f3);
} }
// The 2013 Nexus 7 (Qualcomm Krait) kernel configuration forgets to report IDIV
// support.
TEST(CpuinfoArmTest, Nexus7_2013_0x511006f0)
{
ResetHwcaps();
auto& fs = GetEmptyFilesystem();
fs.CreateFile("/proc/cpuinfo",
R"(CPU implementer : 0x51
CPU architecture: 7
CPU variant : 0x1
CPU part : 0x06f
CPU revision : 0)");
const auto info = GetArmInfo();
EXPECT_TRUE(info.features.idiva);
EXPECT_TRUE(info.features.idivt);
EXPECT_EQ(GetArmCpuId(&info), 0x511006f0);
}
// The emulator-specific Android 4.2 kernel fails to report support for the // The emulator-specific Android 4.2 kernel fails to report support for the
// 32-bit ARM IDIV instruction. Technically, this is a feature of the virtual // 32-bit ARM IDIV instruction. Technically, this is a feature of the virtual
// CPU implemented by the emulator. // CPU implemented by the emulator.
@ -340,7 +352,6 @@ CPU architecture: 7
CPU variant : 0x0 CPU variant : 0x0
CPU part : 0xc08 CPU part : 0xc08
CPU revision : 0 CPU revision : 0
Hardware : Goldfish Hardware : Goldfish
Revision : 0000 Revision : 0000
Serial : 0000000000000000)"); Serial : 0000000000000000)");

View File

@ -16,6 +16,7 @@
namespace cpu_features namespace cpu_features
{ {
class FakeCpu class FakeCpu
{ {
public: public:
@ -41,7 +42,7 @@ public:
xcr0_eax_ = os_backups_extended_registers ? -1 : 0; xcr0_eax_ = os_backups_extended_registers ? -1 : 0;
} }
#if defined(CPU_FEATURES_OS_DARWIN) #if defined(CPU_FEATURES_OS_MACOS)
bool GetDarwinSysCtlByName(std::string name) const bool GetDarwinSysCtlByName(std::string name) const
{ {
return darwin_sysctlbyname_.count(name); return darwin_sysctlbyname_.count(name);
@ -51,7 +52,7 @@ public:
{ {
darwin_sysctlbyname_.insert(name); darwin_sysctlbyname_.insert(name);
} }
#endif // CPU_FEATURES_OS_DARWIN #endif // CPU_FEATURES_OS_MACOS
#if defined(CPU_FEATURES_OS_WINDOWS) #if defined(CPU_FEATURES_OS_WINDOWS)
bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature)
@ -67,9 +68,9 @@ public:
private: private:
std::map<std::pair<uint32_t, int>, Leaf> cpuid_leaves_; std::map<std::pair<uint32_t, int>, Leaf> cpuid_leaves_;
#if defined(CPU_FEATURES_OS_DARWIN) #if defined(CPU_FEATURES_OS_MACOS)
std::set<std::string> darwin_sysctlbyname_; std::set<std::string> darwin_sysctlbyname_;
#endif // CPU_FEATURES_OS_DARWIN #endif // CPU_FEATURES_OS_MACOS
#if defined(CPU_FEATURES_OS_WINDOWS) #if defined(CPU_FEATURES_OS_WINDOWS)
std::set<DWORD> windows_isprocessorfeaturepresent_; std::set<DWORD> windows_isprocessorfeaturepresent_;
#endif // CPU_FEATURES_OS_WINDOWS #endif // CPU_FEATURES_OS_WINDOWS
@ -91,12 +92,12 @@ extern "C" Leaf GetCpuidLeaf(uint32_t leaf_id, int ecx)
extern "C" uint32_t GetXCR0Eax(void) { return cpu().GetXCR0Eax(); } extern "C" uint32_t GetXCR0Eax(void) { return cpu().GetXCR0Eax(); }
#if defined(CPU_FEATURES_OS_DARWIN) #if defined(CPU_FEATURES_OS_MACOS)
extern "C" bool GetDarwinSysCtlByName(const char* name) extern "C" bool GetDarwinSysCtlByName(const char* name)
{ {
return cpu().GetDarwinSysCtlByName(name); return cpu().GetDarwinSysCtlByName(name);
} }
#endif // CPU_FEATURES_OS_DARWIN #endif // CPU_FEATURES_OS_MACOS
#if defined(CPU_FEATURES_OS_WINDOWS) #if defined(CPU_FEATURES_OS_WINDOWS)
extern "C" bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) extern "C" bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature)
@ -107,6 +108,7 @@ extern "C" bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature)
namespace namespace
{ {
class CpuidX86Test : public ::testing::Test class CpuidX86Test : public ::testing::Test
{ {
protected: protected:
@ -430,6 +432,8 @@ TEST_F(CpuidX86Test, AMD_K15_EXCAVATOR_STONEY_RIDGE)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x15); EXPECT_EQ(info.family, 0x15);
EXPECT_EQ(info.model, 0x70); EXPECT_EQ(info.model, 0x70);
EXPECT_STREQ(info.brand_string,
"AMD A9-9410 RADEON R5, 5 COMPUTE CORES 2C+3G ");
EXPECT_EQ(GetX86Microarchitecture(&info), EXPECT_EQ(GetX86Microarchitecture(&info),
X86Microarchitecture::AMD_EXCAVATOR); X86Microarchitecture::AMD_EXCAVATOR);
@ -456,6 +460,8 @@ TEST_F(CpuidX86Test, AMD_K15_PILEDRIVER_ABU_DHABI)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x15); EXPECT_EQ(info.family, 0x15);
EXPECT_EQ(info.model, 0x02); EXPECT_EQ(info.model, 0x02);
EXPECT_STREQ(info.brand_string,
"AMD Opteron(tm) Processor 6376 ");
EXPECT_EQ(GetX86Microarchitecture(&info), EXPECT_EQ(GetX86Microarchitecture(&info),
X86Microarchitecture::AMD_PILEDRIVER); X86Microarchitecture::AMD_PILEDRIVER);
@ -531,6 +537,8 @@ TEST_F(CpuidX86Test, AMD_K15_BULLDOZER_INTERLAGOS)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x15); EXPECT_EQ(info.family, 0x15);
EXPECT_EQ(info.model, 0x01); EXPECT_EQ(info.model, 0x01);
EXPECT_STREQ(info.brand_string,
"AMD Opteron(TM) Processor 6238 ");
EXPECT_EQ(GetX86Microarchitecture(&info), EXPECT_EQ(GetX86Microarchitecture(&info),
X86Microarchitecture::AMD_BULLDOZER); X86Microarchitecture::AMD_BULLDOZER);
@ -559,6 +567,8 @@ TEST_F(CpuidX86Test, AMD_K15_STREAMROLLER_GODAVARI)
EXPECT_EQ(info.family, 0x15); EXPECT_EQ(info.family, 0x15);
EXPECT_EQ(info.model, 0x38); EXPECT_EQ(info.model, 0x38);
EXPECT_EQ(info.stepping, 0x01); EXPECT_EQ(info.stepping, 0x01);
EXPECT_STREQ(info.brand_string,
"AMD A8-7670K Radeon R7, 10 Compute Cores 4C+6G ");
EXPECT_EQ(GetX86Microarchitecture(&info), EXPECT_EQ(GetX86Microarchitecture(&info),
X86Microarchitecture::AMD_STREAMROLLER); X86Microarchitecture::AMD_STREAMROLLER);
@ -585,6 +595,8 @@ TEST_F(CpuidX86Test, AMD_K16_JAGUAR_KABINI)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x16); EXPECT_EQ(info.family, 0x16);
EXPECT_EQ(info.model, 0x00); EXPECT_EQ(info.model, 0x00);
EXPECT_STREQ(info.brand_string,
"AMD A4-5000 APU with Radeon(TM) HD Graphics ");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_JAGUAR); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_JAGUAR);
char brand_string[49]; char brand_string[49];
@ -610,6 +622,8 @@ TEST_F(CpuidX86Test, AMD_K16_PUMA_BEEMA)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x16); EXPECT_EQ(info.family, 0x16);
EXPECT_EQ(info.model, 0x30); EXPECT_EQ(info.model, 0x30);
EXPECT_STREQ(info.brand_string,
"AMD A6-6310 APU with AMD Radeon R4 Graphics ");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_PUMA); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_PUMA);
char brand_string[49]; char brand_string[49];
@ -635,6 +649,8 @@ TEST_F(CpuidX86Test, AMD_K17_ZEN_DALI)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x17); EXPECT_EQ(info.family, 0x17);
EXPECT_EQ(info.model, 0x20); EXPECT_EQ(info.model, 0x20);
EXPECT_STREQ(info.brand_string,
"AMD 3020e with Radeon Graphics ");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN);
char brand_string[49]; char brand_string[49];
@ -660,6 +676,8 @@ TEST_F(CpuidX86Test, AMD_K17_ZEN_PLUS_PINNACLE_RIDGE)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x17); EXPECT_EQ(info.family, 0x17);
EXPECT_EQ(info.model, 0x08); EXPECT_EQ(info.model, 0x08);
EXPECT_STREQ(info.brand_string,
"AMD Ryzen 7 2700X Eight-Core Processor ");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN_PLUS); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN_PLUS);
char brand_string[49]; char brand_string[49];
@ -685,6 +703,7 @@ TEST_F(CpuidX86Test, AMD_K17_ZEN2_XBOX_SERIES_X)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x17); EXPECT_EQ(info.family, 0x17);
EXPECT_EQ(info.model, 0x47); EXPECT_EQ(info.model, 0x47);
EXPECT_STREQ(info.brand_string, "AMD 4700S 8-Core Processor Desktop Kit");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN2); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN2);
char brand_string[49]; char brand_string[49];
@ -710,6 +729,8 @@ TEST_F(CpuidX86Test, AMD_K18_ZEN_DHYANA)
EXPECT_STREQ(info.vendor, "HygonGenuine"); EXPECT_STREQ(info.vendor, "HygonGenuine");
EXPECT_EQ(info.family, 0x18); EXPECT_EQ(info.family, 0x18);
EXPECT_EQ(info.model, 0x00); EXPECT_EQ(info.model, 0x00);
EXPECT_STREQ(info.brand_string,
"Hygon C86 3185 8-core Processor ");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN);
char brand_string[49]; char brand_string[49];
@ -784,6 +805,8 @@ TEST_F(CpuidX86Test, AMD_K19_ZEN3_VERMEER)
EXPECT_STREQ(info.vendor, "AuthenticAMD"); EXPECT_STREQ(info.vendor, "AuthenticAMD");
EXPECT_EQ(info.family, 0x19); EXPECT_EQ(info.family, 0x19);
EXPECT_EQ(info.model, 0x21); EXPECT_EQ(info.model, 0x21);
EXPECT_STREQ(info.brand_string,
"AMD Ryzen 9 5900X 12-Core Processor ");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN3); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN3);
char brand_string[49]; char brand_string[49];
@ -800,7 +823,7 @@ TEST_F(CpuidX86Test, Nehalem)
cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE);
cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE);
#elif defined(CPU_FEATURES_OS_DARWIN) #elif defined(CPU_FEATURES_OS_MACOS)
cpu().SetDarwinSysCtlByName("hw.optional.sse"); cpu().SetDarwinSysCtlByName("hw.optional.sse");
cpu().SetDarwinSysCtlByName("hw.optional.sse2"); cpu().SetDarwinSysCtlByName("hw.optional.sse2");
cpu().SetDarwinSysCtlByName("hw.optional.sse3"); cpu().SetDarwinSysCtlByName("hw.optional.sse3");
@ -817,10 +840,10 @@ FreeBSD is a registered trademark of The FreeBSD Foundation.
Features2=0x5eda2203<SSE3,PCLMULQDQ,SSSE3,CX16,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,RDRAND> Features2=0x5eda2203<SSE3,PCLMULQDQ,SSSE3,CX16,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,RDRAND>
real memory = 2147418112 (2047 MB) real memory = 2147418112 (2047 MB)
)"); )");
#elif defined(CPU_FEATURES_OS_LINUX_OR_ANDROID) #elif defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
auto& fs = GetEmptyFilesystem(); auto& fs = GetEmptyFilesystem();
fs.CreateFile("/proc/cpuinfo", R"(processor : fs.CreateFile("/proc/cpuinfo", R"(processor :
flags : fpu mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 flags : fpu mmx sse sse2 pni ssse3 sse4_1 sse4_2
)"); )");
#endif #endif
cpu().SetLeaves({ cpu().SetLeaves({
@ -856,6 +879,8 @@ flags : fpu mmx sse sse2 sse3 ssse3 sse4_1 sse4_2
EXPECT_EQ(info.family, 0x06); EXPECT_EQ(info.family, 0x06);
EXPECT_EQ(info.model, 0x1A); EXPECT_EQ(info.model, 0x1A);
EXPECT_EQ(info.stepping, 0x02); EXPECT_EQ(info.stepping, 0x02);
EXPECT_STREQ(info.brand_string,
"Genuine Intel(R) CPU @ 0000 @ 1.87GHz");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_NHM); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_NHM);
char brand_string[49]; char brand_string[49];
@ -883,7 +908,7 @@ TEST_F(CpuidX86Test, Atom)
cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE);
cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE);
#elif defined(CPU_FEATURES_OS_DARWIN) #elif defined(CPU_FEATURES_OS_MACOS)
cpu().SetDarwinSysCtlByName("hw.optional.sse"); cpu().SetDarwinSysCtlByName("hw.optional.sse");
cpu().SetDarwinSysCtlByName("hw.optional.sse2"); cpu().SetDarwinSysCtlByName("hw.optional.sse2");
cpu().SetDarwinSysCtlByName("hw.optional.sse3"); cpu().SetDarwinSysCtlByName("hw.optional.sse3");
@ -900,10 +925,10 @@ FreeBSD is a registered trademark of The FreeBSD Foundation.
Features2=0x5eda2203<SSE3,PCLMULQDQ,SSSE3,CX16,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,RDRAND> Features2=0x5eda2203<SSE3,PCLMULQDQ,SSSE3,CX16,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,RDRAND>
real memory = 2147418112 (2047 MB) real memory = 2147418112 (2047 MB)
)"); )");
#elif defined(CPU_FEATURES_OS_LINUX_OR_ANDROID) #elif defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
auto& fs = GetEmptyFilesystem(); auto& fs = GetEmptyFilesystem();
fs.CreateFile("/proc/cpuinfo", R"( fs.CreateFile("/proc/cpuinfo", R"(
flags : fpu mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 flags : fpu mmx sse sse2 pni ssse3 sse4_1 sse4_2
)"); )");
#endif #endif
cpu().SetLeaves({ cpu().SetLeaves({
@ -938,6 +963,8 @@ flags : fpu mmx sse sse2 sse3 ssse3 sse4_1 sse4_2
EXPECT_EQ(info.family, 0x06); EXPECT_EQ(info.family, 0x06);
EXPECT_EQ(info.model, 0x37); EXPECT_EQ(info.model, 0x37);
EXPECT_EQ(info.stepping, 0x03); EXPECT_EQ(info.stepping, 0x03);
EXPECT_STREQ(info.brand_string,
" Intel(R) Celeron(R) CPU J1900 @ 1.99GHz");
EXPECT_EQ(GetX86Microarchitecture(&info), EXPECT_EQ(GetX86Microarchitecture(&info),
X86Microarchitecture::INTEL_ATOM_SMT); X86Microarchitecture::INTEL_ATOM_SMT);
@ -1017,7 +1044,7 @@ TEST_F(CpuidX86Test, P3)
cpu().SetOsBackupsExtendedRegisters(false); cpu().SetOsBackupsExtendedRegisters(false);
#if defined(CPU_FEATURES_OS_WINDOWS) #if defined(CPU_FEATURES_OS_WINDOWS)
cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE);
#elif defined(CPU_FEATURES_OS_DARWIN) #elif defined(CPU_FEATURES_OS_MACOS)
cpu().SetDarwinSysCtlByName("hw.optional.sse"); cpu().SetDarwinSysCtlByName("hw.optional.sse");
#elif defined(CPU_FEATURES_OS_FREEBSD) #elif defined(CPU_FEATURES_OS_FREEBSD)
auto& fs = GetEmptyFilesystem(); auto& fs = GetEmptyFilesystem();
@ -1028,7 +1055,7 @@ FreeBSD is a registered trademark of The FreeBSD Foundation.
Features=0x1783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE> Features=0x1783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE>
real memory = 2147418112 (2047 MB) real memory = 2147418112 (2047 MB)
)"); )");
#elif defined(CPU_FEATURES_OS_LINUX_OR_ANDROID) #elif defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
auto& fs = GetEmptyFilesystem(); auto& fs = GetEmptyFilesystem();
fs.CreateFile("/proc/cpuinfo", R"( fs.CreateFile("/proc/cpuinfo", R"(
flags : fpu mmx sse flags : fpu mmx sse
@ -1046,6 +1073,7 @@ flags : fpu mmx sse
EXPECT_EQ(info.family, 0x06); EXPECT_EQ(info.family, 0x06);
EXPECT_EQ(info.model, 0x07); EXPECT_EQ(info.model, 0x07);
EXPECT_EQ(info.stepping, 0x03); EXPECT_EQ(info.stepping, 0x03);
EXPECT_STREQ(info.brand_string, "");
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::X86_UNKNOWN); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::X86_UNKNOWN);
char brand_string[49]; char brand_string[49];
@ -1065,6 +1093,95 @@ flags : fpu mmx sse
#endif // !defined(CPU_FEATURES_OS_WINDOWS) #endif // !defined(CPU_FEATURES_OS_WINDOWS)
} }
// https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel0000480_486_CPUID.txt
TEST_F(CpuidX86Test, INTEL_80486)
{
cpu().SetLeaves({
{{0x00000000, 0}, Leaf{0x00000001, 0x756E6547, 0x6C65746E, 0x49656E69}},
{{0x00000001, 0}, Leaf{0x00000480, 0x00000000, 0x00000000, 0x00000003}},
});
const auto info = GetX86Info();
EXPECT_STREQ(info.vendor, "GenuineIntel");
EXPECT_EQ(info.family, 0x04);
EXPECT_EQ(info.model, 0x08);
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_80486);
}
// https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel0000526_P54C_CPUID.txt
TEST_F(CpuidX86Test, INTEL_P54C)
{
cpu().SetLeaves({
{{0x00000000, 0}, Leaf{0x00000001, 0x756E6547, 0x6C65746E, 0x49656E69}},
{{0x00000001, 0}, Leaf{0x00000525, 0x00000000, 0x00000000, 0x000001BF}},
});
const auto info = GetX86Info();
EXPECT_STREQ(info.vendor, "GenuineIntel");
EXPECT_EQ(info.family, 0x05);
EXPECT_EQ(info.model, 0x02);
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_P5);
}
// https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel0000590_Lakemont_CPUID2.txt
TEST_F(CpuidX86Test, INTEL_LAKEMONT)
{
cpu().SetLeaves({
{{0x00000000, 0}, Leaf{0x00000002, 0x756E6547, 0x6c65746E, 0x49656E69}},
{{0x00000001, 0}, Leaf{0x00000590, 0x00000000, 0x00010200, 0x8000237B}},
});
const auto info = GetX86Info();
EXPECT_STREQ(info.vendor, "GenuineIntel");
EXPECT_EQ(info.family, 0x05);
EXPECT_EQ(info.model, 0x09);
EXPECT_EQ(GetX86Microarchitecture(&info),
X86Microarchitecture::INTEL_LAKEMONT);
}
// https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel0050670_KnightsLanding_CPUID.txt
TEST_F(CpuidX86Test, INTEL_KNIGHTS_LANDING)
{
cpu().SetLeaves({
{{0x00000000, 0}, Leaf{0x0000000D, 0x756E6547, 0x6C65746E, 0x49656E69}},
{{0x00000001, 0}, Leaf{0x00050670, 0x02FF0800, 0x7FF8F3BF, 0xBFEBFBFF}},
});
const auto info = GetX86Info();
EXPECT_STREQ(info.vendor, "GenuineIntel");
EXPECT_EQ(info.family, 0x06);
EXPECT_EQ(info.model, 0x57);
EXPECT_EQ(GetX86Microarchitecture(&info),
X86Microarchitecture::INTEL_KNIGHTS_L);
}
// https://github.com/google/cpu_features/issues/200
// http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00206F2_Eagleton_CPUID.txt
#if defined(CPU_FEATURES_OS_WINDOWS)
TEST_F(CpuidX86Test, WIN_INTEL_WESTMERE_EX)
{
cpu().SetLeaves({
{{0x00000000, 0}, Leaf{0x0000000B, 0x756E6547, 0x6C65746E, 0x49656E69}},
{{0x00000001, 0}, Leaf{0x000206F2, 0x00400800, 0x02BEE3FF, 0xBFEBFBFF}},
});
const auto info = GetX86Info();
EXPECT_EQ(info.family, 0x06);
EXPECT_EQ(info.model, 0x2F);
EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_WSM);
#if (_WIN32_WINNT < 0x0601) // before Win7
EXPECT_FALSE(info.features.ssse3);
EXPECT_FALSE(info.features.sse4_1);
EXPECT_FALSE(info.features.sse4_2);
#else
EXPECT_TRUE(info.features.ssse3);
EXPECT_TRUE(info.features.sse4_1);
EXPECT_TRUE(info.features.sse4_2);
#endif
}
#endif // CPU_FEATURES_OS_WINDOWS
// TODO(user): test what happens when xsave/osxsave are not present. // TODO(user): test what happens when xsave/osxsave are not present.
// TODO(user): test what happens when xmm/ymm/zmm os support are not // TODO(user): test what happens when xmm/ymm/zmm os support are not
// present. // present.

View File

@ -532,10 +532,11 @@ if(NOT (CMAKE_GENERATOR STREQUAL Xcode))
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
) )
if(USE_CPU_FEATURES) if(USE_CPU_FEATURES)
if(CpuFeatures_FOUND) set_source_files_properties(volk_gnsssdr_cpu.c PROPERTIES COMPILE_DEFINITIONS "VOLK_CPU_FEATURES=1")
if(CPUFEATURES_FOUND)
target_include_directories(volk_gnsssdr_obj target_include_directories(volk_gnsssdr_obj
PRIVATE PRIVATE
$<TARGET_PROPERTY:CpuFeatures::cpu_features,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:CpuFeature::cpu_features,INTERFACE_INCLUDE_DIRECTORIES>
) )
else() else()
target_include_directories(volk_gnsssdr_obj target_include_directories(volk_gnsssdr_obj
@ -548,6 +549,10 @@ if(NOT (CMAKE_GENERATOR STREQUAL Xcode))
if(NOT MSVC) if(NOT MSVC)
set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC") set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC")
endif() endif()
else()
if(USE_CPU_FEATURES)
set_source_files_properties(volk_gnsssdr_cpu.c PROPERTIES COMPILE_DEFINITIONS "VOLK_CPU_FEATURES=1")
endif()
endif() endif()
# Add dynamic library # Add dynamic library
@ -557,10 +562,10 @@ else()
add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>) add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>)
endif() endif()
if(USE_CPU_FEATURES) if(USE_CPU_FEATURES)
if(CpuFeatures_FOUND) if(CPUFEATURES_FOUND)
target_link_libraries(volk_gnsssdr target_link_libraries(volk_gnsssdr
PUBLIC ${volk_gnsssdr_libraries} PUBLIC ${volk_gnsssdr_libraries}
PRIVATE CpuFeatures::cpu_features PRIVATE CpuFeature::cpu_features
) )
else() else()
target_link_libraries(volk_gnsssdr target_link_libraries(volk_gnsssdr
@ -580,10 +585,10 @@ target_include_directories(volk_gnsssdr
PUBLIC $<INSTALL_INTERFACE:include> PUBLIC $<INSTALL_INTERFACE:include>
) )
if(USE_CPU_FEATURES) if(USE_CPU_FEATURES)
if(CpuFeatures_FOUND) if(CPUFEATURES_FOUND)
target_include_directories(volk_gnsssdr target_include_directories(volk_gnsssdr
PRIVATE PRIVATE
$<TARGET_PROPERTY:CpuFeatures::cpu_features,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:CpuFeature::cpu_features,INTERFACE_INCLUDE_DIRECTORIES>
) )
else() else()
target_include_directories(volk_gnsssdr target_include_directories(volk_gnsssdr
@ -620,9 +625,9 @@ if(ENABLE_STATIC_LIBS)
endif() endif()
target_link_libraries(volk_gnsssdr_static PUBLIC ${volk_gnsssdr_libraries}) target_link_libraries(volk_gnsssdr_static PUBLIC ${volk_gnsssdr_libraries})
if(USE_CPU_FEATURES) if(USE_CPU_FEATURES)
if(CpuFeatures_FOUND) if(CPUFEATURES_FOUND)
target_link_libraries(volk_gnsssdr_static target_link_libraries(volk_gnsssdr_static
PRIVATE CpuFeatures::cpu_features PRIVATE CpuFeature::cpu_features
) )
else() else()
target_link_libraries(volk_gnsssdr_static target_link_libraries(volk_gnsssdr_static

View File

@ -14,6 +14,7 @@
#include <string.h> #include <string.h>
// clang-format on // clang-format on
#if defined(VOLK_CPU_FEATURES)
#include "cpu_features_macros.h" #include "cpu_features_macros.h"
#if defined(CPU_FEATURES_ARCH_X86) #if defined(CPU_FEATURES_ARCH_X86)
#include "cpuinfo_x86.h" #include "cpuinfo_x86.h"
@ -31,6 +32,7 @@
#if defined(__cplusplus) #if defined(__cplusplus)
using namespace cpu_features; using namespace cpu_features;
#endif #endif
#endif
struct VOLK_CPU volk_gnsssdr_cpu; struct VOLK_CPU volk_gnsssdr_cpu;

View File

@ -33,11 +33,11 @@ boost::system::error_code Rtl_Tcp_Dongle_Info::read(boost::asio::ip::tcp::socket
{ {
boost::system::error_code ec; boost::system::error_code ec;
unsigned char data[sizeof(char) * 4 + sizeof(uint32_t) * 2]; std::vector<unsigned char> data(sizeof(char) * 4 + sizeof(uint32_t) * 2);
size_t received_bits = socket.receive(boost::asio::buffer(data), 0, ec); size_t received_bits = socket.receive(boost::asio::buffer(data), 0, ec);
if (!ec && (received_bits > 0)) if (!ec && (received_bits > 0))
{ {
std::memcpy(magic_, data, 4); std::memcpy(magic_, data.data(), 4);
uint32_t type; uint32_t type;
std::memcpy(&type, &data[4], 4); std::memcpy(&type, &data[4], 4);

View File

@ -178,8 +178,7 @@ void Galileo_E1_Tcp_Connector_Tracking_cc::start_tracking()
d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_doppler_hz = d_acq_carrier_doppler_hz;
d_current_prn_length_samples = d_vector_length; d_current_prn_length_samples = d_vector_length;
std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
// DEBUG OUTPUT // DEBUG OUTPUT
std::cout << "Tracking of Galileo E1 signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; std::cout << "Tracking of Galileo E1 signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n';

View File

@ -263,8 +263,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking()
d_pll_to_dll_assist_secs_Ti = 0.0; d_pll_to_dll_assist_secs_Ti = 0.0;
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
const std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
d_acc_carrier_phase_initialized = false; d_acc_carrier_phase_initialized = false;
// DEBUG OUTPUT // DEBUG OUTPUT

View File

@ -263,8 +263,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking()
d_pll_to_dll_assist_secs_Ti = 0.0; d_pll_to_dll_assist_secs_Ti = 0.0;
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
const std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
d_acc_carrier_phase_initialized = false; d_acc_carrier_phase_initialized = false;
// DEBUG OUTPUT // DEBUG OUTPUT

View File

@ -205,8 +205,7 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::start_tracking()
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
const std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
d_acc_carrier_phase_initialized = false; d_acc_carrier_phase_initialized = false;
// DEBUG OUTPUT // DEBUG OUTPUT

View File

@ -259,8 +259,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::start_tracking()
d_pll_to_dll_assist_secs_Ti = 0.0; d_pll_to_dll_assist_secs_Ti = 0.0;
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
const std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
// DEBUG OUTPUT // DEBUG OUTPUT
std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n';

View File

@ -260,8 +260,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking()
d_pll_to_dll_assist_secs_Ti = 0.0; d_pll_to_dll_assist_secs_Ti = 0.0;
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
const std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
// DEBUG OUTPUT // DEBUG OUTPUT
std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n';

View File

@ -206,8 +206,7 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::start_tracking()
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
const std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
// DEBUG OUTPUT // DEBUG OUTPUT
std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n';

View File

@ -218,8 +218,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking()
d_pll_to_dll_assist_secs_Ti = 0.0; d_pll_to_dll_assist_secs_Ti = 0.0;
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
const std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
// DEBUG OUTPUT // DEBUG OUTPUT
std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n';

View File

@ -302,8 +302,7 @@ void Gps_L1_Ca_Kf_Tracking_cc::start_tracking()
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
// DEBUG OUTPUT // DEBUG OUTPUT
std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n';

View File

@ -203,8 +203,7 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking()
d_code_phase_samples = d_acq_code_phase_samples; d_code_phase_samples = d_acq_code_phase_samples;
std::string sys_ = &d_acquisition_gnss_synchro->System; sys = std::string(1, d_acquisition_gnss_synchro->System);
sys = sys_.substr(0, 1);
// DEBUG OUTPUT // DEBUG OUTPUT
std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n'; std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << '\n';

View File

@ -19,6 +19,7 @@
#include "gnss_sdr_supl_client.h" #include "gnss_sdr_supl_client.h"
#include "GPS_L1_CA.h" #include "GPS_L1_CA.h"
#include "MATH_CONSTANTS.h"
#include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/map.hpp> #include <boost/serialization/map.hpp>
@ -833,7 +834,7 @@ bool Gnss_Sdr_Supl_Client::load_gal_almanac_xml(const std::string& file_name)
} }
catch (std::exception& e) catch (std::exception& e)
{ {
// Maybe the file is from https://www.gsc-europa.eu/system-status/almanac-data ? // Maybe the file is from https://www.gsc-europa.eu/product-almanacs ?
return this->read_gal_almanac_from_gsa(file_name); return this->read_gal_almanac_from_gsa(file_name);
} }
LOG(INFO) << "Loaded Galileo almanac map data with " << this->gal_almanac_map.size() << " satellites"; LOG(INFO) << "Loaded Galileo almanac map data with " << this->gal_almanac_map.size() << " satellites";
@ -858,6 +859,7 @@ bool Gnss_Sdr_Supl_Client::read_gal_almanac_from_gsa(const std::string& file_nam
Galileo_Almanac gal_alm; Galileo_Almanac gal_alm;
try try
{ {
const double sqrtAnominal = 5440.588203494; // square root of Galileo nominal orbit semi-major axis
uint32_t prn = static_cast<uint32_t>(std::stoi(almanac.child_value("SVID"))); uint32_t prn = static_cast<uint32_t>(std::stoi(almanac.child_value("SVID")));
gal_alm.PRN = prn; gal_alm.PRN = prn;
gal_alm.toa = std::stoi(almanac.child("almanac").child_value("t0a")); gal_alm.toa = std::stoi(almanac.child("almanac").child_value("t0a"));
@ -866,7 +868,7 @@ bool Gnss_Sdr_Supl_Client::read_gal_almanac_from_gsa(const std::string& file_nam
gal_alm.delta_i = std::stod(almanac.child("almanac").child_value("deltai")); gal_alm.delta_i = std::stod(almanac.child("almanac").child_value("deltai"));
gal_alm.M_0 = std::stod(almanac.child("almanac").child_value("m0")); gal_alm.M_0 = std::stod(almanac.child("almanac").child_value("m0"));
gal_alm.ecc = std::stod(almanac.child("almanac").child_value("ecc")); gal_alm.ecc = std::stod(almanac.child("almanac").child_value("ecc"));
gal_alm.sqrtA = std::stod(almanac.child("almanac").child_value("aSqRoot")); gal_alm.sqrtA = std::stod(almanac.child("almanac").child_value("aSqRoot")) + sqrtAnominal;
gal_alm.OMEGA_0 = std::stod(almanac.child("almanac").child_value("omega0")); gal_alm.OMEGA_0 = std::stod(almanac.child("almanac").child_value("omega0"));
gal_alm.omega = std::stod(almanac.child("almanac").child_value("w")); gal_alm.omega = std::stod(almanac.child("almanac").child_value("w"));
gal_alm.OMEGAdot = std::stod(almanac.child("almanac").child_value("omegaDot")); gal_alm.OMEGAdot = std::stod(almanac.child("almanac").child_value("omegaDot"));

View File

@ -6,6 +6,7 @@
set(SYSTEM_PARAMETERS_SOURCES set(SYSTEM_PARAMETERS_SOURCES
gnss_almanac.cc
gnss_ephemeris.cc gnss_ephemeris.cc
gnss_satellite.cc gnss_satellite.cc
gnss_signal.cc gnss_signal.cc

View File

@ -36,7 +36,10 @@ public:
/*! /*!
* Default constructor * Default constructor
*/ */
Beidou_Dnav_Almanac() = default; Beidou_Dnav_Almanac()
{
this->System = 'B';
};
int SV_health{}; //!< SV Health int SV_health{}; //!< SV Health

View File

@ -36,7 +36,10 @@ public:
/*! /*!
* Default constructor * Default constructor
*/ */
Galileo_Almanac() = default; Galileo_Almanac()
{
this->System = 'E';
};
int32_t IODa{}; int32_t IODa{};
int32_t E5b_HS{}; int32_t E5b_HS{};

View File

@ -0,0 +1,275 @@
/*!
* \file gnss_almanac.cc
* \brief Base class for GNSS almanac storage
* \author Carles Fernandez, 2022. cfernandez(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "gnss_almanac.h"
#include "MATH_CONSTANTS.h"
#include "gnss_frequencies.h"
#include <algorithm>
#include <cmath>
#include <functional>
#include <numeric>
#include <vector>
double Gnss_Almanac::check_t(double time) const
{
const double half_week = 302400.0; // seconds
double corrTime = time;
if (time > half_week)
{
corrTime = time - 2.0 * half_week;
}
else if (time < -half_week)
{
corrTime = time + 2.0 * half_week;
}
return corrTime;
}
double Gnss_Almanac::predicted_doppler(double rx_time_s,
double lat,
double lon,
double h,
double ve,
double vn,
double vu,
int band) const
{
const double RE_WGS84 = 6378137.0; //!< earth semimajor axis (WGS84) (m)
const double FE_WGS84 = (1.0 / 298.257223563); //!< earth flattening (WGS84)
const double lat_rad = lat * D2R;
const double lon_rad = lon * D2R;
const double sinp = sin(lat_rad);
const double cosp = cos(lat_rad);
const double sinl = sin(lon_rad);
const double cosl = cos(lon_rad);
const double e2 = FE_WGS84 * (2.0 - FE_WGS84);
const double v = RE_WGS84 / std::sqrt(1.0 - e2 * sinp * sinp);
// Position in EFEF
const std::vector<double> pos_rx = {(v + h) * cosp * cosl, (v + h) * cosp * sinl, (v * (1.0 - e2) + h) * sinp};
// Velocity in EFEF
const double t = cosp * vu - sinp * vn;
const std::vector<double> vel_rx = {cosl * t - sinl * ve, sinl * t + cosl * ve, sinp * vu + cosp * vn};
std::array<double, 7> sat_pos_vel = {0};
satellitePosVelComputation(rx_time_s, sat_pos_vel);
const std::vector<double> pos_sat = {sat_pos_vel[0], sat_pos_vel[1], sat_pos_vel[2]};
const std::vector<double> vel_sat = {sat_pos_vel[3], sat_pos_vel[4], sat_pos_vel[5]};
std::vector<double> x_sr = pos_sat;
std::transform(x_sr.begin(), x_sr.end(), pos_rx.begin(), x_sr.begin(), std::minus<double>()); // pos_sat - pos_rx
const double norm_x_sr = std::sqrt(std::inner_product(x_sr.begin(), x_sr.end(), x_sr.begin(), 0.0)); // Euclidean norm
std::vector<double> v_sr = vel_sat;
std::transform(v_sr.begin(), v_sr.end(), vel_rx.begin(), v_sr.begin(), std::minus<double>()); // vel_sat - vel_rx
const double radial_vel = std::inner_product(v_sr.begin(), v_sr.end(), x_sr.begin(), 0.0) / norm_x_sr;
const double predicted_doppler_normalized = -(radial_vel / SPEED_OF_LIGHT_M_S);
double predicted_doppler = 0.0;
if (this->System == 'E') // Galileo
{
if (band == 1)
{
predicted_doppler = predicted_doppler_normalized * FREQ1;
}
else if (band == 5)
{
predicted_doppler = predicted_doppler_normalized * FREQ5;
}
else if (band == 6)
{
predicted_doppler = predicted_doppler_normalized * FREQ6;
}
else if (band == 7)
{
predicted_doppler = predicted_doppler_normalized * FREQ7;
}
else if (band == 8)
{
predicted_doppler = predicted_doppler_normalized * FREQ8;
}
else
{
predicted_doppler = 0.0;
}
}
else if (this->System == 'G') // GPS
{
if (band == 1)
{
predicted_doppler = predicted_doppler_normalized * FREQ1;
}
else if (band == 2)
{
predicted_doppler = predicted_doppler_normalized * FREQ2;
}
else if (band == 5)
{
predicted_doppler = predicted_doppler_normalized * FREQ5;
}
else
{
predicted_doppler = 0.0;
}
}
else if (this->System == 'B') // Beidou
{
if (band == 1)
{
predicted_doppler = predicted_doppler_normalized * FREQ1_BDS;
}
else if (band == 2)
{
predicted_doppler = predicted_doppler_normalized * FREQ2_BDS;
}
else if (band == 3)
{
predicted_doppler = predicted_doppler_normalized * FREQ3_BDS;
}
else
{
predicted_doppler = 0.0;
}
}
else
{
predicted_doppler = 0.0;
}
return predicted_doppler;
}
void Gnss_Almanac::satellitePosVelComputation(double transmitTime, std::array<double, 7>& pos_vel_dtr) const
{
// Restore semi-major axis
const double a = this->sqrtA * this->sqrtA;
// Computed mean motion
double n;
if (this->System == 'E')
{
n = sqrt(GALILEO_GM / (a * a * a));
}
else if (this->System == 'B')
{
n = sqrt(BEIDOU_GM / (a * a * a));
}
else
{
n = sqrt(GPS_GM / (a * a * a));
}
// Time from ephemeris reference epoch
const double tk = check_t(transmitTime - static_cast<double>(this->toa));
// Mean anomaly
const double M = this->M_0 * GNSS_PI + n * tk;
// Initial guess of eccentric anomaly
double E = M;
double E_old;
double dE;
// --- Iteratively compute eccentric anomaly -------------------------------
for (int32_t ii = 1; ii < 20; ii++)
{
E_old = E;
E = M + this->ecc * sin(E);
dE = fmod(E - E_old, 2.0 * GNSS_PI);
if (fabs(dE) < 1e-12)
{
// Necessary precision is reached, exit from the loop
break;
}
}
const double sek = sin(E);
const double cek = cos(E);
const double OneMinusecosE = 1.0 - this->ecc * cek;
const double sq1e2 = sqrt(1.0 - this->ecc * this->ecc);
const double ekdot = n / OneMinusecosE;
// Compute the true anomaly
const double tmp_Y = sq1e2 * sek;
const double tmp_X = cek - this->ecc;
const double nu = atan2(tmp_Y, tmp_X);
// Compute angle phi (argument of Latitude)
const double phi = nu + this->omega * GNSS_PI;
const double pkdot = sq1e2 * ekdot / OneMinusecosE;
// Correct argument of latitude
const double suk = sin(phi);
const double cuk = cos(phi);
// Correct radius
const double r = a * OneMinusecosE;
const double rkdot = a * this->ecc * sek * ekdot;
// Correct inclination
double i;
if (this->System == 'E')
{
i = ((56.0 / 180.0) + this->delta_i) * GNSS_PI;
}
else
{
i = (0.3 + this->delta_i) * GNSS_PI;
}
const double sik = sin(i);
const double cik = cos(i);
// Compute the angle between the ascending node and the Greenwich meridian
double Omega;
double Omega_dot;
if (this->System == 'B')
{
Omega_dot = this->OMEGAdot * GNSS_PI - BEIDOU_OMEGA_EARTH_DOT;
Omega = this->OMEGA_0 * GNSS_PI + Omega_dot * tk - BEIDOU_OMEGA_EARTH_DOT * static_cast<double>(this->toa);
}
else
{
Omega_dot = this->OMEGAdot * GNSS_PI - GNSS_OMEGA_EARTH_DOT;
Omega = this->OMEGA_0 * GNSS_PI + Omega_dot * tk - GNSS_OMEGA_EARTH_DOT * static_cast<double>(this->toa);
}
const double sok = sin(Omega);
const double cok = cos(Omega);
// --- Compute satellite coordinates in Earth-fixed coordinates
const double xprime = r * cuk;
const double yprime = r * suk;
pos_vel_dtr[0] = xprime * cok - yprime * cik * sok;
pos_vel_dtr[1] = xprime * sok + yprime * cik * cok;
pos_vel_dtr[2] = yprime * sik;
// Satellite's velocity
const double xpkdot = rkdot * cuk - yprime * pkdot;
const double ypkdot = rkdot * suk + xprime * pkdot;
const double tmp = ypkdot * cik;
pos_vel_dtr[3] = -Omega_dot * pos_vel_dtr[1] + xpkdot * cok - tmp * sok;
pos_vel_dtr[4] = Omega_dot * pos_vel_dtr[0] + xpkdot * sok + tmp * cok;
pos_vel_dtr[5] = ypkdot * sik;
pos_vel_dtr[6] = 0;
}

View File

@ -18,6 +18,7 @@
#ifndef GNSS_SDR_GNSS_ALMANAC_H #ifndef GNSS_SDR_GNSS_ALMANAC_H
#define GNSS_SDR_GNSS_ALMANAC_H #define GNSS_SDR_GNSS_ALMANAC_H
#include <array>
#include <cstdint> #include <cstdint>
/** \addtogroup Core /** \addtogroup Core
@ -37,6 +38,46 @@ public:
*/ */
Gnss_Almanac() = default; Gnss_Almanac() = default;
/*!
* \brief Computes prediction of the Doppler shift for a given time and receiver's position and velocity.
* \f[
* f_{d} = - \mathbf{v} \frac{\mathbf{x}^{T}}{\left| \mathbf{x} \right| } \frac{f_{L}}{c}
* \f]
* where:
* \f[
* \mathbf{v} = \mathbf{v}_{sat} - \mathbf{v}_{rx}
* \f]
* \f[
* \mathbf{x} = \mathbf{x}_{sat} - \mathbf{x}_{rx}
* \f]
* \f[
* \left| \mathbf{x} \right| = \sqrt{\mathbf{x}\mathbf{x}^{T}}
* \f]
*
* @param[in] rx_time_s Time of Week in seconds
* @param[in] lat Receiver's latitude in degrees
* @param[in] lon Receiver's longitude in degrees
* @param[in] h Receiver's height in meters
* @param[in] ve Receiver's velocity in the East direction [m/s]
* @param[in] vn Receiver's velocity in the North direction [m/s]
* @param[in] vu Receiver's velocity in the Up direction [m/s]
* @param[in] band Signal band for which the Doppler will be computed
* (1: L1 C/A, E1B, BI1; 2: L2C, BI2; 3: BI3; 5: L5/E5a; 6: E6B; 7: E5b; 8: E5a+E5b)
*/
double predicted_doppler(double rx_time_s,
double lat,
double lon,
double h,
double ve,
double vn,
double vu,
int band) const;
/*!
* \brief Computes satellite Position and Velocity, in ECEF, for a given time (expressed in seconds of week)
*/
void satellitePosVelComputation(double transmitTime, std::array<double, 7>& pos_vel_dtr) const;
uint32_t PRN{}; //!< SV PRN NUMBER uint32_t PRN{}; //!< SV PRN NUMBER
double delta_i{}; //!< Inclination Angle at Reference Time (relative to i_0 = 0.30 semi-circles) double delta_i{}; //!< Inclination Angle at Reference Time (relative to i_0 = 0.30 semi-circles)
int32_t toa{}; //!< Almanac data reference time of week [s] int32_t toa{}; //!< Almanac data reference time of week [s]
@ -49,6 +90,11 @@ public:
double OMEGAdot{}; //!< Rate of Right Ascension [semi-circles/s] double OMEGAdot{}; //!< Rate of Right Ascension [semi-circles/s]
double af0{}; //!< Coefficient 0 of code phase offset model [s] double af0{}; //!< Coefficient 0 of code phase offset model [s]
double af1{}; //!< Coefficient 1 of code phase offset model [s/s] double af1{}; //!< Coefficient 1 of code phase offset model [s/s]
protected:
char System{}; //!< Character ID of the GNSS system. 'G': GPS. 'E': Galileo. 'B': BeiDou
private:
double check_t(double time) const;
}; };

View File

@ -17,10 +17,156 @@
#include "gnss_ephemeris.h" #include "gnss_ephemeris.h"
#include "MATH_CONSTANTS.h" #include "MATH_CONSTANTS.h"
#include "gnss_frequencies.h"
#include <algorithm>
#include <cmath> #include <cmath>
#include <functional>
#include <numeric>
#include <vector>
double Gnss_Ephemeris::sv_clock_drift(double transmitTime)
{
const double dt = check_t(transmitTime - this->toc);
this->dtr = sv_clock_relativistic_term(transmitTime);
this->satClkDrift = this->af0 + this->af1 * dt + this->af2 * (dt * dt) + this->dtr;
return this->satClkDrift;
}
double Gnss_Ephemeris::predicted_doppler(double rx_time_s,
double lat,
double lon,
double h,
double ve,
double vn,
double vu,
int band) const
{
const double RE_WGS84 = 6378137.0; //!< earth semimajor axis (WGS84) (m)
const double FE_WGS84 = (1.0 / 298.257223563); //!< earth flattening (WGS84)
const double lat_rad = lat * D2R;
const double lon_rad = lon * D2R;
const double sinp = sin(lat_rad);
const double cosp = cos(lat_rad);
const double sinl = sin(lon_rad);
const double cosl = cos(lon_rad);
const double e2 = FE_WGS84 * (2.0 - FE_WGS84);
const double v = RE_WGS84 / std::sqrt(1.0 - e2 * sinp * sinp);
// Position in EFEF
const std::vector<double> pos_rx = {(v + h) * cosp * cosl, (v + h) * cosp * sinl, (v * (1.0 - e2) + h) * sinp};
// Velocity in EFEF
const double t = cosp * vu - sinp * vn;
const std::vector<double> vel_rx = {cosl * t - sinl * ve, sinl * t + cosl * ve, sinp * vu + cosp * vn};
std::array<double, 7> sat_pos_vel = {0};
satellitePosVelComputation(rx_time_s, sat_pos_vel);
const std::vector<double> pos_sat = {sat_pos_vel[0], sat_pos_vel[1], sat_pos_vel[2]};
const std::vector<double> vel_sat = {sat_pos_vel[3], sat_pos_vel[4], sat_pos_vel[5]};
std::vector<double> x_sr = pos_sat;
std::transform(x_sr.begin(), x_sr.end(), pos_rx.begin(), x_sr.begin(), std::minus<double>()); // pos_sat - pos_rx
const double norm_x_sr = std::sqrt(std::inner_product(x_sr.begin(), x_sr.end(), x_sr.begin(), 0.0)); // Euclidean norm
std::vector<double> v_sr = vel_sat;
std::transform(v_sr.begin(), v_sr.end(), vel_rx.begin(), v_sr.begin(), std::minus<double>()); // vel_sat - vel_rx
const double radial_vel = std::inner_product(v_sr.begin(), v_sr.end(), x_sr.begin(), 0.0) / norm_x_sr;
const double predicted_doppler_normalized = -(radial_vel / SPEED_OF_LIGHT_M_S);
double predicted_doppler = 0.0;
if (this->System == 'E') // Galileo
{
if (band == 1)
{
predicted_doppler = predicted_doppler_normalized * FREQ1;
}
else if (band == 5)
{
predicted_doppler = predicted_doppler_normalized * FREQ5;
}
else if (band == 6)
{
predicted_doppler = predicted_doppler_normalized * FREQ6;
}
else if (band == 7)
{
predicted_doppler = predicted_doppler_normalized * FREQ7;
}
else if (band == 8)
{
predicted_doppler = predicted_doppler_normalized * FREQ8;
}
else
{
predicted_doppler = 0.0;
}
}
else if (this->System == 'G') // GPS
{
if (band == 1)
{
predicted_doppler = predicted_doppler_normalized * FREQ1;
}
else if (band == 2)
{
predicted_doppler = predicted_doppler_normalized * FREQ2;
}
else if (band == 5)
{
predicted_doppler = predicted_doppler_normalized * FREQ5;
}
else
{
predicted_doppler = 0.0;
}
}
else if (this->System == 'B') // Beidou
{
if (band == 1)
{
predicted_doppler = predicted_doppler_normalized * FREQ1_BDS;
}
else if (band == 2)
{
predicted_doppler = predicted_doppler_normalized * FREQ2_BDS;
}
else if (band == 3)
{
predicted_doppler = predicted_doppler_normalized * FREQ3_BDS;
}
else
{
predicted_doppler = 0.0;
}
}
else
{
predicted_doppler = 0.0;
}
return predicted_doppler;
}
void Gnss_Ephemeris::satellitePosition(double transmitTime) void Gnss_Ephemeris::satellitePosition(double transmitTime)
{
std::array<double, 7> pos_vel_dtr = {0};
satellitePosVelComputation(transmitTime, pos_vel_dtr);
this->satpos_X = pos_vel_dtr[0];
this->satpos_Y = pos_vel_dtr[1];
this->satpos_Z = pos_vel_dtr[2];
this->satvel_X = pos_vel_dtr[3];
this->satvel_Y = pos_vel_dtr[4];
this->satvel_Z = pos_vel_dtr[5];
this->dtr = pos_vel_dtr[6];
}
void Gnss_Ephemeris::satellitePosVelComputation(double transmitTime, std::array<double, 7>& pos_vel_dtr) const
{ {
// Restore semi-major axis // Restore semi-major axis
const double a = this->sqrtA * this->sqrtA; const double a = this->sqrtA * this->sqrtA;
@ -47,10 +193,7 @@ void Gnss_Ephemeris::satellitePosition(double transmitTime)
const double n = n0 + this->delta_n; const double n = n0 + this->delta_n;
// Mean anomaly // Mean anomaly
double M = this->M_0 + n * tk; const double M = this->M_0 + n * tk;
// Reduce mean anomaly to between 0 and 2pi
M = fmod((M + 2.0 * GNSS_PI), (2.0 * GNSS_PI));
// Initial guess of eccentric anomaly // Initial guess of eccentric anomaly
double E = M; double E = M;
@ -82,10 +225,9 @@ void Gnss_Ephemeris::satellitePosition(double transmitTime)
const double nu = atan2(tmp_Y, tmp_X); const double nu = atan2(tmp_Y, tmp_X);
// Compute angle phi (argument of Latitude) // Compute angle phi (argument of Latitude)
double phi = nu + this->omega; const double phi = nu + this->omega;
// Reduce phi to between 0 and 2*pi rad // Reduce phi to between 0 and 2*pi rad
phi = fmod((phi), (2.0 * GNSS_PI));
const double s2pk = sin(2.0 * phi); const double s2pk = sin(2.0 * phi);
const double c2pk = cos(2.0 * phi); const double c2pk = cos(2.0 * phi);
const double pkdot = sq1e2 * ekdot / OneMinusecosE; const double pkdot = sq1e2 * ekdot / OneMinusecosE;
@ -120,53 +262,59 @@ void Gnss_Ephemeris::satellitePosition(double transmitTime)
Omega = this->OMEGA_0 + Omega_dot * tk - GNSS_OMEGA_EARTH_DOT * static_cast<double>(this->toe); Omega = this->OMEGA_0 + Omega_dot * tk - GNSS_OMEGA_EARTH_DOT * static_cast<double>(this->toe);
} }
// Reduce to between 0 and 2*pi rad
Omega = fmod((Omega + 2.0 * GNSS_PI), (2.0 * GNSS_PI));
const double sok = sin(Omega); const double sok = sin(Omega);
const double cok = cos(Omega); const double cok = cos(Omega);
// --- Compute satellite coordinates in Earth-fixed coordinates // --- Compute satellite coordinates in Earth-fixed coordinates
const double xprime = r * cuk; const double xprime = r * cuk;
const double yprime = r * suk; const double yprime = r * suk;
this->satpos_X = xprime * cok - yprime * cik * sok;
this->satpos_Y = xprime * sok + yprime * cik * cok; // ********NOTE: in GALILEO ICD this expression is not correct because it has minus (- sin(u) * r * cos(i) * cos(Omega)) instead of plus pos_vel_dtr[0] = xprime * cok - yprime * cik * sok;
this->satpos_Z = yprime * sik; pos_vel_dtr[1] = xprime * sok + yprime * cik * cok; // ********NOTE: in GALILEO ICD this expression is not correct because it has minus (- sin(u) * r * cos(i) * cos(Omega)) instead of plus
pos_vel_dtr[2] = yprime * sik;
// Satellite's velocity. Can be useful for Vector Tracking loops // Satellite's velocity. Can be useful for Vector Tracking loops
const double xpkdot = rkdot * cuk - yprime * ukdot; const double xpkdot = rkdot * cuk - yprime * ukdot;
const double ypkdot = rkdot * suk + xprime * ukdot; const double ypkdot = rkdot * suk + xprime * ukdot;
const double tmp = ypkdot * cik - this->satpos_Z * ikdot; const double tmp = ypkdot * cik - pos_vel_dtr[2] * ikdot;
this->satvel_X = -Omega_dot * this->satpos_Y + xpkdot * cok - tmp * sok; pos_vel_dtr[3] = -Omega_dot * pos_vel_dtr[1] + xpkdot * cok - tmp * sok;
this->satvel_Y = Omega_dot * this->satpos_X + xpkdot * sok + tmp * cok; pos_vel_dtr[4] = Omega_dot * pos_vel_dtr[0] + xpkdot * sok + tmp * cok;
this->satvel_Z = yprime * cik * ikdot + ypkdot * sik; pos_vel_dtr[5] = yprime * cik * ikdot + ypkdot * sik;
// Time from ephemeris reference clock // Time from ephemeris reference clock
tk = check_t(transmitTime - this->toc); tk = check_t(transmitTime - this->toc);
this->dtr = this->af0 + this->af1 * tk + this->af2 * tk * tk; pos_vel_dtr[6] = this->af0 + this->af1 * tk + this->af2 * tk * tk;
if (this->System == 'E') if (this->System == 'E')
{ {
this->dtr -= 2.0 * sqrt(GALILEO_GM * a) * this->ecc * sek / (SPEED_OF_LIGHT_M_S * SPEED_OF_LIGHT_M_S); pos_vel_dtr[6] -= 2.0 * sqrt(GALILEO_GM * a) * this->ecc * sek / (SPEED_OF_LIGHT_M_S * SPEED_OF_LIGHT_M_S);
} }
else if (this->System == 'B') else if (this->System == 'B')
{ {
this->dtr -= 2.0 * sqrt(BEIDOU_GM * a) * this->ecc * sek / (SPEED_OF_LIGHT_M_S * SPEED_OF_LIGHT_M_S); pos_vel_dtr[6] -= 2.0 * sqrt(BEIDOU_GM * a) * this->ecc * sek / (SPEED_OF_LIGHT_M_S * SPEED_OF_LIGHT_M_S);
} }
else else
{ {
this->dtr -= 2.0 * sqrt(GPS_GM * a) * this->ecc * sek / (SPEED_OF_LIGHT_M_S * SPEED_OF_LIGHT_M_S); pos_vel_dtr[6] -= 2.0 * sqrt(GPS_GM * a) * this->ecc * sek / (SPEED_OF_LIGHT_M_S * SPEED_OF_LIGHT_M_S);
} }
} }
double Gnss_Ephemeris::sv_clock_drift(double transmitTime) double Gnss_Ephemeris::check_t(double time) const
{ {
const double dt = check_t(transmitTime - this->toc); const double half_week = 302400.0; // seconds
this->dtr = sv_clock_relativistic_term(transmitTime); double corrTime = time;
this->satClkDrift = this->af0 + this->af1 * dt + this->af2 * (dt * dt) + this->dtr; if (time > half_week)
return this->satClkDrift; {
corrTime = time - 2.0 * half_week;
}
else if (time < -half_week)
{
corrTime = time + 2.0 * half_week;
}
return corrTime;
} }
@ -184,7 +332,7 @@ double Gnss_Ephemeris::sv_clock_relativistic_term(double transmitTime) const
{ {
n0 = sqrt(GALILEO_GM / (a * a * a)); n0 = sqrt(GALILEO_GM / (a * a * a));
} }
else if (this->System == 'E') else if (this->System == 'B')
{ {
n0 = sqrt(BEIDOU_GM / (a * a * a)); n0 = sqrt(BEIDOU_GM / (a * a * a));
} }
@ -198,9 +346,6 @@ double Gnss_Ephemeris::sv_clock_relativistic_term(double transmitTime) const
// Mean anomaly // Mean anomaly
const double M = this->M_0 + n * tk; const double M = this->M_0 + n * tk;
// Reduce mean anomaly to between 0 and 2pi
// M = fmod((M + 2.0 * GNSS_PI), (2.0 * GNSS_PI));
// Initial guess of eccentric anomaly // Initial guess of eccentric anomaly
double E = M; double E = M;
double E_old; double E_old;
@ -235,19 +380,3 @@ double Gnss_Ephemeris::sv_clock_relativistic_term(double transmitTime) const
} }
return dtr_; return dtr_;
} }
double Gnss_Ephemeris::check_t(double time) const
{
const double half_week = 302400.0; // seconds
double corrTime = time;
if (time > half_week)
{
corrTime = time - 2.0 * half_week;
}
else if (time < -half_week)
{
corrTime = time + 2.0 * half_week;
}
return corrTime;
}

View File

@ -19,6 +19,7 @@
#ifndef GNSS_SDR_GNSS_EPHEMERIS_H #ifndef GNSS_SDR_GNSS_EPHEMERIS_H
#define GNSS_SDR_GNSS_EPHEMERIS_H #define GNSS_SDR_GNSS_EPHEMERIS_H
#include <array>
#include <cstdint> #include <cstdint>
/*! /*!
@ -36,6 +37,34 @@ public:
*/ */
double sv_clock_drift(double transmitTime); double sv_clock_drift(double transmitTime);
/*!
* \brief Computes prediction of the Doppler shift for a given time and receiver's position and velocity.
* \f[
* f_{d} = - \mathbf{v} \frac{\mathbf{x}^{T}}{\left| \mathbf{x} \right| } \frac{f_{L}}{c}
* \f]
* where:
* \f[
* \mathbf{v} = \mathbf{v}_{sat} - \mathbf{v}_{rx}
* \f]
* \f[
* \mathbf{x} = \mathbf{x}_{sat} - \mathbf{x}_{rx}
* \f]
* \f[
* \left| \mathbf{x} \right| = \sqrt{\mathbf{x}\mathbf{x}^{T}}
* \f]
*
* @param[in] rx_time_s Time of Week in seconds
* @param[in] lat Receiver's latitude in degrees
* @param[in] lon Receiver's longitude in degrees
* @param[in] h Receiver's height in meters
* @param[in] ve Receiver's velocity in the East direction [m/s]
* @param[in] vn Receiver's velocity in the North direction [m/s]
* @param[in] vu Receiver's velocity in the Up direction [m/s]
* @param[in] band Signal band for which the Doppler will be computed
* (1: L1 C/A, E1B, BI1; 2: L2C, BI2; 3: BI3; 5: L5/E5a; 6: E6B; 7: E5b; 8: E5a+E5b)
*/
double predicted_doppler(double rx_time_s, double lat, double lon, double h, double ve, double vn, double vu, int band) const;
void satellitePosition(double transmitTime); //!< Computes the ECEF SV coordinates and ECEF velocity void satellitePosition(double transmitTime); //!< Computes the ECEF SV coordinates and ECEF velocity
uint32_t PRN{}; //!< SV ID uint32_t PRN{}; //!< SV ID
@ -83,6 +112,7 @@ protected:
char System{}; //!< Character ID of the GNSS system. 'G': GPS. 'E': Galileo. 'B': BeiDou char System{}; //!< Character ID of the GNSS system. 'G': GPS. 'E': Galileo. 'B': BeiDou
private: private:
void satellitePosVelComputation(double transmitTime, std::array<double, 7>& pos_vel_dtr) const;
double check_t(double time) const; double check_t(double time) const;
double sv_clock_relativistic_term(double transmitTime) const; double sv_clock_relativistic_term(double transmitTime) const;
}; };

View File

@ -525,7 +525,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_
} }
if (system_ == "Galileo") if (system_ == "Galileo")
{ {
// Check https://en.wikipedia.org/wiki/List_of_Galileo_satellites and https://www.gsc-europa.eu/system-status/Constellation-Information // Check https://en.wikipedia.org/wiki/List_of_Galileo_satellites and https://www.gsc-europa.eu/system-service-status/constellation-information
switch (PRN_) switch (PRN_)
{ {
case 1: case 1:

View File

@ -38,7 +38,10 @@ public:
/*! /*!
* Default constructor * Default constructor
*/ */
Gps_Almanac() = default; Gps_Almanac()
{
this->System = 'G';
};
int32_t SV_health{}; //!< SV Health int32_t SV_health{}; //!< SV Health
int32_t AS_status{}; //!< Anti-Spoofing Flags and SV Configuration int32_t AS_status{}; //!< Anti-Spoofing Flags and SV Configuration

View File

@ -465,18 +465,6 @@ Gps_Ephemeris Gps_Navigation_Message::get_ephemeris() const
ephemeris.alert_flag = b_alert_flag; ephemeris.alert_flag = b_alert_flag;
ephemeris.antispoofing_flag = b_antispoofing_flag; ephemeris.antispoofing_flag = b_antispoofing_flag;
// These parameters are empty; can be computed later with
// ephemeris.sv_clock_drift(double transmitTime);
// ephemeris.satellitePosition(double transmitTime);
ephemeris.satClkDrift = d_satClkDrift;
ephemeris.dtr = d_dtr;
ephemeris.satpos_X = d_satpos_X;
ephemeris.satpos_Y = d_satpos_Y;
ephemeris.satpos_Z = d_satpos_Z;
ephemeris.satvel_X = d_satvel_X;
ephemeris.satvel_Y = d_satvel_Y;
ephemeris.satvel_Z = d_satvel_Z;
return ephemeris; return ephemeris;
} }

View File

@ -195,22 +195,6 @@ private:
int32_t i_Toa{}; // Almanac reference time [s] int32_t i_Toa{}; // Almanac reference time [s]
int32_t i_WN_A{}; // Modulo 256 of the GPS week number to which the almanac reference time (i_Toa) is referenced int32_t i_WN_A{}; // Modulo 256 of the GPS week number to which the almanac reference time (i_Toa) is referenced
// clock terms
// double d_master_clock{}; // GPS transmission time
double d_dtr{}; // relativistic clock correction term
double d_satClkDrift{};
// satellite positions
double d_satpos_X{}; // Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and the plane passing through the origin and normal to the Z-axis.
double d_satpos_Y{}; // Earth-fixed coordinate y of the satellite [m]. Completes a right-handed, Earth-Centered, Earth-Fixed orthogonal coordinate system.
double d_satpos_Z{}; // Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP).
// Satellite velocity
double d_satvel_X{}; // Earth-fixed velocity coordinate x of the satellite [m]
double d_satvel_Y{}; // Earth-fixed velocity coordinate y of the satellite [m]
double d_satvel_Z{}; // Earth-fixed velocity coordinate z of the satellite [m]
// satellite identification info // satellite identification info
int32_t i_channel_ID{}; int32_t i_channel_ID{};
uint32_t i_satellite_PRN{}; uint32_t i_satellite_PRN{};

View File

@ -18,7 +18,7 @@
*/ */
#ifndef GNSS_SDR_VERSION #ifndef GNSS_SDR_VERSION
#define GNSS_SDR_VERSION "0.0.16" #define GNSS_SDR_VERSION "0.0.17"
#endif #endif
#ifndef GOOGLE_STRIP_LOG #ifndef GOOGLE_STRIP_LOG

View File

@ -403,12 +403,12 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)
-DCMAKE_C_STANDARD=11 -DCMAKE_C_STANDARD=11
-DCMAKE_C_EXTENSIONS=ON -DCMAKE_C_EXTENSIONS=ON
BUILD_COMMAND ${GPSTK_BUILD_COMMAND} ${GPSTK_PARALLEL_BUILD} BUILD_COMMAND ${GPSTK_BUILD_COMMAND} ${GPSTK_PARALLEL_BUILD}
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX} BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX}
UPDATE_COMMAND "" UPDATE_COMMAND ""
) )
endif() endif()
set(GPSTK_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include CACHE PATH "Local GPSTK headers") set(GPSTK_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include CACHE PATH "Local GPSTK headers")
set(GPSTK_LIBRARY ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX}) set(GPSTK_LIBRARY ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GPSTK_BINDIR ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/bin/) set(GPSTK_BINDIR ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/bin/)
add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}") add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}")
add_library(Gpstk::gpstk STATIC IMPORTED) add_library(Gpstk::gpstk STATIC IMPORTED)

View File

@ -1,7 +1,7 @@
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: 2020 Carles Fernandez-Prades <carles.fernandez@cttc.es> SPDX-FileCopyrightText: 2020 Carles Fernandez-Prades <carles.fernandez@cttc.es>
--- CMakeLists.txt 2020-10-25 10:06:26.000000000 +0100 --- CMakeLists.txt 2022-04-05 23:24:04.000000000 +0200
+++ CMakeLists.txt 2020-10-25 10:06:11.000000000 +0100 +++ CMakeLists.txt 2022-04-05 23:29:02.000000000 +0200
@@ -77,7 +77,16 @@ @@ -77,7 +77,16 @@
@ -20,3 +20,12 @@ SPDX-FileCopyrightText: 2020 Carles Fernandez-Prades <carles.fernandez@cttc.es>
#============================================================ #============================================================
# Core Library Target Files # Core Library Target Files
#============================================================ #============================================================
@@ -160,7 +169,7 @@
add_library( gpstk ${STADYN} ${GPSTK_SRC_FILES} ${GPSTK_INC_FILES} )
# GPSTk library install target
-install( TARGETS gpstk DESTINATION "${CMAKE_INSTALL_LIBDIR}" EXPORT "${EXPORT_TARGETS_FILENAME}" )
+install( TARGETS gpstk DESTINATION lib EXPORT "${EXPORT_TARGETS_FILENAME}" )
# GPSTk header file install target (whether it is version dependent changes based on user flag)
install( FILES ${GPSTK_INC_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )

View File

@ -26,6 +26,7 @@
#include "in_memory_configuration.h" #include "in_memory_configuration.h"
#include "signal_generator.h" #include "signal_generator.h"
#include "signal_generator_c.h" #include "signal_generator_c.h"
#include <boost/exception/diagnostic_information.hpp>
#include <gnuradio/analog/sig_source_waveform.h> #include <gnuradio/analog/sig_source_waveform.h>
#include <gnuradio/blocks/file_source.h> #include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/null_sink.h> #include <gnuradio/blocks/null_sink.h>

View File

@ -35,6 +35,7 @@
#include "gnss_signal.h" #include "gnss_signal.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "in_memory_configuration.h" #include "in_memory_configuration.h"
#include <boost/exception/diagnostic_information.hpp>
#include <gnuradio/analog/sig_source_waveform.h> #include <gnuradio/analog/sig_source_waveform.h>
#include <gnuradio/blocks/file_source.h> #include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/null_sink.h> #include <gnuradio/blocks/null_sink.h>

View File

@ -344,9 +344,9 @@ int main(int argc, char** argv)
{ {
std::cout << "Exception caught while capturing samples (bad lexical cast)\n"; std::cout << "Exception caught while capturing samples (bad lexical cast)\n";
} }
catch (const boost::io::too_few_args& e) catch (const std::exception& e)
{ {
std::cout << "Exception caught while capturing samples (too few args)\n"; std::cout << "Exception caught while capturing samples: " << e.what() << '\n';
} }
catch (...) catch (...)
{ {

View File

@ -10,7 +10,7 @@ if("${ARMADILLO_VERSION_STRING}" VERSION_GREATER "9.800" OR (NOT ARMADILLO_FOUND
find_package(GPSTK QUIET) find_package(GPSTK QUIET)
if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK)
include(GNUInstallDirs) include(GNUInstallDirs)
set(GPSTK_LIBRARY ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX}) set(GPSTK_LIBRARY ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GPSTK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include) set(GPSTK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include)
endif() endif()
@ -55,19 +55,25 @@ if("${ARMADILLO_VERSION_STRING}" VERSION_GREATER "9.800" OR (NOT ARMADILLO_FOUND
add_dependencies(obsdiff matio-${GNSSSDR_MATIO_LOCAL_VERSION}) add_dependencies(obsdiff matio-${GNSSSDR_MATIO_LOCAL_VERSION})
endif() endif()
if(NOT TARGET Gpstk::gpstk)
file(MAKE_DIRECTORY ${GPSTK_INCLUDE_DIR}/gpstk)
add_library(Gpstk::gpstk STATIC IMPORTED)
add_dependencies(Gpstk::gpstk gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION})
set_target_properties(Gpstk::gpstk PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${GPSTK_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GPSTK_INCLUDE_DIR};${GPSTK_INCLUDE_DIR}/gpstk"
INTERFACE_LINK_LIBRARIES "${GPSTK_LIBRARY}"
)
endif()
target_link_libraries(obsdiff target_link_libraries(obsdiff
PRIVATE PRIVATE
Armadillo::armadillo Armadillo::armadillo
Threads::Threads Threads::Threads
Gflags::gflags Gflags::gflags
Matio::matio Matio::matio
${GPSTK_LIBRARY} Gpstk::gpstk
)
target_include_directories(obsdiff
PRIVATE
${GPSTK_INCLUDE_DIR}/gpstk
${GPSTK_INCLUDE_DIR}
) )
if(GPSTK_OLDER_THAN_8) if(GPSTK_OLDER_THAN_8)

View File

@ -0,0 +1,126 @@
#!/bin/sh
# GNSS-SDR shell script that tries to download the latest Galileo Almanac file
# published by the European GNSS Service Centre.
#
# Usage: ./download-galileo-almanac.sh
#
# SPDX-FileCopyrightText: 2022 Carles Fernandez-Prades <cfernandez(at)cttc.es>
# SPDX-License-Identifier: GPL-3.0-or-later
if ! [ -x "$(command -v wget)" ]; then
echo "Please install wget before using this script."
exit 1
fi
help()
{
echo "This script tries to download the most recent Galileo Almanac XML file"
echo "published by the European GNSS Service Centre."
echo "More info at https://www.gsc-europa.eu/product-almanacs"
echo "If today there is no published file, the script will look up to one week ago."
echo ""
echo "Usage:"
echo "./download-galileo-almanac.sh [OPTION]"
echo " Options:"
echo " -h, --help Prints this message"
echo " -r, --rename Gets latest Galileo Almanac XML file and saves it as gal_almanac.xml"
echo " -d, --date [date] Retrieves file for a specific date, with format YYYY-MM-DD"
echo " -rd [date] Retrieves file for a specific date, with format YYYY-MM-DD"
echo " and saves it as gal_almanac.xml"
echo ""
echo " Examples:"
echo " ./download-galileo-almanac.sh # Gets latest Galileo Almanac XML file"
echo " ./download-galileo-almanac.sh -r # Gets latest Galileo Almanac XML file, stores it as gal_almanac.xml"
echo " ./download-galileo-almanac.sh -d 2022-03-15 # Gets Galileo Almanac XML file for that day"
echo " ./download-galileo-almanac.sh -rd 2022-03-15 # Gets Galileo Almanac XML file for that day, stores it as gal_almanac.xml"
}
if (([ "$1" = "-h" ]) || ([ "$1" = "--help" ])) ; then
help
exit 0
fi
RENAME=""
if (([ "$1" = "-r" ]) || ([ "$1" = "--rename" ])) ; then
RENAME=" -O gal_almanac.xml "
fi
BASE_URL="https://www.gsc-europa.eu/sites/default/files/sites/all/files/"
YEAR=$(date '+%Y')
SPACING="-"
MONTH=$(date '+%m')
DAY=$(date '+%d')
TERMINATION1="_0.xml"
TERMINATION2=".xml"
COUNTER=1
MAX_COUNTER=7
if (([ "$1" = "-d" ]) || ([ "$1" = "--date" ])) ; then
if wget "$BASE_URL$2$TERMINATION2" >/dev/null 2>&1 ; then
echo "Downloaded latest Galileo almanac from $BASE_URL$2$TERMINATION2"
exit 0
else
echo "Couldn't find an XML file for that date."
exit 1
fi
elif [ "$1" = "-rd" ] ; then
if wget -O gal_almanac.xml "$BASE_URL$2$TERMINATION2" >/dev/null 2>&1 ; then
echo "Downloaded latest Galileo almanac from $BASE_URL$2$TERMINATION2"
exit 0
else
echo "Couldn't find an XML file for that date."
rm gal_almanac.xml
exit 1
fi
else
echo "According to system time, today is $(date '+%Y-%m-%d'). Searching for the latest Galileo almanac ..."
fi
lowercase()
{
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
OS=`lowercase \`uname\``
date_before()
{
if [ "$OS" = "darwin" ]; then
YEAR=$(date -v -"$COUNTER"d '+%Y')
MONTH=$(date -v -"$COUNTER"d '+%m')
DAY=$(date -v -"$COUNTER"d '+%d')
else
YEAR=$(date -d "$COUNTER day ago" '+%Y')
MONTH=$(date -d "$COUNTER day ago" '+%m')
DAY=$(date -d "$COUNTER day ago" '+%d')
fi
COUNTER=$(($COUNTER+1))
}
try_download()
{
while [ $COUNTER -le $MAX_COUNTER ]
do
url="$BASE_URL$YEAR$SPACING$MONTH$SPACING$DAY$TERMINATION2"
if wget $RENAME $url >/dev/null 2>&1 ; then
echo "Downloaded latest Galileo almanac from $url"
exit 0
else
date_before
try_download
fi
done
}
url="$BASE_URL$YEAR$SPACING$MONTH$SPACING$DAY$TERMINATION1"
if wget $RENAME $url >/dev/null 2>&1 ; then
echo "Downloaded latest Galileo almanac from $url"
else
try_download
echo "Couldn't find a recent Galileo almanac."
exit 1
fi