Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Chiu <achiu@lyft.com>
  • Loading branch information
Alan Chiu committed Jul 10, 2020
1 parent e1881fb commit 6af202b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions include/envoy/common/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,18 @@ struct mmsghdr {
#endif

#ifdef __linux__
#define SUPPORTS_PTHREAD_GETNAME_NP
#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
#endif // __ANDROID_API__ < 26
#if __ANDROID_API__ > 26
#define SUPPORTS_PTHREAD_GETNAME_NP 1
#endif // __ANDROID_API__ > 26
#endif // ifdef __ANDROID_API__

// Ensure we set SUPPORTS_PTHREAD_GETNAME_NP
#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 SUPPORTS_PTHREAD_GETNAME_NP
#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 SUPPORTS_PTHREAD_GETNAME_NP
#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

0 comments on commit 6af202b

Please sign in to comment.