提交 dbbd1ddc 编写于 作者: A arhag

fix compilation issues regarding uint256 usage

上级 f6e4e3a0
......@@ -64,21 +64,13 @@ struct account_permission {
permission_name permission;
};
union {
uint8_t bytes[8];
uint16_t uint16[8];
uint32_t uint32[8];
uint64_t uint64[4];
uint128_t uint128[2];
} typedef uint256;
bool operator==( const uint256& a, const uint256& b ) {
return a.uint128[0] == b.uint128[0] && a.uint128[1] == b.uint128[1];
}
bool operator!=( const uint256& a, const uint256& b ) {
return !(a == b);
}
typedef union {
uint8_t bytes[32];
uint16_t uint16s[16];
uint32_t uint32s[8];
uint64_t uint64s[4];
uint128_t uint128s[2];
} uint256;
#ifdef __cplusplus
} /// extern "C"
......
......@@ -89,5 +89,13 @@ namespace eosio {
};
/// @}
bool operator==( const uint256& a, const uint256& b ) {
return a.uint128s[0] == b.uint128s[0] && a.uint128s[1] == b.uint128s[1];
}
bool operator!=( const uint256& a, const uint256& b ) {
return !(a == b);
}
} // namespace eos
......@@ -135,10 +135,10 @@ namespace identity {
uint64_t primary_key() const { return id; }
constexpr static uint256 key(uint64_t property, uint64_t trusted, uint64_t certifier) {
uint256 key;
key.uint64[0] = property;
key.uint64[1] = trusted;
key.uint64[2] = certifier;
key.uint64[3] = 0;
key.uint64s[0] = property;
key.uint64s[1] = trusted;
key.uint64s[2] = certifier;
key.uint64s[3] = 0;
return key;
}
uint256 get_key() const { return key(property, trusted, certifier); };
......
......@@ -104,17 +104,17 @@ namespace multi_index_test {
const auto& entry1 = testtable.emplace( payer, [&]( auto& o ) {
o.id = 1;
o.val = uint256{.words = {0, 0, 0, 42}};
o.val = uint256{.uint64s = {0, 0, 0, 42}};
});
const auto& entry2 = testtable.emplace( payer, [&]( auto& o ) {
o.id = 2;
o.val = uint256{.words = {1, 2, 3, 4}};
o.val = uint256{.uint64s = {1, 2, 3, 4}};
});
const auto& entry3 = testtable.emplace( payer, [&]( auto& o ) {
o.id = 3;
o.val = uint256{.words = {0, 0, 0, 42}};
o.val = uint256{.uint64s = {0, 0, 0, 42}};
});
const auto* e = testtable.find( 2 );
......@@ -126,10 +126,10 @@ namespace multi_index_test {
auto validx = testtable.get_index<N(byval)>();
auto lower1 = validx.lower_bound(uint256{.words = {0, 0, 0, 40}});
auto lower1 = validx.lower_bound(uint256{.uint64s = {0, 0, 0, 40}});
print("First entry with a val of at least 40 has ID=", lower1->id, ".\n");
auto lower2 = validx.lower_bound(uint256{.words = {0, 0, 0, 50}});
auto lower2 = validx.lower_bound(uint256{.uint64s = {0, 0, 0, 50}});
print("First entry with a val of at least 50 has ID=", lower2->id, ".\n");
if( &*lower2 == e ) {
......@@ -142,7 +142,7 @@ namespace multi_index_test {
cout << item.val << "\n";
}
auto upper = validx.upper_bound(uint256{.words={0, 0, 0, 42}});
auto upper = validx.upper_bound(uint256{.uint64s={0, 0, 0, 42}});
print("First entry with a val greater than 42 has ID=", upper->id, ".\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册