Skip to content

Commit 0ba8571

Browse files
committed
Merge pull request #134 from alexcrichton/merge
Merging a number of PRs into one
2 parents fb83189 + 6cf54d5 commit 0ba8571

File tree

19 files changed

+298
-81
lines changed

19 files changed

+298
-81
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ matrix:
3434
env: TARGET=arm-unknown-linux-gnueabihf
3535
rust: nightly
3636
- os: linux
37-
env: TARGET=mips-unknown-linux-gnu
37+
env: TARGET=mips-unknown-linux-gnu DOCKER=alexcrichton/rust-libc-mips:2016-01-10
3838
rust: nightly
3939
- os: linux
4040
env: TARGET=aarch64-unknown-linux-gnu

ci/cargo-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ linker = "arm-linux-androideabi-gcc"
77
linker = "arm-linux-gnueabihf-gcc-4.7"
88

99
[target.mips-unknown-linux-gnu]
10-
linker = "mips-linux-gnu-gcc"
10+
linker = "mips-linux-gnu-gcc-5"
1111

1212
[target.aarch64-unknown-linux-gnu]
1313
linker = "aarch64-linux-gnu-gcc"

ci/mips/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ubuntu:15.10
2+
3+
RUN apt-get update
4+
RUN apt-get install -y --force-yes --no-install-recommends \
5+
software-properties-common
6+
RUN add-apt-repository ppa:angelsl/mips-cross
7+
RUN apt-get update
8+
RUN apt-get install -y --force-yes --no-install-recommends \
9+
gcc-5-mips-linux-gnu libc6-dev-mips-cross \
10+
gcc-5-mipsel-linux-gnu libc6-dev-mipsel-cross
11+
RUN apt-get install -y --force-yes --no-install-recommends \
12+
build-essential qemu-user

ci/run-travis.sh

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ if [ "$TRAVIS" = "true" ]; then
3737
;;
3838

3939
*)
40-
# Download the rustlib folder from the relevant portion of main distribution's
41-
# tarballs.
40+
# Download the rustlib folder from the relevant portion of main
41+
# distribution's tarballs.
4242
dir=rust-std-$TARGET
4343
pkg=rust-std
4444
if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then
@@ -58,12 +58,24 @@ fi
5858
# travis has (sharing it via `-v`) and otherwise the tests run entirely within
5959
# the container.
6060
if [ "$DOCKER" != "" ]; then
61+
args=""
62+
63+
case "$TARGET" in
64+
mips-unknown-linux-gnu)
65+
args="$args -e CC=mips-linux-gnu-gcc-5"
66+
;;
67+
68+
*)
69+
;;
70+
esac
71+
6172
exec docker run \
6273
--entrypoint bash \
6374
-v `rustc --print sysroot`:/usr/local:ro \
6475
-v `pwd`:/checkout \
6576
-e LD_LIBRARY_PATH=/usr/local/lib \
6677
-e CARGO_TARGET_DIR=/tmp \
78+
$args \
6779
-w /checkout \
6880
-it $DOCKER \
6981
ci/run.sh $TARGET
@@ -88,19 +100,6 @@ case "$TARGET" in
88100
*-apple-ios)
89101
;;
90102

91-
mips-unknown-linux-gnu)
92-
# Download pre-built and custom MIPS libs and then also instsall the MIPS
93-
# compiler according to this post:
94-
# http://sathisharada.blogspot.com/2014_10_01_archive.html
95-
echo 'deb http://ftp.de.debian.org/debian squeeze main' | \
96-
sudo tee -a /etc/apt/sources.list
97-
echo 'deb http://www.emdebian.org/debian/ squeeze main' | \
98-
sudo tee -a /etc/apt/sources.list
99-
install emdebian-archive-keyring
100-
install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes
101-
export CC=mips-linux-gnu-gcc
102-
;;
103-
104103
*)
105104
# clang has better error messages and implements alignof more broadly
106105
export CC=clang

ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ case "$TARGET" in
3131
;;
3232

3333
mips-unknown-linux-gnu)
34-
qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/libc-test
34+
qemu-mips -L /usr/mips-linux-gnu /tmp/$TARGET/debug/libc-test
3535
;;
3636

3737
aarch64-unknown-linux-gnu)

