From 769ff0a8a7350f5fe6eea51f9bb4d5535f938a37 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 23 Jan 2010 22:06:19 +0100 Subject: [PATCH] Added helper macros BITS and TABLE --- lspci.h | 4 ++++ 1 file changed, 4 insertions(+) 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 */ -- 2.39.5