rusty_mos/consts/
types.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Definition of some misc macros about type and offset.

/// Round-up to the specified fractor.
///
/// **REQUIREMENT**: `$n` is **the power of 2**, such 4, 8, 16, etc.
#[macro_export]
macro_rules! ROUND {
    ($x: expr; $n: expr) => {
        ($x + $n - 1) & !($n - 1)
    };
}

/// Round-down to the specified fractor.
///
/// /// **REQUIREMENT**: `$n` is **the power of 2**, such 4, 8, 16, etc.
#[macro_export]
macro_rules! ROUNDDOWN {
    ($x: expr; $n: expr) => {
        $x & !($n - 1)
    };
}