opensourcerouting / c-capnproto

C library/compiler for the Cap'n Proto serialization/RPC protocol
MIT License
118 stars 40 forks source link

Solaris/Sparc 8-byte alignment #17

Open jknotts opened 7 years ago

jknotts commented 7 years ago

I am currently working on a project where I will be using this on Solaris/Sparc 32-bit and I wanted to understand why there is a requirement for 8-byte alignment on the data, len, and cap fields in the struct capn_segment. As of right now, the call to ALIGNED in struct ALIGNED_(8) capn_segment fails. Thank you in advance!

eqvinox commented 7 years ago

Cap'n Proto pointers (in the encoded binary result) have a granularity of 8 bytes (cf. https://capnproto.org/encoding.html), and the C implementation's in-memory layout is tied to the binary encoding. Hence, structures must be aligned to 8 bytes...