@@ -154,6 +154,36 @@ libc_bitflags! {
154
154
/// Pages will be discarded in the core dumps.
155
155
#[ cfg( target_os = "openbsd" ) ]
156
156
MAP_CONCEAL ;
157
+ /// Pages aligned on 64kb
158
+ #[ cfg( target_os = "netbsd" ) ]
159
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
160
+ MAP_ALIGNMENT_64KB ;
161
+ /// Pages aligned on 16mb
162
+ #[ cfg( target_os = "netbsd" ) ]
163
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
164
+ MAP_ALIGNMENT_16MB ;
165
+ /// Pages aligned on 4gb
166
+ #[ cfg( target_os = "netbsd" ) ]
167
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
168
+ MAP_ALIGNMENT_4GB ;
169
+ /// Pages aligned on 1tb
170
+ #[ cfg( target_os = "netbsd" ) ]
171
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
172
+ MAP_ALIGNMENT_1TB ;
173
+ /// Pages aligned on 256tb
174
+ #[ cfg( target_os = "netbsd" ) ]
175
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
176
+ MAP_ALIGNMENT_256TB ;
177
+ /// Pages aligned on 64pb
178
+ #[ cfg( target_os = "netbsd" ) ]
179
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
180
+ MAP_ALIGNMENT_64PB ;
181
+ /// Right operand value for the page alignment bitshift calculation
182
+ #[ cfg( target_os = "netbsd" ) ]
183
+ MAP_ALIGNMENT_SHIFT ;
184
+ /// Mask to get the page alignment (as `(flags & align mask) >> align shift`)
185
+ #[ cfg( target_os = "netbsd" ) ]
186
+ MAP_ALIGNMENT_MASK ;
157
187
}
158
188
}
159
189
@@ -631,3 +661,23 @@ pub fn shm_unlink<P: ?Sized + NixPath>(name: &P) -> Result<()> {
631
661
632
662
Errno :: result ( ret) . map ( drop)
633
663
}
664
+
665
+ /// Matches BSD's `MAP_ALIGNED(x)` macro, x being ilog2(alignment).
666
+ ///
667
+ /// For more information, see [`mmap(2)`].
668
+ ///
669
+ /// [`mmap(2)`]: https://man.freebsd.org/cgi/man.cgi?mmap(2)
670
+ #[ cfg( target_os = "netbsd" ) ]
671
+ pub const fn map_aligned ( v : u32 ) -> u32 {
672
+ v << MapFlags :: MAP_ALIGNMENT_SHIFT . bits ( )
673
+ }
674
+
675
+ /// Handy call to get the alignment set by `map_aligned`.
676
+ ///
677
+ /// For more information, see [`mmap(2)`].
678
+ ///
679
+ /// [`mmap(2)`]: https://man.freebsd.org/cgi/man.cgi?mmap(2)
680
+ #[ cfg( target_os = "netbsd" ) ]
681
+ pub const fn map_alignment ( flags : u32 ) -> u32 {
682
+ ( flags & MapFlags :: MAP_ALIGNMENT_MASK . bits ( ) as u32 ) >> MapFlags :: MAP_ALIGNMENT_SHIFT . bits ( )
683
+ }
0 commit comments