summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2018-03-06 20:31:01 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-03-06 20:31:01 +0000
commit88840820d0ccf17ac1af2bc89f14c82b0b2e04bb (patch)
treed446df32c244bc91b1f571e92ccee6a85c31c654 /libs
parent1d03b9489e7d0c2f62f9e40e75ea781a1da82377 (diff)
parent5ee0787024cc446a21008ff5710dec19c6afc834 (diff)
Merge "Use uint64_t instead of long long as API type for consistent reason." into pi-dev
Diffstat (limited to 'libs')
-rw-r--r--libs/protoutil/include/android/util/ProtoOutputStream.h8
-rw-r--r--libs/protoutil/src/ProtoOutputStream.cpp26
2 files changed, 17 insertions, 17 deletions
diff --git a/libs/protoutil/include/android/util/ProtoOutputStream.h b/libs/protoutil/include/android/util/ProtoOutputStream.h
index 52830d397772..43ac1ec387a4 100644
--- a/libs/protoutil/include/android/util/ProtoOutputStream.h
+++ b/libs/protoutil/include/android/util/ProtoOutputStream.h
@@ -25,7 +25,7 @@ namespace android {
namespace util {
/**
- * Position of the field type in a (long long) fieldId.
+ * Position of the field type in a 64-bits fieldId.
*/
const uint64_t FIELD_TYPE_SHIFT = 32;
@@ -106,8 +106,8 @@ public:
* Returns a token of this write session.
* Must call end(token) when finish write this sub-message.
*/
- long long start(uint64_t fieldId);
- void end(long long token);
+ uint64_t start(uint64_t fieldId);
+ void end(uint64_t token);
/**
* Returns how many bytes are buffered in ProtoOutputStream.
@@ -139,7 +139,7 @@ private:
bool mCompact;
int mDepth;
int mObjectId;
- long long mExpectedObjectToken;
+ uint64_t mExpectedObjectToken;
inline void writeDoubleImpl(uint32_t id, double val);
inline void writeFloatImpl(uint32_t id, float val);
diff --git a/libs/protoutil/src/ProtoOutputStream.cpp b/libs/protoutil/src/ProtoOutputStream.cpp
index 9d9ffec4c588..a040bd223e94 100644
--- a/libs/protoutil/src/ProtoOutputStream.cpp
+++ b/libs/protoutil/src/ProtoOutputStream.cpp
@@ -28,7 +28,7 @@ ProtoOutputStream::ProtoOutputStream()
mCompact(false),
mDepth(0),
mObjectId(0),
- mExpectedObjectToken(0LL)
+ mExpectedObjectToken(0ULL)
{
}
@@ -45,7 +45,7 @@ ProtoOutputStream::clear()
mCompact = false;
mDepth = 0;
mObjectId = 0;
- mExpectedObjectToken = 0LL;
+ mExpectedObjectToken = 0ULL;
}
bool
@@ -222,37 +222,37 @@ ProtoOutputStream::write(uint64_t fieldId, const char* val, size_t size)
* because of the overflow, and only the tokens are compared.
* Bits 0-31 - offset of the first size field in the buffer.
*/
-long long
+uint64_t
makeToken(int tagSize, bool repeated, int depth, int objectId, int sizePos) {
- return ((0x07L & (long long)tagSize) << 61)
+ return ((0x07L & (uint64_t)tagSize) << 61)
| (repeated ? (1LL << 60) : 0)
- | (0x01ffL & (long long)depth) << 51
- | (0x07ffffL & (long long)objectId) << 32
- | (0x0ffffffffL & (long long)sizePos);
+ | (0x01ffL & (uint64_t)depth) << 51
+ | (0x07ffffL & (uint64_t)objectId) << 32
+ | (0x0ffffffffL & (uint64_t)sizePos);
}
/**
* Get the encoded tag size from the token.
*/
-static int getTagSizeFromToken(long long token) {
+static int getTagSizeFromToken(uint64_t token) {
return (int)(0x7 & (token >> 61));
}
/**
* Get the nesting depth of startObject calls from the token.
*/
-static int getDepthFromToken(long long token) {
+static int getDepthFromToken(uint64_t token) {
return (int)(0x01ff & (token >> 51));
}
/**
* Get the location of the childRawSize (the first 32 bit size field) in this object.
*/
-static int getSizePosFromToken(long long token) {
+static int getSizePosFromToken(uint64_t token) {
return (int)token;
}
-long long
+uint64_t
ProtoOutputStream::start(uint64_t fieldId)
{
if ((fieldId & FIELD_TYPE_MASK) != FIELD_TYPE_MESSAGE) {
@@ -275,10 +275,10 @@ ProtoOutputStream::start(uint64_t fieldId)
}
void
-ProtoOutputStream::end(long long token)
+ProtoOutputStream::end(uint64_t token)
{
if (token != mExpectedObjectToken) {
- ALOGE("Unexpected token: 0x%llx, should be 0x%llx", token, mExpectedObjectToken);
+ ALOGE("Unexpected token: 0x%llx, should be 0x%llx", (long long)token, (long long)mExpectedObjectToken);
return;
}