Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
cactorium authored May 5, 2017
2 parents 779984b + c1187f3 commit 96a8306
Show file tree
Hide file tree
Showing 37 changed files with 470 additions and 120 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ matrix:
- os: linux
env: TARGET=i686-linux-android
rust: stable
# as of 2017/05/03 x86_64-linux-android are not on stable
- os: linux
env: TARGET=x86_64-linux-android
rust: beta
- os: linux
env: TARGET=x86_64-unknown-linux-musl
rust: stable
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "libc"
version = "0.2.21"
version = "0.2.22"
authors = ["The Rust Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ We have two automated tests running on [Travis](https://travis-ci.org/rust-lang/
2. Style checker
- `rustc ci/style.rs && ./style src`

### Releasing your change to crates.io

Now that you've done the amazing job of landing your new API or your new
platform in this crate, the next step is to get that sweet, sweet usage from
crates.io! The only next step is to bump the version of libc and then publish
it. If you'd like to get a release out ASAP you can follow these steps:

1. Update the version number in `Cargo.toml`, you'll just be bumping the patch
version number.
2. Run `cargo update` to regenerate the lockfile to encode your version bump in
the lock file. You may pull in some other updated dependencies, that's ok.
3. Send a PR to this repository. It should [look like this][example], but it'd
also be nice to fill out the description with a small rationale for the
release (any rationale is ok though!)
4. Once merged the release will be tagged and published by one of the libc crate
maintainers.

[example]: https://github.com/rust-lang/libc/pull/583

## Platforms and Documentation

The following platforms are currently tested and have documentation available:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
- TARGET: x86_64-pc-windows-msvc
- TARGET: i686-pc-windows-msvc
install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init.exe -y --default-host %TARGET%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin
Expand Down
4 changes: 4 additions & 0 deletions ci/android-install-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ case "$1" in
abi=x86
;;

x86_64)
abi=x86_64
;;

*)
echo "invalid arch: $1"
exit 1
Expand Down
52 changes: 52 additions & 0 deletions ci/android-sysimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

set -ex

URL=https://dl.google.com/android/repository/sys-img/android

main() {
local arch=$1
local name=$2
local dest=/system
local td=$(mktemp -d)

apt-get install --no-install-recommends e2tools

pushd $td
curl -O $URL/$name
unzip -q $name

local system=$(find . -name system.img)
mkdir -p $dest/{bin,lib,lib64}

# Extract android linker and libraries to /system
# This allows android executables to be run directly (or with qemu)
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
e2cp -p $system:/bin/linker64 $dest/bin/
e2cp -p $system:/lib64/libdl.so $dest/lib64/
e2cp -p $system:/lib64/libc.so $dest/lib64/
e2cp -p $system:/lib64/libm.so $dest/lib64/
else
e2cp -p $system:/bin/linker $dest/bin/
e2cp -p $system:/lib/libdl.so $dest/lib/
e2cp -p $system:/lib/libc.so $dest/lib/
e2cp -p $system:/lib/libm.so $dest/lib/
fi

# clean up
apt-get purge --auto-remove -y e2tools

popd

rm -rf $td
}

main "${@}"
26 changes: 26 additions & 0 deletions ci/docker/x86_64-linux-android/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:16.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gcc \
libc-dev \
python \
unzip

WORKDIR /android/
ENV ANDROID_ARCH=x86_64
COPY android-install-ndk.sh /android/
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH

# We do not run x86_64-linux-android tests on an android emulator.
# See ci/android-sysimage.sh for informations about how tests are run.
COPY android-sysimage.sh /android/
RUN bash /android/android-sysimage.sh x86_64 x86_64-21_r04.zip

ENV PATH=$PATH:/rust/bin:/android/ndk-$ANDROID_ARCH/bin \
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \
CC_x86_64_linux_android=x86_64-linux-android-gcc \
CXX_x86_64_linux_android=x86_64-linux-android-g++ \
HOME=/tmp
6 changes: 4 additions & 2 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ run() {
# use -f so we can use ci/ as build context
docker build -t libc -f ci/docker/$1/Dockerfile ci/
mkdir -p target
if [ -w /dev/kvm ]; then
kvm="--volume /dev/kvm:/dev/kvm"
fi
docker run \
--user `id -u`:`id -g` \
--rm \
--volume $HOME/.cargo:/cargo \
$kvm \
--env CARGO_HOME=/cargo \
--volume `rustc --print sysroot`:/rust:ro \
--volume `pwd`:/checkout:ro \
--volume `pwd`/target:/checkout/target \
--env CARGO_TARGET_DIR=/checkout/target \
--workdir /checkout \
--privileged \
--interactive \
--tty \
libc \
ci/run.sh $1
}
Expand Down
9 changes: 8 additions & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,20 @@ case "$TARGET" in
esac

