Skip to content

Commit 195d63a

Browse files
committed
Merge branch 'master' of github.com:rust-lang/libc into exchangedata
2 parents c67224e + 2c063c2 commit 195d63a

File tree

22 files changed

+978
-109
lines changed

22 files changed

+978
-109
lines changed

.travis.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ matrix:
4141
- env: TARGET=i686-unknown-linux-gnu
4242
- os: osx
4343
env: TARGET=x86_64-apple-darwin NO_ADD=1
44-
osx_image: xcode8.3
44+
osx_image: xcode9.4
4545
- os: osx
4646
env: TARGET=i686-apple-darwin
47-
osx_image: xcode8.3
47+
osx_image: xcode9.4
4848
- env: TARGET=arm-linux-androideabi
4949
- env: TARGET=aarch64-linux-android
5050
# FIXME(#826) should reenable
@@ -59,14 +59,14 @@ matrix:
5959
# FIXME(#856)
6060
rust: 1.22.1
6161
- os: osx
62-
osx_image: xcode8.2
62+
osx_image: xcode9.4
6363
env: TARGET=i386-apple-ios
6464
CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest
6565
RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0
6666
before_install:
6767
rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest
6868
- os: osx
69-
osx_image: xcode8.2
69+
osx_image: xcode9.4
7070
env: TARGET=x86_64-apple-ios
7171
CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=$HOME/runtest
7272
RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0
@@ -91,15 +91,15 @@ matrix:
9191
rust: beta
9292
- os: osx
9393
env: TARGET=x86_64-apple-darwin NO_ADD=1
94-
osx_image: xcode8.3
94+
osx_image: xcode9.4
9595
rust: beta
9696

9797
# nightly
9898
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
9999
rust: nightly
100100
- os: osx
101101
env: TARGET=x86_64-apple-darwin NO_ADD=1
102-
osx_image: xcode8.3
102+
osx_image: xcode9.4
103103
rust: nightly
104104
# not available on stable
105105
# without --release the build fails
@@ -109,6 +109,13 @@ matrix:
109109

110110
# QEMU based targets that compile in an emulator
111111
- env: TARGET=x86_64-unknown-freebsd
112+
allow_failures:
113+
- env: TARGET=i386-apple-ios
114+
CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest
115+
RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0
116+
- env: TARGET=x86_64-apple-ios
117+
CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=$HOME/runtest
118+
RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0
112119

113120
notifications:
114121
email:

Cargo.lock

Lines changed: 63 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "libc"
4-
version = "0.2.42"
4+
version = "0.2.43"
55
authors = ["The Rust Project Developers"]
66
license = "MIT/Apache-2.0"
77
readme = "README.md"

ci/ios/deploy_and_run_on_ios_simulator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ fn run_app_on_simulator() {
123123
.arg("com.rust.unittests")
124124
.output());
125125

126+
println!("status: {}", output.status);
126127
println!("stdout --\n{}\n", String::from_utf8_lossy(&output.stdout));
127128
println!("stderr --\n{}\n", String::from_utf8_lossy(&output.stderr));
128129

libc-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ path = ".."
99
default-features = false
1010

1111
[build-dependencies]
12-
ctest = { git = "https://github.com/alexcrichton/ctest" }
12+
ctest = "0.2"
1313

1414
[features]
1515
default = [ "use_std" ]

