blob: c6afff2d23460f45fb106644e57e57a572b041ac [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From c27261a8bc1e45ff7d7a585c79b2b871d47217e4 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 26 Jul 2019 18:56:26 -0700
4Subject: [PATCH] Define gettid() only for glibc < 2.30
5
6glibc 2.30 has added this API, so let us use that when possible
7
8Upstream-Status: Pending
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 src/core/lib/gpr/log_linux.cc | 4 ++++
12 src/core/lib/iomgr/ev_epollex_linux.cc | 7 +++++--
13 2 files changed, 9 insertions(+), 2 deletions(-)
14
15diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc
16index 561276f0c2..25a74864a1 100644
17--- a/src/core/lib/gpr/log_linux.cc
18+++ b/src/core/lib/gpr/log_linux.cc
19@@ -40,7 +40,11 @@
20 #include <time.h>
21 #include <unistd.h>
22
23+#if defined(__GLIBC__) && (__GLIBC_MINOR__ >= 29)
24+#include <unistd.h>
25+#else
26 static long gettid(void) { return syscall(__NR_gettid); }
27+#endif
28
29 void gpr_log(const char* file, int line, gpr_log_severity severity,
30 const char* format, ...) {
31diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc
32index 08116b3ab5..d3d3025111 100644
33--- a/src/core/lib/iomgr/ev_epollex_linux.cc
34+++ b/src/core/lib/iomgr/ev_epollex_linux.cc
35@@ -1101,10 +1101,13 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
36 gpr_atm_no_barrier_fetch_add(&pollset->worker_count, -1);
37 }
38
39-#ifndef NDEBUG
40+#if !defined(DEBUG)
41+#if defined(__GLIBC__) && (__GLIBC_MINOR__ >= 29)
42+#include <unistd.h>
43+#else
44 static long gettid(void) { return syscall(__NR_gettid); }
45 #endif
46-
47+#endif
48 /* pollset->mu lock must be held by the caller before calling this.
49 The function pollset_work() may temporarily release the lock (pollset->po.mu)
50 during the course of its execution but it will always re-acquire the lock and
51--
522.22.0
53