Merge "Reduce <CallStack.h> namespace pollution." into main am: d6ccb0b1d9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2974871
Change-Id: Iffec5a500704a4738bb4240eef3da612250d2782
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/libutils/include/utils/CallStack.h b/libutils/include/utils/CallStack.h
index 54d559b..0239b68 100644
--- a/libutils/include/utils/CallStack.h
+++ b/libutils/include/utils/CallStack.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef ANDROID_CALLSTACK_H
-#define ANDROID_CALLSTACK_H
+#pragma once
#include <memory>
@@ -27,14 +26,14 @@
#include <sys/types.h>
#if !defined(__APPLE__) && !defined(_WIN32)
-# define WEAKS_AVAILABLE 1
+# define CALLSTACK_WEAKS_AVAILABLE 1
#endif
#ifndef CALLSTACK_WEAK
-# ifdef WEAKS_AVAILABLE
+# ifdef CALLSTACK_WEAKS_AVAILABLE
# define CALLSTACK_WEAK __attribute__((weak))
-# else // !WEAKS_AVAILABLE
+# else // !CALLSTACK_WEAKS_AVAILABLE
# define CALLSTACK_WEAK
-# endif // !WEAKS_AVAILABLE
+# endif // !CALLSTACK_WEAKS_AVAILABLE
#endif // CALLSTACK_WEAK predefined
#ifndef CALLSTACK_ALWAYS_INLINE
@@ -91,7 +90,7 @@
//
// DO NOT USE THESE. They will disappear.
struct StackDeleter {
-#ifdef WEAKS_AVAILABLE
+#ifdef CALLSTACK_WEAKS_AVAILABLE
void operator()(CallStack* stack) {
deleteStack(stack);
}
@@ -103,7 +102,7 @@
typedef std::unique_ptr<CallStack, StackDeleter> CallStackUPtr;
// Return current call stack if possible, nullptr otherwise.
-#ifdef WEAKS_AVAILABLE
+#ifdef CALLSTACK_WEAKS_AVAILABLE
static CallStackUPtr CALLSTACK_ALWAYS_INLINE getCurrent(int32_t ignoreDepth = 1) {
if (reinterpret_cast<uintptr_t>(getCurrentInternal) == 0) {
ALOGW("CallStack::getCurrentInternal not linked, returning null");
@@ -112,13 +111,13 @@
return getCurrentInternal(ignoreDepth);
}
}
-#else // !WEAKS_AVAILABLE
+#else // !CALLSTACK_WEAKS_AVAILABLE
static CallStackUPtr CALLSTACK_ALWAYS_INLINE getCurrent(int32_t = 1) {
return CallStackUPtr(nullptr);
}
-#endif // !WEAKS_AVAILABLE
+#endif // !CALLSTACK_WEAKS_AVAILABLE
-#ifdef WEAKS_AVAILABLE
+#ifdef CALLSTACK_WEAKS_AVAILABLE
static void CALLSTACK_ALWAYS_INLINE logStack(const char* logtag,
CallStack* stack = getCurrent().get(),
android_LogPriority priority = ANDROID_LOG_DEBUG) {
@@ -135,9 +134,9 @@
android_LogPriority = ANDROID_LOG_DEBUG) {
ALOG(LOG_WARN, logtag, "CallStack::logStackInternal not linked");
}
-#endif // !WEAKS_AVAILABLE
+#endif // !CALLSTACK_WEAKS_AVAILABLE
-#ifdef WEAKS_AVAILABLE
+#ifdef CALLSTACK_WEAKS_AVAILABLE
static String8 CALLSTACK_ALWAYS_INLINE
stackToString(const char* prefix = nullptr, const CallStack* stack = getCurrent().get()) {
if (reinterpret_cast<uintptr_t>(stackToStringInternal) != 0 && stack != nullptr) {
@@ -146,15 +145,15 @@
return String8::format("%s<CallStack package not linked>", (prefix ? prefix : ""));
}
}
-#else // !WEAKS_AVAILABLE
+#else // !CALLSTACK_WEAKS_AVAILABLE
static String8 CALLSTACK_ALWAYS_INLINE stackToString(const char* prefix = nullptr,
const CallStack* = getCurrent().get()) {
return String8::format("%s<CallStack package not linked>", (prefix ? prefix : ""));
}
-#endif // !WEAKS_AVAILABLE
+#endif // !CALLSTACK_WEAKS_AVAILABLE
private:
-#ifdef WEAKS_AVAILABLE
+#ifdef CALLSTACK_WEAKS_AVAILABLE
static CallStackUPtr CALLSTACK_WEAK getCurrentInternal(int32_t ignoreDepth);
static void CALLSTACK_WEAK logStackInternal(const char* logtag, const CallStack* stack,
android_LogPriority priority);
@@ -162,13 +161,13 @@
// The deleter is only invoked on non-null pointers. Hence it will never be
// invoked if CallStack is not linked.
static void CALLSTACK_WEAK deleteStack(CallStack* stack);
-#endif // WEAKS_AVAILABLE
+#endif // CALLSTACK_WEAKS_AVAILABLE
Vector<String8> mFrameLines;
};
} // namespace android
+#undef CALLSTACK_WEAKS_AVAILABLE
+#undef CALLSTACK_WEAK
#undef CALLSTACK_ALWAYS_INLINE
-
-#endif // ANDROID_CALLSTACK_H