This commit is contained in:
Sergiu Deitsch 2023-12-30 23:40:58 +01:00
parent eb72e4c181
commit 5ea3279ad1
No known key found for this signature in database
3 changed files with 19 additions and 15 deletions

View File

@ -68,12 +68,26 @@
# if __has_attribute(used) # if __has_attribute(used)
# define GLOG_USED __attribute__((used)) # define GLOG_USED __attribute__((used))
# endif // __has_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) #endif // defined(__has_attribute)
#if !defined(GLOG_USED) #if !defined(GLOG_USED)
# define GLOG_USED # define GLOG_USED
#endif // !defined(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/log_severity.h"
#include "glog/vlog_is_on.h" #include "glog/vlog_is_on.h"
@ -499,11 +513,7 @@ GLOG_EXPORT bool IsGoogleLoggingInitialized();
// Shutdown google's logging library. // Shutdown google's logging library.
GLOG_EXPORT void ShutdownGoogleLogging(); GLOG_EXPORT void ShutdownGoogleLogging();
#if defined(__GNUC__) typedef void (*logging_fail_func_t)() GLOG_NORETURN;
typedef void (*logging_fail_func_t)() __attribute__((noreturn));
#else
typedef void (*logging_fail_func_t)();
#endif
// Install a function which will be called after LOG(FATAL). // Install a function which will be called after LOG(FATAL).
GLOG_EXPORT void InstallFailureFunction(logging_fail_func_t fail_func); 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. // Build the error message string. Specify no inlining for code size.
template <typename T1, typename T2> template <typename T1, typename T2>
std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) std::string* MakeCheckOpString(const T1& v1, const T2& v2,
#if defined(__has_attribute) const char* exprtext) GLOG_NOINLINE;
# if __has_attribute(used)
__attribute__((noinline))
# endif
#endif
;
namespace base { namespace base {

View File

@ -31,6 +31,7 @@
// //
// logging_unittest.cc covers the functionality herein // logging_unittest.cc covers the functionality herein
#include <atomic>
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <iomanip> #include <iomanip>

View File

@ -150,9 +150,7 @@ static void DumpStackTrace(int skip_count, DebugWriter* writerfn, void* arg) {
} }
} }
# ifdef __GNUC__ GLOG_NORETURN
__attribute__((noreturn))
# endif
static void static void
DumpStackTraceAndExit() { DumpStackTraceAndExit() {
DumpStackTrace(1, DebugWriteToStderr, nullptr); DumpStackTrace(1, DebugWriteToStderr, nullptr);