libc-test/build.rs

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn main() {
1515
let linux = target.contains("unknown-linux");
1616
let android = target.contains("android");
1717
let apple = target.contains("apple");
18+
let ios = target.contains("apple-ios");
1819
let emscripten = target.contains("asm");
1920
let musl = target.contains("musl") || emscripten;
2021
let uclibc = target.contains("uclibc");
@@ -84,8 +85,10 @@ fn main() {
8485
cfg.header("sys/socket.h");
8586
}
8687
cfg.header("net/if.h");
87-
cfg.header("net/route.h");
88-
cfg.header("net/if_arp.h");
88+
if !ios {
89+
cfg.header("net/route.h");
90+
cfg.header("net/if_arp.h");
91+
}
8992
cfg.header("netdb.h");
9093
cfg.header("netinet/in.h");
9194
cfg.header("netinet/ip.h");
@@ -113,7 +116,7 @@ fn main() {
113116
cfg.header("pwd.h");
114117
cfg.header("grp.h");
115118
cfg.header("sys/utsname.h");
116-
if !solaris {
119+
if !solaris && !ios {
117120
cfg.header("sys/ptrace.h");
118121
}
119122
cfg.header("sys/mount.h");
@@ -175,19 +178,22 @@ fn main() {
175178
cfg.header("util.h");
176179
cfg.header("xlocale.h");
177180
cfg.header("sys/xattr.h");
178-
cfg.header("sys/sys_domain.h");
179-
cfg.header("net/if_utun.h");
180-
cfg.header("net/bpf.h");
181-
if target.starts_with("x86") {
181+
if target.starts_with("x86") && !ios {
182182
cfg.header("crt_externs.h");
183183
}
184-
cfg.header("net/route.h");
185-
cfg.header("netinet/if_ether.h");
186184
cfg.header("netinet/in.h");
187-
cfg.header("sys/proc_info.h");
188-
cfg.header("sys/kern_control.h");
189185
cfg.header("sys/ipc.h");
190186
cfg.header("sys/shm.h");
187+
188+
if !ios {
189+
cfg.header("sys/sys_domain.h");
190+
cfg.header("net/if_utun.h");
191+
cfg.header("net/bpf.h");
192+
cfg.header("net/route.h");
193+
cfg.header("netinet/if_ether.h");
194+
cfg.header("sys/proc_info.h");
195+
cfg.header("sys/kern_control.h");
196+
}
191197
}
192198

193199
if bsdlike {
@@ -449,6 +455,17 @@ fn main() {
449455
// header conflicts when including them with all the other structs.
450456
"termios2" => true,
451457

458+
// Present on historical versions of iOS but missing in more recent
459+
// SDKs
460+
"bpf_hdr" |
461+
"proc_taskinfo" |
462+
"proc_taskallinfo" |
463+
"proc_bsdinfo" |
464+
"proc_threadinfo" |
465+
"sockaddr_inarp" |
466+
"sockaddr_ctl" |
467+
"arphdr" if ios => true,
468+
452469
_ => false
453470
}
454471
});
@@ -594,6 +611,30 @@ fn main() {
594611
// shouldn't be used in code anyway...
595612
"AF_MAX" | "PF_MAX" => true,
596613

614+
// Present on historical versions of iOS, but now removed in more
615+
// recent SDKs
616+
"ARPOP_REQUEST" |
617+
"ARPOP_REPLY" |
618+
"ATF_COM" |
619+
"ATF_PERM" |
620+
"ATF_PUBL" |
621+
"ATF_USETRAILERS" |
622+
"AF_SYS_CONTROL" |
623+
"SYSPROTO_EVENT" |
624+
"PROC_PIDTASKALLINFO" |
625+
"PROC_PIDTASKINFO" |
626+
"PROC_PIDTHREADINFO" |
627+
"UTUN_OPT_FLAGS" |
628+
"UTUN_OPT_IFNAME" |
629+
"BPF_ALIGNMENT" |
630+
"SYSPROTO_CONTROL" if ios => true,
631+
s if ios && s.starts_with("RTF_") => true,
632+
s if ios && s.starts_with("RTM_") => true,
633+
s if ios && s.starts_with("RTA_") => true,
634+
s if ios && s.starts_with("RTAX_") => true,
635+
s if ios && s.starts_with("RTV_") => true,
636+
s if ios && s.starts_with("DLT_") => true,
637+
597638
_ => false,
598639
}
599640
});
@@ -736,6 +777,10 @@ fn main() {
736777
// FIXME: mincore is defined with caddr_t on Solaris.
737778
"mincore" if solaris => true,
738779

780+
// These were all included in historical versions of iOS but appear
781+
// to be removed now
782+
"system" | "ptrace" if ios => true,
783+
739784
_ => false,
740785
}
741786
});

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ mod dox;
104104
cfg_if! {
105105
if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] {
106106
// empty ...
107+
} else if #[cfg(target_os = "switch")] {
108+
// On the Switch, we only define some useful universal types for
109+
// convenience. Those can be found in the switch.rs file.
107110
} else {
108111

109112
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
@@ -296,6 +299,9 @@ cfg_if! {
296299
} else if #[cfg(target_os = "fuchsia")] {
297300
mod fuchsia;
298301
pub use fuchsia::*;
302+
} else if #[cfg(target_os = "switch")] {
303+
mod switch;
304+
pub use switch::*;
299305
} else if #[cfg(unix)] {
300306
mod unix;
301307
pub use unix::*;

