2019-11-02 10:53:39 +01:00
|
|
|
From 9630e0e848da22e27b346c38d9b05f0a16cbf7b3 Mon Sep 17 00:00:00 2001
|
2019-10-29 14:15:43 +01:00
|
|
|
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
2019-11-02 10:53:39 +01:00
|
|
|
Date: Thu, 31 Oct 2019 19:27:16 +0100
|
2019-10-29 14:15:43 +01:00
|
|
|
Subject: [PATCH] src/utilities: fix build without pthread
|
|
|
|
|
2019-11-02 10:53:39 +01:00
|
|
|
- Remove is_default_thread function which is an internal and not used
|
|
|
|
function
|
|
|
|
- Remove g_main_thread_id as it was used only by is_default_thread
|
|
|
|
|
2019-10-29 14:15:43 +01:00
|
|
|
Fixes:
|
|
|
|
- http://autobuild.buildroot.net/results/5320bbe1205e782e3516d9bead8d1ed825bcbaad
|
|
|
|
|
|
|
|
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
2019-11-02 10:53:39 +01:00
|
|
|
[Retrieved from:
|
|
|
|
https://github.com/google/glog/commit/9630e0e848da22e27b346c38d9b05f0a16cbf7b3]
|
2019-10-29 14:15:43 +01:00
|
|
|
---
|
2019-11-02 10:53:39 +01:00
|
|
|
src/utilities.cc | 16 +++-------------
|
|
|
|
src/utilities.h | 2 --
|
|
|
|
2 files changed, 3 insertions(+), 15 deletions(-)
|
2019-10-29 14:15:43 +01:00
|
|
|
|
|
|
|
diff --git a/src/utilities.cc b/src/utilities.cc
|
2019-11-02 10:53:39 +01:00
|
|
|
index d463b33b..9a1e35d0 100644
|
2019-10-29 14:15:43 +01:00
|
|
|
--- a/src/utilities.cc
|
|
|
|
+++ b/src/utilities.cc
|
2019-11-02 10:53:39 +01:00
|
|
|
@@ -61,7 +61,6 @@ using std::string;
|
2019-10-29 14:15:43 +01:00
|
|
|
_START_GOOGLE_NAMESPACE_
|
|
|
|
|
|
|
|
static const char* g_program_invocation_short_name = NULL;
|
2019-11-02 10:53:39 +01:00
|
|
|
-static pthread_t g_main_thread_id;
|
2019-10-29 14:15:43 +01:00
|
|
|
|
|
|
|
_END_GOOGLE_NAMESPACE_
|
|
|
|
|
2019-11-02 10:53:39 +01:00
|
|
|
@@ -181,16 +180,6 @@ bool IsGoogleLoggingInitialized() {
|
2019-10-29 14:15:43 +01:00
|
|
|
return g_program_invocation_short_name != NULL;
|
|
|
|
}
|
|
|
|
|
2019-11-02 10:53:39 +01:00
|
|
|
-bool is_default_thread() {
|
|
|
|
- if (g_program_invocation_short_name == NULL) {
|
|
|
|
- // InitGoogleLogging() not yet called, so unlikely to be in a different
|
|
|
|
- // thread
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return pthread_equal(pthread_self(), g_main_thread_id);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
2019-10-29 14:15:43 +01:00
|
|
|
#ifdef OS_WINDOWS
|
|
|
|
struct timeval {
|
2019-11-02 10:53:39 +01:00
|
|
|
long tv_sec, tv_usec;
|
|
|
|
@@ -276,9 +265,11 @@ pid_t GetTID() {
|
2019-10-29 14:15:43 +01:00
|
|
|
return getpid(); // Linux: getpid returns thread ID when gettid is absent
|
|
|
|
#elif defined OS_WINDOWS && !defined OS_CYGWIN
|
|
|
|
return GetCurrentThreadId();
|
|
|
|
-#else
|
2019-11-02 10:53:39 +01:00
|
|
|
+#elif defined(HAVE_PTHREAD)
|
2019-10-29 14:15:43 +01:00
|
|
|
// If none of the techniques above worked, we use pthread_self().
|
|
|
|
return (pid_t)(uintptr_t)pthread_self();
|
2019-11-02 10:53:39 +01:00
|
|
|
+#else
|
|
|
|
+ return -1;
|
2019-10-29 14:15:43 +01:00
|
|
|
#endif
|
2019-11-02 10:53:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@@ -350,7 +341,6 @@ void InitGoogleLoggingUtilities(const char* argv0) {
|
2019-10-29 14:15:43 +01:00
|
|
|
if (!slash) slash = strrchr(argv0, '\\');
|
|
|
|
#endif
|
|
|
|
g_program_invocation_short_name = slash ? slash + 1 : argv0;
|
2019-11-02 10:53:39 +01:00
|
|
|
- g_main_thread_id = pthread_self();
|
2019-10-29 14:15:43 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_STACKTRACE
|
|
|
|
InstallFailureFunction(&DumpStackTraceAndExit);
|
|
|
|
diff --git a/src/utilities.h b/src/utilities.h
|
2019-11-02 10:53:39 +01:00
|
|
|
index ca21cfb3..c66f9146 100644
|
2019-10-29 14:15:43 +01:00
|
|
|
--- a/src/utilities.h
|
|
|
|
+++ b/src/utilities.h
|
2019-11-02 10:53:39 +01:00
|
|
|
@@ -163,8 +163,6 @@ const char* ProgramInvocationShortName();
|
2019-10-29 14:15:43 +01:00
|
|
|
|
|
|
|
bool IsGoogleLoggingInitialized();
|
|
|
|
|
2019-11-02 10:53:39 +01:00
|
|
|
-bool is_default_thread();
|
|
|
|
-
|
2019-10-29 14:15:43 +01:00
|
|
|
int64 CycleClock_Now();
|
|
|
|
|
2019-11-02 10:53:39 +01:00
|
|
|
int64 UsecToCycles(int64 usec);
|