@@ -105,7 +105,16 @@ impl MmapRegion {
105
105
///
106
106
/// # Arguments
107
107
/// * `size` - The size of the memory region in bytes.
108
- pub fn new ( size : usize , policy : PageSizePolicy ) -> Result < Self > {
108
+ pub fn new ( size : usize ) -> Result < Self > {
109
+ Self :: with_policy ( size, PageSizePolicy :: BasePages )
110
+ }
111
+
112
+ /// Creates a shared anonymous mapping of `size` bytes.
113
+ ///
114
+ /// # Arguments
115
+ /// * `size` - The size of the memory region in bytes.
116
+ /// * `policy` - The page size policy of the memory region.
117
+ pub fn with_policy ( size : usize , policy : PageSizePolicy ) -> Result < Self > {
109
118
Self :: build (
110
119
None ,
111
120
size,
@@ -121,7 +130,22 @@ impl MmapRegion {
121
130
/// * `file_offset` - The mapping will be created at offset `file_offset.start` in the file
122
131
/// referred to by `file_offset.file`.
123
132
/// * `size` - The size of the memory region in bytes.
124
- pub fn from_file ( file_offset : FileOffset , size : usize , policy : PageSizePolicy ) -> Result < Self > {
133
+ pub fn from_file ( file_offset : FileOffset , size : usize ) -> Result < Self > {
134
+ Self :: from_file_with_policy ( file_offset, size, PageSizePolicy :: BasePages )
135
+ }
136
+
137
+ /// Creates a shared file mapping of `size` bytes.
138
+ ///
139
+ /// # Arguments
140
+ /// * `file_offset` - The mapping will be created at offset `file_offset.start` in the file
141
+ /// referred to by `file_offset.file`.
142
+ /// * `size` - The size of the memory region in bytes.
143
+ /// * `policy` - The page size policy of the memory region.
144
+ pub fn from_file_with_policy (
145
+ file_offset : FileOffset ,
146
+ size : usize ,
147
+ policy : PageSizePolicy ,
148
+ ) -> Result < Self > {
125
149
Self :: build (
126
150
Some ( file_offset) ,
127
151
size,
@@ -412,6 +436,7 @@ mod tests {
412
436
size,
413
437
prot,
414
438
flags,
439
+ PageSizePolicy :: BasePages ,
415
440
) ;
416
441
assert_eq ! ( format!( "{:?}" , r. unwrap_err( ) ) , "InvalidOffsetLength" ) ;
417
442
@@ -421,6 +446,7 @@ mod tests {
421
446
size,
422
447
prot,
423
448
flags,
449
+ PageSizePolicy :: BasePages ,
424
450
) ;
425
451
assert_eq ! ( format!( "{:?}" , r. unwrap_err( ) ) , "MappingPastEof" ) ;
426
452
@@ -430,6 +456,7 @@ mod tests {
430
456
size,
431
457
prot,
432
458
flags | libc:: MAP_FIXED ,
459
+ PageSizePolicy :: BasePages ,
433
460
) ;
434
461
assert_eq ! ( format!( "{:?}" , r. unwrap_err( ) ) , "MapFixed" ) ;
435
462
@@ -442,6 +469,7 @@ mod tests {
442
469
size,
443
470
prot,
444
471
flags,
472
+ PageSizePolicy :: BasePages ,
445
473
) ;
446
474
assert_eq ! ( r. unwrap_err( ) . raw_os_error( ) , libc:: EINVAL ) ;
447
475
@@ -451,6 +479,7 @@ mod tests {
451
479
size,
452
480
prot,
453
481
flags,
482
+ PageSizePolicy :: BasePages ,
454
483
)
455
484
. unwrap ( ) ;
456
485
0 commit comments