Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86cf941c authored by Dan Willemsen's avatar Dan Willemsen
Browse files

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
Change-Id: I4e43e7cf18a96f22b3a9a08dbab8c3e960c12930
parent 9c551a1b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -68,7 +68,13 @@
#include <windows.h>
#endif

static pid_t GetThreadId() {
#if defined(_WIN32)
typedef uint32_t thread_id;
#else
typedef pid_t thread_id;
#endif

static thread_id GetThreadId() {
#if defined(__BIONIC__)
  return gettid();
#elif defined(__APPLE__)
+4 −0
Original line number Diff line number Diff line
@@ -29,7 +29,11 @@
extern "C" {
#endif

#ifdef _WIN32
typedef uint32_t android_thread_id_t;
#else
typedef void* android_thread_id_t;
#endif

typedef int (*android_thread_func_t)(void*);

+4 −0
Original line number Diff line number Diff line
@@ -367,7 +367,11 @@ static void showLog(LogState *state,
    char prefixBuf[128], suffixBuf[128];
    char priChar;
    time_t when;
#if !defined(_WIN32)
    pid_t pid, tid;
#else
    uint32_t pid, tid;
#endif

    TRACE("LOG %d: %s %s", logPrio, tag, msg);

+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ commonSources:= \
	Log.cpp \
	NativeHandle.cpp \
	Printer.cpp \
	ProcessCallStack.cpp \
	PropertyMap.cpp \
	RefBase.cpp \
	SharedBuffer.cpp \
@@ -44,7 +43,7 @@ host_commonCflags := -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -Werror
# =====================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= $(commonSources)
LOCAL_SRC_FILES_linux := Looper.cpp
LOCAL_SRC_FILES_linux := Looper.cpp ProcessCallStack.cpp
LOCAL_CFLAGS_darwin := -Wno-unused-parameter
LOCAL_MODULE:= libutils
LOCAL_STATIC_LIBRARIES := liblog
@@ -67,6 +66,7 @@ LOCAL_SRC_FILES:= \
	$(commonSources) \
	BlobCache.cpp \
	Looper.cpp \
	ProcessCallStack.cpp \
	Trace.cpp

ifeq ($(TARGET_ARCH),mips)
+0 −2
Original line number Diff line number Diff line
@@ -146,7 +146,6 @@ void ProcessCallStack::update() {
    clear();

    // Get current time.
#ifndef USE_MINGW
    {
        time_t t = time(NULL);
        struct tm tm;
@@ -199,7 +198,6 @@ void ProcessCallStack::update() {
        ALOGE("%s: Failed to readdir from %s: %s",
              __FUNCTION__, PATH_SELF_TASK, strerror(code));
    }
#endif

    closedir(dp);
}