From: Martin Mares Date: Sun, 18 Feb 2024 11:07:50 +0000 (+0100) Subject: bitops.h moved to root X-Git-Tag: v3.11.0~34 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=1ffd04a805a5b72fdc95748401225c285493d65a;p=pciutils.git bitops.h moved to root It is a part of the utilities, not of libpci. --- diff --git a/bitops.h b/bitops.h new file mode 100644 index 0000000..029741e --- /dev/null +++ b/bitops.h @@ -0,0 +1,39 @@ +/* + * The PCI Utilities -- Decode bits and bit fields + * + * Copyright (c) 2023 Martin Mares + * Copyright (c) 2023 KNS Group LLC (YADRO) + * + * Can be freely distributed and used under the terms of the GNU GPL v2+. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _BITOPS_H +#define _BITOPS_H + +#ifndef _PCI_LIB_H +#error Import only from pci.h +#endif + +/* Useful macros for decoding of bits and bit fields */ + +#define FLAG(x, y) ((x & y) ? '+' : '-') + +// Generate mask + +#define BIT(at) ((u64)1 << (at)) +// Boundaries inclusive +#define MASK(h, l) ((((u64)1 << ((h) + 1)) - 1) & ~(((u64)1 << (l)) - 1)) + +// Get/set from register + +#define BITS(x, at, width) (((x) >> (at)) & ((1 << (width)) - 1)) +#define GET_REG_MASK(reg, mask) (((reg) & (mask)) / ((mask) & ~((mask) << 1))) +#define SET_REG_MASK(reg, mask, val) \ + (((reg) & ~(mask)) | (((val) * ((mask) & ~((mask) << 1))) & (mask))) + +#define TABLE(tab, x, buf) \ + ((x) < sizeof(tab) / sizeof((tab)[0]) ? (tab)[x] : (sprintf((buf), "??%d", (x)), (buf))) + +#endif diff --git a/lib/bitops.h b/lib/bitops.h deleted file mode 100644 index 029741e..0000000 --- a/lib/bitops.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The PCI Utilities -- Decode bits and bit fields - * - * Copyright (c) 2023 Martin Mares - * Copyright (c) 2023 KNS Group LLC (YADRO) - * - * Can be freely distributed and used under the terms of the GNU GPL v2+. - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef _BITOPS_H -#define _BITOPS_H - -#ifndef _PCI_LIB_H -#error Import only from pci.h -#endif - -/* Useful macros for decoding of bits and bit fields */ - -#define FLAG(x, y) ((x & y) ? '+' : '-') - -// Generate mask - -#define BIT(at) ((u64)1 << (at)) -// Boundaries inclusive -#define MASK(h, l) ((((u64)1 << ((h) + 1)) - 1) & ~(((u64)1 << (l)) - 1)) - -// Get/set from register - -#define BITS(x, at, width) (((x) >> (at)) & ((1 << (width)) - 1)) -#define GET_REG_MASK(reg, mask) (((reg) & (mask)) / ((mask) & ~((mask) << 1))) -#define SET_REG_MASK(reg, mask, val) \ - (((reg) & ~(mask)) | (((val) * ((mask) & ~((mask) << 1))) & (mask))) - -#define TABLE(tab, x, buf) \ - ((x) < sizeof(tab) / sizeof((tab)[0]) ? (tab)[x] : (sprintf((buf), "??%d", (x)), (buf))) - -#endif diff --git a/lmr/lmr.h b/lmr/lmr.h index f728fca..7375c33 100644 --- a/lmr/lmr.h +++ b/lmr/lmr.h @@ -14,7 +14,6 @@ #include #include "pciutils.h" -#include "lib/bitops.h" #define MARGIN_STEP_MS 1000 diff --git a/pciutils.h b/pciutils.h index 9e85089..036f0dc 100644 --- a/pciutils.h +++ b/pciutils.h @@ -10,7 +10,7 @@ #include "lib/pci.h" #include "lib/sysdep.h" -#include "lib/bitops.h" +#include "bitops.h" /* * gcc predefines macro __MINGW32__ for all MinGW targets.