From 5c15de21dab52c40342671a79ee7791d5e26feec Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Fri, 10 Dec 2021 05:32:17 +0000 Subject: [PATCH 1/2] Disable call stacks on every OS except Linux/Android To keep libutils (and consequently libbinder) as compact and portable as possible, this disables call stacks on all operating systems except Linux and Android. Bug: 224644083 Test: m Change-Id: I0d77c49022e852c2b8607f555174c4f9d54ed3df --- libutils/RefBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp index 99fefee40..4ddac3d2e 100644 --- a/libutils/RefBase.cpp +++ b/libutils/RefBase.cpp @@ -50,7 +50,7 @@ // log all reference counting operations #define PRINT_REFS 0 -#if !defined(_WIN32) && !defined(__APPLE__) +#if defined(__linux__) // CallStack is only supported on linux type platforms. #define CALLSTACK_ENABLED 1 #else From aa4ebf2ce1c030fcbb877205d9c6bcbac4e42d97 Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Tue, 15 Mar 2022 01:51:02 +0000 Subject: [PATCH 2/2] Fix Errors.h on systems that define NO_ERROR Some systems (originally only Windows) define their own NO_ERROR macro that overlaps with the enumerator from Errors.h. The enumerator is only defined if the macro was not. Bug: 224644083 Test: m Change-Id: Iee0932b5259b3bfcf6494656b27e6e7488319f5c --- libutils/include/utils/Errors.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libutils/include/utils/Errors.h b/libutils/include/utils/Errors.h index d14d2231d..22fb36d25 100644 --- a/libutils/include/utils/Errors.h +++ b/libutils/include/utils/Errors.h @@ -34,15 +34,13 @@ typedef int32_t status_t; * All error codes are negative values. */ -// Win32 #defines NO_ERROR as well. It has the same value, so there's no -// real conflict, though it's a bit awkward. -#ifdef _WIN32 -# undef NO_ERROR -#endif - enum { OK = 0, // Preferred constant for checking success. +#ifndef NO_ERROR + // Win32 #defines NO_ERROR as well. It has the same value, so there's no + // real conflict, though it's a bit awkward. NO_ERROR = OK, // Deprecated synonym for `OK`. Prefer `OK` because it doesn't conflict with Windows. +#endif UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value @@ -76,10 +74,4 @@ enum { // Human readable name of error std::string statusToString(status_t status); -// Restore define; enumeration is in "android" namespace, so the value defined -// there won't work for Win32 code in a different namespace. -#ifdef _WIN32 -# define NO_ERROR 0L -#endif - } // namespace android