Merge "liblog: remove more endianness functions"
am: 173e4ba26a
Change-Id: I964992eecfb5192df874976b6051568c8ea5428a
diff --git a/liblog/log_event_list.cpp b/liblog/log_event_list.cpp
index f148ef3..18ea930 100644
--- a/liblog/log_event_list.cpp
+++ b/liblog/log_event_list.cpp
@@ -176,13 +176,6 @@
return 0;
}
-static inline void copy4LE(uint8_t* buf, uint32_t val) {
- buf[0] = val & 0xFF;
- buf[1] = (val >> 8) & 0xFF;
- buf[2] = (val >> 16) & 0xFF;
- buf[3] = (val >> 24) & 0xFF;
-}
-
int android_log_write_int32(android_log_context ctx, int32_t value) {
size_t needed;
android_log_context_internal* context;
@@ -201,22 +194,11 @@
}
context->count[context->list_nest_depth]++;
context->storage[context->pos + 0] = EVENT_TYPE_INT;
- copy4LE(&context->storage[context->pos + 1], value);
+ *reinterpret_cast<int32_t*>(&context->storage[context->pos + 1]) = value;
context->pos += needed;
return 0;
}
-static inline void copy8LE(uint8_t* buf, uint64_t val) {
- buf[0] = val & 0xFF;
- buf[1] = (val >> 8) & 0xFF;
- buf[2] = (val >> 16) & 0xFF;
- buf[3] = (val >> 24) & 0xFF;
- buf[4] = (val >> 32) & 0xFF;
- buf[5] = (val >> 40) & 0xFF;
- buf[6] = (val >> 48) & 0xFF;
- buf[7] = (val >> 56) & 0xFF;
-}
-
int android_log_write_int64(android_log_context ctx, int64_t value) {
size_t needed;
android_log_context_internal* context;
@@ -235,7 +217,7 @@
}
context->count[context->list_nest_depth]++;
context->storage[context->pos + 0] = EVENT_TYPE_LONG;
- copy8LE(&context->storage[context->pos + 1], value);
+ *reinterpret_cast<int64_t*>(&context->storage[context->pos + 1]) = value;
context->pos += needed;
return 0;
}
@@ -267,7 +249,7 @@
}
context->count[context->list_nest_depth]++;
context->storage[context->pos + 0] = EVENT_TYPE_STRING;
- copy4LE(&context->storage[context->pos + 1], len);
+ *reinterpret_cast<ssize_t*>(&context->storage[context->pos + 1]) = len;
if (len) {
memcpy(&context->storage[context->pos + 5], value, len);
}
@@ -299,7 +281,7 @@
ivalue = *(uint32_t*)&value;
context->count[context->list_nest_depth]++;
context->storage[context->pos + 0] = EVENT_TYPE_FLOAT;
- copy4LE(&context->storage[context->pos + 1], ivalue);
+ *reinterpret_cast<uint32_t*>(&context->storage[context->pos + 1]) = ivalue;
context->pos += needed;
return 0;
}
diff --git a/liblog/pmsg_writer.cpp b/liblog/pmsg_writer.cpp
index f74fd4c..54980d9 100644
--- a/liblog/pmsg_writer.cpp
+++ b/liblog/pmsg_writer.cpp
@@ -99,7 +99,7 @@
return -EINVAL;
}
- if (SNET_EVENT_LOG_TAG != *static_cast<uint8_t*>(vec[0].iov_base)) {
+ if (SNET_EVENT_LOG_TAG != *static_cast<uint32_t*>(vec[0].iov_base)) {
return -EPERM;
}
}