From ab8b1e2f822141bfb31b6a3a4178b8867a388cf0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 22 Nov 2021 14:30:24 +0100 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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";