From: Martin Mares Date: Sat, 23 Jan 2010 21:06:19 +0000 (+0100) Subject: Added helper macros BITS and TABLE X-Git-Tag: v3.1.6~8 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=769ff0a8a7350f5fe6eea51f9bb4d5535f938a37;p=pciutils.git Added helper macros BITS and TABLE --- diff --git a/lspci.h b/lspci.h index c498b7c..e31805a 100644 --- a/lspci.h +++ b/lspci.h @@ -52,7 +52,11 @@ byte get_conf_byte(struct device *d, unsigned int pos); void get_subid(struct device *d, word *subvp, word *subdp); +/* Useful macros for decoding of bits and bit fields */ + #define FLAG(x,y) ((x & y) ? '+' : '-') +#define BITS(x,at,width) (((x) >> (at)) & ((1 << (width)) - 1)) +#define TABLE(tab,x,buf) ((x) < sizeof(tab)/sizeof((tab)[0]) ? (tab)[x] : (sprintf((buf), "??%d", (x)), (buf))) /* ls-vpd.c */