3 ms·
Sounds like VMF. It’s such a pain to debug when you can’t even rely on marker strings being recognizable in dump output. One time I had to make little- and big
by gbacon 9y ago
Sounds like VMF. It’s such a pain to debug when you can’t even rely on marker strings being recognizable in dump output.
One time I had to make little- and big-endian machines talk nicely was for a message engine that ran on Intel/Linux. All the messages in the ICD were glorified packed structs that were native on the IBM/AIX side.
I used the ICD wire format as my storage format. I defined containers for all the primitive types with correct sizes and that swapped values on assignment and read (except for strings, of course). I added the appropriate pragmata to pack the underlying structs and locked down their sizes with static_asserts that would fail at compilation time until everything fit perfectly.
These classes gave me what looked like native structs on the Linux side, e.g.,
msg.foo = 3;
or
msg1.date = msg2.date + 1;
and the byte swapping happened transparently all around, both on the way in and on the way out. Yes, if latency had been a concern, this design may have been problematic. The Linux box faked messages on behalf of three other systems so we could command the AIX software into different modes with complex prerequisites. Changing a few fields per cycle, I could then dump the struct onto the wire.
A cool aspect to the story was it all worked correctly the first time out of the box even though I did not have access to the AIX box during implementation. When it came time to integrate with the AIX side, all that was left to do was some low-level socket stuff to hook up to the message flow.
I’d moved to a different project full-time and worked this message engine during evenings and weekends. We got the code unpacked, so I run make check like I had been so frequently.
“Wow, you had time to write unit tests and everything?” asked one of the guys from behind my shoulder.
A moment of Zen hit.
“I didn’t have time not to.”