From a6998cd87140da116aa853ff67d42ae14c2ed073 Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Thu, 9 Jul 2020 13:42:11 -0700 Subject: [PATCH 01/10] add SUPPORTS_PTHREAD_GETNAME_NP definition Signed-off-by: Alan Chiu --- include/envoy/common/platform.h | 14 ++++++++++++++ source/common/common/posix/thread_impl.cc | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 80870d24240dd..92b9efde4bfdb 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -235,3 +235,17 @@ struct mmsghdr { unsigned int msg_len; }; #endif + + +#define SUPPORTS_PTHREAD_GETNAME_NP +#ifdef __linux__ +#undef SUPPORTS_PTHREAD_GETNAME_NP +#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 +#undef SUPPORTS_PTHREAD_GETNAME_NP +#endif // __ANDROID_API__ < 26 +#endif // ifdef __ANDROID_API__ \ No newline at end of file diff --git a/source/common/common/posix/thread_impl.cc b/source/common/common/posix/thread_impl.cc index 359af8245ed97..7c23a56be9c22 100644 --- a/source/common/common/posix/thread_impl.cc +++ b/source/common/common/posix/thread_impl.cc @@ -93,7 +93,7 @@ class ThreadImplPosix : public Thread { } private: -#ifdef __linux__ +#ifdef 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. From bb595e233403be48d2cd714201a060c939e671c4 Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Thu, 9 Jul 2020 14:04:25 -0700 Subject: [PATCH 02/10] another if-def Signed-off-by: Alan Chiu --- source/common/common/posix/thread_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/common/posix/thread_impl.cc b/source/common/common/posix/thread_impl.cc index 7c23a56be9c22..c063d97d53d8e 100644 --- a/source/common/common/posix/thread_impl.cc +++ b/source/common/common/posix/thread_impl.cc @@ -52,7 +52,7 @@ class ThreadImplPosix : public Thread { this); RELEASE_ASSERT(rc == 0, ""); -#ifdef __linux__ +#ifdef 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. From 5b6fdc6911a9253edde500edee095b9578e12f00 Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Thu, 9 Jul 2020 14:25:50 -0700 Subject: [PATCH 03/10] opps didnt save Signed-off-by: Alan Chiu --- include/envoy/common/platform.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 92b9efde4bfdb..6842406a7f820 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -236,16 +236,14 @@ struct mmsghdr { }; #endif - -#define SUPPORTS_PTHREAD_GETNAME_NP #ifdef __linux__ -#undef SUPPORTS_PTHREAD_GETNAME_NP +#define SUPPORTS_PTHREAD_GETNAME_NP #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 -#undef SUPPORTS_PTHREAD_GETNAME_NP +#define SUPPORTS_PTHREAD_GETNAME_NP #endif // __ANDROID_API__ < 26 #endif // ifdef __ANDROID_API__ \ No newline at end of file From 5846c225c992e67672f02b08914bfec9a9a3b684 Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Thu, 9 Jul 2020 14:26:57 -0700 Subject: [PATCH 04/10] newline Signed-off-by: Alan Chiu --- include/envoy/common/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 6842406a7f820..aef0edddb9761 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -246,4 +246,4 @@ struct mmsghdr { #if __ANDROID_API__ < 26 #define SUPPORTS_PTHREAD_GETNAME_NP #endif // __ANDROID_API__ < 26 -#endif // ifdef __ANDROID_API__ \ No newline at end of file +#endif // ifdef __ANDROID_API__ From e1881fbfbb5cdd92b0a121254517f3fde106ba78 Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Thu, 9 Jul 2020 15:58:08 -0700 Subject: [PATCH 05/10] add spelling Signed-off-by: Alan Chiu --- tools/spelling/spelling_dictionary.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/spelling/spelling_dictionary.txt b/tools/spelling/spelling_dictionary.txt index 4b8f9a058a249..b4285aa45a736 100644 --- a/tools/spelling/spelling_dictionary.txt +++ b/tools/spelling/spelling_dictionary.txt @@ -617,6 +617,7 @@ getaddrinfo getaffinity gethostname getifaddrs +getname getpeername getsockname getsockopt From 6af202b2aa6e38f78884ebdd9a86ecc8711f786b Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Thu, 9 Jul 2020 18:13:57 -0700 Subject: [PATCH 06/10] pr feedback Signed-off-by: Alan Chiu --- include/envoy/common/platform.h | 13 +++++++++---- source/common/common/posix/thread_impl.cc | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index aef0edddb9761..97ffb349e66a9 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -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 diff --git a/source/common/common/posix/thread_impl.cc b/source/common/common/posix/thread_impl.cc index c063d97d53d8e..c85bbfce57ec0 100644 --- a/source/common/common/posix/thread_impl.cc +++ b/source/common/common/posix/thread_impl.cc @@ -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. @@ -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. From 90082ee0135a7ea648fff3b15db2d32852c7b03c Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Thu, 9 Jul 2020 18:15:48 -0700 Subject: [PATCH 07/10] better comment Signed-off-by: Alan Chiu --- include/envoy/common/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 97ffb349e66a9..bfa9e15ef1d1d 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -248,7 +248,7 @@ struct mmsghdr { #endif // __ANDROID_API__ > 26 #endif // ifdef __ANDROID_API__ -// Ensure we set SUPPORTS_PTHREAD_GETNAME_NP +// Ensure SUPPORTS_PTHREAD_GETNAME_NP is set #ifndef SUPPORTS_PTHREAD_GETNAME_NP #define SUPPORTS_PTHREAD_GETNAME_NP 0 #endif From af1083379e440ab4e94a312bf6ff12f280eac59a Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Fri, 10 Jul 2020 10:09:26 -0700 Subject: [PATCH 08/10] add np Signed-off-by: Alan Chiu --- tools/spelling/spelling_dictionary.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/spelling/spelling_dictionary.txt b/tools/spelling/spelling_dictionary.txt index b4285aa45a736..442072da0da1a 100644 --- a/tools/spelling/spelling_dictionary.txt +++ b/tools/spelling/spelling_dictionary.txt @@ -792,6 +792,7 @@ noncopyable nonresponsive noop nop +np nthreads ntohl ntop From fe5cf72537a63b86c4b347f08a83c2b84b6b78cc Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Fri, 10 Jul 2020 11:36:37 -0700 Subject: [PATCH 09/10] single back ticks Signed-off-by: Alan Chiu --- include/envoy/common/platform.h | 2 +- tools/spelling/spelling_dictionary.txt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index bfa9e15ef1d1d..7cc2052aa81ce 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -241,7 +241,7 @@ struct mmsghdr { #endif // https://android.googlesource.com/platform/bionic/+/master/docs/status.md -// pthread_getname_np is introduced in API 26 +// `pthread_getname_np` is introduced in API 26 #ifdef __ANDROID_API__ #if __ANDROID_API__ > 26 #define SUPPORTS_PTHREAD_GETNAME_NP 1 diff --git a/tools/spelling/spelling_dictionary.txt b/tools/spelling/spelling_dictionary.txt index 442072da0da1a..4b8f9a058a249 100644 --- a/tools/spelling/spelling_dictionary.txt +++ b/tools/spelling/spelling_dictionary.txt @@ -617,7 +617,6 @@ getaddrinfo getaffinity gethostname getifaddrs -getname getpeername getsockname getsockopt @@ -792,7 +791,6 @@ noncopyable nonresponsive noop nop -np nthreads ntohl ntop From 5ac5ef947d08426db1916a2a307d242b099a3b81 Mon Sep 17 00:00:00 2001 From: Alan Chiu Date: Fri, 10 Jul 2020 12:33:28 -0700 Subject: [PATCH 10/10] more backticks Signed-off-by: Alan Chiu --- include/envoy/common/platform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 7cc2052aa81ce..11dcc122c195f 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -241,14 +241,14 @@ struct mmsghdr { #endif // https://android.googlesource.com/platform/bionic/+/master/docs/status.md -// `pthread_getname_np` is introduced in API 26 +// ``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 +// Ensure `SUPPORTS_PTHREAD_GETNAME_NP` is set #ifndef SUPPORTS_PTHREAD_GETNAME_NP #define SUPPORTS_PTHREAD_GETNAME_NP 0 #endif