Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Unified Diff: net/base/int128.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/int128.h
diff --git a/net/base/int128.h b/net/base/int128.h
index b17801be575825ae4e6039a53a4d78419feacb56..fd71f092c5e585cc75aa35fce66468d7c5c854fe 100644
--- a/net/base/int128.h
+++ b/net/base/int128.h
@@ -13,14 +13,14 @@ struct uint128_pod;
// An unsigned 128-bit integer type. Thread-compatible.
class uint128 {
-public:
+ public:
uint128(); // Sets to 0, but don't trust on this behavior.
uint128(uint64 top, uint64 bottom);
uint128(int bottom);
- uint128(uint32 bottom); // Top 96 bits = 0
- uint128(uint64 bottom); // hi_ = 0
- uint128(const uint128 &val);
- uint128(const uint128_pod &val);
+ uint128(uint32 bottom); // Top 96 bits = 0
+ uint128(uint64 bottom); // hi_ = 0
+ uint128(const uint128& val);
+ uint128(const uint128_pod& val);
void Initialize(uint64 top, uint64 bottom);
@@ -48,12 +48,12 @@ public:
friend NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& o,
const uint128& b);
-private:
+ private:
// Little-endian memory order optimizations can benefit from
// having lo_ first, hi_ last.
// See util/endian/endian.h and Load128/Store128 for storing a uint128.
- uint64 lo_;
- uint64 hi_;
+ uint64 lo_;
+ uint64 hi_;
// Not implemented, just declared for catching automatic type conversions.
uint128(uint8);
@@ -83,8 +83,12 @@ NET_EXPORT_PRIVATE extern std::ostream& operator<<(std::ostream& o,
// Methods to access low and high pieces of 128-bit value.
// Defined externally from uint128 to facilitate conversion
// to native 128-bit types when compilers support them.
-inline uint64 Uint128Low64(const uint128& v) { return v.lo_; }
-inline uint64 Uint128High64(const uint128& v) { return v.hi_; }
+inline uint64 Uint128Low64(const uint128& v) {
+ return v.lo_;
+}
+inline uint64 Uint128High64(const uint128& v) {
+ return v.hi_;
+}
// TODO: perhaps it would be nice to have int128, a signed 128-bit type?
@@ -104,12 +108,18 @@ inline uint128& uint128::operator=(const uint128& b) {
return *this;
}
-inline uint128::uint128(): lo_(0), hi_(0) { }
-inline uint128::uint128(uint64 top, uint64 bottom) : lo_(bottom), hi_(top) { }
-inline uint128::uint128(const uint128 &v) : lo_(v.lo_), hi_(v.hi_) { }
-inline uint128::uint128(const uint128_pod &v) : lo_(v.lo), hi_(v.hi) { }
-inline uint128::uint128(uint64 bottom) : lo_(bottom), hi_(0) { }
-inline uint128::uint128(uint32 bottom) : lo_(bottom), hi_(0) { }
+inline uint128::uint128() : lo_(0), hi_(0) {
+}
+inline uint128::uint128(uint64 top, uint64 bottom) : lo_(bottom), hi_(top) {
+}
+inline uint128::uint128(const uint128& v) : lo_(v.lo_), hi_(v.hi_) {
+}
+inline uint128::uint128(const uint128_pod& v) : lo_(v.lo), hi_(v.hi) {
+}
+inline uint128::uint128(uint64 bottom) : lo_(bottom), hi_(0) {
+}
+inline uint128::uint128(uint32 bottom) : lo_(bottom), hi_(0) {
+}
inline uint128::uint128(int bottom) : lo_(bottom), hi_(0) {
if (bottom < 0) {
--hi_;
@@ -122,17 +132,17 @@ inline void uint128::Initialize(uint64 top, uint64 bottom) {
// Comparison operators.
-#define CMP128(op) \
-inline bool operator op(const uint128& lhs, const uint128& rhs) { \
- return (Uint128High64(lhs) == Uint128High64(rhs)) ? \
- (Uint128Low64(lhs) op Uint128Low64(rhs)) : \
- (Uint128High64(lhs) op Uint128High64(rhs)); \
-}
+#define CMP128(op) \
+ inline bool operator op(const uint128& lhs, const uint128& rhs) { \
+ return (Uint128High64(lhs) == Uint128High64(rhs)) \
+ ? (Uint128Low64(lhs) op Uint128Low64(rhs)) \
+ : (Uint128High64(lhs) op Uint128High64(rhs)); \
+ }
-CMP128(<)
-CMP128(>)
-CMP128(>=)
-CMP128(<=)
+CMP128(< )
+CMP128(> )
+CMP128(>= )
+CMP128(<= )
#undef CMP128
@@ -158,28 +168,28 @@ inline uint128 operator~(const uint128& val) {
return uint128(~Uint128High64(val), ~Uint128Low64(val));
}
-#define LOGIC128(op) \
-inline uint128 operator op(const uint128& lhs, const uint128& rhs) { \
- return uint128(Uint128High64(lhs) op Uint128High64(rhs), \
- Uint128Low64(lhs) op Uint128Low64(rhs)); \
-}
+#define LOGIC128(op) \
+ inline uint128 operator op(const uint128& lhs, const uint128& rhs) { \
+ return uint128(Uint128High64(lhs) op Uint128High64(rhs), \
+ Uint128Low64(lhs) op Uint128Low64(rhs)); \
+ }
-LOGIC128(|)
+LOGIC128(| )
LOGIC128(&)
-LOGIC128(^)
+LOGIC128 (^)
#undef LOGIC128
-#define LOGICASSIGN128(op) \
-inline uint128& uint128::operator op(const uint128& other) { \
- hi_ op other.hi_; \
- lo_ op other.lo_; \
- return *this; \
-}
+#define LOGICASSIGN128(op) \
+ inline uint128& uint128::operator op(const uint128& other) { \
+ hi_ op other.hi_; \
+ lo_ op other.lo_; \
+ return *this; \
+ }
-LOGICASSIGN128(|=)
-LOGICASSIGN128(&=)
-LOGICASSIGN128(^=)
+LOGICASSIGN128(|= )
+LOGICASSIGN128(&= )
+LOGICASSIGN128(^= )
#undef LOGICASSIGN128
@@ -191,8 +201,8 @@ inline uint128 operator<<(const uint128& val, int amount) {
if (amount == 0) {
return val;
}
- uint64 new_hi = (Uint128High64(val) << amount) |
- (Uint128Low64(val) >> (64 - amount));
+ uint64 new_hi =
+ (Uint128High64(val) << amount) | (Uint128Low64(val) >> (64 - amount));
uint64 new_lo = Uint128Low64(val) << amount;
return uint128(new_hi, new_lo);
} else if (amount < 128) {
@@ -209,8 +219,8 @@ inline uint128 operator>>(const uint128& val, int amount) {
return val;
}
uint64 new_hi = Uint128High64(val) >> amount;
- uint64 new_lo = (Uint128Low64(val) >> amount) |
- (Uint128High64(val) << (64 - amount));
+ uint64 new_lo =
+ (Uint128Low64(val) >> amount) | (Uint128High64(val) << (64 - amount));
return uint128(new_hi, new_lo);
} else if (amount < 128) {
return uint128(0, Uint128High64(val) >> (amount - 64));

Powered by Google App Engine
This is Rietveld 408576698