libc-test/build.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ fn main() {
1616
let freebsd = target.contains("freebsd");
1717
let mips = target.contains("mips");
1818
let netbsd = target.contains("netbsd");
19+
let openbsd = target.contains("openbsd");
1920
let rumprun = target.contains("rumprun");
20-
let bsdlike = freebsd || apple || netbsd;
21+
let bsdlike = freebsd || apple || netbsd || openbsd;
2122
let mut cfg = ctest::TestGenerator::new();
2223

2324
// Pull in extra goodies on linux/mingw
@@ -61,6 +62,9 @@ fn main() {
6162
} else {
6263
cfg.header("ctype.h");
6364
cfg.header("dirent.h");
65+
if openbsd {
66+
cfg.header("sys/socket.h");
67+
}
6468
cfg.header("net/if.h");
6569
cfg.header("netdb.h");
6670
cfg.header("netinet/in.h");
@@ -88,6 +92,7 @@ fn main() {
8892
cfg.header("sys/uio.h");
8993
cfg.header("sched.h");
9094
cfg.header("termios.h");
95+
cfg.header("poll.h");
9196
}
9297

9398
if android {
@@ -96,13 +101,15 @@ fn main() {
96101
} else if !windows {
97102
cfg.header("glob.h");
98103
cfg.header("ifaddrs.h");
99-
cfg.header("sys/quota.h");
104+
if !openbsd {
105+
cfg.header("sys/quota.h");
106+
}
100107
cfg.header("sys/statvfs.h");
101108

102109
if !musl {
103110
cfg.header("sys/sysctl.h");
104111

105-
if !netbsd {
112+
if !netbsd && !openbsd {
106113
cfg.header("execinfo.h");
107114
}
108115
}
@@ -161,6 +168,13 @@ fn main() {
161168
cfg.header("sys/ioctl_compat.h");
162169
}
163170

171+
if openbsd {
172+
cfg.header("ufs/ufs/quota.h");
173+
cfg.header("rpcsvc/rex.h");
174+
cfg.header("pthread_np.h");
175+
cfg.header("sys/syscall.h");
176+
}
177+
164178
cfg.type_name(move |ty, is_struct| {
165179
match ty {
166180
// Just pass all these through, no need for a "struct" prefix
@@ -200,6 +214,8 @@ fn main() {
200214
let target2 = target.clone();
201215
cfg.field_name(move |struct_, field| {
202216
match field {
217+
"st_birthtime" if openbsd && struct_ == "stat" => "__st_birthtime".to_string(),
218+
"st_birthtime_nsec" if openbsd && struct_ == "stat" => "__st_birthtimensec".to_string(),
203219
// Our stat *_nsec fields normally don't actually exist but are part
204220
// of a timeval struct
205221
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
@@ -303,7 +319,7 @@ fn main() {
303319
"strerror_r" if linux => true, // actually xpg-something-or-other
304320

305321
// typed 2nd arg on linux and android
306-
"gettimeofday" if linux || android || freebsd => true,
322+
"gettimeofday" if linux || android || freebsd || openbsd => true,
307323

308324
// not declared in newer android toolchains
309325
"getdtablesize" if android => true,

src/unix/bsd/apple/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,16 @@ pub const VT1: ::c_int = 0x00010000;
809809
pub const IUTF8: ::tcflag_t = 0x00004000;
810810
pub const CRTSCTS: ::tcflag_t = 0x00030000;
811811

812+
pub const NI_MAXHOST: ::socklen_t = 1025;
813+
812814
extern {
815+
pub fn getnameinfo(sa: *const ::sockaddr,
816+
salen: ::socklen_t,
817+
host: *mut ::c_char,
818+
hostlen: ::socklen_t,
819+
serv: *mut ::c_char,
820+
sevlen: ::socklen_t,
821+
flags: ::c_int) -> ::c_int;
813822
pub fn mincore(addr: *const ::c_void, len: ::size_t,
814823
vec: *mut ::c_char) -> ::c_int;
815824
pub fn sysctlnametomib(name: *const ::c_char,

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,16 @@ pub const ST_NOSUID: ::c_ulong = 2;
557557

558558
pub const HW_AVAILCPU: ::c_int = 25;
559559

560+
pub const NI_MAXHOST: ::size_t = 1025;
561+
560562
extern {
563+
pub fn getnameinfo(sa: *const ::sockaddr,
564+
salen: ::socklen_t,
565+
host: *mut ::c_char,
566+
hostlen: ::size_t,
567+
serv: *mut ::c_char,
568+
servlen: ::size_t,
569+
flags: ::c_int) -> ::c_int;
561570
pub fn mincore(addr: *const ::c_void, len: ::size_t,
562571
vec: *mut ::c_char) -> ::c_int;
563572
pub fn sysctlnametomib(name: *const ::c_char,

src/unix/bsd/mod.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub type blkcnt_t = i64;
66
pub type socklen_t = u32;
77
pub type sa_family_t = u8;
88
pub type pthread_t = ::uintptr_t;
9+
pub type nfds_t = ::c_uint;
910

1011
s! {
1112
pub struct sockaddr {
@@ -43,7 +44,8 @@ s! {
4344

4445
#[cfg(not(any(target_os = "macos",
4546
target_os = "ios",
46-
target_os = "netbsd")))]
47+
target_os = "netbsd",
48+
target_os = "openbsd")))]
4749
pub pw_fields: ::c_int,
4850
}
4951

@@ -146,8 +148,6 @@ pub const IPV6_V6ONLY: ::c_int = 27;
146148

147149
pub const ST_RDONLY: ::c_ulong = 1;
148150

149-
pub const NI_MAXHOST: ::socklen_t = 1025;
150-
151151
pub const CTL_HW: ::c_int = 6;
152152
pub const HW_NCPU: ::c_int = 3;
153153

@@ -321,13 +321,6 @@ extern {
321321
pub fn setgroups(ngroups: ::c_int,
322322
ptr: *const ::gid_t) -> ::c_int;
323323
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
324-
pub fn getnameinfo(sa: *const ::sockaddr,
325-
salen: ::socklen_t,
326-
host: *mut ::c_char,
327-
hostlen: ::socklen_t,
328-
serv: *mut ::c_char,
329-
sevlen: ::socklen_t,
330-
flags: ::c_int) -> ::c_int;
331324
pub fn kqueue() -> ::c_int;
332325
pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
333326
pub fn syscall(num: ::c_int, ...) -> ::c_int;

src/unix/bsd/openbsdlike/bitrig.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ s! {
9999
pub si_errno: ::c_int,
100100
pub si_addr: *mut ::c_void
101101
}
102+
103+
pub struct Dl_info {
104+
pub dli_fname: *const ::c_char,
105+
pub dli_fbase: *mut ::c_void,
106+
pub dli_sname: *const ::c_char,
107+
pub dli_saddr: *mut ::c_void,
108+
}
102109
}
103110

104111
pub const O_CLOEXEC: ::c_int = 0x10000;
@@ -208,7 +215,18 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
208215
pub const HW_AVAILCPU: ::c_int = 25;
209216
pub const KERN_PROC_ARGS: ::c_int = 55;
210217

218+
pub const TMP_MAX : ::c_uint = 0x7fffffff;
219+
220+
pub const NI_MAXHOST: ::size_t = 256;
221+
211222
extern {
223+
pub fn getnameinfo(sa: *const ::sockaddr,
224+
salen: ::socklen_t,
225+
host: *mut ::c_char,
226+
hostlen: ::size_t,
227+
serv: *mut ::c_char,
228+
servlen: ::size_t,
229+
flags: ::c_int) -> ::c_int;
212230
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
213231
-> ::c_int;
214232
pub fn sysctl(name: *mut ::c_int,

src/unix/bsd/openbsdlike/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ s! {
2424
pub ss_flags: ::c_int,
2525
}
2626

27-
pub struct Dl_info {
28-
pub dli_fname: *const ::c_char,
29-
pub dli_fbase: *mut ::c_void,
30-
pub dli_sname: *const ::c_char,
31-
pub dli_saddr: *const ::c_void,
32-
}
33-
3427
pub struct sockaddr_in {
3528
pub sin_len: u8,
3629
pub sin_family: ::sa_family_t,
@@ -64,7 +57,6 @@ pub const BUFSIZ : ::c_uint = 1024;
6457
pub const FOPEN_MAX : ::c_uint = 20;
6558
pub const FILENAME_MAX : ::c_uint = 1024;
6659
pub const L_tmpnam : ::c_uint = 1024;
67-
pub const TMP_MAX : ::c_uint = 308915776;
6860
pub const O_RDONLY : ::c_int = 0;
6961
pub const O_WRONLY : ::c_int = 1;
7062
pub const O_RDWR : ::c_int = 2;
@@ -368,13 +360,12 @@ extern {
368360
#[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")]
369361
pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
370362
pub fn __errno() -> *mut ::c_int;
371-
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::size_t) -> ::size_t;
372363
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
373364
-> ::c_int;
374-
pub fn pthread_main_np() -> ::c_uint;
365+
pub fn pthread_main_np() -> ::c_int;
375366
pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
376367
pub fn pthread_stackseg_np(thread: ::pthread_t,
377-
sinfo: *mut ::stack_t) -> ::c_uint;
368+
sinfo: *mut ::stack_t) -> ::c_int;
378369
pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
379370
}
380371

src/unix/bsd/openbsdlike/netbsd.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ s! {
182182
pub dqb_btime: ::int32_t,
183183
pub dqb_itime: ::int32_t,
184184
}
185+
186+
pub struct Dl_info {
187+
pub dli_fname: *const ::c_char,
188+
pub dli_fbase: *mut ::c_void,
189+
pub dli_sname: *const ::c_char,
190+
pub dli_saddr: *const ::c_void,
191+
}
185192
}
186193

187194
pub const O_CLOEXEC: ::c_int = 0x400000;
@@ -313,7 +320,18 @@ pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000;
313320

314321
pub const CRTSCTS: ::tcflag_t = 0x00010000;
315322

323+
pub const TMP_MAX : ::c_uint = 308915776;
324+
325+
pub const NI_MAXHOST: ::socklen_t = 1025;
326+
316327
extern {
328+
pub fn getnameinfo(sa: *const ::sockaddr,
329+
salen: ::socklen_t,
330+
host: *mut ::c_char,
331+
hostlen: ::socklen_t,
332+
serv: *mut ::c_char,
333+
sevlen: ::socklen_t,
334+
flags: ::c_int) -> ::c_int;
317335
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
318336
-> ::c_int;
319337
pub fn sysctl(name: *const ::c_int,

0 commit comments

Comments
 (0)