summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen2016-02-04 01:29:32 -0600
committerStephen Hines2016-02-25 20:43:55 -0600
commit9dddd137c72a989b414c1bc8e928fb67ee46fac3 (patch)
tree6ed4d4de61ea60772f12c2b356b44d3fc3ef1a8b
parent97b3e66d3ef598ccf8cad42bbb723273d8d61f7c (diff)
downloadplatform-system-core-9dddd137c72a989b414c1bc8e928fb67ee46fac3.tar.gz
platform-system-core-9dddd137c72a989b414c1bc8e928fb67ee46fac3.tar.xz
platform-system-core-9dddd137c72a989b414c1bc8e928fb67ee46fac3.zip
Fix windows 64-bit builds
pid_t is 64-bit in 64-bit mingw, but the windows process/thread functions return a DWORD(uint32_t). Instead of promoting to a pid_t and fixing the format strings, just use a uint32_t to store the values. android_thread_id also cannot be a 64-bit pointer, so for windows just force it to be a uint32_t. libutils/ProcessCallStack only works under Linux, since it makes heavy use of /proc. Don't compile it under Windows or Darwin. Bug: 26957718 (cherry picked from commit 86cf941c480de8d5693a24d3feb45574f5c89a86) Change-Id: I8d39d1951fea1b3011caf585c983e1da7959f7c0
-rw-r--r--base/logging.cpp8
-rw-r--r--include/utils/ThreadDefs.h4
-rw-r--r--liblog/fake_log_device.c4
-rw-r--r--libutils/Android.mk4
-rw-r--r--libutils/ProcessCallStack.cpp2
5 files changed, 17 insertions, 5 deletions
diff --git a/base/logging.cpp b/base/logging.cpp
index a385902e8..174187149 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -68,7 +68,13 @@
68#include <windows.h> 68#include <windows.h>
69#endif 69#endif
70 70
71static pid_t GetThreadId() { 71#if defined(_WIN32)
72typedef uint32_t thread_id;
73#else
74typedef pid_t thread_id;
75#endif
76
77static thread_id GetThreadId() {
72#if defined(__BIONIC__) 78#if defined(__BIONIC__)
73 return gettid(); 79 return gettid();
74#elif defined(__APPLE__) 80#elif defined(__APPLE__)
diff --git a/include/utils/ThreadDefs.h b/include/utils/ThreadDefs.h
index 9711c1379..ae091e40f 100644
--- a/include/utils/ThreadDefs.h
+++ b/include/utils/ThreadDefs.h
@@ -29,7 +29,11 @@
29extern "C" { 29extern "C" {
30#endif 30#endif
31 31
32#ifdef _WIN32
33typedef uint32_t android_thread_id_t;
34#else
32typedef void* android_thread_id_t; 35typedef void* android_thread_id_t;
36#endif
33 37
34typedef int (*android_thread_func_t)(void*); 38typedef int (*android_thread_func_t)(void*);
35 39
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index f4e071b8c..2fe5f6d13 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -367,7 +367,11 @@ static void showLog(LogState *state,
367 char prefixBuf[128], suffixBuf[128]; 367 char prefixBuf[128], suffixBuf[128];
368 char priChar; 368 char priChar;
369 time_t when; 369 time_t when;
370#if !defined(_WIN32)
370 pid_t pid, tid; 371 pid_t pid, tid;
372#else
373 uint32_t pid, tid;
374#endif
371 375
372 TRACE("LOG %d: %s %s", logPrio, tag, msg); 376 TRACE("LOG %d: %s %s", logPrio, tag, msg);
373 377
diff --git a/libutils/Android.mk b/libutils/Android.mk
index 3584b6a21..84bac32f9 100644
--- a/libutils/Android.mk
+++ b/libutils/Android.mk
@@ -22,7 +22,6 @@ commonSources:= \
22 Log.cpp \ 22 Log.cpp \
23 NativeHandle.cpp \ 23 NativeHandle.cpp \
24 Printer.cpp \ 24 Printer.cpp \
25 ProcessCallStack.cpp \
26 PropertyMap.cpp \ 25 PropertyMap.cpp \
27 RefBase.cpp \ 26 RefBase.cpp \
28 SharedBuffer.cpp \ 27 SharedBuffer.cpp \
@@ -44,7 +43,7 @@ host_commonCflags := -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -Werror
44# ===================================================== 43# =====================================================
45include $(CLEAR_VARS) 44include $(CLEAR_VARS)
46LOCAL_SRC_FILES:= $(commonSources) 45LOCAL_SRC_FILES:= $(commonSources)
47LOCAL_SRC_FILES_linux := Looper.cpp 46LOCAL_SRC_FILES_linux := Looper.cpp ProcessCallStack.cpp
48LOCAL_CFLAGS_darwin := -Wno-unused-parameter 47LOCAL_CFLAGS_darwin := -Wno-unused-parameter
49LOCAL_MODULE:= libutils 48LOCAL_MODULE:= libutils
50LOCAL_STATIC_LIBRARIES := liblog 49LOCAL_STATIC_LIBRARIES := liblog
@@ -67,6 +66,7 @@ LOCAL_SRC_FILES:= \
67 $(commonSources) \ 66 $(commonSources) \
68 BlobCache.cpp \ 67 BlobCache.cpp \
69 Looper.cpp \ 68 Looper.cpp \
69 ProcessCallStack.cpp \
70 Trace.cpp 70 Trace.cpp
71 71
72ifeq ($(TARGET_ARCH),mips) 72ifeq ($(TARGET_ARCH),mips)
diff --git a/libutils/ProcessCallStack.cpp b/libutils/ProcessCallStack.cpp
index 011c30291..cdb586d98 100644
--- a/libutils/ProcessCallStack.cpp
+++ b/libutils/ProcessCallStack.cpp
@@ -146,7 +146,6 @@ void ProcessCallStack::update() {
146 clear(); 146 clear();
147 147
148 // Get current time. 148 // Get current time.
149#ifndef USE_MINGW
150 { 149 {
151 time_t t = time(NULL); 150 time_t t = time(NULL);
152 struct tm tm; 151 struct tm tm;
@@ -199,7 +198,6 @@ void ProcessCallStack::update() {
199 ALOGE("%s: Failed to readdir from %s: %s", 198 ALOGE("%s: Failed to readdir from %s: %s",
200 __FUNCTION__, PATH_SELF_TASK, strerror(code)); 199 __FUNCTION__, PATH_SELF_TASK, strerror(code));
201 } 200 }
202#endif
203 201
204 closedir(dp); 202 closedir(dp);
205} 203}