include/sal/log.hxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
New commits: commit f6b9b77d65c70ae77fa617c53e11d149a9fee1d1 Author: Noel Grandin <[email protected]> AuthorDate: Fri Oct 10 10:04:28 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Oct 11 08:44:00 2025 +0200 move SAL_LOG code out of line which is beneficial when we have a --enable-sal-log release build, since most of the time the logging stuff will not be executed. This is restricted to GCC because clang seems to have trouble with the lambda binding in some places. (tested with clang 12.0.1) I get errors like: cppuhelper/source/servicemanager.cxx:775:40: error: reference to local binding 'rImpls' declared in enclosing function 'cppuhelper::ServiceManager::addSingletonContextEntries' "Arbitrarily choosing " << rImpls[0]->name Change-Id: I3fe6deb94996542b552af1e201f5a68f0136c680 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192151 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/include/sal/log.hxx b/include/sal/log.hxx index a60d8dc24829..f769b58ccfda 100644 --- a/include/sal/log.hxx +++ b/include/sal/log.hxx @@ -146,6 +146,29 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { (level), (area), (where), sal_detail_stream, 0); \ } +#if defined LIBO_INTERNAL_ONLY && defined __GNUC__ && !defined __clang__ +// move cold/seldom-used code out of line, and into a separate linker section +#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \ + do { \ + if (SAL_UNLIKELY(condition)) \ + { \ + [&]() __attribute__((noinline,cold)) \ + { \ + switch (sal_detail_log_report(level, area)) \ + { \ + case SAL_DETAIL_LOG_ACTION_IGNORE: break; \ + case SAL_DETAIL_LOG_ACTION_LOG: \ + SAL_DETAIL_LOG_STREAM_PRIVATE_(level, area, where, stream); \ + break; \ + case SAL_DETAIL_LOG_ACTION_FATAL: \ + SAL_DETAIL_LOG_STREAM_PRIVATE_(level, area, where, stream); \ + std::abort(); \ + break; \ + } \ + }(); \ + } \ + } while (false) +#else #define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \ do { \ if (SAL_UNLIKELY(condition)) \ @@ -163,6 +186,7 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { } \ } \ } while (false) +#endif /// @endcond
