raft
raft copied to clipboard
make typedefs platform independent
The coverage check seems to be not relevant because I added 2 new lines (include and new line) which is not covered.
The purpose of this PR was that I have to serialize and transport the raft packages over network. But because I have to support two platforms (x64 and ARM32) this was a problem. The serialization (flatbuffers) needs an explicit type and cannot change between platforms between 32 and 64 bits.
Now with the current changes on the library I got compiler warnings like:
| src/raft_node.c: In function 'raft_node_get_next_idx':
| src/raft_node.c:60:31: error: cast increases required alignment of target type [-Werror=cast-align]
| raft_node_private_t* me = (raft_node_private_t*)me_;
This is because the new raft_node_private_t
is 64bit aligned but the void*
only 32bit on ARM32.
At the end I went back to all 32bit types to have no alignement problems and fixed types for serialization.
Please consider all those experiences when defining the final fix for this whole problem or provide an explanation why long int
was chosen. Because it differs in memory size on different platforms, see: en.cppreference.com/w/cpp/language/types