Skip to content

Commit 0ac0bc0

Browse files
committed
Merge pull request rust-lang#93 from alexcrichton/nix-additions
Add a load of constants/definitions from nix
2 parents 4920c7e + 8dce9ad commit 0ac0bc0

File tree

21 files changed

+1538
-38
lines changed

21 files changed

+1538
-38
lines changed

ci/run-travis.sh

+27-23
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,38 @@ DATE=$(echo $TRAVIS_RUST_VERSION | sed s/nightly-//)
2020
EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/$DATE
2121

2222
install() {
23-
sudo apt-get update
24-
sudo apt-get install -y $@
23+
if [ "$TRAVIS" = "true" ]; then
24+
sudo apt-get update
25+
sudo apt-get install -y $@
26+
fi
2527
}
2628

2729
mkdir -p .cargo
2830
cp ci/cargo-config .cargo/config
2931

30-
case "$TARGET" in
31-
*-apple-ios | *-rumprun-*)
32-
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | \
33-
tar xzf - -C `rustc --print sysroot`/lib/rustlib
34-
;;
35-
36-
*)
37-
# Download the rustlib folder from the relevant portion of main distribution's
38-
# tarballs.
39-
dir=rust-std-$TARGET
40-
pkg=rust-std
41-
if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then
42-
pkg=rust
43-
dir=rustc
44-
fi
45-
curl -s $MAIN_TARGETS/$pkg-$TRAVIS_RUST_VERSION-$TARGET.tar.gz | \
46-
tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \
47-
$pkg-$TRAVIS_RUST_VERSION-$TARGET/$dir/lib/rustlib/$TARGET
48-
;;
49-
50-
esac
32+
if [ "$TRAVIS" = "true" ]; then
33+
case "$TARGET" in
34+
*-apple-ios | *-rumprun-*)
35+
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | \
36+
tar xzf - -C `rustc --print sysroot`/lib/rustlib
37+
;;
38+
39+
*)
40+
# Download the rustlib folder from the relevant portion of main distribution's
41+
# tarballs.
42+
dir=rust-std-$TARGET
43+
pkg=rust-std
44+
if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then
45+
pkg=rust
46+
dir=rustc
47+
fi
48+
curl -s $MAIN_TARGETS/$pkg-$TRAVIS_RUST_VERSION-$TARGET.tar.gz | \
49+
tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \
50+
$pkg-$TRAVIS_RUST_VERSION-$TARGET/$dir/lib/rustlib/$TARGET
51+
;;
52+
53+
esac
54+
fi
5155

5256
# Pull a pre-built docker image for testing android, then run tests entirely
5357
# within that image. Note that this is using the same rustc installation that

libc-test/build.rs

+57-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::env;
66

