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

android: add SUPPORTS_PTHREAD_GETNAME_NP definition #12011

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
17 changes: 17 additions & 0 deletions include/envoy/common/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,20 @@ struct mmsghdr {
#undef SUPPORTS_GETIFADDRS
#endif // __ANDROID_API__ < 24
#endif // ifdef __ANDROID_API__

#ifdef __linux__
#define SUPPORTS_PTHREAD_GETNAME_NP 1
#endif

// https://android.googlesource.com/platform/bionic/+/master/docs/status.md
// ``pthread_getname_np`` is introduced in API 26
#ifdef __ANDROID_API__
#if __ANDROID_API__ > 26
#define SUPPORTS_PTHREAD_GETNAME_NP 1
#endif // __ANDROID_API__ > 26
#endif // ifdef __ANDROID_API__

// Ensure `SUPPORTS_PTHREAD_GETNAME_NP` is set
#ifndef SUPPORTS_PTHREAD_GETNAME_NP
#define SUPPORTS_PTHREAD_GETNAME_NP 0
#endif
4 changes: 2 additions & 2 deletions source/common/common/posix/thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ThreadImplPosix : public Thread {
this);
RELEASE_ASSERT(rc == 0, "");

#ifdef __linux__
#if SUPPORTS_PTHREAD_GETNAME_NP
// If the name was not specified, get it from the OS. If the name was
// specified, write it into the thread, and assert that the OS sees it the
// same way.
Expand Down Expand Up @@ -93,7 +93,7 @@ class ThreadImplPosix : public Thread {
}

private:
#ifdef __linux__
#if SUPPORTS_PTHREAD_GETNAME_NP
// Attempts to get the name from the operating system, returning true and
// updating 'name' if successful. Note that during normal operation this
// may fail, if the thread exits prior to the system call.
Expand Down