Skip to content

Commit 6492988

Browse files
committed
Auto merge of #2451 - GuillaumeGomez:freebsd-items, r=JohnTitor
Freebsd items
2 parents 5d7f90c + b540e1b commit 6492988

File tree

9 files changed

+558
-18
lines changed

9 files changed

+558
-18
lines changed

.github/workflows/bors.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ jobs:
258258
- uses: actions/checkout@v2
259259
- name: Setup Rust toolchain
260260
# Should update the semverver revision in semver.sh if we touch nightly ver.
261-
run: TOOLCHAIN=nightly-2021-07-23 sh ./ci/install-rust.sh
261+
run: TOOLCHAIN=nightly-2021-09-30 sh ./ci/install-rust.sh
262262
- name: Check breaking changes
263263
run: sh ci/semver.sh linux
264264

@@ -270,7 +270,7 @@ jobs:
270270
- uses: actions/checkout@v2
271271
- name: Setup Rust toolchain
272272
# Pin nightly version to make semverver compilable.
273-
run: TOOLCHAIN=nightly-2021-07-23 sh ./ci/install-rust.sh
273+
run: TOOLCHAIN=nightly-2021-09-30 sh ./ci/install-rust.sh
274274
- name: Check breaking changes
275275
run: sh ci/semver.sh macos
276276

ci/semver.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fi
1616
rustup component add rustc-dev llvm-tools-preview
1717

1818
# Should update the nightly version in bors CI config if we touch this.
19-
cargo install semverver --version=0.1.47
19+
cargo install semverver --version=0.1.48
2020

2121
TARGETS=
2222
case "${OS}" in

libc-test/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ default-features = false
1818
[build-dependencies]
1919
cc = "1.0.61"
2020
# FIXME: Use fork ctest until the maintainer gets back.
21-
ctest2 = "0.4"
21+
ctest2 = "0.4.2"
2222

2323
[features]
2424
default = [ "std" ]

libc-test/build.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,7 @@ fn test_freebsd(target: &str) {
18401840
"sys/times.h",
18411841
"sys/timex.h",
18421842
"sys/types.h",
1843+
"kvm.h", // must be after "sys/types.h"
18431844
"sys/ucontext.h",
18441845
"sys/uio.h",
18451846
"sys/ktrace.h",
@@ -1994,6 +1995,16 @@ fn test_freebsd(target: &str) {
19941995
}
19951996
});
19961997

