resources: remove unneeded export of AddressAllocator

Nobody relies on this.

BUG=None
TEST=build

Change-Id: I79e34103079a0e9660a0ff79db4a154125f04bfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450016
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
This commit is contained in:
Junichi Uekawa 2022-02-10 08:49:29 +09:00 committed by Commit Bot
parent b451dc78f1
commit 120318d6e6
2 changed files with 22 additions and 14 deletions

View file

@ -11,19 +11,6 @@ use crate::{Alloc, Error, Result};
/// Use `AddressAllocator` whenever an address range needs to be allocated to different users.
/// Allocations must be uniquely tagged with an Alloc enum, which can be used for lookup.
/// An human-readable tag String must also be provided for debugging / reference.
///
/// # Examples
///
/// ```
/// // Anon is used for brevity. Don't manually instantiate Anon allocs!
/// # use resources::{Alloc, AddressAllocator};
/// AddressAllocator::new(0x1000, 0x10000, Some(0x100), None).map(|mut pool| {
/// assert_eq!(pool.allocate(0x110, Alloc::Anon(0), "caps".to_string()), Ok(0x1000));
/// assert_eq!(pool.allocate(0x100, Alloc::Anon(1), "cache".to_string()), Ok(0x1200));
/// assert_eq!(pool.allocate(0x100, Alloc::Anon(2), "etc".to_string()), Ok(0x1300));
/// assert_eq!(pool.get(&Alloc::Anon(1)), Some(&(0x1200, 0x100, "cache".to_string())));
/// });
/// ```
#[derive(Debug, Eq, PartialEq)]
pub struct AddressAllocator {
pool_base: u64,
@ -429,6 +416,28 @@ impl<'a> AddressAllocatorSet<'a> {
mod tests {
use super::*;
#[test]
fn example() {
// Anon is used for brevity. Don't manually instantiate Anon allocs!
let mut pool = AddressAllocator::new(0x1000, 0x10000, Some(0x100), None).unwrap();
assert_eq!(
pool.allocate(0x110, Alloc::Anon(0), "caps".to_string()),
Ok(0x1000)
);
assert_eq!(
pool.allocate(0x100, Alloc::Anon(1), "cache".to_string()),
Ok(0x1200)
);
assert_eq!(
pool.allocate(0x100, Alloc::Anon(2), "etc".to_string()),
Ok(0x1300)
);
assert_eq!(
pool.get(&Alloc::Anon(1)),
Some(&(0x1200, 0x100, "cache".to_string()))
);
}
#[test]
fn new_fails_overflow() {
assert!(AddressAllocator::new(u64::max_value(), 0x100, None, None).is_err());

View file

@ -8,7 +8,6 @@ use remain::sorted;
use serde::{Deserialize, Serialize};
use thiserror::Error;
pub use crate::address_allocator::AddressAllocator;
pub use crate::system_allocator::{MemRegion, MmioType, SystemAllocator, SystemAllocatorConfig};
mod address_allocator;