From 5ea3279ad10c326b6a21bd5a07a532022e08428b Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Sat, 30 Dec 2023 23:40:58 +0100 Subject: [PATCH] wip --- src/glog/logging.h | 29 +++++++++++++++++------------ src/raw_logging.cc | 1 + src/utilities.cc | 4 +--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/glog/logging.h b/src/glog/logging.h index 17c99c1..67e035b 100644 --- a/src/glog/logging.h +++ b/src/glog/logging.h @@ -68,12 +68,26 @@ # if __has_attribute(used) # define GLOG_USED __attribute__((used)) # endif // __has_attribute(used) +# if __has_attribute(noreturn) +# define GLOG_NORETURN __attribute__((noreturn)) +# endif // __has_attribute(noreturn) +# if __has_attribute(noinline) +# define GLOG_NOINLINE __attribute__((noinline)) +# endif // __has_attribute(noinline) #endif // defined(__has_attribute) #if !defined(GLOG_USED) # define GLOG_USED #endif // !defined(GLOG_USED) +#if !defined(GLOG_NORETURN) +# define GLOG_NORETURN +#endif // !defined(GLOG_NORETURN) + +#if !defined(GLOG_NOINLINE) +# define GLOG_NOINLINE +#endif // !defined(GLOG_NOINLINE) + #include "glog/log_severity.h" #include "glog/vlog_is_on.h" @@ -499,11 +513,7 @@ GLOG_EXPORT bool IsGoogleLoggingInitialized(); // Shutdown google's logging library. GLOG_EXPORT void ShutdownGoogleLogging(); -#if defined(__GNUC__) -typedef void (*logging_fail_func_t)() __attribute__((noreturn)); -#else -typedef void (*logging_fail_func_t)(); -#endif +typedef void (*logging_fail_func_t)() GLOG_NORETURN; // Install a function which will be called after LOG(FATAL). GLOG_EXPORT void InstallFailureFunction(logging_fail_func_t fail_func); @@ -652,13 +662,8 @@ GLOG_EXPORT void MakeCheckOpValueString(std::ostream* os, // Build the error message string. Specify no inlining for code size. template -std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) -#if defined(__has_attribute) -# if __has_attribute(used) - __attribute__((noinline)) -# endif -#endif - ; +std::string* MakeCheckOpString(const T1& v1, const T2& v2, + const char* exprtext) GLOG_NOINLINE; namespace base { diff --git a/src/raw_logging.cc b/src/raw_logging.cc index 75bf054..ed5cdce 100644 --- a/src/raw_logging.cc +++ b/src/raw_logging.cc @@ -31,6 +31,7 @@ // // logging_unittest.cc covers the functionality herein +#include #include #include #include diff --git a/src/utilities.cc b/src/utilities.cc index 4b1f5e0..d84cb7a 100644 --- a/src/utilities.cc +++ b/src/utilities.cc @@ -150,9 +150,7 @@ static void DumpStackTrace(int skip_count, DebugWriter* writerfn, void* arg) { } } -# ifdef __GNUC__ -__attribute__((noreturn)) -# endif +GLOG_NORETURN static void DumpStackTraceAndExit() { DumpStackTrace(1, DebugWriteToStderr, nullptr);