77
fn main() {
88
let target = env::var("TARGET").unwrap();
9+
let x86_64 = target.contains("x86_64");
910
let windows = target.contains("windows");
1011
let mingw = target.contains("windows-gnu");
1112
let linux = target.contains("unknown-linux");
@@ -20,7 +21,7 @@ fn main() {
2021
let mut cfg = ctest::TestGenerator::new();
2122

2223
// Pull in extra goodies on linux/mingw
23-
if target.contains("unknown-linux") {
24+
if linux || android {
2425
cfg.define("_GNU_SOURCE", None);
2526
} else if windows {
2627
cfg.define("_WIN32_WINNT", Some("0x8000"));
@@ -81,6 +82,12 @@ fn main() {
8182
cfg.header("utime.h");
8283
cfg.header("pwd.h");
8384
cfg.header("grp.h");
85+
cfg.header("sys/utsname.h");
86+
cfg.header("sys/ptrace.h");
87+
cfg.header("sys/mount.h");
88+
cfg.header("sys/uio.h");
89+
cfg.header("sched.h");
90+
cfg.header("termios.h");
8491
}
8592

8693
if android {
@@ -89,6 +96,7 @@ fn main() {
8996
} else if !windows {
9097
cfg.header("glob.h");
9198
cfg.header("ifaddrs.h");
99+
cfg.header("sys/quota.h");
92100
cfg.header("sys/statvfs.h");
93101

94102
if !musl {
@@ -109,29 +117,49 @@ fn main() {
109117
}
110118
}
111119

120+
if bsdlike {
121+
cfg.header("sys/event.h");
122+
}
123+
112124
if linux {
125+
cfg.header("mqueue.h");
126+
cfg.header("sys/signalfd.h");
113127
cfg.header("sys/xattr.h");
114128
cfg.header("sys/ipc.h");
115129
cfg.header("sys/shm.h");
116130
}
117131

118132
if linux || android {
119-
cfg.header("netpacket/packet.h");
120-
cfg.header("net/ethernet.h");
121133
cfg.header("malloc.h");
134+
cfg.header("net/ethernet.h");
135+
cfg.header("netpacket/packet.h");
136+
cfg.header("sched.h");
137+
cfg.header("sys/epoll.h");
138+
cfg.header("sys/eventfd.h");
122139
cfg.header("sys/prctl.h");
123-
/* linux kernel header */
140+
cfg.header("sys/vfs.h");
124141
if !musl {
125142
cfg.header("linux/netlink.h");
143+
cfg.header("linux/magic.h");
144+
cfg.header("linux/fs.h");
145+
146+
if !mips {
147+
cfg.header("linux/quota.h");
148+
}
126149
}
127-
cfg.header("sched.h");
128150
}
129151

130152
if freebsd {
131153
cfg.header("pthread_np.h");
132154
cfg.header("sched.h");
133155
}
134156

157+
if netbsd {
158+
cfg.header("ufs/ufs/quota.h");
159+
cfg.header("ufs/ufs/quota1.h");
160+
cfg.header("sys/ioctl_compat.h");
161+
}
162+
135163
cfg.type_name(move |ty, is_struct| {
136164
match ty {
137165
// Just pass all these through, no need for a "struct" prefix
@@ -182,6 +210,7 @@ fn main() {
182210
s.replace("e_nsec", ".tv_nsec")
183211
}
184212
}
213+
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
185214
s => s.to_string(),
186215
}
187216
});
@@ -198,6 +227,10 @@ fn main() {
198227
cfg.skip_struct(move |ty| {
199228
match ty {
200229
"sockaddr_nl" => musl,
230+
231+
// The alignment of this is 4 on 64-bit OSX...
232+
"kevent" if apple && x86_64 => true,
233+
201234
_ => false
202235
}
203236
});
@@ -239,6 +272,19 @@ fn main() {
239272
// work around super old mips toolchain
240273
"SCHED_IDLE" | "SHM_NORESERVE" => mips,
241274

275+
// weird signed extension or something like that?
276+
"MS_NOUSER" => true,
277+
278+
// These OSX constants are flagged as deprecated
279+
"NOTE_EXIT_REPARENTED" |
280+
"NOTE_REAP" if apple => true,
281+
282+
// The linux/quota.h header file which defines these can't be
283+
// included with sys/quota.h currently on MIPS, so we don't include
284+
// it and just ignore these constants
285+
"QFMT_VFS_OLD" |
286+
"QFMT_VFS_V0" if mips && linux => true,
287+
242288
_ => false,
243289
}
244290
});
@@ -265,6 +311,10 @@ fn main() {
265311
// Rust, but is close enough to *mut
266312
"timegm" if apple => true,
267313

314+
// OSX's daemon is deprecated in 10.5 so we'll get a warning (which
315+
// we turn into an error) so just ignore it.
316+
"daemon" if apple => true,
317+
268318
// These functions presumably exist on netbsd but don't look like
269319
// they're implemented on rumprun yet, just let them slide for now.
270320
// Some of them look like they have headers but then don't have
@@ -275,6 +325,8 @@ fn main() {
275325
"pthread_stackseg_np" |
276326
"shm_open" |
277327
"shm_unlink" |
328+
"syscall" |
329+
"ptrace" |
278330
"sigaltstack" if rumprun => true,
279331

280332
_ => false,

src/dox.rs

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ mod imp {
2626
#[lang = "copy"]
2727
pub trait Copy {}
2828

29+
#[lang = "sync"]
30+
pub trait Sync {}
31+
impl<T> Sync for T {}
32+
2933
#[lang = "sized"]
3034
pub trait Sized {}
3135

0 commit comments

Comments
 (0)