From 877b2cf790a66cc7ff741a8c1474b0f052540f09 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Mon, 3 Feb 2020 23:01:00 +0000 Subject: [PATCH] libvapours: introduce BITL, MASK, MASKL, MASK2, MASK2L which were already present in other ams components --- .../libvapours/include/vapours/types.hpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libraries/libvapours/include/vapours/types.hpp b/libraries/libvapours/include/vapours/types.hpp index 891d661db..0d4b4b6f0 100644 --- a/libraries/libvapours/include/vapours/types.hpp +++ b/libraries/libvapours/include/vapours/types.hpp @@ -52,6 +52,31 @@ typedef u32 Result; ///< Function error code result type. #define BIT(n) (1U<<(n)) #endif +/// Creates a bitmask from a bit number (long). +#ifndef BITL +#define BITL(n) (1UL<<(n)) +#endif + +/// Creates a bitmask representing the n least significant bits. +#ifndef MASK +#define MASK(n) (BIT(n) - 1U) +#endif + +/// Creates a bitmask representing the n least significant bits (long). +#ifndef MASKL +#define MASKL(n) (BITL(n) - 1UL) +#endif + +/// Creates a bitmask for bit range extraction. +#ifndef MASK2 +#define MASK2(a,b) (MASK(a) & ~MASK(b)) +#endif + +/// Creates a bitmask for bit range extraction (long). +#ifndef MASK2L +#define MASK2L(a,b) (MASKL(a) & ~MASKL(b)) +#endif + /// Marks a function as not returning, for the purposes of compiler optimization. #ifndef NORETURN #define NORETURN __attribute__((noreturn))