1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
mod buffer;
#[cfg(all(
unix,
not(all(
any(
target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "ios"
),
not(feature = "unix_sysv")
))
))]
mod sysv;
#[cfg(all(
unix,
not(all(
any(
target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "ios"
),
not(feature = "unix_sysv")
))
))]
pub(crate) use self::sysv::{
allocate_mirrored, allocation_granularity, deallocate_mirrored,
};
#[cfg(all(
any(target_os = "linux", target_os = "android"),
not(feature = "unix_sysv")
))]
mod linux;
#[cfg(all(
any(target_os = "linux", target_os = "android"),
not(feature = "unix_sysv")
))]
pub(crate) use self::linux::{
allocate_mirrored, allocation_granularity, deallocate_mirrored,
};
#[cfg(all(
any(target_os = "macos", target_os = "ios"),
not(feature = "unix_sysv")
))]
mod macos;
#[cfg(all(
any(target_os = "macos", target_os = "ios"),
not(feature = "unix_sysv")
))]
pub(crate) use self::macos::{
allocate_mirrored, allocation_granularity, deallocate_mirrored,
};
#[cfg(target_os = "windows")]
mod winapi;
#[cfg(target_os = "windows")]
pub(crate) use self::winapi::{
allocate_mirrored, allocation_granularity, deallocate_mirrored,
};
pub use self::buffer::Buffer;
use super::*;
pub enum AllocError {
Oom,
Other,
}
impl crate::fmt::Debug for AllocError {
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
match self {
AllocError::Oom => write!(f, "out-of-memory"),
AllocError::Other => write!(f, "other (not out-of-memory)"),
}
}
}