From 991c1ed100661d01d64116093537d1223edf219b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Nov 2021 18:04:12 +0100 Subject: [PATCH 01/11] Update changelog --- docs/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ac5a78d20..23328ce24 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -56,6 +56,10 @@ All notable changes to GNSS-SDR will be documented in this file. ### Improvements in Reliability: - Fixed some potential buffer overflows. +- Avoid source code lines longer than 512 characters. This was a warning raised + by Lintian (very-long-line-length-in-source-file). Long lines in source code + could be used to obfuscate the source code and to hide stuff like backdoors or + security problems. ### Improvements in Usability: From 740a2762bc8c8e809308d36c2932fe8b6e88ed7c Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 15 Nov 2021 12:47:33 +0100 Subject: [PATCH 02/11] Initialize the dynamic bit selection shift register --- .../signal_source/libs/fpga_dynamic_bit_selection.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc index 1802324c5..0e7a5afca 100644 --- a/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc +++ b/src/algorithms/signal_source/libs/fpga_dynamic_bit_selection.cc @@ -59,6 +59,12 @@ Fpga_dynamic_bit_selection::Fpga_dynamic_bit_selection(const std::string &device shift_out_bits_band1 = shift_out_bits_default; shift_out_bits_band2 = shift_out_bits_default; + // init bit selection corresopnding to frequency band 1 + d_map_base1[0] = shift_out_bits_band1; + + // init bit selection corresponding to frequency band 2 + d_map_base2[0] = shift_out_bits_band2; + DLOG(INFO) << "Dynamic bit selection FPGA class created"; } From ab8b1e2f822141bfb31b6a3a4178b8867a388cf0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 22 Nov 2021 14:30:24 +0100 Subject: [PATCH 03/11] Update gsl-lite to v0.40.0 --- docs/CHANGELOG.md | 4 +- .../libs/gsl/include/gsl/gsl-lite.hpp | 304 ++++++++++++++---- 2 files changed, 237 insertions(+), 71 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 23328ce24..dda9f46c6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -38,8 +38,8 @@ All notable changes to GNSS-SDR will be documented in this file. for easier detection of unused data members (see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md/#Rc-initialize). - Non-functional change: Fixed formatting defects detected by clang-format 13.0. -- Updated GSL implementation to v0.39.0. See - https://github.com/gsl-lite/gsl-lite/releases/tag/v0.39.0 +- Updated GSL implementation to v0.40.0. See + https://github.com/gsl-lite/gsl-lite/releases/tag/v0.40.0 - CI - `cpplint` job on GitHub: Added the `build/include_what_you_use` filter for early detection of missing includes. - CI - `clang-tidy` job on GitHub: More robust detection of LLVM paths installed diff --git a/src/algorithms/libs/gsl/include/gsl/gsl-lite.hpp b/src/algorithms/libs/gsl/include/gsl/gsl-lite.hpp index 2afbdb27c..50ae0af72 100644 --- a/src/algorithms/libs/gsl/include/gsl/gsl-lite.hpp +++ b/src/algorithms/libs/gsl/include/gsl/gsl-lite.hpp @@ -14,6 +14,7 @@ #define GSL_GSL_LITE_HPP_INCLUDED #include // for size_t, ptrdiff_t, nullptr_t +#include // for abort() #include // for exception, terminate(), uncaught_exceptions() #include // for ios_base, streamsize #include // for basic_ostream<> @@ -24,7 +25,7 @@ #include // for move(), forward<>(), swap() #define gsl_lite_MAJOR 0 -#define gsl_lite_MINOR 39 +#define gsl_lite_MINOR 40 #define gsl_lite_PATCH 0 #define gsl_lite_VERSION gsl_STRINGIFY(gsl_lite_MAJOR) "." gsl_STRINGIFY(gsl_lite_MINOR) "." gsl_STRINGIFY(gsl_lite_PATCH) @@ -324,6 +325,21 @@ #pragma message("invalid configuration value gsl_CONFIG_CONTRACT_CHECKING_OFF=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_CHECKING_OFF) "; macro must be defined without value") #endif #endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT) "; macro must be defined without value") +#endif +#endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON) "; macro must be defined without value") +#endif +#endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF) "; macro must be defined without value") +#endif +#endif #if defined(gsl_CONFIG_CONTRACT_VIOLATION_THROWS) #if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_CONTRACT_VIOLATION_THROWS) #pragma message("invalid configuration value gsl_CONFIG_CONTRACT_VIOLATION_THROWS=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_VIOLATION_THROWS) "; macro must be defined without value") @@ -349,6 +365,21 @@ #pragma message("invalid configuration value gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER) "; macro must be defined without value") #endif #endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS) "; macro must be defined without value") +#endif +#endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS) "; macro must be defined without value") +#endif +#endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER) "; macro must be defined without value") +#endif +#endif #if defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) #if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) #pragma message("invalid configuration value gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME=" gsl_STRINGIFY(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) "; macro must be defined without value") @@ -359,29 +390,83 @@ #pragma message("invalid configuration value gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE=" gsl_STRINGIFY(gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE) "; macro must be defined without value") #endif #endif +#if defined(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME) "; macro must be defined without value") +#endif +#endif +#if defined(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE) +#if !gsl_CHECK_CFG_NO_VALUE_(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE) +#pragma message("invalid configuration value gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE) "; macro must be defined without value") +#endif +#endif + +#if defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_THROWS) +#error cannot use gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_THROWS because exceptions are not supported in device code; use gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS or gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS +#endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TERMINATES) +#error gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TERMINATES is not supported; use gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS or gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS +#endif #if 1 < defined(gsl_CONFIG_CONTRACT_CHECKING_AUDIT) + defined(gsl_CONFIG_CONTRACT_CHECKING_ON) + defined(gsl_CONFIG_CONTRACT_CHECKING_OFF) #error only one of gsl_CONFIG_CONTRACT_CHECKING_AUDIT, gsl_CONFIG_CONTRACT_CHECKING_ON, and gsl_CONFIG_CONTRACT_CHECKING_OFF may be defined #endif +#if 1 < defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT) + defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON) + defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF) +#error only one of gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT, gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON, and gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF may be defined +#endif #if 1 < defined(gsl_CONFIG_CONTRACT_VIOLATION_THROWS) + defined(gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES) + defined(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) + defined(gsl_CONFIG_CONTRACT_VIOLATION_TRAPS) + defined(gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER) #error only one of gsl_CONFIG_CONTRACT_VIOLATION_THROWS, gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES, gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS, gsl_CONFIG_CONTRACT_VIOLATION_TRAPS, and gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER may be defined #endif +#if 1 < defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS) + defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS) + defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER) +#error only one of gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS, gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS, and gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER may be defined +#endif #if 1 < defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) + defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE) #error only one of gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME and gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE may be defined #endif +#if 1 < defined(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME) + defined(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE) +#error only one of gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME and gsl_CONFIG_UNENFORCED_DEVICE_CONTRACTS_ELIDE may be defined +#endif #if 0 == defined(gsl_CONFIG_CONTRACT_CHECKING_AUDIT) + defined(gsl_CONFIG_CONTRACT_CHECKING_ON) + defined(gsl_CONFIG_CONTRACT_CHECKING_OFF) // select default #define gsl_CONFIG_CONTRACT_CHECKING_ON #endif +#if 0 == defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT) + defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON) + defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF) +// select default +#if defined(gsl_CONFIG_CONTRACT_CHECKING_AUDIT) +#define gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT +#elif defined(gsl_CONFIG_CONTRACT_CHECKING_OFF) +#define gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF +#else +#define gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON +#endif +#endif #if 0 == defined(gsl_CONFIG_CONTRACT_VIOLATION_THROWS) + defined(gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES) + defined(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) + defined(gsl_CONFIG_CONTRACT_VIOLATION_TRAPS) + defined(gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER) // select default #define gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES #endif +#if 0 == defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS) + defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS) + defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER) +// select default +#if defined(gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER) +#define gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER +#elif defined(gsl_CONFIG_CONTRACT_VIOLATION_TRAPS) +#define gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS +#else +#define gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS +#endif +#endif #if 0 == defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) + defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE) // select default #define gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE #endif +#if 0 == defined(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME) + defined(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE) +// select default +#if defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) +#define gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME +#else +#define gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE +#endif +#endif // C++ language version detection (C++20 is speculative): // Note: VC14.0/1900 (VS2015) lacks too much from C++14. @@ -527,6 +612,15 @@ #endif #define gsl_HAVE_WCHAR_() gsl_HAVE_WCHAR +// Compiling device code: + +#if defined(__CUDACC__) && defined(__CUDA_ARCH__) +#define gsl_DEVICE_CODE 1 +#else +#define gsl_DEVICE_CODE 0 +#endif + + // Presence of language & library features: #if gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_APPLECLANG_VERSION @@ -1036,7 +1130,7 @@ #include #endif -#if defined(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) +#if defined(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) || gsl_DEVICE_CODE #include #endif @@ -1762,16 +1856,30 @@ gsl_DISABLE_MSVC_WARNINGS(26432 26410 26415 26418 26472 26439 26440 26455 26473 #endif #define gsl_NO_OP_() (static_cast(0)) -#if defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) -#if defined(__CUDACC__) && defined(__CUDA_ARCH__) +#if gsl_COMPILER_NVHPC_VERSION +// Suppress "controlling expression is constant" warning when using `gsl_Expects()`, `gsl_Ensures()`, `gsl_Assert()`, etc. +#define gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ _Pragma("diag_suppress 236") +#define gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ _Pragma("diag_default 236") +#else +#define gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ +#define gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ +#endif + +#if gsl_DEVICE_CODE +#if defined(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME) #if gsl_COMPILER_NVCC_VERSION >= 113 #define gsl_ASSUME_(x) ((x) ? static_cast(0) : __builtin_unreachable()) #define gsl_ASSUME_UNREACHABLE_() __builtin_unreachable() -#else -#define gsl_ASSUME_(x) gsl_ELIDE_(x) /* there is no assume intrinsic in CUDA device code */ -#define gsl_ASSUME_UNREACHABLE_() gsl_NO_OP_() /* there is no assume intrinsic in CUDA device code */ +#else // unknown device compiler +#error gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME: gsl-lite does not know how to generate UB optimization hints in device code for this compiler; use gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE instead #endif -#elif gsl_COMPILER_MSVC_VERSION >= 140 +#define gsl_CONTRACT_UNENFORCED_(x) gsl_ASSUME_(x) +#else // defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE ) [default] +#define gsl_CONTRACT_UNENFORCED_(x) gsl_ELIDE_(x) +#endif +#else // host code +#if defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) +#if gsl_COMPILER_MSVC_VERSION >= 140 #define gsl_ASSUME_(x) __assume(x) #define gsl_ASSUME_UNREACHABLE_() __assume(0) #elif gsl_COMPILER_GNUC_VERSION @@ -1787,19 +1895,42 @@ gsl_DISABLE_MSVC_WARNINGS(26432 26410 26415 26418 26472 26439 26440 26455 26473 #else #error gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME: gsl-lite does not know how to generate UB optimization hints for this compiler; use gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE instead #endif -#endif // defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME ) - -#if defined(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) #define gsl_CONTRACT_UNENFORCED_(x) gsl_ASSUME_(x) #else // defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE ) [default] #define gsl_CONTRACT_UNENFORCED_(x) gsl_ELIDE_(x) #endif +#endif // gsl_DEVICE_CODE -#if defined(gsl_CONFIG_CONTRACT_VIOLATION_TRAPS) -#if defined(__CUDACC__) && defined(__CUDA_ARCH__) +#if gsl_DEVICE_CODE +#if gsl_COMPILER_NVCC_VERSION #define gsl_TRAP_() __trap() -#elif gsl_COMPILER_MSVC_VERSION >= 110 // __fastfail() supported by VS 2012 and later -#define gsl_TRAP_() __fastfail(0) /* legacy failure code for buffer-overrun errors, cf. winnt.h, "Fast fail failure codes" */ +#elif defined(__has_builtin) +#if __has_builtin(__builtin_trap) +#define gsl_TRAP_() __builtin_trap() +#else +#error gsl-lite does not know how to generate a trap instruction for this device compiler +#endif +#else +#error gsl-lite does not know how to generate a trap instruction for this device compiler +#endif +#if defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS) +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_(x) ? static_cast(0) : gsl_TRAP_() gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) +#define gsl_FAILFAST_() (gsl_TRAP_()) +#elif defined(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER) +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_(x) ? static_cast(0) : ::gsl::fail_fast_assert_handler(#x, str, __FILE__, __LINE__) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) +#define gsl_FAILFAST_() (::gsl::fail_fast_assert_handler("", "GSL: failure", __FILE__, __LINE__), gsl_TRAP_()) /* do not let the custom assertion handler continue execution */ +#else // defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS ) [default] +#if !defined(NDEBUG) +#define gsl_CONTRACT_CHECK_(str, x) assert(str && (x)) +#else +#define gsl_CONTRACT_CHECK_(str, x) ((x) ? static_cast(0) : gsl_TRAP_()) +#endif +#define gsl_FAILFAST_() (gsl_TRAP_()) +#endif +#else // host code +#if defined(gsl_CONFIG_CONTRACT_VIOLATION_TRAPS) +#if gsl_COMPILER_MSVC_VERSION >= 110 // __fastfail() supported by VS 2012 and later +#define gsl_TRAP_() __fastfail(0) /* legacy failure code for buffer-overrun errors, cf. winnt.h, "Fast fail failure codes" */ #elif gsl_COMPILER_GNUC_VERSION #define gsl_TRAP_() __builtin_trap() #elif defined(__has_builtin) @@ -1811,90 +1942,106 @@ gsl_DISABLE_MSVC_WARNINGS(26432 26410 26415 26418 26472 26439 26440 26455 26473 #else #error gsl_CONFIG_CONTRACT_VIOLATION_TRAPS: gsl-lite does not know how to generate a trap instruction for this compiler; use gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES instead #endif -#endif // defined( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) - -#if gsl_COMPILER_NVHPC_VERSION -// Suppress "controlling expression is constant" warning when using gsl_Expects, -// gsl_Ensures, gsl_Assert, gsl_FailFast and so on. -#define gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ _Pragma("diag_suppress 236") -#define gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ _Pragma("diag_default 236") -#else -#define gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ -#define gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ -#endif -#if defined(gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER) -#define gsl_CONTRACT_CHECK_(str, x) ((x) ? static_cast(0) : ::gsl::fail_fast_assert_handler(#x, str, __FILE__, __LINE__)) -#if defined(__CUDACC__) && defined(__CUDA_ARCH__) -#define gsl_FAILFAST_() (::gsl::fail_fast_assert_handler("", "GSL: failure", __FILE__, __LINE__), gsl_TRAP_()) /* do not let the custom assertion handler continue execution */ -#else -#define gsl_FAILFAST_() (::gsl::fail_fast_assert_handler("", "GSL: failure", __FILE__, __LINE__), ::gsl::detail::fail_fast_terminate()) /* do not let the custom assertion handler continue execution */ -#endif -#elif defined(__CUDACC__) && defined(__CUDA_ARCH__) -#if defined(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) || !defined(NDEBUG) -#define gsl_CONTRACT_CHECK_(str, x) assert(str && (x)) -#else -#define gsl_CONTRACT_CHECK_(str, x) ((x) ? static_cast(0) : __trap()) -#endif -#define gsl_FAILFAST_() (__trap()) -#elif defined(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) -#define gsl_CONTRACT_CHECK_(str, x) gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ assert(str && (x)) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ -#if !defined(NDEBUG) -#define gsl_FAILFAST_() (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ assert(!"GSL: failure") gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_, ::gsl::detail::fail_fast_terminate()) -#else -#define gsl_FAILFAST_() (::gsl::detail::fail_fast_terminate()) -#endif -#elif defined(gsl_CONFIG_CONTRACT_VIOLATION_TRAPS) -#define gsl_CONTRACT_CHECK_(str, x) ((x) ? static_cast(0) : gsl_TRAP_()) +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_(x) ? static_cast(0) : gsl_TRAP_() gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) #if gsl_COMPILER_MSVC_VERSION #define gsl_FAILFAST_() (gsl_TRAP_(), ::gsl::detail::fail_fast_terminate()) #else #define gsl_FAILFAST_() (gsl_TRAP_()) #endif +#elif defined(gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER) +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_(x) ? static_cast(0) : ::gsl::fail_fast_assert_handler(#x, str, __FILE__, __LINE__) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) +#define gsl_FAILFAST_() (::gsl::fail_fast_assert_handler("", "GSL: failure", __FILE__, __LINE__), ::gsl::detail::fail_fast_terminate()) /* do not let the custom assertion handler continue execution */ +#elif defined(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) +#if !defined(NDEBUG) +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ assert(str && (x)) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) +#define gsl_FAILFAST_() (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ assert(!"GSL: failure") gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_, ::gsl::detail::fail_fast_abort()) +#else +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_(x) ? static_cast(0) : ::gsl::detail::fail_fast_abort() gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) +#define gsl_FAILFAST_() (::gsl::detail::fail_fast_abort()) +#endif #elif defined(gsl_CONFIG_CONTRACT_VIOLATION_THROWS) -#define gsl_CONTRACT_CHECK_(str, x) gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_((x) ? static_cast(0) : ::gsl::detail::fail_fast_throw(str ": '" #x "' at " __FILE__ ":" gsl_STRINGIFY(__LINE__))) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_((x) ? static_cast(0) : ::gsl::detail::fail_fast_throw(str ": '" #x "' at " __FILE__ ":" gsl_STRINGIFY(__LINE__))) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) #define gsl_FAILFAST_() (::gsl::detail::fail_fast_throw("GSL: failure at " __FILE__ ":" gsl_STRINGIFY(__LINE__))) #else // defined( gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES ) [default] -#define gsl_CONTRACT_CHECK_(str, x) gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_((x) ? static_cast(0) : ::gsl::detail::fail_fast_terminate()) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ +#define gsl_CONTRACT_CHECK_(str, x) (gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_((x) ? static_cast(0) : ::gsl::detail::fail_fast_terminate()) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_) #define gsl_FAILFAST_() (::gsl::detail::fail_fast_terminate()) #endif +#endif // gsl_DEVICE_CODE -#if defined(gsl_CONFIG_CONTRACT_CHECKING_OFF) || defined(gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF) -#define gsl_Expects(x) gsl_CONTRACT_UNENFORCED_(x) -#else +#if (!gsl_DEVICE_CODE && defined(gsl_CONFIG_CONTRACT_CHECKING_OFF)) || (gsl_DEVICE_CODE && defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF)) +#define gsl_CHECK_CONTRACTS_ 0 +#define gsl_CHECK_DEBUG_CONTRACTS_ 0 +#define gsl_CHECK_AUDIT_CONTRACTS_ 0 +#elif (!gsl_DEVICE_CODE && defined(gsl_CONFIG_CONTRACT_CHECKING_AUDIT)) || (gsl_DEVICE_CODE && defined(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT)) +#define gsl_CHECK_CONTRACTS_ 1 +#define gsl_CHECK_DEBUG_CONTRACTS_ 1 +#define gsl_CHECK_AUDIT_CONTRACTS_ 1 +#else // gsl_CONFIG_[DEVICE_]CONTRACT_CHECKING_ON [default] +#define gsl_CHECK_CONTRACTS_ 1 +#if !defined(NDEBUG) +#define gsl_CHECK_DEBUG_CONTRACTS_ 1 +#else // defined( NDEBUG ) +#define gsl_CHECK_DEBUG_CONTRACTS_ 0 +#endif +#define gsl_CHECK_AUDIT_CONTRACTS_ 0 +#endif + +#if gsl_CHECK_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF) #define gsl_Expects(x) gsl_CONTRACT_CHECK_("GSL: Precondition failure", x) +#else +#define gsl_Expects(x) gsl_CONTRACT_UNENFORCED_(x) #endif #define Expects(x) gsl_Expects(x) -#if !defined(gsl_CONFIG_CONTRACT_CHECKING_AUDIT) || defined(gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF) -#define gsl_ExpectsAudit(x) gsl_ELIDE_(x) +#if gsl_CHECK_DEBUG_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF) +#define gsl_ExpectsDebug(x) gsl_CONTRACT_CHECK_("GSL: Precondition failure (debug)", x) #else +#define gsl_ExpectsDebug(x) gsl_ELIDE_(x) +#endif +#if gsl_CHECK_AUDIT_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF) #define gsl_ExpectsAudit(x) gsl_CONTRACT_CHECK_("GSL: Precondition failure (audit)", x) +#else +#define gsl_ExpectsAudit(x) gsl_ELIDE_(x) #endif -#if defined(gsl_CONFIG_CONTRACT_CHECKING_OFF) || defined(gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF) -#define gsl_Ensures(x) gsl_CONTRACT_UNENFORCED_(x) -#else +#if gsl_CHECK_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF) #define gsl_Ensures(x) gsl_CONTRACT_CHECK_("GSL: Postcondition failure", x) +#else +#define gsl_Ensures(x) gsl_CONTRACT_UNENFORCED_(x) #endif #define Ensures(x) gsl_Ensures(x) -#if !defined(gsl_CONFIG_CONTRACT_CHECKING_AUDIT) || defined(gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF) -#define gsl_EnsuresAudit(x) gsl_ELIDE_(x) +#if gsl_CHECK_DEBUG_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF) +#define gsl_EnsuresDebug(x) gsl_CONTRACT_CHECK_("GSL: Postcondition failure (debug)", x) #else +#define gsl_EnsuresDebug(x) gsl_ELIDE_(x) +#endif +#if gsl_CHECK_AUDIT_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF) #define gsl_EnsuresAudit(x) gsl_CONTRACT_CHECK_("GSL: Postcondition failure (audit)", x) +#else +#define gsl_EnsuresAudit(x) gsl_ELIDE_(x) #endif -#if defined(gsl_CONFIG_CONTRACT_CHECKING_OFF) || defined(gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF) -#define gsl_Assert(x) gsl_CONTRACT_UNENFORCED_(x) -#else +#if gsl_CHECK_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF) #define gsl_Assert(x) gsl_CONTRACT_CHECK_("GSL: Assertion failure", x) -#endif -#if !defined(gsl_CONFIG_CONTRACT_CHECKING_AUDIT) || defined(gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF) -#define gsl_AssertAudit(x) gsl_ELIDE_(x) #else +#define gsl_Assert(x) gsl_CONTRACT_UNENFORCED_(x) +#endif +#if gsl_CHECK_DEBUG_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF) +#define gsl_AssertDebug(x) gsl_CONTRACT_CHECK_("GSL: Assertion failure (debug)", x) +#else +#define gsl_AssertDebug(x) gsl_ELIDE_(x) +#endif +#if gsl_CHECK_AUDIT_CONTRACTS_ && !defined(gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF) #define gsl_AssertAudit(x) gsl_CONTRACT_CHECK_("GSL: Assertion failure (audit)", x) +#else +#define gsl_AssertAudit(x) gsl_ELIDE_(x) #endif #define gsl_FailFast() gsl_FAILFAST_() +#undef gsl_CHECK_CONTRACTS_ +#undef gsl_CHECK_DEBUG_CONTRACTS_ +#undef gsl_CHECK_AUDIT_CONTRACTS_ + struct fail_fast : public std::logic_error { @@ -1914,6 +2061,10 @@ gsl_DISABLE_MSVC_WARNINGS(26432 26410 26415 26418 26472 26439 26440 26455 26473 { std::terminate(); } + gsl_NORETURN inline void fail_fast_abort() gsl_noexcept + { + std::abort(); + } } // namespace detail @@ -3197,18 +3348,33 @@ gsl_DISABLE_MSVC_WARNINGS(26432 26410 26415 26418 26472 26439 26440 26455 26473 } #endif // gsl_HAVE( MOVE_FORWARD ) template - gsl_NODISCARD gsl_api gsl_constexpr14 T const &as_nullable(not_null const &p) + gsl_NODISCARD gsl_api gsl_constexpr14 T const & + as_nullable(not_null const &p) { T const &result = detail::not_null_accessor::get(p); gsl_Expects(result != gsl_nullptr); return result; } template - gsl_NODISCARD gsl_api gsl_constexpr T *as_nullable(not_null p) gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr T * + as_nullable(not_null p) gsl_noexcept { return detail::not_null_accessor::get(p); } + template + gsl_NODISCARD gsl_api gsl_constexpr bool + is_valid(not_null const &p) + { + return detail::not_null_accessor::get(p) != gsl_nullptr; + } + template + gsl_NODISCARD gsl_api gsl_constexpr bool + is_valid(not_null const &) + { + return true; + } + } // namespace no_adl } // namespace detail From ede805f9c3d9db9a7a65096a7854664dac0288d3 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Mon, 22 Nov 2021 17:47:00 +0100 Subject: [PATCH 04/11] Fix some build errors for Android cross-compiling --- CMakeLists.txt | 4 +- src/algorithms/PVT/libs/CMakeLists.txt | 4 ++ src/algorithms/PVT/libs/rinex_printer.cc | 83 ++++++++++++++++++++---- src/core/receiver/CMakeLists.txt | 4 ++ src/core/receiver/control_thread.cc | 10 ++- 5 files changed, 90 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4784d3ef9..4014e7d73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -683,7 +683,9 @@ set(Boost_ADDITIONAL_VERSIONS "1.70.0" "1.70" "1.71.0" "1.71" ) set(Boost_USE_MULTITHREAD ON) -set(Boost_USE_STATIC_LIBS OFF) +#set(Boost_USE_STATIC_LIBS OFF) +option(Boost_USE_STATIC_LIBS "Use Boost static libs" OFF) + set(BOOST_COMPONENTS atomic chrono date_time serialization system thread) if(NOT ${FILESYSTEM_FOUND}) set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem) diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index e450a1b8e..9d1e8af04 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -76,6 +76,10 @@ else() ) endif() +if(CMAKE_ANDROID_ARCH_ABI) + target_compile_definitions(pvt_libs PUBLIC -DANDROID=1) +endif(CMAKE_ANDROID_ARCH_ABI) + target_link_libraries(pvt_libs PUBLIC Boost::date_time diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index a320bd527..4b41dcd2a 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -1511,6 +1511,9 @@ std::string Rinex_Printer::getLocalTime() const line += std::string("GNSS-SDR"); line += std::string(12, ' '); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) @@ -1521,6 +1524,8 @@ std::string Rinex_Printer::getLocalTime() const { username = "UNKNOWN USER"; } +#endif + line += Rinex_Printer::leftJustify(username, 20); const boost::gregorian::date today = boost::gregorian::day_clock::local_day(); @@ -3527,8 +3532,11 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const line.clear(); line += Rinex_Printer::leftJustify("GNSS-SDR", 20); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -3537,6 +3545,7 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const { username = "UNKNOWN USER"; } +#endif line += Rinex_Printer::leftJustify(username, 20); // Date of file creation (dd-mmm-yy hhmm) const boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); @@ -6001,8 +6010,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -6011,6 +6023,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -6327,8 +6340,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -6337,6 +6353,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -6682,8 +6699,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -6692,6 +6712,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -6991,8 +7012,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7001,6 +7025,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -7314,8 +7339,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7324,6 +7352,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -7571,8 +7600,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7581,6 +7613,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -7822,8 +7855,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7832,6 +7868,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -8103,8 +8140,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -8113,6 +8153,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -8449,8 +8490,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -8459,6 +8503,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -8767,8 +8812,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -8777,6 +8825,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -9034,8 +9083,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -9044,6 +9096,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -9316,8 +9369,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -9326,6 +9382,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index 4b4fa761d..86d886dd9 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -62,6 +62,10 @@ else() ) endif() +if(CMAKE_ANDROID_ARCH_ABI) + target_compile_definitions(core_receiver PUBLIC -DANDROID=1) +endif(CMAKE_ANDROID_ARCH_ABI) + if(ENABLE_FPGA) target_compile_definitions(core_receiver PUBLIC -DENABLE_FPGA=1) endif() diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index ff0eecfa1..d34b79c9a 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -418,7 +418,11 @@ int ControlThread::run() { pthread_t id = keyboard_thread_.native_handle(); keyboard_thread_.detach(); +#ifndef ANDROID pthread_cancel(id); +#else + //todo: find alternative +#endif } // Terminate telecommand thread @@ -426,8 +430,12 @@ int ControlThread::run() { pthread_t id2 = cmd_interface_thread_.native_handle(); cmd_interface_thread_.detach(); +#ifndef ANDROID pthread_cancel(id2); - } +#else + //todo: find alternative +#endif + } LOG(INFO) << "Flowgraph stopped"; From b0fd24476dc7ad6619ede40dc6d6e3e6f6bcfd2e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 22 Nov 2021 19:38:56 +0100 Subject: [PATCH 05/11] Fix formatting --- src/algorithms/PVT/libs/CMakeLists.txt | 2 +- src/core/receiver/CMakeLists.txt | 2 +- src/core/receiver/control_thread.cc | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index 9d1e8af04..9af6b61c2 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -78,7 +78,7 @@ endif() if(CMAKE_ANDROID_ARCH_ABI) target_compile_definitions(pvt_libs PUBLIC -DANDROID=1) -endif(CMAKE_ANDROID_ARCH_ABI) +endif() target_link_libraries(pvt_libs PUBLIC diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index 86d886dd9..8e291a872 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -64,7 +64,7 @@ endif() if(CMAKE_ANDROID_ARCH_ABI) target_compile_definitions(core_receiver PUBLIC -DANDROID=1) -endif(CMAKE_ANDROID_ARCH_ABI) +endif() if(ENABLE_FPGA) target_compile_definitions(core_receiver PUBLIC -DENABLE_FPGA=1) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index d34b79c9a..cac176f7f 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -421,7 +421,7 @@ int ControlThread::run() #ifndef ANDROID pthread_cancel(id); #else - //todo: find alternative + // todo: find alternative #endif } @@ -430,12 +430,12 @@ int ControlThread::run() { pthread_t id2 = cmd_interface_thread_.native_handle(); cmd_interface_thread_.detach(); -#ifndef ANDROID +#ifndef ANDROID pthread_cancel(id2); #else - //todo: find alternative -#endif - } + // todo: find alternative +#endif + } LOG(INFO) << "Flowgraph stopped"; From cc38d6bc080004fb40b0492b70c442b6b6bd4412 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Nov 2021 13:30:48 +0100 Subject: [PATCH 06/11] Fixes for building against GNU Radio master Log4cpp has been replaced by spdlog --- CMakeLists.txt | 13 ++++++------- cmake/Modules/FindGNURADIO.cmake | 17 +++++++++++++++++ .../input_filter/gnuradio_blocks/CMakeLists.txt | 8 +++++++- .../gnuradio_blocks/labsat23_source.cc | 2 +- src/utils/rinex-tools/obsdiff.cc | 1 + 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4014e7d73..99d5c7274 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -609,13 +609,12 @@ endif() ################################################################################ # Log4cpp - http://log4cpp.sourceforge.net/ ################################################################################ -find_package(LOG4CPP) -set_package_properties(LOG4CPP PROPERTIES - PURPOSE "Required by GNU Radio." - TYPE REQUIRED -) -if(NOT LOG4CPP_FOUND) - message(FATAL_ERROR "*** Log4cpp is required to build gnss-sdr") +if(GNURADIO_USES_LOG4CPP) + find_package(LOG4CPP) + set_package_properties(LOG4CPP PROPERTIES + PURPOSE "Required by GNU Radio." + TYPE OPTIONAL + ) endif() diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 4ea557a19..39b0d2997 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -392,6 +392,23 @@ if(GNURADIO_PMT_INCLUDE_DIRS) endif() endif() +# Check if GNU Radio uses log4cpp or spdlog +if(GNURADIO_RUNTIME_INCLUDE_DIRS) + if(EXISTS "${GNURADIO_RUNTIME_INCLUDE_DIRS}/gnuradio/logger.h") + file(STRINGS ${GNURADIO_RUNTIME_INCLUDE_DIRS}/gnuradio/logger.h _logger_content) + set(_uses_log4cpp FALSE) + foreach(_loop_var IN LISTS _logger_content) + string(STRIP "${_loop_var}" _file_line) + if("#include " STREQUAL "${_file_line}") + set(_uses_log4cpp TRUE) + endif() + endforeach() + if(${_uses_log4cpp}) + set(GNURADIO_USES_LOG4CPP TRUE) + endif() + endif() +endif() + set_package_properties(GNURADIO PROPERTIES URL "https://www.gnuradio.org/" ) diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index f6b8ee7ca..72942522c 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -46,9 +46,15 @@ target_link_libraries(input_filter_gr_blocks algorithms_libs PRIVATE Volk::volk - Log4cpp::log4cpp ) +if(LOG4CPP_FOUND) + target_link_libraries(input_filter_gr_blocks + PRIVATE + Log4cpp::log4cpp + ) +endif() + target_include_directories(input_filter_gr_blocks PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index ddd2cc000..331141428 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -21,12 +21,12 @@ #include "INIReader.h" #include "command_event.h" #include "gnss_sdr_make_unique.h" -#include #include #include #include #include #include +#include #include #include #include diff --git a/src/utils/rinex-tools/obsdiff.cc b/src/utils/rinex-tools/obsdiff.cc index 489b88e6a..16c753f03 100644 --- a/src/utils/rinex-tools/obsdiff.cc +++ b/src/utils/rinex-tools/obsdiff.cc @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include From bcec8331e6bf320d0740c0691ddf08ef33cd9d7d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Nov 2021 16:38:50 +0100 Subject: [PATCH 07/11] Fixes for building against GNU Radio master Log4cpp has been replaced by spdlog and fmt --- CMakeLists.txt | 29 ++++++- cmake/Modules/FindFMT.cmake | 76 +++++++++++++++++ cmake/Modules/FindGNURADIO.cmake | 7 ++ cmake/Modules/FindSPDLOG.cmake | 84 +++++++++++++++++++ src/algorithms/PVT/adapters/CMakeLists.txt | 8 ++ src/algorithms/channel/libs/CMakeLists.txt | 8 ++ .../conditioner/adapters/CMakeLists.txt | 8 ++ .../gnuradio_blocks/CMakeLists.txt | 8 ++ .../gnuradio_blocks/CMakeLists.txt | 8 ++ src/algorithms/libs/CMakeLists.txt | 8 ++ .../gnuradio_blocks/CMakeLists.txt | 8 ++ .../resampler/gnuradio_blocks/CMakeLists.txt | 8 ++ .../signal_generator/adapters/CMakeLists.txt | 8 ++ .../signal_source/libs/CMakeLists.txt | 8 ++ .../telemetry_decoder/adapters/CMakeLists.txt | 8 ++ src/core/monitor/CMakeLists.txt | 8 ++ src/tests/system-tests/position_test.cc | 2 + src/tests/system-tests/ttff.cc | 2 + .../libs/CMakeLists.txt | 8 ++ 19 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 cmake/Modules/FindFMT.cmake create mode 100644 cmake/Modules/FindSPDLOG.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 99d5c7274..8bc9b9c91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -613,7 +613,33 @@ if(GNURADIO_USES_LOG4CPP) find_package(LOG4CPP) set_package_properties(LOG4CPP PROPERTIES PURPOSE "Required by GNU Radio." - TYPE OPTIONAL + TYPE REQUIRED + ) +endif() + + + +################################################################################ +# spdlog - https://github.com/gabime/spdlog +################################################################################ +if(GNURADIO_USES_SPDLOG) + find_package(SPDLOG REQUIRED) + set_package_properties(SPDLOG PROPERTIES + PURPOSE "Required by GNU Radio." + TYPE REQUIRED + ) +endif() + + + +################################################################################ +# fmt - https://github.com/fmtlib/fmt +################################################################################ +if(GNURADIO_USES_SPDLOG) + find_package(FMT REQUIRED) + set_package_properties(FMT PROPERTIES + PURPOSE "Required by GNU Radio." + TYPE REQUIRED ) endif() @@ -665,6 +691,7 @@ if((NOT PMT_USES_BOOST_ANY) AND (CMAKE_CXX_STANDARD VERSION_LESS 17)) endif() + ################################################################################ # Boost - https://www.boost.org ################################################################################ diff --git a/cmake/Modules/FindFMT.cmake b/cmake/Modules/FindFMT.cmake new file mode 100644 index 000000000..49d091d8a --- /dev/null +++ b/cmake/Modules/FindFMT.cmake @@ -0,0 +1,76 @@ +# 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 + +if(NOT COMMAND feature_summary) + include(FeatureSummary) +endif() + +# Locate header +find_path(FMT_INCLUDE_DIR fmt/core.h + HINTS ${FMT_ROOT_DIR}/include + PATHS + /usr/include + /usr/local/include + /opt/local/include +) + +# Locate library +find_library(FMT_LIBRARY NAMES fmt + HINTS ${FMT_ROOT_DIR}/lib ${FMT_ROOT_DIR}/lib64 + 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 +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FMT DEFAULT_MSG FMT_INCLUDE_DIR FMT_LIBRARY) + +set_package_properties(FMT PROPERTIES + URL "https://github.com/fmtlib/fmt" + DESCRIPTION "An open-source formatting library" +) + +# Add imported target. +if(FMT_FOUND) + set(FMT_INCLUDE_DIRS "${FMT_INCLUDE_DIR}") + + if(NOT TARGET fmt::fmt) + add_library(fmt::fmt UNKNOWN IMPORTED) + set_target_properties(fmt::fmt PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FMT_INCLUDE_DIRS}" + ) + set_property(TARGET fmt::fmt APPEND PROPERTY + IMPORTED_LOCATION "${FMT_LIBRARY}" + ) + endif() +endif() diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 39b0d2997..93e6082cd 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -397,15 +397,22 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS) if(EXISTS "${GNURADIO_RUNTIME_INCLUDE_DIRS}/gnuradio/logger.h") file(STRINGS ${GNURADIO_RUNTIME_INCLUDE_DIRS}/gnuradio/logger.h _logger_content) set(_uses_log4cpp FALSE) + set(_uses_spdlog FALSE) foreach(_loop_var IN LISTS _logger_content) string(STRIP "${_loop_var}" _file_line) if("#include " STREQUAL "${_file_line}") set(_uses_log4cpp TRUE) endif() + if("#include " STREQUAL "${_file_line}") + set(_uses_spdlog TRUE) + endif() endforeach() if(${_uses_log4cpp}) set(GNURADIO_USES_LOG4CPP TRUE) endif() + if(${_uses_spdlog}) + set(GNURADIO_USES_SPDLOG TRUE) + endif() endif() endif() diff --git a/cmake/Modules/FindSPDLOG.cmake b/cmake/Modules/FindSPDLOG.cmake new file mode 100644 index 000000000..ac53fc870 --- /dev/null +++ b/cmake/Modules/FindSPDLOG.cmake @@ -0,0 +1,84 @@ +# 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 + +if(NOT COMMAND feature_summary) + include(FeatureSummary) +endif() + +# Locate header +find_path(SPDLOG_INCLUDE_DIR spdlog/spdlog.h + HINTS ${SPDLOG_ROOT_DIR}/include + PATHS + /usr/include + /usr/local/include + /opt/local/include +) + +# Locate library +find_library(SPDLOG_LIBRARY NAMES spdlog spdlogd + HINTS ${SPDLOG_ROOT_DIR}/lib ${SPDLOG_ROOT_DIR}/lib64 + 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 +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SPDLOG DEFAULT_MSG SPDLOG_INCLUDE_DIR SPDLOG_LIBRARY) + +set_package_properties(SPDLOG PROPERTIES + URL "https://github.com/gabime/spdlog" + DESCRIPTION "Very fast, header-only/compiled, C++ logging library" +) + +# Add imported target. +if(SPDLOG_FOUND) + set(SPDLOG_INCLUDE_DIRS "${SPDLOG_INCLUDE_DIR}") + + if(NOT TARGET spdlog::spdlog) + add_library(spdlog::spdlog UNKNOWN IMPORTED) + set_target_properties(spdlog::spdlog PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${SPDLOG_INCLUDE_DIRS}" + ) + set_property(TARGET spdlog::spdlog APPEND PROPERTY + IMPORTED_LOCATION "${SPDLOG_LIBRARY}" + ) + endif() + + if(CMAKE_VERSION VERSION_GREATER 3.11.0) + target_compile_definitions(spdlog::spdlog INTERFACE -DSPDLOG_FMT_EXTERNAL=1) + else() + set_property(TARGET spdlog::spdlog APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS SPDLOG_FMT_EXTERNAL=1 + ) + endif() +endif() diff --git a/src/algorithms/PVT/adapters/CMakeLists.txt b/src/algorithms/PVT/adapters/CMakeLists.txt index 023ffce27..57ab83031 100644 --- a/src/algorithms/PVT/adapters/CMakeLists.txt +++ b/src/algorithms/PVT/adapters/CMakeLists.txt @@ -39,6 +39,14 @@ if(USE_OLD_BOOST_MATH_COMMON_FACTOR) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(pvt_adapters + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(pvt_adapters diff --git a/src/algorithms/channel/libs/CMakeLists.txt b/src/algorithms/channel/libs/CMakeLists.txt index 5d65ca047..1454d9d7c 100644 --- a/src/algorithms/channel/libs/CMakeLists.txt +++ b/src/algorithms/channel/libs/CMakeLists.txt @@ -54,6 +54,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(channel_libs + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + if(USE_GENERIC_LAMBDAS) set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) diff --git a/src/algorithms/conditioner/adapters/CMakeLists.txt b/src/algorithms/conditioner/adapters/CMakeLists.txt index d8683e4de..cb4db5424 100644 --- a/src/algorithms/conditioner/adapters/CMakeLists.txt +++ b/src/algorithms/conditioner/adapters/CMakeLists.txt @@ -42,6 +42,14 @@ target_link_libraries(conditioner_adapters Glog::glog ) +if(GNURADIO_USES_SPDLOG) + target_link_libraries(conditioner_adapters + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + target_include_directories(conditioner_adapters PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt index d7be7b5f5..56c821b01 100644 --- a/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt @@ -55,6 +55,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(data_type_gr_blocks + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + set_property(TARGET data_type_gr_blocks APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index 72942522c..a6a22a351 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -55,6 +55,14 @@ if(LOG4CPP_FOUND) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(input_filter_gr_blocks + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + target_include_directories(input_filter_gr_blocks PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index 7eb20fa87..57e614b34 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -117,6 +117,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(algorithms_libs + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + if(FILESYSTEM_FOUND) target_compile_definitions(algorithms_libs PUBLIC -DHAS_STD_FILESYSTEM=1) if(find_experimental) diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index 5035ab2ee..192e307c9 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -36,6 +36,14 @@ target_link_libraries(obs_gr_blocks Matio::matio ) +if(GNURADIO_USES_SPDLOG) + target_link_libraries(obs_gr_blocks + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + target_include_directories(obs_gr_blocks PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt index 8e182b23a..0a27cf6d8 100644 --- a/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/resampler/gnuradio_blocks/CMakeLists.txt @@ -50,6 +50,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(NOT GNURADIO_USES_LOG4CPP) + target_link_libraries(resampler_gr_blocks + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + target_include_directories(resampler_gr_blocks PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/signal_generator/adapters/CMakeLists.txt b/src/algorithms/signal_generator/adapters/CMakeLists.txt index 2b08f3c44..aa3d3d9fc 100644 --- a/src/algorithms/signal_generator/adapters/CMakeLists.txt +++ b/src/algorithms/signal_generator/adapters/CMakeLists.txt @@ -44,6 +44,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(signal_generator_adapters + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(signal_generator_adapters diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index 30bb8f5d8..fbb1f2911 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -76,6 +76,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(signal_source_libs + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + if(ENABLE_FMCOMMS2 OR ENABLE_AD9361) target_link_libraries(signal_source_libs PUBLIC diff --git a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt index a374f25d0..12c3e8a25 100644 --- a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt @@ -64,6 +64,14 @@ target_link_libraries(telemetry_decoder_adapters Gnuradio::runtime ) +if(GNURADIO_USES_SPDLOG) + target_link_libraries(telemetry_decoder_adapters + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + target_include_directories(telemetry_decoder_adapters PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces diff --git a/src/core/monitor/CMakeLists.txt b/src/core/monitor/CMakeLists.txt index 9d067c909..fe8743c05 100644 --- a/src/core/monitor/CMakeLists.txt +++ b/src/core/monitor/CMakeLists.txt @@ -73,6 +73,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(core_monitor + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + if(USE_BOOST_ASIO_IO_CONTEXT) target_compile_definitions(core_monitor PUBLIC diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index 29fc4b2e0..f3f96c0da 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -36,6 +36,8 @@ #include "test_flags.h" #include "tracking_tests_flags.h" // acquisition resampler #include +#include +#include #include #include #include diff --git a/src/tests/system-tests/ttff.cc b/src/tests/system-tests/ttff.cc index 0816e0ad2..55f0698cf 100644 --- a/src/tests/system-tests/ttff.cc +++ b/src/tests/system-tests/ttff.cc @@ -24,6 +24,8 @@ #include "gps_acq_assist.h" #include "in_memory_configuration.h" #include +#include +#include #include #include #include diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt index 8b9096c68..f5da39a39 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt +++ b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt @@ -53,6 +53,14 @@ target_include_directories(signal_processing_testing_lib ${CMAKE_SOURCE_DIR}/src/tests/common-files ) +if(GNURADIO_USES_SPDLOG) + target_link_libraries(signal_processing_testing_lib + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + if(USE_GENERIC_LAMBDAS) set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) From 6a625bdba6d6b7de0c7182f28755ed476cb1e55b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Nov 2021 17:13:58 +0100 Subject: [PATCH 08/11] Fix linking against GNU Radio master --- src/algorithms/telemetry_decoder/adapters/CMakeLists.txt | 8 -------- .../telemetry_decoder/gnuradio_blocks/CMakeLists.txt | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt index 12c3e8a25..a374f25d0 100644 --- a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt @@ -64,14 +64,6 @@ target_link_libraries(telemetry_decoder_adapters Gnuradio::runtime ) -if(GNURADIO_USES_SPDLOG) - target_link_libraries(telemetry_decoder_adapters - PUBLIC - fmt::fmt - spdlog::spdlog - ) -endif() - target_include_directories(telemetry_decoder_adapters PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index d1858d7ef..b47f56187 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -67,6 +67,14 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_USES_SPDLOG) + target_link_libraries(telemetry_decoder_gr_blocks + PUBLIC + fmt::fmt + spdlog::spdlog + ) +endif() + target_include_directories(telemetry_decoder_gr_blocks PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces From 3ff534bb4c3025a3bca7908c9c91f14f35c794f1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 23 Nov 2021 18:53:56 +0100 Subject: [PATCH 09/11] Fix selection of C++ standard --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bc9b9c91..a501d2d0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -655,7 +655,7 @@ if(NOT ENABLE_OWN_GPSTK) PURPOSE "Used in some Extra Tests." ) endif() -if(NOT (GNURADIO_VERSION VERSION_LESS 3.8) AND LOG4CPP_READY_FOR_CXX17) +if(NOT (GNURADIO_VERSION VERSION_LESS 3.8) AND (LOG4CPP_READY_FOR_CXX17 OR GNURADIO_USES_SPDLOG)) # Check if we have std::filesystem if(NOT (CMAKE_VERSION VERSION_LESS 3.8)) if(NOT GPSTK_FOUND OR NOT (GPSTK_FOUND AND GPSTK_OLDER_THAN_8)) # Fix for GPSTk < 8.0.0 From c4aca73e67b3c519d347e6a9e3b05d46e36a564d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 29 Nov 2021 16:50:43 +0100 Subject: [PATCH 10/11] Update changelog --- docs/CHANGELOG.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index dda9f46c6..588edd754 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -48,9 +48,13 @@ All notable changes to GNSS-SDR will be documented in this file. ### Improvements in Portability: - Fixed building against the new API in the gr-iio component present in GNU - Radio's `master` branch (currently v3.10.0.git). -- Fixed building against current GNU Radio's `master` branch, which does not - support the C++20 standard. + Radio v3.10.0.0-rc1. +- Fixed building against GNU Radio v3.10.0.0-rc1, which does not support the + C++20 standard. +- Fixed building against GNU Radio v3.10.0.0-rc1, which replaced + [log4cpp](http://log4cpp.sourceforge.net/) by + [spdlog](https://github.com/gabime/spdlog) and + [fmt](https://github.com/fmtlib/fmt) libraries. - Updated `cpu_features` library for improved processor detection. ### Improvements in Reliability: From 5f2f752421347faab262180299f2def59482bfd1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 29 Nov 2021 17:01:58 +0100 Subject: [PATCH 11/11] Fix a bug that prevented from obtaining PVT fixes with Galileo E1 signals if frame 0 was the first to be decoded --- docs/CHANGELOG.md | 2 ++ .../galileo_telemetry_decoder_gs.cc | 16 +++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 588edd754..9f748194c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -19,6 +19,8 @@ All notable changes to GNSS-SDR will be documented in this file. - Improved Time-To-First-Fix when using GPS L1 C/A signals, fixing a bug that was making the receiver to drop the satellite if the PLL got locked at 180 degrees, and making some optimizations on bit transition detection. +- Fixed a bug that prevented from obtaining PVT fixes with Galileo E1 OS signals + if the I/NAV subframe type 0 was the first decoded subframe. ### Improvements in Interoperability: diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc index 1656c04a1..81e4cd6bc 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc @@ -882,15 +882,13 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); d_inav_nav.set_TOW6_flag(false); } - // warning: type 0 frame does not contain a valid TOW in some simulated signals, thus it is not safe to activate the following code: - // else if (d_inav_nav.is_TOW0_set() == true) // page 0 arrived and decoded - // { - // // TOW_0 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay - // d_TOW_at_Preamble_ms = static_cast(d_inav_nav.get_TOW0() * 1000.0); - // d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); - // d_inav_nav.set_TOW0_flag(false); - // // std::cout << "FRAME 0 current tow: " << tmp_d_TOW_at_current_symbol_ms << " vs. " << d_TOW_at_current_symbol_ms + d_PRN_code_period_ms << "\n"; - // } + else if (d_inav_nav.is_TOW0_set() == true) // page 0 arrived and decoded + { + // TOW_0 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay + d_TOW_at_Preamble_ms = static_cast(d_inav_nav.get_TOW0() * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * d_PRN_code_period_ms); + d_inav_nav.set_TOW0_flag(false); + } else { // this page has no timing information