summaryrefslogtreecommitdiffstats
path: root/base/logging.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-11-11 18:02:29 +0000
committerElliott Hughes <enh@google.com>2015-11-11 18:23:00 -0800
commitc1fd492ac5c14a42acfbbd9b47ed178fbf1378d3 (patch)
tree73a610a40d14d6070073550327c34470273b0b50 /base/logging.cpp
parent524716889bb619e7604910cbb13864516d5e1467 (diff)
downloadsystem_core-c1fd492ac5c14a42acfbbd9b47ed178fbf1378d3.tar.gz
system_core-c1fd492ac5c14a42acfbbd9b47ed178fbf1378d3.tar.bz2
system_core-c1fd492ac5c14a42acfbbd9b47ed178fbf1378d3.zip
Revert "Revert "adb/base: fix adb push of Unicode filenames on Win32""
This reverts commit cc8cd59456ca485a51cd6fd388c8bcb1af4a8f9b. With the dependency on libcutils (for gettid for non-bionic) removed, this no longer breaks the build. Change-Id: I645bd6876e2502ddc1535b69af1e645c0df9d178
Diffstat (limited to 'base/logging.cpp')
-rw-r--r--base/logging.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/base/logging.cpp b/base/logging.cpp
index 248cd0617..01a046a0f 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -53,6 +53,33 @@
#include <unistd.h>
#endif
+// For gettid.
+#if defined(__APPLE__)
+#include "AvailabilityMacros.h" // For MAC_OS_X_VERSION_MAX_ALLOWED
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <unistd.h>
+#elif defined(__linux__) && !defined(__ANDROID__)
+#include <syscall.h>
+#include <unistd.h>
+#elif defined(_WIN32)
+#include <windows.h>
+#endif
+
+static pid_t GetThreadId() {
+#if defined(__BIONIC__)
+ return gettid();
+#elif defined(__APPLE__)
+ return syscall(SYS_thread_selfid);
+#elif defined(__linux__)
+ return syscall(__NR_gettid);
+#elif defined(_WIN32)
+ return GetCurrentThreadId();
+#endif
+}
+
namespace {
#ifndef _WIN32
using std::mutex;
@@ -158,7 +185,7 @@ void StderrLogger(LogId, LogSeverity severity, const char*, const char* file,
"Mismatch in size of log_characters and values in LogSeverity");
char severity_char = log_characters[severity];
fprintf(stderr, "%s %c %5d %5d %s:%u] %s\n", ProgramInvocationName(),
- severity_char, getpid(), gettid(), file, line, message);
+ severity_char, getpid(), GetThreadId(), file, line, message);
}