Skip to content

Commit

Permalink
please windows builder warnings + x86
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola-cab committed Mar 5, 2024
1 parent 382f56d commit 4837a65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/realm/array_direct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,15 @@ constexpr uint32_t inverse_width[65] = {
inline int first_field_marked(int width, uint64_t vector)
{
#if REALM_WINDOWS
#ifdef _WIN32
int lz = (int)_tzcnt_u32(vector);
#else
int lz = (int)_tzcnt_u64(vector); // TODO: not clear if this is ok on all platforms
#endif
#else
int lz = __builtin_ctzll(vector);
#endif

int field = (lz * inverse_width[width]) >> 22;
REALM_ASSERT_DEBUG(field == (lz / width));
return field;
Expand Down
10 changes: 5 additions & 5 deletions src/realm/node_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,11 @@ class NodeHeader {
}
else if (enc == Encoding::Packed) {
hb[2] = 0;
hb[3] = bits_pr_elem;
hb[3] = static_cast<uint8_t>(bits_pr_elem);
hb[4] = (flags << 5) | (wtype_Extend << 3);
hb[5] = (uint8_t)enc - wtype_Extend;
auto hw = (uint16_t*)header;
hw[3] = num_elems;
hw[3] = static_cast<uint16_t>(num_elems);
}
else {
REALM_ASSERT(false && "Illegal header encoding for chosen kind of header");
Expand Down Expand Up @@ -452,8 +452,8 @@ class NodeHeader {
REALM_ASSERT(bits_pr_elemB <= 64);
REALM_ASSERT(num_elemsA < 1024);
REALM_ASSERT(num_elemsB < 1024);
hh[1] = ((bits_pr_elemB - 1) << 10) | num_elemsB;
hh[3] = ((bits_pr_elemA - 1) << 10) | num_elemsA;
hh[1] = static_cast<uint16_t>(((bits_pr_elemB - 1) << 10) | num_elemsB);
hh[3] = static_cast<uint16_t>(((bits_pr_elemA - 1) << 10) | num_elemsA);
}

// Setting element size for encodings with a single element size:
Expand Down Expand Up @@ -530,7 +530,7 @@ void inline NodeHeader::set_element_size<NodeHeader::Encoding::Packed>(char* hea
{
REALM_ASSERT(get_encoding(header) == Encoding::Packed);
REALM_ASSERT(bits_per_element <= 64);
((uint8_t*)header)[3] = static_cast<uint16_t>(bits_per_element);
((uint8_t*)header)[3] = static_cast<uint8_t>(bits_per_element);
}
template <>
void inline NodeHeader::set_element_size<NodeHeader::Encoding::WTypBits>(char* header, size_t bits_per_element)
Expand Down

0 comments on commit 4837a65

Please sign in to comment.