@@ -184,6 +184,40 @@ libc_bitflags! {
184
184
#[ cfg( target_os = "openbsd" ) ]
185
185
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
186
186
MAP_CONCEAL ;
187
+ /// Pages aligned on 64kb
188
+ #[ cfg( target_os = "netbsd" ) ]
189
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
190
+ MAP_ALIGNMENT_64KB ;
191
+ /// Pages aligned on 16mb
192
+ #[ cfg( target_os = "netbsd" ) ]
193
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
194
+ MAP_ALIGNMENT_16MB ;
195
+ /// Pages aligned on 4gb
196
+ #[ cfg( target_os = "netbsd" ) ]
197
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
198
+ MAP_ALIGNMENT_4GB ;
199
+ /// Pages aligned on 1tb
200
+ #[ cfg( target_os = "netbsd" ) ]
201
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
202
+ MAP_ALIGNMENT_1TB ;
203
+ /// Pages aligned on 256tb
204
+ #[ cfg( target_os = "netbsd" ) ]
205
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
206
+ MAP_ALIGNMENT_256TB ;
207
+ /// Pages aligned on 64pb
208
+ #[ cfg( target_os = "netbsd" ) ]
209
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
210
+ MAP_ALIGNMENT_64PB ;
211
+ /// Right operand value for the page alignment bitshift calculation
212
+ /// FIXME: not present in libc for FreeBSD
213
+ #[ cfg( target_os = "netbsd" ) ]
214
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
215
+ MAP_ALIGNMENT_SHIFT ;
216
+ /// Mask to get the page alignment (as `(flags & align mask) >> align shift`)
217
+ #[ cfg( target_os = "netbsd" ) ]
218
+ /// FIXME: not present in libc for FreeBSD
219
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
220
+ MAP_ALIGNMENT_MASK ;
187
221
}
188
222
}
189
223
@@ -605,3 +639,23 @@ pub fn shm_unlink<P: ?Sized + NixPath>(name: &P) -> Result<()> {
605
639
606
640
Errno :: result ( ret) . map ( drop)
607
641
}
642
+
643
+ /// Matches BSD's `MAP_ALIGNED(x)` macro, x being ilog2(alignment).
644
+ ///
645
+ /// For more information, see [`mmap(2)`].
646
+ ///
647
+ /// [`mmap(2)`]: https://man.freebsd.org/cgi/man.cgi?mmap(2)
648
+ #[ cfg( target_os = "netbsd" ) ]
649
+ pub const fn map_aligned ( v : u32 ) -> u32 {
650
+ v << MapFlags :: MAP_ALIGNMENT_SHIFT . bits ( )
651
+ }
652
+
653
+ /// Handy call to get the alignment set by `map_aligned`.
654
+ ///
655
+ /// For more information, see [`mmap(2)`].
656
+ ///
657
+ /// [`mmap(2)`]: https://man.freebsd.org/cgi/man.cgi?mmap(2)
658
+ #[ cfg( target_os = "netbsd" ) ]
659
+ pub const fn map_alignment ( flags : u32 ) -> u32 {
660
+ ( flags & MapFlags :: MAP_ALIGNMENT_MASK . bits ( ) as u32 ) >> MapFlags :: MAP_ALIGNMENT_SHIFT . bits ( )
661
+ }
0 commit comments