Skip to content

Commit 96a8306

Browse files
authored
Merge branch 'master' into master
2 parents 779984b + c1187f3 commit 96a8306

File tree

37 files changed

+470
-120
lines changed

37 files changed

+470
-120
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ matrix:
5656
- os: linux
5757
env: TARGET=i686-linux-android
5858
rust: stable
59+
# as of 2017/05/03 x86_64-linux-android are not on stable
60+
- os: linux
61+
env: TARGET=x86_64-linux-android
62+
rust: beta
5963
- os: linux
6064
env: TARGET=x86_64-unknown-linux-musl
6165
rust: stable

Cargo.lock

Lines changed: 2 additions & 2 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.21"
4+
version = "0.2.22"
55
authors = ["The Rust Project Developers"]
66
license = "MIT/Apache-2.0"
77
readme = "README.md"

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,25 @@ We have two automated tests running on [Travis](https://travis-ci.org/rust-lang/
9898
2. Style checker
9999
- `rustc ci/style.rs && ./style src`
100100

101+
### Releasing your change to crates.io
102+
103+
Now that you've done the amazing job of landing your new API or your new
104+
platform in this crate, the next step is to get that sweet, sweet usage from
105+
crates.io! The only next step is to bump the version of libc and then publish
106+
it. If you'd like to get a release out ASAP you can follow these steps:
107+
108+
1. Update the version number in `Cargo.toml`, you'll just be bumping the patch
109+
version number.
110+
2. Run `cargo update` to regenerate the lockfile to encode your version bump in
111+
the lock file. You may pull in some other updated dependencies, that's ok.
112+
3. Send a PR to this repository. It should [look like this][example], but it'd
113+
also be nice to fill out the description with a small rationale for the
114+
release (any rationale is ok though!)
115+
4. Once merged the release will be tagged and published by one of the libc crate
116+
maintainers.
117+
118+
[example]: https://github.com/rust-lang/libc/pull/583
119+
101120
## Platforms and Documentation
102121

103122
The following platforms are currently tested and have documentation available:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
- TARGET: x86_64-pc-windows-msvc
88
- TARGET: i686-pc-windows-msvc
99
install:
10-
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
10+
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
1111
- rustup-init.exe -y --default-host %TARGET%
1212
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
1313
- if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin

ci/android-install-sdk.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ case "$1" in
3737
abi=x86
3838
;;
3939

40+
x86_64)
41+
abi=x86_64
42+
;;
43+
4044
*)
4145
echo "invalid arch: $1"
4246
exit 1

ci/android-sysimage.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
# file at the top-level directory of this distribution and at
3+
# http://rust-lang.org/COPYRIGHT.
4+
#
5+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
# option. This file may not be copied, modified, or distributed
9+
# except according to those terms.
10+
11+
set -ex
12+
13+
URL=https://dl.google.com/android/repository/sys-img/android
14+
15+
main() {
16+
local arch=$1
17+
local name=$2
18+
local dest=/system
19+
local td=$(mktemp -d)
20+
21+
apt-get install --no-install-recommends e2tools
22+
23+
pushd $td
24+
curl -O $URL/$name
25+
unzip -q $name
26+
27+
local system=$(find . -name system.img)
28+
mkdir -p $dest/{bin,lib,lib64}
29+
30+
# Extract android linker and libraries to /system
31+
# This allows android executables to be run directly (or with qemu)
32+
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
33+
e2cp -p $system:/bin/linker64 $dest/bin/
34+
e2cp -p $system:/lib64/libdl.so $dest/lib64/
35+
e2cp -p $system:/lib64/libc.so $dest/lib64/
36+
e2cp -p $system:/lib64/libm.so $dest/lib64/
37+
else
38+
e2cp -p $system:/bin/linker $dest/bin/
39+
e2cp -p $system:/lib/libdl.so $dest/lib/
40+
e2cp -p $system:/lib/libc.so $dest/lib/
41+
e2cp -p $system:/lib/libm.so $dest/lib/
42+
fi
43+
44+
# clean up
45+
apt-get purge --auto-remove -y e2tools
46+
47+
popd
48+
49+
rm -rf $td
50+
}
51+
52+
main "${@}"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update && \
4+
apt-get install -y --no-install-recommends \
5+
ca-certificates \
6+
curl \
7+
gcc \
8+
libc-dev \
9+
python \
10+
unzip
11+
12+
WORKDIR /android/
13+
ENV ANDROID_ARCH=x86_64
14+
COPY android-install-ndk.sh /android/
15+
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
16+
17+
# We do not run x86_64-linux-android tests on an android emulator.
18+
# See ci/android-sysimage.sh for informations about how tests are run.
19+
COPY android-sysimage.sh /android/
20+
RUN bash /android/android-sysimage.sh x86_64 x86_64-21_r04.zip
21+
22+
ENV PATH=$PATH:/rust/bin:/android/ndk-$ANDROID_ARCH/bin \
23+
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \
24+
CC_x86_64_linux_android=x86_64-linux-android-gcc \
25+
CXX_x86_64_linux_android=x86_64-linux-android-g++ \
26+
HOME=/tmp

