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

Commit 593b19b5 authored by Serdar Kocdemir's avatar Serdar Kocdemir
Browse files

Check if ALWAYS_INLINE is already defined

Fixes build errors when using callstack library in gfxstream
project, where the definition is already made.

Test: build
Change-Id: I80d4038160725b5dc70f9af93d338aca66a2f0d5
parent 66dc1bde
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -37,7 +37,9 @@
# endif // !WEAKS_AVAILABLE
#endif // CALLSTACK_WEAK predefined

#define ALWAYS_INLINE __attribute__((always_inline))
#ifndef CALLSTACK_ALWAYS_INLINE
#define CALLSTACK_ALWAYS_INLINE __attribute__((always_inline))
#endif  // CALLSTACK_ALWAYS_INLINE predefined

namespace android {

@@ -102,7 +104,7 @@ public:

    // Return current call stack if possible, nullptr otherwise.
#ifdef WEAKS_AVAILABLE
    static CallStackUPtr ALWAYS_INLINE getCurrent(int32_t ignoreDepth = 1) {
    static CallStackUPtr CALLSTACK_ALWAYS_INLINE getCurrent(int32_t ignoreDepth = 1) {
        if (reinterpret_cast<uintptr_t>(getCurrentInternal) == 0) {
            ALOGW("CallStack::getCurrentInternal not linked, returning null");
            return CallStackUPtr(nullptr);
@@ -111,13 +113,14 @@ public:
        }
    }
#else // !WEAKS_AVAILABLE
    static CallStackUPtr ALWAYS_INLINE getCurrent(int32_t = 1) {
    static CallStackUPtr CALLSTACK_ALWAYS_INLINE getCurrent(int32_t = 1) {
        return CallStackUPtr(nullptr);
    }
#endif // !WEAKS_AVAILABLE

#ifdef WEAKS_AVAILABLE
    static void ALWAYS_INLINE logStack(const char* logtag, CallStack* stack = getCurrent().get(),
    static void CALLSTACK_ALWAYS_INLINE logStack(const char* logtag,
                                                 CallStack* stack = getCurrent().get(),
                                                 android_LogPriority priority = ANDROID_LOG_DEBUG) {
        if (reinterpret_cast<uintptr_t>(logStackInternal) != 0 && stack != nullptr) {
            logStackInternal(logtag, stack, priority);
@@ -127,15 +130,16 @@ public:
    }

#else
    static void ALWAYS_INLINE logStack(const char* logtag, CallStack* = getCurrent().get(),
    static void CALLSTACK_ALWAYS_INLINE logStack(const char* logtag,
                                                 CallStack* = getCurrent().get(),
                                                 android_LogPriority = ANDROID_LOG_DEBUG) {
        ALOG(LOG_WARN, logtag, "CallStack::logStackInternal not linked");
    }
#endif // !WEAKS_AVAILABLE

#ifdef WEAKS_AVAILABLE
    static String8 ALWAYS_INLINE stackToString(const char* prefix = nullptr,
                                               const CallStack* stack = getCurrent().get()) {
    static String8 CALLSTACK_ALWAYS_INLINE
    stackToString(const char* prefix = nullptr, const CallStack* stack = getCurrent().get()) {
        if (reinterpret_cast<uintptr_t>(stackToStringInternal) != 0 && stack != nullptr) {
            return stackToStringInternal(prefix, stack);
        } else {
@@ -143,7 +147,7 @@ public:
        }
    }
#else // !WEAKS_AVAILABLE
    static String8 ALWAYS_INLINE stackToString(const char* prefix = nullptr,
    static String8 CALLSTACK_ALWAYS_INLINE stackToString(const char* prefix = nullptr,
                                                         const CallStack* = getCurrent().get()) {
        return String8::format("%s<CallStack package not linked>", (prefix ? prefix : ""));
    }
@@ -165,4 +169,6 @@ public:

}  // namespace android

#undef CALLSTACK_ALWAYS_INLINE

#endif // ANDROID_CALLSTACK_H