Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make typedefs platform independent #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

langchr86
Copy link

No description provided.

@langchr86
Copy link
Author

The coverage check seems to be not relevant because I added 2 new lines (include and new line) which is not covered.

@langchr86
Copy link
Author

langchr86 commented Jan 22, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant