mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-18 07:08:18 +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:
committed by
Christian Helmuth
parent
b856bfdfcd
commit
dc36b63acb
@ -30,15 +30,15 @@ namespace Genode {
|
|||||||
* Alignment to the power of two
|
* Alignment to the power of two
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline T _align_mask(T align) {
|
static constexpr T _align_mask(T align) {
|
||||||
return ~(((T)1 << align) - 1); }
|
return ~(((T)1 << align) - (T)1); }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline T _align_offset(T align) {
|
static constexpr T _align_offset(T align) {
|
||||||
return ((T)1 << align) - 1; }
|
return ((T)1 << align) - (T)1; }
|
||||||
|
|
||||||
template <typename T>
|
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); }
|
return (addr + _align_offset((T)align)) & _align_mask((T)align); }
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user