Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 1 | From c27261a8bc1e45ff7d7a585c79b2b871d47217e4 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 26 Jul 2019 18:56:26 -0700 |
| 4 | Subject: [PATCH] Define gettid() only for glibc < 2.30 |
| 5 | |
| 6 | glibc 2.30 has added this API, so let us use that when possible |
| 7 | |
| 8 | Upstream-Status: Pending |
| 9 | Signed-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 | |
| 15 | diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc |
| 16 | index 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, ...) { |
| 31 | diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc |
| 32 | index 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 | -- |
| 52 | 2.22.0 |
| 53 | |