mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-11 13:22:33 +00:00
base: turn align_addr tool into constexpr
Thereby, the tool can be used to calculate static compile-time values. Ref #1588
This commit is contained in:
parent
b856bfdfcd
commit
dc36b63acb
@ -30,15 +30,15 @@ namespace Genode {
|
||||
* Alignment to the power of two
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T _align_mask(T align) {
|
||||
return ~(((T)1 << align) - 1); }
|
||||
static constexpr T _align_mask(T align) {
|
||||
return ~(((T)1 << align) - (T)1); }
|
||||
|
||||
template <typename T>
|
||||
static inline T _align_offset(T align) {
|
||||
return ((T)1 << align) - 1; }
|
||||
static constexpr T _align_offset(T align) {
|
||||
return ((T)1 << align) - (T)1; }
|
||||
|
||||
template <typename T>
|
||||
static inline T align_addr(T addr, int align) {
|
||||
static constexpr T align_addr(T addr, int align) {
|
||||
return (addr + _align_offset((T)align)) & _align_mask((T)align); }
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user