@@ -105,7 +105,16 @@ impl MmapRegion {
105105 ///
106106 /// # Arguments
107107 /// * `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 > {
109118 Self :: build (
110119 None ,
111120 size,
@@ -121,7 +130,22 @@ impl MmapRegion {
121130 /// * `file_offset` - The mapping will be created at offset `file_offset.start` in the file
122131 /// referred to by `file_offset.file`.
123132 /// * `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 > {
125149 Self :: build (
126150 Some ( file_offset) ,
127151 size,
@@ -412,6 +436,7 @@ mod tests {
412436 size,
413437 prot,
414438 flags,
439+ PageSizePolicy :: BasePages ,
415440 ) ;
416441 assert_eq ! ( format!( "{:?}" , r. unwrap_err( ) ) , "InvalidOffsetLength" ) ;
417442
@@ -421,6 +446,7 @@ mod tests {
421446 size,
422447 prot,
423448 flags,
449+ PageSizePolicy :: BasePages ,
424450 ) ;
425451 assert_eq ! ( format!( "{:?}" , r. unwrap_err( ) ) , "MappingPastEof" ) ;
426452
@@ -430,6 +456,7 @@ mod tests {
430456 size,
431457 prot,
432458 flags | libc:: MAP_FIXED ,
459+ PageSizePolicy :: BasePages ,
433460 ) ;
434461 assert_eq ! ( format!( "{:?}" , r. unwrap_err( ) ) , "MapFixed" ) ;
435462
@@ -442,6 +469,7 @@ mod tests {
442469 size,
443470 prot,
444471 flags,
472+ PageSizePolicy :: BasePages ,
445473 ) ;
446474 assert_eq ! ( r. unwrap_err( ) . raw_os_error( ) , libc:: EINVAL ) ;
447475
@@ -451,6 +479,7 @@ mod tests {
451479 size,
452480 prot,
453481 flags,
482+ PageSizePolicy :: BasePages ,
454483 )
455484 . unwrap ( ) ;
456485
0 commit comments