Skip to content

Commit d075426

Browse files
authored
Merge pull request #1727 from GuillaumeDIDIER/feature/map_huge_table_size
Add defines for HUGETLB size - solves #1700
2 parents a1c4092 + c646f96 commit d075426

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,7 @@ fn test_linux(target: &str) {
22402240
"linux/keyctl.h",
22412241
"linux/magic.h",
22422242
"linux/memfd.h",
2243+
"linux/mman.h",
22432244
"linux/module.h",
22442245
"linux/net_tstamp.h",
22452246
"linux/netfilter/nfnetlink.h",

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,47 @@ cfg_if! {
399399
}
400400
}
401401

402+
// include/uapi/asm-generic/hugetlb_encode.h
403+
pub const HUGETLB_FLAG_ENCODE_SHIFT: ::c_int = 26;
404+
pub const HUGETLB_FLAG_ENCODE_MASK: ::c_int = 0x3f;
405+
406+
pub const HUGETLB_FLAG_ENCODE_64KB: ::c_int = 16 << HUGETLB_FLAG_ENCODE_SHIFT;
407+
pub const HUGETLB_FLAG_ENCODE_512KB: ::c_int = 19 << HUGETLB_FLAG_ENCODE_SHIFT;
408+
pub const HUGETLB_FLAG_ENCODE_1MB: ::c_int = 20 << HUGETLB_FLAG_ENCODE_SHIFT;
409+
pub const HUGETLB_FLAG_ENCODE_2MB: ::c_int = 21 << HUGETLB_FLAG_ENCODE_SHIFT;
410+
pub const HUGETLB_FLAG_ENCODE_8MB: ::c_int = 23 << HUGETLB_FLAG_ENCODE_SHIFT;
411+
pub const HUGETLB_FLAG_ENCODE_16MB: ::c_int = 24 << HUGETLB_FLAG_ENCODE_SHIFT;
412+
pub const HUGETLB_FLAG_ENCODE_32MB: ::c_int = 25 << HUGETLB_FLAG_ENCODE_SHIFT;
413+
pub const HUGETLB_FLAG_ENCODE_256MB: ::c_int = 28 << HUGETLB_FLAG_ENCODE_SHIFT;
414+
pub const HUGETLB_FLAG_ENCODE_512MB: ::c_int = 29 << HUGETLB_FLAG_ENCODE_SHIFT;
415+
pub const HUGETLB_FLAG_ENCODE_1GB: ::c_int = 30 << HUGETLB_FLAG_ENCODE_SHIFT;
416+
pub const HUGETLB_FLAG_ENCODE_2GB: ::c_int = 31 << HUGETLB_FLAG_ENCODE_SHIFT;
417+
pub const HUGETLB_FLAG_ENCODE_16GB: ::c_int = 34 << HUGETLB_FLAG_ENCODE_SHIFT;
418+
419+
// include/uapi/linux/mman.h
420+
/*
421+
* Huge page size encoding when MAP_HUGETLB is specified, and a huge page
422+
* size other than the default is desired. See hugetlb_encode.h.
423+
* All known huge page size encodings are provided here. It is the
424+
* responsibility of the application to know which sizes are supported on
425+
* the running system. See mmap(2) man page for details.
426+
*/
427+
pub const MAP_HUGE_SHIFT: ::c_int = HUGETLB_FLAG_ENCODE_SHIFT;
428+
pub const MAP_HUGE_MASK: ::c_int = HUGETLB_FLAG_ENCODE_MASK;
429+
430+
pub const MAP_HUGE_64KB: ::c_int = HUGETLB_FLAG_ENCODE_64KB;
431+
pub const MAP_HUGE_512KB: ::c_int = HUGETLB_FLAG_ENCODE_512KB;
432+
pub const MAP_HUGE_1MB: ::c_int = HUGETLB_FLAG_ENCODE_1MB;
433+
pub const MAP_HUGE_2MB: ::c_int = HUGETLB_FLAG_ENCODE_2MB;
434+
pub const MAP_HUGE_8MB: ::c_int = HUGETLB_FLAG_ENCODE_8MB;
435+
pub const MAP_HUGE_16MB: ::c_int = HUGETLB_FLAG_ENCODE_16MB;
436+
pub const MAP_HUGE_32MB: ::c_int = HUGETLB_FLAG_ENCODE_32MB;
437+
pub const MAP_HUGE_256MB: ::c_int = HUGETLB_FLAG_ENCODE_256MB;
438+
pub const MAP_HUGE_512MB: ::c_int = HUGETLB_FLAG_ENCODE_512MB;
439+
pub const MAP_HUGE_1GB: ::c_int = HUGETLB_FLAG_ENCODE_1GB;
440+
pub const MAP_HUGE_2GB: ::c_int = HUGETLB_FLAG_ENCODE_2GB;
441+
pub const MAP_HUGE_16GB: ::c_int = HUGETLB_FLAG_ENCODE_16GB;
442+
402443
pub const RLIMIT_CPU: ::__rlimit_resource_t = 0;
403444
pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
404445
pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;

src/unix/linux_like/linux/musl/b32/hexagon.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ pub const MAP_ANON: ::c_int = 32;
258258
pub const MAP_DENYWRITE: ::c_int = 2048;
259259
pub const MAP_EXECUTABLE: ::c_int = 4096;
260260
pub const MAP_GROWSDOWN: ::c_int = 256;
261-
pub const MAP_HUGE_MASK: ::c_int = 63;
262-
pub const MAP_HUGE_SHIFT: ::c_int = 26;
263261
pub const MAP_HUGETLB: ::c_int = 262144;
264262
pub const MAP_LOCKED: ::c_int = 8192;
265263
pub const MAP_NONBLOCK: ::c_int = 65536;

src/unix/linux_like/linux/musl/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,30 @@ cfg_if! {
199199
}
200200
}
201201

202+
// include/sys/mman.h
203+
/*
204+
* Huge page size encoding when MAP_HUGETLB is specified, and a huge page
205+
* size other than the default is desired. See hugetlb_encode.h.
206+
* All known huge page size encodings are provided here. It is the
207+
* responsibility of the application to know which sizes are supported on
208+
* the running system. See mmap(2) man page for details.
209+
*/
210+
pub const MAP_HUGE_SHIFT: ::c_int = 26;
211+
pub const MAP_HUGE_MASK: ::c_int = 0x3f;
212+
213+
pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT;
214+
pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT;
215+
pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT;
216+
pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT;
217+
pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT;
218+
pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT;
219+
pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT;
220+
pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT;
221+
pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT;
222+
pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT;
223+
pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT;
224+
pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT;
225+
202226
pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
203227

204228
pub const SFD_CLOEXEC: ::c_int = 0x080000;

0 commit comments

Comments
 (0)