ci/run-docker.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ run() {
88
# use -f so we can use ci/ as build context
99
docker build -t libc -f ci/docker/$1/Dockerfile ci/
1010
mkdir -p target
11+
if [ -w /dev/kvm ]; then
12+
kvm="--volume /dev/kvm:/dev/kvm"
13+
fi
1114
docker run \
1215
--user `id -u`:`id -g` \
1316
--rm \
1417
--volume $HOME/.cargo:/cargo \
18+
$kvm \
1519
--env CARGO_HOME=/cargo \
1620
--volume `rustc --print sysroot`:/rust:ro \
1721
--volume `pwd`:/checkout:ro \
1822
--volume `pwd`/target:/checkout/target \
1923
--env CARGO_TARGET_DIR=/checkout/target \
2024
--workdir /checkout \
2125
--privileged \
22-
--interactive \
23-
--tty \
2426
libc \
2527
ci/run.sh $1
2628
}

ci/run.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,20 @@ case "$TARGET" in
105105
esac
106106

107107
case "$TARGET" in
108+
# Android emulator for x86_64 does not work on travis (missing hardware
109+
# acceleration). Tests are run on case *). See ci/android-sysimage.sh for
110+
# informations about how tests are run.
108111
arm-linux-androideabi | aarch64-linux-android | i686-linux-android)
109112
# set SHELL so android can detect a 64bits system, see
110113
# http://stackoverflow.com/a/41789144
111114
# https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791
112115
export SHELL=/bin/dash
113116
arch=$(echo $TARGET | cut -d- -f1)
114-
emulator @$arch -no-window -no-accel &
117+
accel="-no-accel"
118+
if emulator -accel-check; then
119+
accel=""
120+
fi
121+
emulator @$arch -no-window $accel &
115122
adb wait-for-device
116123
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test
117124
adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out

