@@ -56,25 +56,26 @@ fn aligned_size(new_layout: Layout) -> usize {
56
56
57
57
/// # Invariants
58
58
///
59
- /// One of the following: `krealloc_node `, `vrealloc_node `, `kvrealloc_node `.
59
+ /// One of the following: `krealloc_node_align `, `vrealloc_node_align `, `kvrealloc_node_align `.
60
60
struct ReallocFunc (
61
61
unsafe extern "C" fn (
62
62
* const crate :: ffi:: c_void ,
63
63
usize ,
64
+ crate :: ffi:: c_ulong ,
64
65
u32 ,
65
66
crate :: ffi:: c_int ,
66
67
) -> * mut crate :: ffi:: c_void ,
67
68
) ;
68
69
69
70
impl ReallocFunc {
70
- // INVARIANT: `krealloc_node ` satisfies the type invariants.
71
- const KREALLOC : Self = Self ( bindings:: krealloc_node ) ;
71
+ // INVARIANT: `krealloc_node_align ` satisfies the type invariants.
72
+ const KREALLOC : Self = Self ( bindings:: krealloc_node_align ) ;
72
73
73
- // INVARIANT: `vrealloc_node ` satisfies the type invariants.
74
- const VREALLOC : Self = Self ( bindings:: vrealloc_node ) ;
74
+ // INVARIANT: `vrealloc_node_align ` satisfies the type invariants.
75
+ const VREALLOC : Self = Self ( bindings:: vrealloc_node_align ) ;
75
76
76
- // INVARIANT: `kvrealloc_node ` satisfies the type invariants.
77
- const KVREALLOC : Self = Self ( bindings:: kvrealloc_node ) ;
77
+ // INVARIANT: `kvrealloc_node_align ` satisfies the type invariants.
78
+ const KVREALLOC : Self = Self ( bindings:: kvrealloc_node_align ) ;
78
79
79
80
/// # Safety
80
81
///
@@ -116,7 +117,7 @@ impl ReallocFunc {
116
117
// - Those functions provide the guarantees of this function.
117
118
let raw_ptr = unsafe {
118
119
// If `size == 0` and `ptr != NULL` the memory behind the pointer is freed.
119
- self . 0 ( ptr. cast ( ) , size, flags. 0 , nid. 0 ) . cast ( )
120
+ self . 0 ( ptr. cast ( ) , size, layout . align ( ) , flags. 0 , nid. 0 ) . cast ( )
120
121
} ;
121
122
122
123
let ptr = if size == 0 {
@@ -160,12 +161,6 @@ unsafe impl Allocator for Vmalloc {
160
161
flags : Flags ,
161
162
nid : NumaNode ,
162
163
) -> Result < NonNull < [ u8 ] > , AllocError > {
163
- // TODO: Support alignments larger than PAGE_SIZE.
164
- if layout. align ( ) > bindings:: PAGE_SIZE {
165
- pr_warn ! ( "Vmalloc does not support alignments larger than PAGE_SIZE yet.\n " ) ;
166
- return Err ( AllocError ) ;
167
- }
168
-
169
164
// SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously
170
165
// allocated with this `Allocator`.
171
166
unsafe { ReallocFunc :: VREALLOC . call ( ptr, layout, old_layout, flags, nid) }
@@ -185,12 +180,6 @@ unsafe impl Allocator for KVmalloc {
185
180
flags : Flags ,
186
181
nid : NumaNode ,
187
182
) -> Result < NonNull < [ u8 ] > , AllocError > {
188
- // TODO: Support alignments larger than PAGE_SIZE.
189
- if layout. align ( ) > bindings:: PAGE_SIZE {
190
- pr_warn ! ( "KVmalloc does not support alignments larger than PAGE_SIZE yet.\n " ) ;
191
- return Err ( AllocError ) ;
192
- }
193
-
194
183
// SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously
195
184
// allocated with this `Allocator`.
196
185
unsafe { ReallocFunc :: KVREALLOC . call ( ptr, layout, old_layout, flags, nid) }
0 commit comments