]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
encoding: new {ENCODE,DECODE}_{START,FINISH} macros
authorSage Weil <sage.weil@dreamhost.com>
Tue, 10 Jan 2012 22:00:31 +0000 (14:00 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Mon, 23 Jan 2012 04:36:16 +0000 (20:36 -0800)
commitd32139351433124aed5a3b98786f55828f4e1531
tree58da26dcc42a8bd57be7a8a5c284f97b6fd8fc9d
parenta7106421a75077abd263cb41af5629ef31f42719
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>
src/include/encoding.h