Skip to content

Commit 4fc045c

Browse files
authored
Merge pull request #1630 from myfreeweb/freebsd-mcontext
2 parents 16f8b94 + 962b984 commit 4fc045c

File tree

17 files changed

+334
-85
lines changed

17 files changed

+334
-85
lines changed

libc-test/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,7 @@ fn test_freebsd(target: &str) {
17031703
"sys/times.h",
17041704
"sys/timex.h",
17051705
"sys/types.h",
1706+
"sys/ucontext.h",
17061707
"sys/uio.h",
17071708
"sys/un.h",
17081709
"sys/utsname.h",
@@ -1809,6 +1810,22 @@ fn test_freebsd(target: &str) {
18091810
// base system anyway.
18101811
"CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "USER_MAXID" => true,
18111812

1813+
// This was renamed in FreeBSD 12.2 and 13 (r352486).
1814+
"CTL_UNSPEC" | "CTL_SYSCTL" => true,
1815+
1816+
// These were added in FreeBSD 12.2 and 13 (r352486),
1817+
// but they are just names for magic numbers that existed for ages.
1818+
"CTL_SYSCTL_DEBUG"
1819+
| "CTL_SYSCTL_NAME"
1820+
| "CTL_SYSCTL_NEXT"
1821+
| "CTL_SYSCTL_NAME2OID"
1822+
| "CTL_SYSCTL_OIDFMT"
1823+
| "CTL_SYSCTL_OIDDESCR"
1824+
| "CTL_SYSCTL_OIDLABEL" => true,
1825+
1826+
// This was renamed in FreeBSD 12.2 and 13 (r350749).
1827+
"IPPROTO_SEP" | "IPPROTO_DCCP" => true,
1828+
18121829
_ => false,
18131830
}
18141831
});

src/unix/bsd/apple/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//!
33
//! This covers *-apple-* triples currently
44
pub type c_char = i8;
5+
pub type wchar_t = i32;
56
pub type clock_t = c_ulong;
67
pub type time_t = c_long;
78
pub type suseconds_t = i32;

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub type dev_t = u32;
22
pub type c_char = i8;
3+
pub type wchar_t = i32;
34
pub type clock_t = u64;
45
pub type ino_t = u64;
56
pub type lwpid_t = i32;
Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
11
pub type c_char = u8;
22
pub type c_long = i64;
33
pub type c_ulong = u64;
4+
pub type wchar_t = u32;
45
pub type time_t = i64;
56
pub type suseconds_t = i64;
6-
7-
s! {
8-
pub struct stat {
9-
pub st_dev: ::dev_t,
10-
pub st_ino: ::ino_t,
11-
pub st_mode: ::mode_t,
12-
pub st_nlink: ::nlink_t,
13-
pub st_uid: ::uid_t,
14-
pub st_gid: ::gid_t,
15-
pub st_rdev: ::dev_t,
16-
pub st_atime: ::time_t,
17-
pub st_atime_nsec: ::c_long,
18-
pub st_mtime: ::time_t,
19-
pub st_mtime_nsec: ::c_long,
20-
pub st_ctime: ::time_t,
21-
pub st_ctime_nsec: ::c_long,
22-
pub st_size: ::off_t,
23-
pub st_blocks: ::blkcnt_t,
24-
pub st_blksize: ::blksize_t,
25-
pub st_flags: ::fflags_t,
26-
pub st_gen: u32,
27-
pub st_lspare: i32,
28-
pub st_birthtime: ::time_t,
29-
pub st_birthtime_nsec: ::c_long,
30-
}
31-
}
7+
pub type register_t = i64;
328

339
// should be pub(crate), but that requires Rust 1.18.0
3410
cfg_if! {
@@ -42,3 +18,4 @@ cfg_if! {
4218
}
4319

4420
pub const MAP_32BIT: ::c_int = 0x00080000;
21+
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4

src/unix/bsd/freebsdlike/freebsd/arm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
pub type c_char = u8;
22
pub type c_long = i32;
33
pub type c_ulong = u32;
4+
pub type wchar_t = u32;
45
pub type time_t = i64;
56
pub type suseconds_t = i32;
7+
pub type register_t = i32;
68

79
s! {
810
pub struct stat {
@@ -45,3 +47,4 @@ cfg_if! {
4547
}
4648
}
4749
pub const MAP_32BIT: ::c_int = 0x00080000;
50+
pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ extern "C" {
217217
}
218218

219219
cfg_if! {
220-
if #[cfg(target_arch = "x86_64")] {
221-
mod x86_64;
222-
pub use self::x86_64::*;
220+
if #[cfg(any(target_arch = "x86_64",
221+
target_arch = "aarch64"))] {
222+
mod b64;
223+
pub use self::b64::*;
223224
}
224225
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ extern "C" {
217217
}
218218

