Skip to content

Commit 27bd326

Browse files
Andrew HsiehGerrit Code Review
authored andcommitted
Merge "[MIPS] Allow errno safe logging"
2 parents 62eb6d3 + 7ddc46b commit 27bd326

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ndk/sources/android/libportable/common/include/log_portable.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ static inline char *portable_tag() {
7070
#define LOG_TAG PORTABLE_TAG
7171
#endif
7272

73+
/*
74+
* Override LOG_PRI() defined in ${AOSP}/system/core/include/cutils/log.h
75+
* to preserve the value of errno while logging.
76+
*/
77+
#define LOG_PRI(priority, tag, ...) ({ \
78+
int _errno = errno; \
79+
int _rv = android_printLog(priority, tag, __VA_ARGS__); \
80+
errno = _errno; \
81+
_rv; /* Returned to caller */ \
82+
})
83+
7384
# include <cutils/log.h>
7485

7586
# define PERROR(str) { \

0 commit comments

Comments
 (0)