Rather than open coding the masks, add helper macros to do the magic. This makes code easier to read. Signed-off-by: Mike Frysinger <vapier@gentoo.org>