case "$TARGET" in
# Android emulator for x86_64 does not work on travis (missing hardware
# acceleration). Tests are run on case *). See ci/android-sysimage.sh for
# informations about how tests are run.
arm-linux-androideabi | aarch64-linux-android | i686-linux-android)
# set SHELL so android can detect a 64bits system, see
# http://stackoverflow.com/a/41789144
# https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791
export SHELL=/bin/dash
arch=$(echo $TARGET | cut -d- -f1)
emulator @$arch -no-window -no-accel &
accel="-no-accel"
if emulator -accel-check; then
accel=""
fi
emulator @$arch -no-window $accel &
adb wait-for-device
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test
adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out
Expand Down
21 changes: 19 additions & 2 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ fn main() {
cfg.header("netinet/in.h");
cfg.header("netinet/ip.h");
cfg.header("netinet/tcp.h");
cfg.header("resolv.h");
cfg.header("pthread.h");
cfg.header("dlfcn.h");
cfg.header("signal.h");
Expand Down Expand Up @@ -107,8 +108,8 @@ fn main() {
}

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

// int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that
// they match the interface defined by Linux verbatim, but they conflict with other
// send*/recv* syscalls
"sendmmsg" | "recvmmsg" if musl => true,

// typed 2nd arg on linux and android
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,

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


// These are either unimplemented or optionally built into uClibc
// or "sysinfo", where it's defined but the structs in linux/sysinfo.h and sys/sysinfo.h
// clash so it can't be tested
Expand All @@ -492,6 +499,16 @@ fn main() {
"backtrace" |
"sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" |
"nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true,

// Apparently res_init exists on Android, but isn't defined in a header:
// https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html
"res_init" if android => true,

// On macOS and iOS, res_init is available, but requires linking with libresolv:
// http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
// See discussion for skipping here:
// https://github.com/rust-lang/libc/pull/585#discussion_r114561460
"res_init" if apple => true,

_ => false,
}
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ pub const P_PID: idtype_t = 0;
pub const P_PGID: idtype_t = 2;
pub const P_ALL: idtype_t = 7;

pub const B460800: ::speed_t = 460800;
pub const B921600: ::speed_t = 921600;

extern {
pub fn __error() -> *mut ::c_int;

Expand Down
4 changes: 2 additions & 2 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,13 +869,13 @@ pub const B57600: speed_t = 57600;
pub const B76800: speed_t = 76800;
pub const B115200: speed_t = 115200;
pub const B230400: speed_t = 230400;
pub const B460800: speed_t = 460800;
pub const B921600: speed_t = 921600;
pub const EXTA: speed_t = 19200;
pub const EXTB: speed_t = 38400;

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

pub const CRTSCTS: ::tcflag_t = 0x00030000;

f! {
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0x13
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ pub const WNOHANG: ::c_int = 0x00000001;
pub const WUNTRACED: ::c_int = 0x00000002;

pub const RTLD_NOW: ::c_int = 0x2;
pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void;
pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void;

pub const LOG_CRON: ::c_int = 9 << 3;
pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ pub const P_ALL: idtype_t = 0;
pub const P_PID: idtype_t = 1;
pub const P_PGID: idtype_t = 4;

pub const B460800: ::speed_t = 460800;
pub const B921600: ::speed_t = 921600;

extern {
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
Expand Down
17 changes: 17 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ extern {
link_name = "pthread_join$UNIX2003")]
pub fn pthread_join(native: ::pthread_t,
value: *mut *mut ::c_void) -> ::c_int;
pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
parent: Option<unsafe extern fn()>,
child: Option<unsafe extern fn()>) -> ::c_int;
pub fn pthread_exit(value: *mut ::c_void);
pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
Expand Down Expand Up @@ -691,6 +694,14 @@ extern {
res: *mut *mut addrinfo) -> ::c_int;
pub fn freeaddrinfo(res: *mut addrinfo);
pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
#[cfg_attr(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "freebsd",
target_os = "dragonfly"),
link_name = "__res_init")]
#[cfg_attr(any(target_os = "macos", target_os = "ios"),
link_name = "res_9_init")]
pub fn res_init() -> ::c_int;

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

#[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
pub fn sigprocmask(how: ::c_int,
set: *const sigset_t,
oldset: *mut sigset_t)
-> ::c_int;

#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
pub fn timegm(tm: *mut ::tm) -> time_t;

Expand Down
3 changes: 3 additions & 0 deletions src/unix/notbsd/android/b32/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// The following definitions are correct for arm and i686,
// but may be wrong for mips

pub type c_long = i32;
pub type c_ulong = u32;
pub type mode_t = u16;
Expand Down
Loading

0 comments on commit 96a8306

Please sign in to comment.