forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user