X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftcon%2Ftcon.h;fp=ccan%2Ftcon%2Ftcon.h;h=c33070d6a6067f04f0666def6cb019e7560af2f9;hp=62bacf537b4261e2095fa59b35e0be51df7ff981;hb=fd48aee6393bda1e4eda9f9e52e6d9f818b77211;hpb=cc3db07ecc15f3e1e556387d82318697956e8e0c diff --git a/ccan/tcon/tcon.h b/ccan/tcon/tcon.h index 62bacf53..c33070d6 100644 --- a/ccan/tcon/tcon.h +++ b/ccan/tcon/tcon.h @@ -166,6 +166,28 @@ */ #define tcon_sizeof(x, canary) sizeof((x)->_tcon[0].canary) +/** + * TCON_VALUE - encode an integer value in a type canary + * @canary: name of the value canary + * @val: positive integer compile time constant value + * + * This macro can be included inside the declarations in a TCON() or + * TCON_WRAP(), constructing a special "type" canary which encodes the + * integer value @val (which must be a compile time constant, and a + * positive integer in the range of size_t). + */ +#define TCON_VALUE(canary, val) char _value_##canary[val] + +/** + * tcon_value - retrieve the value of a TCON_VALUE canary + * @x: the structure containing the TCON + * @canary: name of the value canary + * + * This macros expands to the value previously encoded into a TCON + * using TCON_VALUE(). + */ +#define tcon_value(x, canary) tcon_sizeof(x, _value_##canary) + /** * tcon_ptr_type - pointer to the type within a container (or void *) * @x: the structure containing the TCON.