Align a value down to the specified alignment boundary. If `value` is already aligned, the same value is returned. Commonly used to determine the base address of the enclosing page. Args: value: a value to align alignment: alignment boundary; must be
(self, value: int, alignment: Optional[int] = None)
| 262 | return next((lbound for lbound, info in stripped if os.path.basename(info) == filename), None) |
| 263 | |
| 264 | def align(self, value: int, alignment: Optional[int] = None) -> int: |
| 265 | """Align a value down to the specified alignment boundary. If `value` is already |
| 266 | aligned, the same value is returned. Commonly used to determine the base address |
| 267 | of the enclosing page. |
| 268 | |
| 269 | Args: |
| 270 | value: a value to align |
| 271 | alignment: alignment boundary; must be a power of 2. if not specified value |
| 272 | will be aligned to page size |
| 273 | |
| 274 | Returns: value aligned down to boundary |
| 275 | """ |
| 276 | |
| 277 | if alignment is None: |
| 278 | alignment = self.pagesize |
| 279 | |
| 280 | # make sure alignment is a power of 2 |
| 281 | assert alignment & (alignment - 1) == 0 |
| 282 | |
| 283 | # round down to nearest alignment |
| 284 | return value & ~(alignment - 1) |
| 285 | |
| 286 | def align_up(self, value: int, alignment: Optional[int] = None) -> int: |
| 287 | """Align a value up to the specified alignment boundary. If `value` is already |
no outgoing calls
no test coverage detected