Skip to content

Commit c620c55

Browse files
committed
solarish lgrp api subset
1 parent 3151997 commit c620c55

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

libc-test/build.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ fn test_solarish(target: &str) {
775775
"sys/file.h",
776776
"sys/filio.h",
777777
"sys/ioctl.h",
778+
"sys/lgrp_user.h",
778779
"sys/loadavg.h",
779780
"sys/mman.h",
780781
"sys/mount.h",
@@ -809,12 +810,9 @@ fn test_solarish(target: &str) {
809810
"wchar.h",
810811
}
811812

812-
cfg.skip_type(move |ty| {
813-
match ty {
814-
// sighandler_t is not present here
815-
"sighandler_t" => true,
816-
_ => false,
817-
}
813+
cfg.skip_type(move |ty| match ty {
814+
"sighandler_t" => true,
815+
_ => false,
818816
});
819817

820818
cfg.type_name(move |ty, is_struct, is_union| match ty {

src/unix/solarish/mod.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ pub type id_t = ::c_int;
4343
pub type idtype_t = ::c_uint;
4444
pub type shmatt_t = ::c_ulong;
4545

46+
pub type lgrp_rsrc_t = ::c_int;
47+
pub type lgrp_affinity_t = ::c_int;
48+
pub type lgrp_id_t = ::id_t;
49+
pub type lgrp_mem_size_t = ::c_longlong;
50+
pub type lgrp_cookie_t = ::uintptr_t;
51+
pub type lgrp_content_t = ::c_uint;
52+
pub type lgrp_lat_between_t = ::c_uint;
53+
pub type lgrp_mem_size_flag_t = ::c_uint;
54+
pub type lgrp_view_t = ::c_uint;
55+
4656
#[cfg_attr(feature = "extra_traits", derive(Debug))]
4757
pub enum timezone {}
4858
impl ::Copy for timezone {}
@@ -434,6 +444,13 @@ s! {
434444
pub mr_prot: ::c_uint,
435445
pub mr_flags: ::c_uint,
436446
}
447+
448+
pub struct lgrp_affinity_args {
449+
pub idtype: ::idtype_t,
450+
pub id: ::id_t,
451+
pub lgrp: ::lgrp_id_t,
452+
pub aff: ::lgrp_affinity_t,
453+
}
437454
}
438455

439456
s_no_extra_traits! {
@@ -2309,6 +2326,23 @@ pub const SI_ARCHITECTURE_64: ::c_int = 517;
23092326
pub const SI_ARCHITECTURE_K: ::c_int = 518;
23102327
pub const SI_ARCHITECTURE_NATIVE: ::c_int = 519;
23112328

2329+
// sys/lgrp_user.h
2330+
pub const LGRP_COOKIE_NONE: ::lgrp_cookie_t = 0;
2331+
pub const LGRP_AFF_NONE: ::lgrp_affinity_t = 0x0;
2332+
pub const LGRP_AFF_WEAK: ::lgrp_affinity_t = 0x10;
2333+
pub const LGRP_AFF_STRONG: ::lgrp_affinity_t = 0x100;
2334+
pub const LGRP_RSRC_COUNT: ::lgrp_rsrc_t = 2;
2335+
pub const LGRP_RSRC_CPU: ::lgrp_rsrc_t = 0;
2336+
pub const LGRP_RSRC_MEM: ::lgrp_rsrc_t = 1;
2337+
pub const LGRP_CONTENT_ALL: ::lgrp_content_t = 0;
2338+
pub const LGRP_CONTENT_HIERARCHY: ::lgrp_content_t = LGRP_CONTENT_ALL;
2339+
pub const LGRP_CONTENT_DIRECT: ::lgrp_content_t = 1;
2340+
pub const LGRP_LAT_CPU_TO_MEM: ::lgrp_lat_between_t = 0;
2341+
pub const LGRP_MEM_SZ_FREE: ::lgrp_mem_size_flag_t = 0;
2342+
pub const LGRP_MEM_SZ_INSTALLED: ::lgrp_mem_size_flag_t = 1;
2343+
pub const LGRP_VIEW_CALLER: ::lgrp_view_t = 0;
2344+
pub const LGRP_VIEW_OS: ::lgrp_view_t = 1;
2345+
23122346
// As per sys/socket.h, header alignment must be 8 bytes on SPARC
23132347
// and 4 bytes everywhere else:
23142348
#[cfg(target_arch = "sparc64")]
@@ -2925,6 +2959,38 @@ extern "C" {
29252959
pub fn strsep(string: *mut *mut ::c_char, delim: *const ::c_char) -> *mut ::c_char;
29262960
}
29272961

2962+
#[link(name = "lgrp")]
2963+
extern "C" {
2964+
pub fn lgrp_init(view: lgrp_view_t) -> lgrp_cookie_t;
2965+
pub fn lgrp_fini(cookie: lgrp_cookie_t) -> ::c_int;
2966+
pub fn lgrp_affinity_get(
2967+
idtype: ::idtype_t,
2968+
id: ::id_t,
2969+
lgrp: ::lgrp_id_t,
2970+
) -> ::lgrp_affinity_t;
2971+
pub fn lgrp_affinity_set(
2972+
idtype: ::idtype_t,
2973+
id: ::id_t,
2974+
lgrp: ::lgrp_id_t,
2975+
aff: lgrp_affinity_t,
2976+
) -> ::lgrp_affinity_t;
2977+
pub fn lgrp_cpus(
2978+
cookie: ::lgrp_cookie_t,
2979+
lgrp: ::lgrp_id_t,
2980+
cpuids: *mut ::processorid_t,
2981+
count: ::c_uint,
2982+
content: ::lgrp_content_t,
2983+
) -> ::c_int;
2984+
pub fn lgrp_mem_size(
2985+
cookie: ::lgrp_cookie_t,
2986+
lgrp: ::lgrp_id_t,
2987+
tpe: ::lgrp_mem_size_flag_t,
2988+
content: ::lgrp_content_t,
2989+
) -> ::lgrp_mem_size_t;
2990+
pub fn lgrp_nlgrps(cookie: ::lgrp_cookie_t) -> ::c_int;
2991+
pub fn lgrp_view(cookie: ::lgrp_cookie_t) -> ::lgrp_view_t;
2992+
}
2993+
29282994
mod compat;
29292995
pub use self::compat::*;
29302996

0 commit comments

Comments
 (0)