android_stub: fix missing prototypes issues

When the compiler is configured to complain about missing
prototypes, the lack of prototypes can cause issues:

src/android_stub/cutils_stub.cpp:13:1:
   error: no previous prototype for function 'atrace_begin_body' [-Werror,-Wmissing-prototypes]
   13 | atrace_begin_body(const char * /*name*/)

Update cutils/trace.h to the version in android-16.0.0_r3 [1], and
add proper header includes to fix this.

[1] https://android.googlesource.com/platform/system/core.git/+/refs/tags/android-16.0.0_r3/libcutils/include/cutils/trace.h

Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38644>
This commit is contained in:
Gurchetan Singh 2025-11-24 14:14:07 -08:00 committed by Marge Bot
parent 1997987b58
commit 57ae8eb70f
2 changed files with 95 additions and 7 deletions

View file

@ -75,7 +75,8 @@ __BEGIN_DECLS
#define ATRACE_TAG_AIDL (1<<24) #define ATRACE_TAG_AIDL (1<<24)
#define ATRACE_TAG_NNAPI (1<<25) #define ATRACE_TAG_NNAPI (1<<25)
#define ATRACE_TAG_RRO (1<<26) #define ATRACE_TAG_RRO (1<<26)
#define ATRACE_TAG_LAST ATRACE_TAG_RRO #define ATRACE_TAG_THERMAL (1 << 27)
#define ATRACE_TAG_LAST ATRACE_TAG_THERMAL
// Reserved for initialization. // Reserved for initialization.
#define ATRACE_TAG_NOT_READY (1ULL<<63) #define ATRACE_TAG_NOT_READY (1ULL<<63)
@ -88,6 +89,36 @@ __BEGIN_DECLS
#error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h
#endif #endif
/** Internal implementation detail. Do not use. */
void atrace_begin_body(const char*);
/** Internal implementation detail. Do not use. */
void atrace_end_body();
/** Internal implementation detail. Do not use. */
void atrace_async_begin_body(const char*, int32_t);
/** Internal implementation detail. Do not use. */
void atrace_async_end_body(const char*, int32_t);
/** Internal implementation detail. Do not use. */
void atrace_async_for_track_begin_body(const char*, const char*, int32_t);
/** Internal implementation detail. Do not use. */
void atrace_async_for_track_end_body(const char*, int32_t);
/** Internal implementation detail. Do not use. */
void atrace_instant_body(const char*);
/** Internal implementation detail. Do not use. */
void atrace_instant_for_track_body(const char*, const char*);
/** Internal implementation detail. Do not use. */
void atrace_int_body(const char*, int32_t);
/** Internal implementation detail. Do not use. */
void atrace_int64_body(const char*, int64_t);
/** /**
* Opens the trace file for writing and reads the property for initial tags. * Opens the trace file for writing and reads the property for initial tags.
* The atrace.tags.enableflags property sets the tags to trace. * The atrace.tags.enableflags property sets the tags to trace.
@ -158,7 +189,6 @@ static inline uint64_t atrace_is_tag_enabled(uint64_t tag)
static inline void atrace_begin(uint64_t tag, const char* name) static inline void atrace_begin(uint64_t tag, const char* name)
{ {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
void atrace_begin_body(const char*);
atrace_begin_body(name); atrace_begin_body(name);
} }
} }
@ -171,7 +201,6 @@ static inline void atrace_begin(uint64_t tag, const char* name)
static inline void atrace_end(uint64_t tag) static inline void atrace_end(uint64_t tag)
{ {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
void atrace_end_body();
atrace_end_body(); atrace_end_body();
} }
} }
@ -189,7 +218,6 @@ static inline void atrace_async_begin(uint64_t tag, const char* name,
int32_t cookie) int32_t cookie)
{ {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
void atrace_async_begin_body(const char*, int32_t);
atrace_async_begin_body(name, cookie); atrace_async_begin_body(name, cookie);
} }
} }
@ -202,11 +230,72 @@ static inline void atrace_async_begin(uint64_t tag, const char* name,
static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie)
{ {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
void atrace_async_end_body(const char*, int32_t);
atrace_async_end_body(name, cookie); atrace_async_end_body(name, cookie);
} }
} }
/**
* Trace the beginning of an asynchronous event. In addition to the name and a
* cookie as in ATRACE_ASYNC_BEGIN/ATRACE_ASYNC_END, a track name argument is
* provided, which is the name of the row where this async event should be
* recorded. The track name, name, and cookie used to begin an event must be
* used to end it.
* The cookie here must be unique on the track_name level, not the name level.
*/
#define ATRACE_ASYNC_FOR_TRACK_BEGIN(track_name, name, cookie) \
atrace_async_for_track_begin(ATRACE_TAG, track_name, name, cookie)
static inline void atrace_async_for_track_begin(uint64_t tag, const char* track_name,
const char* name, int32_t cookie) {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
atrace_async_for_track_begin_body(track_name, name, cookie);
}
}
/**
* Trace the end of an asynchronous event.
* This should correspond to a previous ATRACE_ASYNC_FOR_TRACK_BEGIN.
*/
#define ATRACE_ASYNC_FOR_TRACK_END(track_name, cookie) \
atrace_async_for_track_end(ATRACE_TAG, track_name, cookie)
static inline void atrace_async_for_track_end(uint64_t tag, const char* track_name,
int32_t cookie) {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
atrace_async_for_track_end_body(track_name, cookie);
}
}
/**
* Trace an instantaneous context. name is used to identify the context.
*
* An "instant" is an event with no defined duration. Visually is displayed like a single marker
* in the timeline (rather than a span, in the case of begin/end events).
*
* By default, instant events are added into a dedicated track that has the same name of the event.
* Use atrace_instant_for_track to put different instant events into the same timeline track/row.
*/
#define ATRACE_INSTANT(name) atrace_instant(ATRACE_TAG, name)
static inline void atrace_instant(uint64_t tag, const char* name) {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
atrace_instant_body(name);
}
}
/**
* Trace an instantaneous context. name is used to identify the context.
* track_name is the name of the row where the event should be recorded.
*
* An "instant" is an event with no defined duration. Visually is displayed like a single marker
* in the timeline (rather than a span, in the case of begin/end events).
*/
#define ATRACE_INSTANT_FOR_TRACK(trackName, name) \
atrace_instant_for_track(ATRACE_TAG, trackName, name)
static inline void atrace_instant_for_track(uint64_t tag, const char* track_name,
const char* name) {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
atrace_instant_for_track_body(track_name, name);
}
}
/** /**
* Traces an integer counter value. name is used to identify the counter. * Traces an integer counter value. name is used to identify the counter.
* This can be used to track how a value changes over time. * This can be used to track how a value changes over time.
@ -215,7 +304,6 @@ static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cook
static inline void atrace_int(uint64_t tag, const char* name, int32_t value) static inline void atrace_int(uint64_t tag, const char* name, int32_t value)
{ {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
void atrace_int_body(const char*, int32_t);
atrace_int_body(name, value); atrace_int_body(name, value);
} }
} }
@ -228,7 +316,6 @@ static inline void atrace_int(uint64_t tag, const char* name, int32_t value)
static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value)
{ {
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
void atrace_int64_body(const char*, int64_t);
atrace_int64_body(name, value); atrace_int64_body(name, value);
} }
} }

View file

@ -1,4 +1,5 @@
#include <vndk/window.h> #include <vndk/window.h>
#include <vndk/hardware_buffer.h>
extern "C" { extern "C" {