encoding: new {ENCODE,DECODE}_{START,FINISH} macros
New macros to bracket encode/decode methods. The encoding scheme:
1 byte - version
1 byte - incompat version
4 bytes - length
... data ...
On decode, we verify that our known version is not < incompat version.
Otherwise, we throw an assertion, because the new code has decide that we
are too old to understand. We also throw an assert if we overrun/decode
past the end (as determined by the length). If we don't reach the end, we
skip whatever extra data is there.
An additional DECODE_START_LEGACY() macro is defined that takes an
additional lencompat argument. If the decoded version is < than this
value, we do not decode the length. This lets us transition away from
old encodings that do not include a length.
The value struct_v is defined for the "body" of the decode (between
_START and _FINISH).
The _START and _FINISH macros open a do { } while (false) block, so break
can be used to jump to _FINISH.
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>