From 7ddc46bf9f51d20a2442a5c87f23f9d15f6da7cd Mon Sep 17 00:00:00 2001 From: Pete Delaney Date: Mon, 25 Feb 2013 22:52:02 -0800 Subject: [PATCH] [MIPS] Allow errno safe logging Change-Id: I35b4a9007572bec15ab7ba81aad3756fa96c5eb2 Signed-off-by: Chris Dearman Signed-off-by: Pete Delaney --- .../android/libportable/common/include/log_portable.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ndk/sources/android/libportable/common/include/log_portable.h b/ndk/sources/android/libportable/common/include/log_portable.h index 77f9e63f7..f48780a9d 100644 --- a/ndk/sources/android/libportable/common/include/log_portable.h +++ b/ndk/sources/android/libportable/common/include/log_portable.h @@ -70,6 +70,17 @@ static inline char *portable_tag() { #define LOG_TAG PORTABLE_TAG #endif +/* + * Override LOG_PRI() defined in ${AOSP}/system/core/include/cutils/log.h + * to preserve the value of errno while logging. + */ +#define LOG_PRI(priority, tag, ...) ({ \ + int _errno = errno; \ + int _rv = android_printLog(priority, tag, __VA_ARGS__); \ + errno = _errno; \ + _rv; /* Returned to caller */ \ +}) + # include # define PERROR(str) { \