diff options
author | Mark Salyzyn <salyzyn@google.com> | 2015-03-06 20:42:57 +0000 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2015-03-06 20:46:31 +0000 |
commit | 8470dad24f17f6e13aab7f723821a2acb318baad (patch) | |
tree | f0dc31f7dbf9a9478b8a03ff2e992adf785f30f8 | |
parent | 8b1a94c07cb02a0398238ebaab4a2a0a23f7d28c (diff) | |
download | system_core-8470dad24f17f6e13aab7f723821a2acb318baad.zip system_core-8470dad24f17f6e13aab7f723821a2acb318baad.tar.gz system_core-8470dad24f17f6e13aab7f723821a2acb318baad.tar.bz2 |
Revert "liblog: logprint use <endian.h>"
This reverts commit 66bfc5ccbda1c36923230b8dea36e86e8ac62d67.
Bug: 19634248
Change-Id: I7c4851a247042193674f226fd0d5c5663e8074c7
-rw-r--r-- | liblog/logprint.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/liblog/logprint.c b/liblog/logprint.c index b5145fd..7ba4c8e 100644 --- a/liblog/logprint.c +++ b/liblog/logprint.c @@ -20,7 +20,6 @@ #include <arpa/inet.h> #include <assert.h> #include <ctype.h> -#include <endian.h> #include <errno.h> #include <stdbool.h> #include <stdint.h> @@ -417,6 +416,27 @@ int android_log_processLogBuffer(struct logger_entry *buf, } /* + * Extract a 4-byte value from a byte stream. + */ +static inline uint32_t get4LE(const uint8_t* src) +{ + return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); +} + +/* + * Extract an 8-byte value from a byte stream. + */ +static inline uint64_t get8LE(const uint8_t* src) +{ + uint32_t low, high; + + low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); + high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24); + return ((long long) high << 32) | (long long) low; +} + + +/* * Recursively convert binary log data to printable form. * * This needs to be recursive because you can have lists of lists. @@ -453,7 +473,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, if (eventDataLen < 4) return -1; - ival = le32toh(*((int32_t *)eventData)); + ival = get4LE(eventData); eventData += 4; eventDataLen -= 4; @@ -474,7 +494,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, if (eventDataLen < 8) return -1; - lval = le64toh(*((int64_t *)eventData)); + lval = get8LE(eventData); eventData += 8; eventDataLen -= 8; @@ -495,7 +515,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, if (eventDataLen < 4) return -1; - strLen = le32toh(*((int32_t *)eventData)); + strLen = get4LE(eventData); eventData += 4; eventDataLen -= 4; @@ -610,7 +630,7 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf, inCount = buf->len; if (inCount < 4) return -1; - tagIndex = le32toh(*((int32_t *)eventData)); + tagIndex = get4LE(eventData); eventData += 4; inCount -= 4; |