• David Sterba's avatar
    btrfs: add helper for bit enumeration · d549ff7b
    David Sterba authored
    Define helper macro that can be used in enum {} to utilize the automatic
    increment to define all bits without directly defining the values or
    using additional linear bits.
    
    1. capture the sequence value, N
    2. use the value to define the given enum with N-th bit set
    3. reset the sequence back to N
    
    Use for enums that do not require fixed values for symbolic names (like
    for on-disk structures):
    
    enum {
    	ENUM_BIT(FIRST),
    	ENUM_BIT(SECOND),
    	ENUM_BIT(THIRD)
    };
    
    Where the values would be 0x1, 0x2 and 0x4.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    d549ff7b
misc.h 3.48 KB