blob: 88b0af7f887ad9887953ead308c1f20f301044e3 [file] [log] [blame]
Brad Bishopc1d34332019-09-09 14:56:00 -04001Upstream-Status: Backport
Brad Bishop26bdd442019-08-16 17:08:17 -04002
Brad Bishopc1d34332019-09-09 14:56:00 -04003From de6255941a5e1c2fb2d50e57f84e38c09f45023d Mon Sep 17 00:00:00 2001
4From: Juanli Shen <juanlishen@google.com>
5Date: Fri, 23 Aug 2019 08:46:09 -0700
6Subject: [PATCH] Fix gettid() naming conflict
Brad Bishop26bdd442019-08-16 17:08:17 -04007
Brad Bishop26bdd442019-08-16 17:08:17 -04008---
Brad Bishopc1d34332019-09-09 14:56:00 -04009 src/core/lib/gpr/log_linux.cc | 6 ++++--
10 1 file changed, 4 insertions(+), 2 deletions(-)
Brad Bishop26bdd442019-08-16 17:08:17 -040011
12diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc
Brad Bishopc1d34332019-09-09 14:56:00 -040013index 561276f0c20..81026e5689b 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040014--- a/src/core/lib/gpr/log_linux.cc
15+++ b/src/core/lib/gpr/log_linux.cc
Brad Bishopc1d34332019-09-09 14:56:00 -040016@@ -40,7 +40,9 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040017 #include <time.h>
18 #include <unistd.h>
19
Brad Bishopc1d34332019-09-09 14:56:00 -040020-static long gettid(void) { return syscall(__NR_gettid); }
21+// Not naming it as gettid() to avoid duplicate declarations when complied with
22+// GCC 9.1.
23+static long local_gettid(void) { return syscall(__NR_gettid); }
Brad Bishop26bdd442019-08-16 17:08:17 -040024
25 void gpr_log(const char* file, int line, gpr_log_severity severity,
26 const char* format, ...) {
Brad Bishopc1d34332019-09-09 14:56:00 -040027@@ -70,7 +72,7 @@ void gpr_default_log(gpr_log_func_args* args) {
28 gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
29 struct tm tm;
30 static __thread long tid = 0;
31- if (tid == 0) tid = gettid();
32+ if (tid == 0) tid = local_gettid();
33
34 timer = static_cast<time_t>(now.tv_sec);
35 final_slash = strrchr(args->file, '/');
36From 57586a1ca7f17b1916aed3dea4ff8de872dbf853 Mon Sep 17 00:00:00 2001
37From: Benjamin Peterson <benjamin@dropbox.com>
38Date: Fri, 3 May 2019 08:11:00 -0700
39Subject: [PATCH] Rename gettid() functions.
40
41glibc 2.30 will declare its own gettid; see https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92. Rename the grpc versions to avoid naming conflicts.
42---
43 src/core/lib/gpr/log_linux.cc | 6 ++----
44 src/core/lib/gpr/log_posix.cc | 4 ++--
45 src/core/lib/iomgr/ev_epollex_linux.cc | 4 ++--
46 3 files changed, 6 insertions(+), 8 deletions(-)
47
48diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc
49index 81026e5689b..8b597b4cf2f 100644
50--- a/src/core/lib/gpr/log_linux.cc
51+++ b/src/core/lib/gpr/log_linux.cc
52@@ -40,9 +40,7 @@
53 #include <time.h>
54 #include <unistd.h>
55
56-// Not naming it as gettid() to avoid duplicate declarations when complied with
57-// GCC 9.1.
58-static long local_gettid(void) { return syscall(__NR_gettid); }
59+static long sys_gettid(void) { return syscall(__NR_gettid); }
60
61 void gpr_log(const char* file, int line, gpr_log_severity severity,
62 const char* format, ...) {
63@@ -72,7 +70,7 @@ void gpr_default_log(gpr_log_func_args* args) {
64 gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
65 struct tm tm;
66 static __thread long tid = 0;
67- if (tid == 0) tid = local_gettid();
68+ if (tid == 0) tid = sys_gettid();
69
70 timer = static_cast<time_t>(now.tv_sec);
71 final_slash = strrchr(args->file, '/');
72diff --git a/src/core/lib/gpr/log_posix.cc b/src/core/lib/gpr/log_posix.cc
73index b6edc14ab6b..2f7c6ce3760 100644
74--- a/src/core/lib/gpr/log_posix.cc
75+++ b/src/core/lib/gpr/log_posix.cc
76@@ -31,7 +31,7 @@
77 #include <string.h>
78 #include <time.h>
79
80-static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
81+static intptr_t sys_gettid(void) { return (intptr_t)pthread_self(); }
82
83 void gpr_log(const char* file, int line, gpr_log_severity severity,
84 const char* format, ...) {
85@@ -86,7 +86,7 @@ void gpr_default_log(gpr_log_func_args* args) {
86 char* prefix;
87 gpr_asprintf(&prefix, "%s%s.%09d %7" PRIdPTR " %s:%d]",
88 gpr_log_severity_string(args->severity), time_buffer,
89- (int)(now.tv_nsec), gettid(), display_file, args->line);
90+ (int)(now.tv_nsec), sys_gettid(), display_file, args->line);
91
92 fprintf(stderr, "%-70s %s\n", prefix, args->message);
93 gpr_free(prefix);
Brad Bishop26bdd442019-08-16 17:08:17 -040094diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc
Brad Bishopc1d34332019-09-09 14:56:00 -040095index c2d80c08ddb..4a83cb6c215 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040096--- a/src/core/lib/iomgr/ev_epollex_linux.cc
97+++ b/src/core/lib/iomgr/ev_epollex_linux.cc
Brad Bishopc1d34332019-09-09 14:56:00 -040098@@ -1077,7 +1077,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
Brad Bishop26bdd442019-08-16 17:08:17 -040099 }
100
Brad Bishopc1d34332019-09-09 14:56:00 -0400101 #ifndef NDEBUG
102-static long gettid(void) { return syscall(__NR_gettid); }
103+static long sys_gettid(void) { return syscall(__NR_gettid); }
Brad Bishop26bdd442019-08-16 17:08:17 -0400104 #endif
Brad Bishopc1d34332019-09-09 14:56:00 -0400105
Brad Bishop26bdd442019-08-16 17:08:17 -0400106 /* pollset->mu lock must be held by the caller before calling this.
Brad Bishopc1d34332019-09-09 14:56:00 -0400107@@ -1097,7 +1097,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
108 #define WORKER_PTR (&worker)
109 #endif
110 #ifndef NDEBUG
111- WORKER_PTR->originator = gettid();
112+ WORKER_PTR->originator = sys_gettid();
113 #endif
114 if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
115 gpr_log(GPR_INFO,