libc-test/build.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ fn main() {
7878
cfg.header("netinet/in.h");
7979
cfg.header("netinet/ip.h");
8080
cfg.header("netinet/tcp.h");
81+
cfg.header("resolv.h");
8182
cfg.header("pthread.h");
8283
cfg.header("dlfcn.h");
8384
cfg.header("signal.h");
@@ -107,8 +108,8 @@ fn main() {
107108
}
108109

109110
if android {
110-
if !aarch64 {
111-
// time64_t is not define for aarch64
111+
if !aarch64 && !x86_64 {
112+
// time64_t is not define for aarch64 and x86_64
112113
// If included it will generate the error 'Your time_t is already 64-bit'
113114
cfg.header("time64.h");
114115
}
@@ -419,6 +420,11 @@ fn main() {
419420
"prlimit" | "prlimit64" | // non-int in 2nd arg
420421
"strerror_r" if linux => true, // actually xpg-something-or-other
421422

423+
// int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that
424+
// they match the interface defined by Linux verbatim, but they conflict with other
425+
// send*/recv* syscalls
426+
"sendmmsg" | "recvmmsg" if musl => true,
427+
422428
// typed 2nd arg on linux and android
423429
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
424430

@@ -483,6 +489,7 @@ fn main() {
483489
// it's in a header file?
484490
"endpwent" if android => true,
485491

492+
486493
// These are either unimplemented or optionally built into uClibc
487494
// or "sysinfo", where it's defined but the structs in linux/sysinfo.h and sys/sysinfo.h
488495
// clash so it can't be tested
@@ -492,6 +499,16 @@ fn main() {
492499
"backtrace" |
493500
"sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" |
494501
"nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true,
502+
503+
// Apparently res_init exists on Android, but isn't defined in a header:
504+
// https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html
505+
"res_init" if android => true,
506+
507+
// On macOS and iOS, res_init is available, but requires linking with libresolv:
508+
// http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
509+
// See discussion for skipping here:
510+
// https://github.com/rust-lang/libc/pull/585#discussion_r114561460
511+
"res_init" if apple => true,
495512

496513
_ => false,
497514
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ pub const P_PID: idtype_t = 0;
505505
pub const P_PGID: idtype_t = 2;
506506
pub const P_ALL: idtype_t = 7;
507507

508+
pub const B460800: ::speed_t = 460800;
509+
pub const B921600: ::speed_t = 921600;
510+
508511
extern {
509512
pub fn __error() -> *mut ::c_int;
510513

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,13 +869,13 @@ pub const B57600: speed_t = 57600;
869869
pub const B76800: speed_t = 76800;
870870
pub const B115200: speed_t = 115200;
871871
pub const B230400: speed_t = 230400;
872-
pub const B460800: speed_t = 460800;
873-
pub const B921600: speed_t = 921600;
874872
pub const EXTA: speed_t = 19200;
875873
pub const EXTB: speed_t = 38400;
876874

877875
pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t;
878876

877+
pub const CRTSCTS: ::tcflag_t = 0x00030000;
878+
879879
f! {
880880
pub fn WIFCONTINUED(status: ::c_int) -> bool {
881881
status == 0x13

src/unix/bsd/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ pub const WNOHANG: ::c_int = 0x00000001;
275275
pub const WUNTRACED: ::c_int = 0x00000002;
276276

277277
pub const RTLD_NOW: ::c_int = 0x2;
278+
pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void;
278279
pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
280+
pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void;
279281

280282
pub const LOG_CRON: ::c_int = 9 << 3;
281283
pub const LOG_AUTHPRIV: ::c_int = 10 << 3;

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ pub const P_ALL: idtype_t = 0;
641641
pub const P_PID: idtype_t = 1;
642642
pub const P_PGID: idtype_t = 4;
643643

644+
pub const B460800: ::speed_t = 460800;
645+
pub const B921600: ::speed_t = 921600;
646+
644647
extern {
645648
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
646649
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;

src/unix/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ extern {
576576
link_name = "pthread_join$UNIX2003")]
577577
pub fn pthread_join(native: ::pthread_t,
578578
value: *mut *mut ::c_void) -> ::c_int;
579+
pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
580+
parent: Option<unsafe extern fn()>,
581+
child: Option<unsafe extern fn()>) -> ::c_int;
579582
pub fn pthread_exit(value: *mut ::c_void);
580583
pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
581584
pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
@@ -691,6 +694,14 @@ extern {
691694
res: *mut *mut addrinfo) -> ::c_int;
692695
pub fn freeaddrinfo(res: *mut addrinfo);
693696
pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
697+
#[cfg_attr(any(
698+
all(target_os = "linux", not(target_env = "musl")),
699+
target_os = "freebsd",
700+
target_os = "dragonfly"),
701+
link_name = "__res_init")]
702+
#[cfg_attr(any(target_os = "macos", target_os = "ios"),
703+
link_name = "res_9_init")]
704+
pub fn res_init() -> ::c_int;
694705

695706
#[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
696707
pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
@@ -777,6 +788,12 @@ extern {
777788
#[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
778789
pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
779790

791+
#[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
792+
pub fn sigprocmask(how: ::c_int,
793+
set: *const sigset_t,
794+
oldset: *mut sigset_t)
795+
-> ::c_int;
796+
780797
#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
781798
pub fn timegm(tm: *mut ::tm) -> time_t;
782799

src/unix/notbsd/android/b32/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// The following definitions are correct for arm and i686,
2+
// but may be wrong for mips
3+
14
pub type c_long = i32;
25
pub type c_ulong = u32;
36
pub type mode_t = u16;

0 commit comments

Comments
 (0)