0002-src-utilities-fix-build-without-pthread.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From 9630e0e848da22e27b346c38d9b05f0a16cbf7b3 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Thu, 31 Oct 2019 19:27:16 +0100
  4. Subject: [PATCH] src/utilities: fix build without pthread
  5. - Remove is_default_thread function which is an internal and not used
  6. function
  7. - Remove g_main_thread_id as it was used only by is_default_thread
  8. Fixes:
  9. - http://autobuild.buildroot.net/results/5320bbe1205e782e3516d9bead8d1ed825bcbaad
  10. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  11. [Retrieved from:
  12. https://github.com/google/glog/commit/9630e0e848da22e27b346c38d9b05f0a16cbf7b3]
  13. ---
  14. src/utilities.cc | 16 +++-------------
  15. src/utilities.h | 2 --
  16. 2 files changed, 3 insertions(+), 15 deletions(-)
  17. diff --git a/src/utilities.cc b/src/utilities.cc
  18. index d463b33b..9a1e35d0 100644
  19. --- a/src/utilities.cc
  20. +++ b/src/utilities.cc
  21. @@ -61,7 +61,6 @@ using std::string;
  22. _START_GOOGLE_NAMESPACE_
  23. static const char* g_program_invocation_short_name = NULL;
  24. -static pthread_t g_main_thread_id;
  25. _END_GOOGLE_NAMESPACE_
  26. @@ -181,16 +180,6 @@ bool IsGoogleLoggingInitialized() {
  27. return g_program_invocation_short_name != NULL;
  28. }
  29. -bool is_default_thread() {
  30. - if (g_program_invocation_short_name == NULL) {
  31. - // InitGoogleLogging() not yet called, so unlikely to be in a different
  32. - // thread
  33. - return true;
  34. - } else {
  35. - return pthread_equal(pthread_self(), g_main_thread_id);
  36. - }
  37. -}
  38. -
  39. #ifdef OS_WINDOWS
  40. struct timeval {
  41. long tv_sec, tv_usec;
  42. @@ -276,9 +265,11 @@ pid_t GetTID() {
  43. return getpid(); // Linux: getpid returns thread ID when gettid is absent
  44. #elif defined OS_WINDOWS && !defined OS_CYGWIN
  45. return GetCurrentThreadId();
  46. -#else
  47. +#elif defined(HAVE_PTHREAD)
  48. // If none of the techniques above worked, we use pthread_self().
  49. return (pid_t)(uintptr_t)pthread_self();
  50. +#else
  51. + return -1;
  52. #endif
  53. }
  54. @@ -350,7 +341,6 @@ void InitGoogleLoggingUtilities(const char* argv0) {
  55. if (!slash) slash = strrchr(argv0, '\\');
  56. #endif
  57. g_program_invocation_short_name = slash ? slash + 1 : argv0;
  58. - g_main_thread_id = pthread_self();
  59. #ifdef HAVE_STACKTRACE
  60. InstallFailureFunction(&DumpStackTraceAndExit);
  61. diff --git a/src/utilities.h b/src/utilities.h
  62. index ca21cfb3..c66f9146 100644
  63. --- a/src/utilities.h
  64. +++ b/src/utilities.h
  65. @@ -163,8 +163,6 @@ const char* ProgramInvocationShortName();
  66. bool IsGoogleLoggingInitialized();
  67. -bool is_default_thread();
  68. -
  69. int64 CycleClock_Now();
  70. int64 UsecToCycles(int64 usec);