1998+
cfg.skip_type(move |ty| {
1999+
match ty {
2000+
// the struct "__kvm" is quite tricky to bind so since we only use a pointer to it
2001+
// for now, it doesn't matter too much...
2002+
"kvm_t" => true,
2003+
2004+
_ => false,
2005+
}
2006+
});
2007+
19972008
cfg.skip_struct(move |ty| {
19982009
if ty.starts_with("__c_anonymous_") {
19992010
return true;
@@ -2087,6 +2098,21 @@ fn test_freebsd(target: &str) {
20872098
// a_un field is a union
20882099
("Elf32_Auxinfo", "a_un") => true,
20892100
("Elf64_Auxinfo", "a_un") => true,
2101+
2102+
// FIXME: structs too complicated to bind for now...
2103+
("kinfo_proc", "ki_paddr") => true,
2104+
("kinfo_proc", "ki_addr") => true,
2105+
("kinfo_proc", "ki_tracep") => true,
2106+
("kinfo_proc", "ki_textvp") => true,
2107+
("kinfo_proc", "ki_fd") => true,
2108+
("kinfo_proc", "ki_vmspace") => true,
2109+
("kinfo_proc", "ki_pcb") => true,
2110+
("kinfo_proc", "ki_tdaddr") => true,
2111+
("kinfo_proc", "ki_pd") => true,
2112+
2113+
// We ignore this field because we needed to use a hack in order to make rust 1.19
2114+
// happy...
2115+
("kinfo_proc", "ki_sparestrings") => true,
20902116
_ => false,
20912117
}
20922118
});

src/unix/bsd/apple/mod.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub type host_flavor_t = integer_t;
5252
pub type host_info64_t = *mut integer_t;
5353
pub type processor_flavor_t = ::c_int;
5454
pub type thread_flavor_t = natural_t;
55-
pub type thread_inspect_t = mach_port_t;
55+
pub type thread_inspect_t = ::mach_port_t;
5656
pub type policy_t = ::c_int;
5757
pub type mach_vm_address_t = u64;
5858
pub type mach_vm_offset_t = u64;
@@ -90,7 +90,7 @@ pub type thread_identifier_info_data_t = thread_identifier_info;
9090
pub type thread_extended_info_t = *mut thread_extended_info;
9191
pub type thread_extended_info_data_t = thread_extended_info;
9292

93-
pub type thread_t = mach_port_t;
93+
pub type thread_t = ::mach_port_t;
9494
pub type thread_policy_flavor_t = natural_t;
9595
pub type thread_policy_t = *mut integer_t;
9696
pub type thread_latency_qos_t = integer_t;
@@ -120,7 +120,7 @@ pub type vm_statistics_data_t = vm_statistics;
120120
pub type vm_statistics64_t = *mut vm_statistics64;
121121
pub type vm_statistics64_data_t = vm_statistics64;
122122

123-
pub type task_t = mach_port_t;
123+
pub type task_t = ::mach_port_t;
124124

125125
pub type sysdir_search_path_enumeration_state = ::c_uint;
126126

@@ -5293,11 +5293,14 @@ extern "C" {
52935293
out_processor_infoCnt: *mut mach_msg_type_number_t,
52945294
) -> ::kern_return_t;
52955295

5296-
pub static mut mach_task_self_: mach_port_t;
5297-
pub fn task_for_pid(host: mach_port_t, pid: ::pid_t, task: *mut mach_port_t)
5298-
-> ::kern_return_t;
5296+
pub static mut mach_task_self_: ::mach_port_t;
5297+
pub fn task_for_pid(
5298+
host: ::mach_port_t,
5299+
pid: ::pid_t,
5300+
task: *mut ::mach_port_t,
5301+
) -> ::kern_return_t;
52995302
pub fn task_info(
5300-
host: mach_port_t,
5303+
host: ::mach_port_t,
53015304
flavor: task_flavor_t,
53025305
task_info_out: task_info_t,
53035306
task_info_count: *mut mach_msg_type_number_t,
@@ -5322,7 +5325,7 @@ extern "C" {
53225325
pub static vm_page_size: vm_size_t;
53235326
}
53245327

5325-
pub unsafe fn mach_task_self() -> mach_port_t {
5328+
pub unsafe fn mach_task_self() -> ::mach_port_t {
53265329
mach_task_self_
53275330
}
53285331

src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ cfg_if! {
191191

192192
pub const ELAST: ::c_int = 96;
193193
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
194+
pub const KI_NSPARE_PTR: usize = 6;
194195

195196
extern "C" {
196197
// Return type ::c_int was removed in FreeBSD 12

src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ s! {
2626
pub udata: *mut ::c_void,
2727
pub ext: [u64; 4],
2828
}
29+
30+
pub struct kvm_page {
31+
pub version: ::c_uint,
32+
pub paddr: ::c_ulong,
33+
pub kmap_vaddr: ::c_ulong,
34+
pub dmap_vaddr: ::c_ulong,
35+
pub prot: ::vm_prot_t,
36+
pub offset: ::u_long,
37+
pub len: ::size_t,
38+
}
2939
}
3040

3141
s_no_extra_traits! {
@@ -212,6 +222,10 @@ pub const SO_DOMAIN: ::c_int = 0x1019;
212222
pub const EINTEGRITY: ::c_int = 97;
213223
pub const ELAST: ::c_int = 97;
214224

225+
/// max length of devicename
226+
pub const SPECNAMELEN: ::c_int = 63;
227+
pub const KI_NSPARE_PTR: usize = 6;
228+
215229
extern "C" {
216230
pub fn setgrent();
217231
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;

src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs

+23
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ pub type nlink_t = u64;
44
pub type dev_t = u64;
55
pub type ino_t = ::c_ulong;
66
pub type shmatt_t = ::c_uint;
7+
pub type kpaddr_t = u64;
8+
pub type kssize_t = i64;
79

810
s! {
911
pub struct shmid_ds {
@@ -37,6 +39,16 @@ s! {
3739
pub sc_ngroups: ::c_int,
3840
pub sc_groups: [::gid_t; 1],
3941
}
42+
43+
pub struct kvm_page {
44+
pub kp_version: ::u_int,
45+
pub kp_paddr: ::kpaddr_t,
46+
pub kp_kmap_vaddr: ::kvaddr_t,
47+
pub kp_dmap_vaddr: ::kvaddr_t,
48+
pub kp_prot: ::vm_prot_t,
49+
pub kp_offset: ::off_t,
50+
pub kp_len: ::size_t,
51+
}
4052
}
4153

4254
s_no_extra_traits! {
@@ -228,6 +240,12 @@ pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
228240
pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3;
229241
pub const SCM_CREDS2: ::c_int = 0x08;
230242

243+
pub const KF_TYPE_EVENTFD: ::c_int = 13;
244+
245+
/// max length of devicename
246+
pub const SPECNAMELEN: ::c_int = 255;
247+
pub const KI_NSPARE_PTR: usize = 5;
248+
231249
f! {
232250
pub fn SOCKCRED2SIZE(ngrps: usize) -> usize {
233251
let ngrps = if ngrps > 0 {
@@ -269,6 +287,11 @@ extern "C" {
269287
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
270288
}
271289

290+
#[link(name = "kvm")]
291+
extern "C" {
292+
pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t;
293+
}
294+
272295
cfg_if! {
273296
if #[cfg(any(target_arch = "x86_64",
274297
target_arch = "aarch64"))] {

0 commit comments

Comments
 (0)