• David Gibson's avatar
    tcon: Add an alternate way of building type canaries · 43992de4
    David Gibson authored
    The tcon module allows you to add "type canaries" to a structures, which
    can be used for later typechecks.  The canaries are implemented using
    a flexible array member, to avoid them taking any actual space at runtime.
    That means the canaries must go at the end of your structure.
    
    That doesn't seem like a big limitation, except that it also means the
    structure containing the canaries must be at the end of any structure it
    is embedded in in turn, which is a rather more serious limitation.
    
    This patch adds a TCON_WRAP() macro which wraps a given type in a new type
    which also contains type canaries, and doesn't suffer the last member
    limitation.  The drawback is that if the wrapped type has smaller size than
    a pointer, the type canaries will pad the wrapped type out to the size of a
    pointer.
    
    By constructing the wrappers carefully, the existing tcon macros will work
    on both wrapper types constructed with TCON_WRAP and on structures
    explicitly including TCON type canaries.
    Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
    43992de4
compile_ok-void.c 608 Bytes