starnix_types/
math.rs

1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use super::PAGE_SIZE;
6
7use starnix_uapi::errors::Errno;
8use starnix_uapi::math::{round_down_to_increment, round_up_to_increment};
9
10pub fn round_up_to_system_page_size<N>(size: N) -> Result<N, Errno>
11where
12    N: TryInto<u64>,
13    N: TryFrom<u64>,
14{
15    round_up_to_increment(size, *PAGE_SIZE)
16}
17
18pub fn round_down_to_system_page_size<N>(size: N) -> Result<N, Errno>
19where
20    N: TryInto<u64>,
21    N: TryFrom<u64>,
22{
23    round_down_to_increment(size, *PAGE_SIZE)
24}