219219
cfg_if! {
220-
if #[cfg(target_arch = "x86_64")] {
221-
mod x86_64;
222-
pub use self::x86_64::*;
220+
if #[cfg(any(target_arch = "x86_64",
221+
target_arch = "aarch64"))] {
222+
mod b64;
223+
pub use self::b64::*;
223224
}
224225
}

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,17 @@ pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0;
322322
pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
323323
pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
324324

325-
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
326-
pub const PTHREAD_STACK_MIN: ::size_t = 2048;
325+
cfg_if! {
326+
if #[cfg(any(freebsd10, freebsd11, freebsd12))] {
327+
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
328+
} else {
329+
pub const RAND_MAX: ::c_int = 0x7fff_ffff;
330+
}
331+
}
332+
333+
pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ;
327334
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
328-
pub const SIGSTKSZ: ::size_t = 34816;
335+
pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + 32768;
329336
pub const SF_NODISKIO: ::c_int = 0x00000001;
330337
pub const SF_MNOWAIT: ::c_int = 0x00000002;
331338
pub const SF_SYNC: ::c_int = 0x00000004;
@@ -442,7 +449,13 @@ pub const CLOCK_SECOND: ::clockid_t = 13;
442449
pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14;
443450
pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15;
444451

452+
#[doc(hidden)]
453+
#[deprecated(
454+
since = "0.2.72",
455+
note = "CTL_UNSPEC is deprecated. Use CTL_SYSCTL instead"
456+
)]
445457
pub const CTL_UNSPEC: ::c_int = 0;
458+
pub const CTL_SYSCTL: ::c_int = 0;
446459
pub const CTL_KERN: ::c_int = 1;
447460
pub const CTL_VM: ::c_int = 2;
448461
pub const CTL_VFS: ::c_int = 3;
@@ -452,6 +465,13 @@ pub const CTL_HW: ::c_int = 6;
452465
pub const CTL_MACHDEP: ::c_int = 7;
453466
pub const CTL_USER: ::c_int = 8;
454467
pub const CTL_P1003_1B: ::c_int = 9;
468+
pub const CTL_SYSCTL_DEBUG: ::c_int = 0;
469+
pub const CTL_SYSCTL_NAME: ::c_int = 1;
470+
pub const CTL_SYSCTL_NEXT: ::c_int = 2;
471+
pub const CTL_SYSCTL_NAME2OID: ::c_int = 3;
472+
pub const CTL_SYSCTL_OIDFMT: ::c_int = 4;
473+
pub const CTL_SYSCTL_OIDDESCR: ::c_int = 5;
474+
pub const CTL_SYSCTL_OIDLABEL: ::c_int = 6;
455475
pub const KERN_OSTYPE: ::c_int = 1;
456476
pub const KERN_OSRELEASE: ::c_int = 2;
457477
pub const KERN_OSREV: ::c_int = 3;
@@ -769,8 +789,14 @@ pub const IPPROTO_BLT: ::c_int = 30;
769789
pub const IPPROTO_NSP: ::c_int = 31;
770790
/// Merit Internodal
771791
pub const IPPROTO_INP: ::c_int = 32;
772-
/// Sequential Exchange
792+
#[doc(hidden)]
793+
#[deprecated(
794+
since = "0.2.72",
795+
note = "IPPROTO_SEP is deprecated. Use IPPROTO_DCCP instead"
796+
)]
773797
pub const IPPROTO_SEP: ::c_int = 33;
798+
/// Datagram Congestion Control Protocol
799+
pub const IPPROTO_DCCP: ::c_int = 33;
774800
/// Third Party Connect
775801
pub const IPPROTO_3PC: ::c_int = 34;
776802
/// InterDomain Policy Routing

0 commit comments

Comments
 (0)