Skip to content

Commit a742158

Browse files
Adrian RatiuJim Pollock
authored andcommitted
threads.h: avoid defining gettid on glibc >= 2.32
Glibc >=2.32 exposes a gettid() which clashes with libcutils thread.h, so add a check to not expose it if building against newer glibc (ChromiumOS will still use glibc 2.27 besides 2.32). Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1182060 Test: Builds without errors on both glibc 2.32 and 2.27. Change-Id: Ib71fa1bc9fa185e3668002407dbed05a80c87740
1 parent 3aab337 commit a742158

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

libcutils/include/cutils/threads.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ extern "C" {
3131
//
3232
// Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows.
3333
//
34+
#if !defined(__GLIBC__) || __GLIBC__ >= 2 && __GLIBC_MINOR__ < 32
3435
extern pid_t gettid();
36+
#endif
3537

3638
#ifdef __cplusplus
3739
}

libcutils/threads.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
#include <windows.h>
2626
#endif
2727

28-
#if defined(__BIONIC__)
28+
#if defined(__BIONIC__) || defined(__GLIBC__) && __GLIBC_MINOR__ >= 32
2929
// No definition needed for Android because we'll just pick up bionic's copy.
30+
// No definition needed for Glibc >= 2.32 because it exposes its own copy.
3031
#else
3132
pid_t gettid() {
3233
#if defined(__APPLE__)

0 commit comments

Comments
 (0)