Skip to content

Commit 6ddb680

Browse files
committed
Auto merge of #3170 - devnexen:netbsd_map_aligned, r=JohnTitor
netbsd add MAP_ALIGNED macro
2 parents 68e06ad + 4c6ba40 commit 6ddb680

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

libc-test/semver/netbsd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ MADV_NORMAL
628628
MADV_RANDOM
629629
MADV_SEQUENTIAL
630630
MADV_WILLNEED
631+
MAP_ALIGNED
631632
MAP_ALIGNMENT_16MB
632633
MAP_ALIGNMENT_1TB
633634
MAP_ALIGNMENT_256TB

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,13 +1663,13 @@ pub const MAP_WIRED: ::c_int = 0x800;
16631663
pub const MAP_STACK: ::c_int = 0x2000;
16641664
// map alignment aliases for MAP_ALIGNED
16651665
pub const MAP_ALIGNMENT_SHIFT: ::c_int = 24;
1666-
pub const MAP_ALIGNMENT_MASK: ::c_int = 0xff << MAP_ALIGNMENT_SHIFT;
1667-
pub const MAP_ALIGNMENT_64KB: ::c_int = 16 << MAP_ALIGNMENT_SHIFT;
1668-
pub const MAP_ALIGNMENT_16MB: ::c_int = 24 << MAP_ALIGNMENT_SHIFT;
1669-
pub const MAP_ALIGNMENT_4GB: ::c_int = 32 << MAP_ALIGNMENT_SHIFT;
1670-
pub const MAP_ALIGNMENT_1TB: ::c_int = 40 << MAP_ALIGNMENT_SHIFT;
1671-
pub const MAP_ALIGNMENT_256TB: ::c_int = 48 << MAP_ALIGNMENT_SHIFT;
1672-
pub const MAP_ALIGNMENT_64PB: ::c_int = 56 << MAP_ALIGNMENT_SHIFT;
1666+
pub const MAP_ALIGNMENT_MASK: ::c_int = MAP_ALIGNED(0xff);
1667+
pub const MAP_ALIGNMENT_64KB: ::c_int = MAP_ALIGNED(16);
1668+
pub const MAP_ALIGNMENT_16MB: ::c_int = MAP_ALIGNED(24);
1669+
pub const MAP_ALIGNMENT_4GB: ::c_int = MAP_ALIGNED(32);
1670+
pub const MAP_ALIGNMENT_1TB: ::c_int = MAP_ALIGNED(40);
1671+
pub const MAP_ALIGNMENT_256TB: ::c_int = MAP_ALIGNED(48);
1672+
pub const MAP_ALIGNMENT_64PB: ::c_int = MAP_ALIGNED(56);
16731673
// mremap flag
16741674
pub const MAP_REMAPDUP: ::c_int = 0x004;
16751675

@@ -2377,6 +2377,19 @@ pub const GRND_NONBLOCK: ::c_uint = 0x1;
23772377
pub const GRND_RANDOM: ::c_uint = 0x2;
23782378
pub const GRND_INSECURE: ::c_uint = 0x4;
23792379

2380+
cfg_if! {
2381+
2382+
if #[cfg(libc_const_extern_fn)] {
2383+
pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int {
2384+
alignment << MAP_ALIGNMENT_SHIFT
2385+
}
2386+
} else {
2387+
pub fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int {
2388+
alignment << MAP_ALIGNMENT_SHIFT
2389+
}
2390+
}
2391+
}
2392+
23802393
const_fn! {
23812394
{const} fn _ALIGN(p: usize) -> usize {
23822395
(p + _ALIGNBYTES) & !_ALIGNBYTES

0 commit comments

Comments
 (0)