Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/utilities: fix build without pthread #477

Merged
merged 1 commit into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ using std::string;
_START_GOOGLE_NAMESPACE_

static const char* g_program_invocation_short_name = NULL;
static pthread_t g_main_thread_id;

_END_GOOGLE_NAMESPACE_

Expand Down Expand Up @@ -181,16 +180,6 @@ bool IsGoogleLoggingInitialized() {
return g_program_invocation_short_name != NULL;
}

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);
}
}

#ifdef OS_WINDOWS
struct timeval {
long tv_sec, tv_usec;
Expand Down Expand Up @@ -276,9 +265,11 @@ pid_t GetTID() {
return getpid(); // Linux: getpid returns thread ID when gettid is absent
#elif defined OS_WINDOWS && !defined OS_CYGWIN
return GetCurrentThreadId();
#else
#elif defined(HAVE_PTHREAD)
// If none of the techniques above worked, we use pthread_self().
return (pid_t)(uintptr_t)pthread_self();
#else
return -1;
#endif
}

Expand Down Expand Up @@ -350,7 +341,6 @@ void InitGoogleLoggingUtilities(const char* argv0) {
if (!slash) slash = strrchr(argv0, '\\');
#endif
g_program_invocation_short_name = slash ? slash + 1 : argv0;
g_main_thread_id = pthread_self();

#ifdef HAVE_STACKTRACE
InstallFailureFunction(&DumpStackTraceAndExit);
Expand Down
2 changes: 0 additions & 2 deletions src/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ const char* ProgramInvocationShortName();

bool IsGoogleLoggingInitialized();

bool is_default_thread();

int64 CycleClock_Now();

int64 UsecToCycles(int64 usec);
Expand Down