Skip to content

Commit 9863d56

Browse files
committed
Merge pull request rust-lang#105 from alexcrichton/fix-bsd
Fix compiles on various BSDs
2 parents 3e1791c + 37b7142 commit 9863d56

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

src/lib.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,24 @@
5454
#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc(
5555
html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-msvc"
5656
))]
57-
#![cfg_attr(all(target_os = "android"), doc(
57+
#![cfg_attr(target_os = "android", doc(
5858
html_root_url = "https://doc.rust-lang.org/libc/arm-linux-androideabi"
5959
))]
60+
#![cfg_attr(target_os = "freebsd", doc(
61+
html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-freebsd"
62+
))]
63+
#![cfg_attr(target_os = "openbsd", doc(
64+
html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-openbsd"
65+
))]
66+
#![cfg_attr(target_os = "bitrig", doc(
67+
html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-bitrig"
68+
))]
69+
#![cfg_attr(target_os = "netbsd", doc(
70+
html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-netbsd"
71+
))]
72+
#![cfg_attr(target_os = "dragonfly", doc(
73+
html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly"
74+
))]
6075

6176
// Attributes needed when building as part of the standard library
6277
#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute))]

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub type pthread_rwlock_t = *mut ::c_void;
1414
pub type pthread_key_t = ::c_int;
1515
pub type fsblkcnt_t = ::c_uint;
1616
pub type fsfilcnt_t = ::c_uint;
17+
pub type tcflag_t = ::c_uint;
18+
pub type speed_t = ::c_uint;
1719

1820
pub enum timezone {}
1921

@@ -120,6 +122,16 @@ s! {
120122
pub sin_addr: ::in_addr,
121123
pub sin_zero: [::c_char; 8],
122124
}
125+
126+
pub struct termios {
127+
pub c_iflag: ::tcflag_t,
128+
pub c_oflag: ::tcflag_t,
129+
pub c_cflag: ::tcflag_t,
130+
pub c_lflag: ::tcflag_t,
131+
pub c_cc: [::cc_t; ::NCCS],
132+
pub c_ispeed: ::speed_t,
133+
pub c_ospeed: ::speed_t,
134+
}
123135
}
124136

125137
pub const EXIT_FAILURE: ::c_int = 1;
@@ -547,8 +559,8 @@ pub const HW_AVAILCPU: ::c_int = 25;
547559

548560
extern {
549561
pub fn mincore(addr: *const ::c_void, len: ::size_t,
550-
vec: *mut c_char) -> ::c_int;
551-
pub fn sysctlnametomib(name: *const c_char,
562+
vec: *mut ::c_char) -> ::c_int;
563+
pub fn sysctlnametomib(name: *const ::c_char,
552564
mibp: *mut ::c_int,
553565
sizep: *mut ::size_t)
554566
-> ::c_int;

src/unix/bsd/openbsdlike/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub type nlink_t = ::uint32_t;
66
pub type ino_t = ::uint64_t;
77
pub type pthread_key_t = ::c_int;
88
pub type rlim_t = u64;
9+
pub type speed_t = ::c_uint;
10+
pub type tcflag_t = ::c_uint;
911

1012
pub enum timezone {}
1113

@@ -36,6 +38,16 @@ s! {
3638
pub sin_addr: ::in_addr,
3739
pub sin_zero: [::int8_t; 8],
3840
}
41+
42+
pub struct termios {
43+
pub c_iflag: ::tcflag_t,
44+
pub c_oflag: ::tcflag_t,
45+
pub c_cflag: ::tcflag_t,
46+
pub c_lflag: ::tcflag_t,
47+
pub c_cc: [::cc_t; ::NCCS],
48+
pub c_ispeed: ::c_int,
49+
pub c_ospeed: ::c_int,
50+
}
3951
}
4052

4153
pub const EXIT_FAILURE : ::c_int = 1;

src/unix/bsd/openbsdlike/netbsd.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ pub type dev_t = u64;
44
pub type blksize_t = ::int32_t;
55
pub type fsblkcnt_t = ::uint64_t;
66
pub type fsfilcnt_t = ::uint64_t;
7-
pub type speed_t = ::c_uint;
8-
pub type tcflag_t = ::c_uint;
97

108
s! {
119
pub struct dirent {
@@ -184,16 +182,6 @@ s! {
184182
pub dqb_btime: ::int32_t,
185183
pub dqb_itime: ::int32_t,
186184
}
187-
188-
pub struct termios {
189-
pub c_iflag: ::tcflag_t,
190-
pub c_oflag: ::tcflag_t,
191-
pub c_cflag: ::tcflag_t,
192-
pub c_lflag: ::tcflag_t,
193-
pub c_cc: [::cc_t; ::NCCS],
194-
pub c_ispeed: ::c_int,
195-
pub c_ospeed: ::c_int,
196-
}
197185
}
198186

199187
pub const O_CLOEXEC: ::c_int = 0x400000;

0 commit comments

Comments
 (0)