* include/utility.h: Macros use now first and last bit values instead
	of shift and length parameters.
This commit is contained in:
Sebastian Huber
2010-05-21 08:01:14 +00:00
parent bc74b337e4
commit 23f35aa559
2 changed files with 13 additions and 8 deletions

View File

@@ -1,3 +1,8 @@
2010-05-21 Sebastian Huber <sebastian.huber@embedded-brains.de>
* include/utility.h: Macros use now first and last bit values instead
of shift and length parameters.
2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de>
* include/utility.h: Removed superfluous macros.

View File

@@ -27,16 +27,16 @@
#define BIT32(bit) \
((uint32_t) 1 << (bit))
#define MASK32(shift, length) \
((BIT32(length) - (uint32_t) 1) << (shift))
#define MASK32(first_bit, last_bit) \
((BIT32((last_bit) - (first_bit) + 1) - (uint32_t) 1) << (first_bit))
#define FIELD32(val, shift, length) \
(((uint32_t) (val) << (shift)) & MASK32(shift, length))
#define FIELD32(val, first_bit, last_bit) \
(((uint32_t) (val) << (first_bit)) & MASK32(first_bit, last_bit))
#define GETFIELD32(reg, shift, length) \
(((uint32_t) (reg) & MASK32(shift, length)) >> (shift))
#define GETFIELD32(reg, first_bit, last_bit) \
(((reg) & MASK32(first_bit, last_bit)) >> (first_bit))
#define SETFIELD32(reg, val, shift, length) \
(((uint32_t) (reg) & ~MASK32(shift, length)) | FIELD(val, shift, length))
#define SETFIELD32(reg, val, first_bit, last_bit) \
(((reg) & ~MASK32(first_bit, last_bit)) | FIELD32(val, first_bit, last_bit))
#endif /* LIBCPU_SHARED_UTILITY_H */