src/switch.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//! Switch C type definitions
2+
3+
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
4+
// more optimization opportunities around it recognizing things like
5+
// malloc/free.
6+
#[repr(u8)]
7+
pub enum c_void {
8+
// Two dummy variants so the #[repr] attribute can be used.
9+
#[doc(hidden)]
10+
__variant1,
11+
#[doc(hidden)]
12+
__variant2,
13+
}
14+
15+
pub type int8_t = i8;
16+
pub type int16_t = i16;
17+
pub type int32_t = i32;
18+
pub type int64_t = i64;
19+
pub type uint8_t = u8;
20+
pub type uint16_t = u16;
21+
pub type uint32_t = u32;
22+
pub type uint64_t = u64;
23+
24+
pub type c_schar = i8;
25+
pub type c_uchar = u8;
26+
pub type c_short = i16;
27+
pub type c_ushort = u16;
28+
pub type c_int = i32;
29+
pub type c_uint = u32;
30+
pub type c_float = f32;
31+
pub type c_double = f64;
32+
pub type c_longlong = i64;
33+
pub type c_ulonglong = u64;
34+
pub type intmax_t = i64;
35+
pub type uintmax_t = u64;
36+
37+
pub type size_t = usize;
38+
pub type ptrdiff_t = isize;
39+
pub type intptr_t = isize;
40+
pub type uintptr_t = usize;
41+
pub type ssize_t = isize;
42+
43+
// Arch specific
44+
pub type off_t = i64;
45+
pub type c_char = u8;
46+
pub type c_long = i64;
47+
pub type c_ulong = u64;
48+
pub type wchar_t = u32;

src/unix/bsd/apple/mod.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -765,16 +765,8 @@ pub const VM_FLAGS_SUPERPAGE_MASK: ::c_int = 0x70000;
765765
pub const VM_FLAGS_RETURN_DATA_ADDR: ::c_int = 0x100000;
766766
pub const VM_FLAGS_RETURN_4K_DATA_ADDR: ::c_int = 0x800000;
767767
pub const VM_FLAGS_ALIAS_MASK: ::c_int = 0xFF000000;
768-
pub const VM_FLAGS_USER_ALLOCATE: ::c_int = VM_FLAGS_FIXED | VM_FLAGS_ANYWHERE |
769-
VM_FLAGS_PURGABLE |
770-
VM_FLAGS_RANDOM_ADDR |
771-
VM_FLAGS_NO_CACHE |
772-
VM_FLAGS_OVERWRITE |
773-
VM_FLAGS_SUPERPAGE_MASK |
774-
VM_FLAGS_ALIAS_MASK;
775-
pub const VM_FLAGS_USER_MAP: ::c_int = VM_FLAGS_USER_ALLOCATE |
776-
VM_FLAGS_RETURN_4K_DATA_ADDR |
777-
VM_FLAGS_RETURN_DATA_ADDR;
768+
pub const VM_FLAGS_USER_ALLOCATE: ::c_int = 0xff07401b;
769+
pub const VM_FLAGS_USER_MAP: ::c_int = 0xff97401b;
778770
pub const VM_FLAGS_USER_REMAP: ::c_int = VM_FLAGS_FIXED | VM_FLAGS_ANYWHERE |
779771
VM_FLAGS_RANDOM_ADDR |
780772
VM_FLAGS_OVERWRITE |
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub type c_long = i64;
22
pub type c_ulong = u64;
3+
pub type c_char = u8;

0 commit comments

Comments
 (0)