diff options
Diffstat (limited to 'extern/libmv/third_party/glog/src/utilities.cc')
-rw-r--r-- | extern/libmv/third_party/glog/src/utilities.cc | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/extern/libmv/third_party/glog/src/utilities.cc b/extern/libmv/third_party/glog/src/utilities.cc index 6d64b923703..c9db2b7f7cd 100644 --- a/extern/libmv/third_party/glog/src/utilities.cc +++ b/extern/libmv/third_party/glog/src/utilities.cc @@ -77,9 +77,11 @@ typedef void DebugWriter(const char*, void*); // For some environments, add two extra bytes for the leading "0x". static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*); -static void DebugWriteToStderr(const char* data, void *unused) { +static void DebugWriteToStderr(const char* data, void *) { // This one is signal-safe. - write(STDERR_FILENO, data, strlen(data)); + if (write(STDERR_FILENO, data, strlen(data)) < 0) { + // Ignore errors. + } } void DebugWriteToString(const char* data, void *arg) { @@ -221,8 +223,17 @@ int32 GetMainThreadPid() { return g_main_thread_pid; } +bool PidHasChanged() { + int32 pid = getpid(); + if (g_main_thread_pid == pid) { + return false; + } + g_main_thread_pid = pid; + return true; +} + pid_t GetTID() { - // On Linux and FreeBSD, we try to use gettid(). + // On Linux and MACOSX , we try to use gettid(). #if defined OS_LINUX || defined OS_MACOSX #ifndef __NR_gettid #ifdef OS_MACOSX @@ -245,7 +256,7 @@ pid_t GetTID() { // the value change to "true". lacks_gettid = true; } -#endif // OS_LINUX || OS_FREEBSD +#endif // OS_LINUX || OS_MACOSX // If gettid() could not be used, we use one of the following. #if defined OS_LINUX @@ -302,9 +313,7 @@ void SetCrashReason(const CrashReason* r) { r); } -} // namespace glog_internal_namespace_ - -void InitGoogleLogging(const char* argv0) { +void InitGoogleLoggingUtilities(const char* argv0) { CHECK(!IsGoogleLoggingInitialized()) << "You called InitGoogleLogging() twice!"; const char* slash = strrchr(argv0, '/'); @@ -319,14 +328,16 @@ void InitGoogleLogging(const char* argv0) { #endif } -void ShutdownGoogleLogging() { +void ShutdownGoogleLoggingUtilities() { CHECK(IsGoogleLoggingInitialized()) - << "You called ShutdownGoogleLogging() without InitGoogleLogging() first!"; + << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!"; #ifdef HAVE_SYSLOG_H closelog(); #endif } +} // namespace glog_internal_namespace_ + _END_GOOGLE_NAMESPACE_ // Make an implementation of stacktrace compiled. |