From 599eec37814e85253923fc3d66703ebd9e7ce650 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 23 Feb 2017 16:08:29 -0300 Subject: [PATCH 1/9] Add test support for {aarch64, i686}-linux-android --- ...licenses.sh => android-accept-licenses.sh} | 0 .../install-ndk.sh => android-install-ndk.sh} | 19 ++++++++-- .../install-sdk.sh => android-install-sdk.sh} | 36 ++++++++++++++----- ci/docker/aarch64-linux-android/Dockerfile | 32 +++++++++++++++++ ci/docker/arm-linux-androideabi/Dockerfile | 20 +++++------ ci/docker/i686-linux-android/Dockerfile | 32 +++++++++++++++++ ci/run-docker.sh | 3 +- ci/run.sh | 13 ++++--- 8 files changed, 129 insertions(+), 26 deletions(-) rename ci/{docker/arm-linux-androideabi/accept-licenses.sh => android-accept-licenses.sh} (100%) rename ci/{docker/arm-linux-androideabi/install-ndk.sh => android-install-ndk.sh} (81%) rename ci/{docker/arm-linux-androideabi/install-sdk.sh => android-install-sdk.sh} (61%) create mode 100644 ci/docker/aarch64-linux-android/Dockerfile create mode 100644 ci/docker/i686-linux-android/Dockerfile diff --git a/ci/docker/arm-linux-androideabi/accept-licenses.sh b/ci/android-accept-licenses.sh similarity index 100% rename from ci/docker/arm-linux-androideabi/accept-licenses.sh rename to ci/android-accept-licenses.sh diff --git a/ci/docker/arm-linux-androideabi/install-ndk.sh b/ci/android-install-ndk.sh similarity index 81% rename from ci/docker/arm-linux-androideabi/install-ndk.sh rename to ci/android-install-ndk.sh index 566a3191848a3..75bcd20f2f77d 100644 --- a/ci/docker/arm-linux-androideabi/install-ndk.sh +++ b/ci/android-install-ndk.sh @@ -13,9 +13,24 @@ set -ex curl -O https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip unzip -q android-ndk-r13b-linux-x86_64.zip + +case "$1" in + aarch64) + arch=arm64 + ;; + + i686) + arch=x86 + ;; + + *) + arch=$1 + ;; +esac; + android-ndk-r13b/build/tools/make_standalone_toolchain.py \ - --install-dir /android/ndk-arm \ - --arch arm \ + --install-dir /android/ndk-$1 \ + --arch $arch \ --api 24 rm -rf ./android-ndk-r13b-linux-x86_64.zip ./android-ndk-r13b diff --git a/ci/docker/arm-linux-androideabi/install-sdk.sh b/ci/android-install-sdk.sh similarity index 61% rename from ci/docker/arm-linux-androideabi/install-sdk.sh rename to ci/android-install-sdk.sh index 3f20837fe061a..0762dcb45d0b7 100644 --- a/ci/docker/arm-linux-androideabi/install-sdk.sh +++ b/ci/android-install-sdk.sh @@ -19,15 +19,35 @@ set -ex # which apparently magically accepts the licenses. mkdir sdk -curl https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz | \ - tar xzf - -C sdk --strip-components=1 +curl https://dl.google.com/android/repository/tools_r25.2.5-linux.zip -O +unzip -d sdk tools_r25.2.5-linux.zip -filter="platform-tools,android-21" -filter="$filter,sys-img-armeabi-v7a-android-21" +filter="platform-tools,android-24" -./accept-licenses.sh "android - update sdk -a --no-ui --filter $filter" +case "$1" in + arm | armv7) + abi=armeabi-v7a + ;; + + aarch64) + abi=arm64-v8a + ;; + + i686) + abi=x86 + ;; + + *) + echo "invalid arch: $1" + exit 1 + ;; +esac; + +filter="$filter,sys-img-$abi-android-24" + +./android-accept-licenses.sh "android - update sdk -a --no-ui --filter $filter" echo "no" | android create avd \ - --name arm-21 \ - --target android-21 \ - --abi armeabi-v7a + --name $1 \ + --target android-24 \ + --abi $abi diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile new file mode 100644 index 0000000000000..7ad84926bf82b --- /dev/null +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:16.04 + +RUN dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + file \ + curl \ + ca-certificates \ + python \ + unzip \ + expect \ + openjdk-9-jre \ + libstdc++6:i386 \ + libpulse0 \ + gcc \ + libc6-dev + +WORKDIR /android/ +COPY android* /android/ + +ENV ANDROID_ARCH=aarch64 +ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools + +RUN sh /android/android-install-ndk.sh $ANDROID_ARCH +RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN mv /root/.android /tmp +RUN chmod 777 -R /tmp/.android +RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* + +ENV PATH=$PATH:/rust/bin \ + CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ + HOME=/tmp diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 1911fbd87970e..054941416dfb5 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -11,24 +11,22 @@ RUN dpkg --add-architecture i386 && \ expect \ openjdk-9-jre \ libstdc++6:i386 \ + libpulse0 \ gcc \ libc6-dev WORKDIR /android/ +COPY android* /android/ -COPY install-ndk.sh /android/ -RUN sh /android/install-ndk.sh +ENV ANDROID_ARCH=arm +ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools -ENV PATH=$PATH:/android/ndk-arm/bin:/android/sdk/tools:/android/sdk/platform-tools - -COPY install-sdk.sh accept-licenses.sh /android/ -RUN sh /android/install-sdk.sh +RUN sh /android/android-install-ndk.sh $ANDROID_ARCH +RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN mv /root/.android /tmp +RUN chmod 777 -R /tmp/.android +RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ - ANDROID_EMULATOR_FORCE_32BIT=1 \ HOME=/tmp -RUN chmod 755 /android/sdk/tools/* - -RUN cp -r /root/.android /tmp -RUN chmod 777 -R /tmp/.android diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile new file mode 100644 index 0000000000000..bee904379645f --- /dev/null +++ b/ci/docker/i686-linux-android/Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:16.04 + +RUN dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + file \ + curl \ + ca-certificates \ + python \ + unzip \ + expect \ + openjdk-9-jre \ + libstdc++6:i386 \ + libpulse0 \ + gcc \ + libc6-dev + +WORKDIR /android/ +COPY android* /android/ + +ENV ANDROID_ARCH=i686 +ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools + +RUN sh /android/android-install-ndk.sh $ANDROID_ARCH +RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN mv /root/.android /tmp +RUN chmod 777 -R /tmp/.android +RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* + +ENV PATH=$PATH:/rust/bin \ + CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \ + HOME=/tmp diff --git a/ci/run-docker.sh b/ci/run-docker.sh index a7702ae1dc512..1ac419a349c08 100644 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -5,7 +5,8 @@ set -ex run() { echo $1 - docker build -t libc ci/docker/$1 + # use -f so we can use ci/ as build context + docker build -t libc -f ci/docker/$1/Dockerfile ci/ mkdir -p target docker run \ --user `id -u`:`id -g` \ diff --git a/ci/run.sh b/ci/run.sh index d33af30fd91c7..1b6e0fb1d4549 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -105,11 +105,16 @@ case "$TARGET" in esac case "$TARGET" in - arm-linux-androideabi) - emulator @arm-21 -no-window & + 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 & adb wait-for-device - adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/libc-test - adb shell /data/libc-test 2>&1 | tee /tmp/out + 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 grep "^PASSED .* tests" /tmp/out ;; From c53251867fb4d635ff4d23a9e211448e4150ccca Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 23 Feb 2017 16:40:28 -0300 Subject: [PATCH 2/9] Fix i686-linux-android failing tests --- src/unix/notbsd/android/mod.rs | 27 ++++++++++++++++++++++----- src/unix/notbsd/mod.rs | 4 +++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index ec6aa90ef44ba..0d1c7d07e9fd1 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -2,11 +2,19 @@ use dox::mem; -pub type c_char = u8; +cfg_if! { + if #[cfg(target_arch = "x86")] { + pub type c_char = i8; + pub type wchar_t = i32; + } else { + pub type c_char = u8; + pub type wchar_t = u32; + } +} + pub type clock_t = ::c_long; pub type time_t = ::c_long; pub type suseconds_t = ::c_long; -pub type wchar_t = u32; pub type off_t = ::c_long; pub type blkcnt_t = ::c_ulong; pub type blksize_t = ::c_ulong; @@ -447,12 +455,21 @@ pub const O_EXCL: ::c_int = 128; pub const O_NOCTTY: ::c_int = 256; pub const O_NONBLOCK: ::c_int = 2048; pub const O_SYNC: ::c_int = 0x101000; -pub const O_DIRECT: ::c_int = 0x10000; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; +cfg_if! { + if #[cfg(target_arch = "x86")] { + pub const O_DIRECT: ::c_int = 0x4000; + pub const O_DIRECTORY: ::c_int = 0x10000; + pub const O_NOFOLLOW: ::c_int = 0x20000; + } else { + pub const O_DIRECT: ::c_int = 0x10000; + pub const O_DIRECTORY: ::c_int = 0x4000; + pub const O_NOFOLLOW: ::c_int = 0x8000; + } +} + pub const NI_MAXHOST: ::size_t = 1025; pub const NCCS: usize = 19; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 10aa0b5bcb21e..634d74b0bd0ff 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -120,7 +120,9 @@ s! { pub dli_saddr: *mut ::c_void, } - #[cfg_attr(any(all(target_arch = "x86", not(target_env = "musl")), + #[cfg_attr(any(all(target_arch = "x86", + not(target_env = "musl"), + not(target_os = "android")), target_arch = "x86_64"), repr(packed))] pub struct epoll_event { From 92ce51823cc442e5054805c0b535b9cf0e551b0e Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 23 Feb 2017 18:15:02 -0300 Subject: [PATCH 3/9] Make libc-tests compile for aarch64-linux-android - some tests are failing - remove readlink, timegm and sig* functions in favor of the unix/mod.rs definitions - remove time64_t (it is not defined for aarch64) - move some definitions to android/b32.rs and create appropriated definitions in android/b64.rs --- libc-test/build.rs | 7 ++- src/unix/mod.rs | 88 +++++++++++++++++++--------------- src/unix/notbsd/android/b32.rs | 7 +++ src/unix/notbsd/android/b64.rs | 13 +++-- src/unix/notbsd/android/mod.rs | 71 +++++++++++++-------------- 5 files changed, 108 insertions(+), 78 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 2c5e2328e0351..ed336c8254ba6 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -6,6 +6,7 @@ use std::env; fn main() { let target = env::var("TARGET").unwrap(); + let aarch64 = target.contains("aarch64"); let x86_64 = target.contains("x86_64"); let windows = target.contains("windows"); let mingw = target.contains("windows-gnu"); @@ -105,8 +106,12 @@ fn main() { } if android { + if !aarch64 { + // time64_t is not define for aarch64 + // If included it will generate the error 'Your time_t is already 64-bit' + cfg.header("time64.h"); + } cfg.header("arpa/inet.h"); - cfg.header("time64.h"); cfg.header("xlocale.h"); cfg.header("utmp.h"); } else if !windows { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index f10f6bcaa0ae2..e66cb0f0a0ccb 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -274,10 +274,6 @@ extern { link_name = "connect$UNIX2003")] pub fn connect(socket: ::c_int, address: *const sockaddr, len: socklen_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "bind$UNIX2003")] - pub fn bind(socket: ::c_int, address: *const sockaddr, - address_len: socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "listen$UNIX2003")] pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; @@ -680,16 +676,6 @@ extern { #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, dev: ::dev_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "writev$UNIX2003")] - pub fn writev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "readv$UNIX2003")] - pub fn readv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; pub fn uname(buf: *mut ::utsname) -> ::c_int; pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; @@ -709,14 +695,6 @@ extern { link_name = "putenv$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")] pub fn putenv(string: *mut c_char) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "sendmsg$UNIX2003")] - pub fn sendmsg(fd: ::c_int, - msg: *const msghdr, - flags: ::c_int) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recvmsg$UNIX2003")] - pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "poll$UNIX2003")] pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; @@ -750,6 +728,56 @@ extern { -> ::c_int; pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int; pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int; + + pub fn readlink(path: *const c_char, + buf: *mut c_char, + bufsz: ::size_t) + -> ::ssize_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] + pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] + pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")] + pub fn sigfillset(set: *mut sigset_t) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")] + pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; + #[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 = "__timegm50")] + pub fn timegm(tm: *mut ::tm) -> time_t; +} + +// Android has some weirdness in this definition +// See weirdness in src/unix/notbsd/android/mod.rs +#[cfg(any(not(target_os = "android"), // " if " -- appease style checker + not(target_arch = "aarch64")))] +extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "bind$UNIX2003")] + pub fn bind(socket: ::c_int, address: *const sockaddr, + address_len: socklen_t) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "writev$UNIX2003")] + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "readv$UNIX2003")] + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "sendmsg$UNIX2003")] + pub fn sendmsg(fd: ::c_int, + msg: *const msghdr, + flags: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvmsg$UNIX2003")] + pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; } // TODO: get rid of this cfg(not(...)) @@ -785,10 +813,6 @@ extern { pub fn getsid(pid: pid_t) -> pid_t; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - pub fn readlink(path: *const c_char, - buf: *mut c_char, - bufsz: ::size_t) - -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "msync$UNIX2003")] @@ -802,16 +826,6 @@ extern { addrlen: *mut socklen_t) -> ::ssize_t; pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] - pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] - pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")] - pub fn sigfillset(set: *mut sigset_t) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")] - pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")] - pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "pselect$1050")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -827,8 +841,6 @@ extern { offset: ::off_t, whence: ::c_int) -> ::c_int; pub fn ftello(stream: *mut ::FILE) -> ::off_t; - #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] - pub fn timegm(tm: *mut ::tm) -> time_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "tcdrain$UNIX2003")] pub fn tcdrain(fd: ::c_int) -> ::c_int; diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs index bd69ccf37d571..f9c12d336960e 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32.rs @@ -2,6 +2,8 @@ pub type c_long = i32; pub type c_ulong = u32; pub type mode_t = u16; pub type off64_t = ::c_longlong; +pub type sigset_t = ::c_ulong; +pub type time64_t = i64; s! { pub struct sigaction { @@ -11,6 +13,11 @@ s! { pub sa_restorer: ::dox::Option, } + pub struct rlimit64 { + pub rlim_cur: u64, + pub rlim_max: u64, + } + pub struct stat { pub st_dev: ::c_ulonglong, __pad0: [::c_uchar; 4], diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64.rs index b35dde4216059..ff1f1409664e5 100644 --- a/src/unix/notbsd/android/b64.rs +++ b/src/unix/notbsd/android/b64.rs @@ -6,6 +6,10 @@ pub type mode_t = u32; pub type off64_t = i64; s! { + pub struct sigset_t { + __val: [::c_ulong; 1], + } + pub struct sigaction { pub sa_flags: ::c_uint, pub sa_sigaction: ::sighandler_t, @@ -13,6 +17,11 @@ s! { _restorer: *mut ::c_void, } + pub struct rlimit64 { + pub rlim_cur: ::c_ulonglong, + pub rlim_max: ::c_ulonglong, + } + pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, @@ -155,7 +164,3 @@ pub const __CPU_BITS: ::size_t = 64; pub const UT_LINESIZE: usize = 32; pub const UT_NAMESIZE: usize = 32; pub const UT_HOSTSIZE: usize = 256; - -extern { - pub fn timegm(tm: *const ::tm) -> ::time64_t; -} diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 0d1c7d07e9fd1..4b8344cb38eca 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -24,8 +24,6 @@ pub type socklen_t = i32; pub type pthread_t = ::c_long; pub type pthread_mutexattr_t = ::c_long; pub type pthread_condattr_t = ::c_long; -pub type sigset_t = ::c_ulong; -pub type time64_t = i64; // N/A on android pub type fsfilcnt_t = ::c_ulong; pub type fsblkcnt_t = ::c_ulong; pub type nfds_t = ::c_uint; @@ -52,11 +50,6 @@ s! { pub d_name: [::c_char; 256], } - pub struct rlimit64 { - pub rlim_cur: u64, - pub rlim_max: u64, - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, @@ -76,7 +69,7 @@ s! { pub struct msghdr { pub msg_name: *mut ::c_void, - pub msg_namelen: ::c_int, + pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, pub msg_iovlen: ::size_t, pub msg_control: *mut ::c_void, @@ -534,10 +527,15 @@ pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; -pub const PTRACE_GETFPREGS: ::c_int = 14; -pub const PTRACE_SETFPREGS: ::c_int = 15; -pub const PTRACE_GETREGS: ::c_int = 12; -pub const PTRACE_SETREGS: ::c_int = 13; + +cfg_if! { + if #[cfg(not(target_arch = "aarch64"))] { + pub const PTRACE_GETFPREGS: ::c_int = 14; + pub const PTRACE_SETFPREGS: ::c_int = 15; + pub const PTRACE_GETREGS: ::c_int = 12; + pub const PTRACE_SETREGS: ::c_int = 13; + } else {} +} pub const EFD_NONBLOCK: ::c_int = 0x800; @@ -710,25 +708,6 @@ pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); pub const SIGEV_THREAD_ID: ::c_int = 4; f! { - pub fn sigemptyset(set: *mut sigset_t) -> ::c_int { - *set = 0; - return 0 - } - pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int { - *set |= signum as sigset_t; - return 0 - } - pub fn sigfillset(set: *mut sigset_t) -> ::c_int { - *set = !0; - return 0 - } - pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int { - *set &= !(signum as sigset_t); - return 0 - } - pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int { - (*set & (signum as sigset_t)) as ::c_int - } pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t { (*termios).c_cflag & ::CBAUD } @@ -798,14 +777,36 @@ extern { static mut __progname: *mut ::c_char; } +// Some weirdness in Android +#[cfg(target_arch = "aarch64")] // " if " -- appease style checker +extern { + // address_len should be socklen_t, but it is c_int! + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn sendmsg(fd: ::c_int, + msg: *const msghdr, + flags: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::c_int; +} + extern { pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; - pub fn readlink(path: *const ::c_char, - buf: *mut ::c_char, - bufsz: ::size_t) - -> ::c_int; pub fn msync(addr: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) From f2f11296723f3c492b0271898bd8daa8c391001a Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 24 Feb 2017 17:03:51 -0300 Subject: [PATCH 4/9] Fix aarch64-linux-android failing tests --- src/unix/notbsd/android/b32.rs | 1 + src/unix/notbsd/android/b64.rs | 1 + src/unix/notbsd/android/mod.rs | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs index f9c12d336960e..beccb6c308c8b 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32.rs @@ -3,6 +3,7 @@ pub type c_ulong = u32; pub type mode_t = u16; pub type off64_t = ::c_longlong; pub type sigset_t = ::c_ulong; +pub type socklen_t = i32; pub type time64_t = i64; s! { diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64.rs index ff1f1409664e5..230b43dbc417f 100644 --- a/src/unix/notbsd/android/b64.rs +++ b/src/unix/notbsd/android/b64.rs @@ -4,6 +4,7 @@ pub type c_long = i64; pub type c_ulong = u64; pub type mode_t = u32; pub type off64_t = i64; +pub type socklen_t = u32; s! { pub struct sigset_t { diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 4b8344cb38eca..a121a6b017be5 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -20,7 +20,6 @@ pub type blkcnt_t = ::c_ulong; pub type blksize_t = ::c_ulong; pub type nlink_t = u32; pub type useconds_t = u32; -pub type socklen_t = i32; pub type pthread_t = ::c_long; pub type pthread_mutexattr_t = ::c_long; pub type pthread_condattr_t = ::c_long; @@ -61,6 +60,7 @@ s! { pub si_errno: ::c_int, pub si_code: ::c_int, pub _pad: [::c_int; 29], + _align: [usize; 0], } pub struct __fsid_t { @@ -109,6 +109,8 @@ s! { pub struct sem_t { count: ::c_uint, + #[cfg(target_pointer_width = "64")] + __reserved: [::c_int; 3], } pub struct lastlog { @@ -150,6 +152,8 @@ s! { pub f_fsid: ::c_ulong, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, + #[cfg(target_pointer_width = "64")] + __f_reserved: [u32; 6], } } @@ -577,10 +581,19 @@ pub const TIOCMSET: ::c_int = 0x5418; pub const FIONREAD: ::c_int = 0x541B; pub const TIOCCONS: ::c_int = 0x541D; -pub const RTLD_GLOBAL: ::c_int = 0x2; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const RTLD_NOW: ::c_int = 0; -pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + pub const RTLD_GLOBAL: ::c_int = 0x00100; + pub const RTLD_NOW: ::c_int = 2; + pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; + } else { + pub const RTLD_GLOBAL: ::c_int = 2; + pub const RTLD_NOW: ::c_int = 0; + pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; + } +} pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; From d500a458a0584dc136e9951bc2f3faf2fba846a5 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 24 Feb 2017 17:21:56 -0300 Subject: [PATCH 5/9] Enable travis tests for {i686, aarch64}-linux-android --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3172a6fd69f9e..93236a8d0c6a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,12 @@ matrix: - os: linux env: TARGET=arm-linux-androideabi rust: stable + - os: linux + env: TARGET=aarch64-linux-android + rust: stable + - os: linux + env: TARGET=i686-linux-android + rust: stable - os: linux env: TARGET=x86_64-unknown-linux-musl rust: stable From 1175c6657dd710ac66a561a0ea3d4f530876c854 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 27 Feb 2017 16:06:27 -0300 Subject: [PATCH 6/9] Remove cfg_if from src/unix/notbsd/android/ --- src/unix/notbsd/android/b32/arm.rs | 6 ++ .../notbsd/android/{b32.rs => b32/mod.rs} | 21 ++++++ src/unix/notbsd/android/b32/x86.rs | 6 ++ .../notbsd/android/{b64.rs => b64/mod.rs} | 36 ++++++++++ src/unix/notbsd/android/mod.rs | 69 ------------------- 5 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 src/unix/notbsd/android/b32/arm.rs rename src/unix/notbsd/android/{b32.rs => b32/mod.rs} (89%) create mode 100644 src/unix/notbsd/android/b32/x86.rs rename src/unix/notbsd/android/{b64.rs => b64/mod.rs} (78%) diff --git a/src/unix/notbsd/android/b32/arm.rs b/src/unix/notbsd/android/b32/arm.rs new file mode 100644 index 0000000000000..1c9d033d17dba --- /dev/null +++ b/src/unix/notbsd/android/b32/arm.rs @@ -0,0 +1,6 @@ +pub type c_char = u8; +pub type wchar_t = u32; + +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32/mod.rs similarity index 89% rename from src/unix/notbsd/android/b32.rs rename to src/unix/notbsd/android/b32/mod.rs index beccb6c308c8b..d3dc22167be91 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32/mod.rs @@ -129,6 +129,15 @@ s! { } } +pub const RTLD_GLOBAL: ::c_int = 2; +pub const RTLD_NOW: ::c_int = 0; +pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; + +pub const PTRACE_GETFPREGS: ::c_int = 14; +pub const PTRACE_SETFPREGS: ::c_int = 15; +pub const PTRACE_GETREGS: ::c_int = 12; +pub const PTRACE_SETREGS: ::c_int = 13; + pub const SYS_gettid: ::c_long = 224; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, @@ -157,3 +166,15 @@ pub const UT_HOSTSIZE: usize = 16; extern { pub fn timegm64(tm: *const ::tm) -> ::time64_t; } + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else { + // Unknown target_arch + } +} diff --git a/src/unix/notbsd/android/b32/x86.rs b/src/unix/notbsd/android/b32/x86.rs new file mode 100644 index 0000000000000..c4b8197de55bc --- /dev/null +++ b/src/unix/notbsd/android/b32/x86.rs @@ -0,0 +1,6 @@ +pub type c_char = i8; +pub type wchar_t = i32; + +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x20000; diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64/mod.rs similarity index 78% rename from src/unix/notbsd/android/b64.rs rename to src/unix/notbsd/android/b64/mod.rs index 230b43dbc417f..19232834b8d45 100644 --- a/src/unix/notbsd/android/b64.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -1,10 +1,12 @@ // The following definitions are correct for aarch64 and may be wrong for x86_64 +pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; pub type mode_t = u32; pub type off64_t = i64; pub type socklen_t = u32; +pub type wchar_t = u32; s! { pub struct sigset_t { @@ -141,6 +143,14 @@ s! { } } +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; + +pub const RTLD_GLOBAL: ::c_int = 0x00100; +pub const RTLD_NOW: ::c_int = 2; +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; + pub const SYS_gettid: ::c_long = 178; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, @@ -165,3 +175,29 @@ pub const __CPU_BITS: ::size_t = 64; pub const UT_LINESIZE: usize = 32; pub const UT_NAMESIZE: usize = 32; pub const UT_HOSTSIZE: usize = 256; + +// Some weirdness in Android +extern { + // address_len should be socklen_t, but it is c_int! + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn sendmsg(fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int) -> ::c_int; + + // the return type should be ::ssize_t, but it is c_int! + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::c_int; +} + diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index a121a6b017be5..bbb8fa7f2a6bf 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -2,16 +2,6 @@ use dox::mem; -cfg_if! { - if #[cfg(target_arch = "x86")] { - pub type c_char = i8; - pub type wchar_t = i32; - } else { - pub type c_char = u8; - pub type wchar_t = u32; - } -} - pub type clock_t = ::c_long; pub type time_t = ::c_long; pub type suseconds_t = ::c_long; @@ -455,18 +445,6 @@ pub const O_SYNC: ::c_int = 0x101000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; -cfg_if! { - if #[cfg(target_arch = "x86")] { - pub const O_DIRECT: ::c_int = 0x4000; - pub const O_DIRECTORY: ::c_int = 0x10000; - pub const O_NOFOLLOW: ::c_int = 0x20000; - } else { - pub const O_DIRECT: ::c_int = 0x10000; - pub const O_DIRECTORY: ::c_int = 0x4000; - pub const O_NOFOLLOW: ::c_int = 0x8000; - } -} - pub const NI_MAXHOST: ::size_t = 1025; pub const NCCS: usize = 19; @@ -532,15 +510,6 @@ pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; -cfg_if! { - if #[cfg(not(target_arch = "aarch64"))] { - pub const PTRACE_GETFPREGS: ::c_int = 14; - pub const PTRACE_SETFPREGS: ::c_int = 15; - pub const PTRACE_GETREGS: ::c_int = 12; - pub const PTRACE_SETREGS: ::c_int = 13; - } else {} -} - pub const EFD_NONBLOCK: ::c_int = 0x800; pub const F_GETLK: ::c_int = 5; @@ -583,18 +552,6 @@ pub const TIOCCONS: ::c_int = 0x541D; pub const RTLD_NOLOAD: ::c_int = 0x4; -cfg_if! { - if #[cfg(target_arch = "aarch64")] { - pub const RTLD_GLOBAL: ::c_int = 0x00100; - pub const RTLD_NOW: ::c_int = 2; - pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; - } else { - pub const RTLD_GLOBAL: ::c_int = 2; - pub const RTLD_NOW: ::c_int = 0; - pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; - } -} - pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; @@ -790,32 +747,6 @@ extern { static mut __progname: *mut ::c_char; } -// Some weirdness in Android -#[cfg(target_arch = "aarch64")] // " if " -- appease style checker -extern { - // address_len should be socklen_t, but it is c_int! - pub fn bind(socket: ::c_int, address: *const ::sockaddr, - address_len: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn writev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn readv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn sendmsg(fd: ::c_int, - msg: *const msghdr, - flags: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::c_int; -} - extern { pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; From fab2d30adaa9a84f05aa3601cd35123e84ff27e7 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 27 Feb 2017 16:41:57 -0300 Subject: [PATCH 7/9] Remove cfg_if from src/unix/mod.rs - Copy 17 functions definitions from src/unix/mod.rs to src/unix/bsd/mod.rs src/unix/haiku/mod.rs src/unix/notbsd/linux/mod.rs and src/unix/solaris/mod.rs - Add some functions to android that was cfged out - Remove cf* and tc* functions implementations for android (they are available with api >= 12, which was release in 2011) --- src/unix/bsd/mod.rs | 68 +++++++++++++++++++++++++ src/unix/haiku/mod.rs | 42 ++++++++++++++++ src/unix/mod.rs | 79 +----------------------------- src/unix/notbsd/android/b32/mod.rs | 15 ++++++ src/unix/notbsd/android/b64/mod.rs | 1 - src/unix/notbsd/android/mod.rs | 35 ------------- src/unix/notbsd/linux/mod.rs | 42 ++++++++++++++++ src/unix/solaris/mod.rs | 43 ++++++++++++++++ 8 files changed, 212 insertions(+), 113 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 2f7024f8276a0..175d4a96be059 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -359,6 +359,74 @@ extern { pub fn getpeereid(socket: ::c_int, euid: *mut ::uid_t, egid: *mut ::gid_t) -> ::c_int; + + #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] + #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] + pub fn glob(pattern: *const c_char, + flags: ::c_int, + errfunc: Option ::c_int>, + pglob: *mut glob_t) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] + pub fn globfree(pglob: *mut glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn shm_unlink(name: *const c_char) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003")] + pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003")] + pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003")] + #[cfg_attr(target_os = "netbsd", link_name = "__msync13")] + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003")] + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "bind$UNIX2003")] + pub fn bind(socket: ::c_int, address: *const sockaddr, + address_len: socklen_t) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "writev$UNIX2003")] + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "readv$UNIX2003")] + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "sendmsg$UNIX2003")] + pub fn sendmsg(fd: ::c_int, + msg: *const msghdr, + flags: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvmsg$UNIX2003")] + pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; } cfg_if! { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 634805ca2ee70..60d9c8ac5a772 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -760,6 +760,48 @@ extern { abstime: *const ::timespec) -> ::c_int; pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; + + pub fn glob(pattern: *const c_char, + flags: ::c_int, + errfunc: Option ::c_int>, + pglob: *mut glob_t) -> ::c_int; + pub fn globfree(pglob: *mut glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn shm_unlink(name: *const c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + + pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; + + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn bind(socket: ::c_int, address: *const sockaddr, + address_len: socklen_t) -> ::c_int; + + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + + pub fn sendmsg(fd: ::c_int, + msg: *const msghdr, + flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; } cfg_if! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e66cb0f0a0ccb..82bf8e21174f6 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -747,83 +747,11 @@ extern { #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] pub fn timegm(tm: *mut ::tm) -> time_t; -} - -// Android has some weirdness in this definition -// See weirdness in src/unix/notbsd/android/mod.rs -#[cfg(any(not(target_os = "android"), // " if " -- appease style checker - not(target_arch = "aarch64")))] -extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "bind$UNIX2003")] - pub fn bind(socket: ::c_int, address: *const sockaddr, - address_len: socklen_t) -> ::c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "writev$UNIX2003")] - pub fn writev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "readv$UNIX2003")] - pub fn readv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "sendmsg$UNIX2003")] - pub fn sendmsg(fd: ::c_int, - msg: *const msghdr, - flags: ::c_int) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recvmsg$UNIX2003")] - pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; -} - -// TODO: get rid of this cfg(not(...)) -#[cfg(not(target_os = "android"))] // " if " -- appease style checker -extern { - #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] - #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] - pub fn glob(pattern: *const c_char, - flags: ::c_int, - errfunc: Option ::c_int>, - pglob: *mut glob_t) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] - pub fn globfree(pglob: *mut glob_t); - - pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - - pub fn shm_unlink(name: *const c_char) -> ::c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "seekdir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "seekdir$INODE64$UNIX2003")] - pub fn seekdir(dirp: *mut ::DIR, loc: c_long); - - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "telldir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "telldir$INODE64$UNIX2003")] - pub fn telldir(dirp: *mut ::DIR) -> c_long; pub fn getsid(pid: pid_t) -> pid_t; - pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "msync$UNIX2003")] - #[cfg_attr(target_os = "netbsd", link_name = "__msync13")] - pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; - pub fn sysconf(name: ::c_int) -> c_long; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recvfrom$UNIX2003")] - pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ::ssize_t; + pub fn sysconf(name: ::c_int) -> ::c_long; + pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), @@ -856,10 +784,7 @@ extern { pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int; pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; pub fn mkstemp(template: *mut ::c_char) -> ::c_int; - pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char; - pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; - pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int); pub fn closelog(); diff --git a/src/unix/notbsd/android/b32/mod.rs b/src/unix/notbsd/android/b32/mod.rs index d3dc22167be91..fb192b5f0484e 100644 --- a/src/unix/notbsd/android/b32/mod.rs +++ b/src/unix/notbsd/android/b32/mod.rs @@ -164,6 +164,21 @@ pub const UT_NAMESIZE: usize = 8; pub const UT_HOSTSIZE: usize = 16; extern { + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: socklen_t) -> ::c_int; + + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + + pub fn sendmsg(fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn timegm64(tm: *const ::tm) -> ::time64_t; } diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs index 19232834b8d45..31a05d657c55e 100644 --- a/src/unix/notbsd/android/b64/mod.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -200,4 +200,3 @@ extern { // the return type should be ::ssize_t, but it is c_int! pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::c_int; } - diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index bbb8fa7f2a6bf..c752dd18f2320 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -678,40 +678,6 @@ pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); pub const SIGEV_THREAD_ID: ::c_int = 4; f! { - pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t { - (*termios).c_cflag & ::CBAUD - } - pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t { - (*termios).c_cflag & ::CBAUD - } - pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int { - let cbaud = ::CBAUD; - (*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud); - return 0 - } - pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int { - let cbaud = ::CBAUD; - (*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud); - return 0 - } - pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int { - ioctl(fd, ::TCGETS, termios) - } - pub fn tcsetattr(fd: ::c_int, - optional_actions: ::c_int, - termios: *const ::termios) -> ::c_int { - ioctl(fd, optional_actions, termios) - } - pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int { - ioctl(fd, ::TCXONC, action as *mut ::c_void) - } - pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int { - ioctl(fd, ::TCFLSH, action as *mut ::c_void) - } - pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int { - ioctl(fd, TCSBRKP, duration as *mut ::c_void) - } - pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { for slot in cpuset.__bits.iter_mut() { *slot = 0; @@ -755,7 +721,6 @@ extern { flags: ::c_int) -> ::c_int; pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; - pub fn sysconf(name: ::c_int) -> ::c_long; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int, addr: *const ::sockaddr, addrlen: *mut ::socklen_t) -> ::ssize_t; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index fd8fffe77c319..048c0b8880e0d 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -900,6 +900,48 @@ extern { new_len: ::size_t, flags: ::c_int, ...) -> *mut ::c_void; + + pub fn glob(pattern: *const c_char, + flags: ::c_int, + errfunc: Option ::c_int>, + pglob: *mut glob_t) -> ::c_int; + pub fn globfree(pglob: *mut glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn shm_unlink(name: *const c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + + pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; + + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn bind(socket: ::c_int, address: *const sockaddr, + address_len: socklen_t) -> ::c_int; + + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + + pub fn sendmsg(fd: ::c_int, + msg: *const msghdr, + flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; } cfg_if! { diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 1800a4cb433c6..452b25f43298c 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -1094,4 +1094,47 @@ extern { abstime: *const ::timespec) -> ::c_int; pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; + + pub fn glob(pattern: *const c_char, + flags: ::c_int, + errfunc: Option ::c_int>, + pglob: *mut glob_t) -> ::c_int; + + pub fn globfree(pglob: *mut glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn shm_unlink(name: *const c_char) -> ::c_int; + + pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + + pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; + + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ::ssize_t; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + + pub fn bind(socket: ::c_int, address: *const sockaddr, + address_len: socklen_t) -> ::c_int; + + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + + pub fn sendmsg(fd: ::c_int, + msg: *const msghdr, + flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; } From a3759d7feb6dba3f17b97e2ddd2a6fd7f265b258 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 27 Feb 2017 17:25:55 -0300 Subject: [PATCH 8/9] Fix missing prefix :: --- src/unix/bsd/mod.rs | 28 ++++++++++++++-------------- src/unix/haiku/mod.rs | 28 ++++++++++++++-------------- src/unix/notbsd/linux/mod.rs | 24 ++++++++++++------------ src/unix/solaris/mod.rs | 28 ++++++++++++++-------------- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 175d4a96be059..7db901a5ff335 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -1,4 +1,4 @@ -use dox::mem; +use dox::{mem, Option}; pub type c_char = i8; pub type wchar_t = i32; @@ -362,30 +362,30 @@ extern { #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] - pub fn glob(pattern: *const c_char, + pub fn glob(pattern: *const ::c_char, flags: ::c_int, - errfunc: Option ::c_int>, - pglob: *mut glob_t) -> ::c_int; + pglob: *mut ::glob_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] - pub fn globfree(pglob: *mut glob_t); + pub fn globfree(pglob: *mut ::glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - pub fn shm_unlink(name: *const c_char) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "seekdir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "seekdir$INODE64$UNIX2003")] - pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "telldir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "telldir$INODE64$UNIX2003")] - pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; @@ -397,16 +397,16 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recvfrom$UNIX2003")] pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ::ssize_t; + flags: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "bind$UNIX2003")] - pub fn bind(socket: ::c_int, address: *const sockaddr, - address_len: socklen_t) -> ::c_int; + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "writev$UNIX2003")] @@ -422,11 +422,11 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sendmsg$UNIX2003")] pub fn sendmsg(fd: ::c_int, - msg: *const msghdr, + msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recvmsg$UNIX2003")] - pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; } cfg_if! { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 60d9c8ac5a772..ee3996e1395bb 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1,4 +1,4 @@ -use dox::mem; +use dox::{mem, Option}; pub type rlim_t = ::uintptr_t; pub type sa_family_t = u8; @@ -761,35 +761,35 @@ extern { pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; - pub fn glob(pattern: *const c_char, + pub fn glob(pattern: *const ::c_char, flags: ::c_int, - errfunc: Option ::c_int>, - pglob: *mut glob_t) -> ::c_int; - pub fn globfree(pglob: *mut glob_t); + pglob: *mut ::glob_t) -> ::c_int; + pub fn globfree(pglob: *mut ::glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - pub fn shm_unlink(name: *const c_char) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; - pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); - pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ::ssize_t; + flags: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; - pub fn bind(socket: ::c_int, address: *const sockaddr, - address_len: socklen_t) -> ::c_int; + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::socklen_t) -> ::c_int; pub fn writev(fd: ::c_int, iov: *const ::iovec, @@ -799,9 +799,9 @@ extern { iovcnt: ::c_int) -> ::ssize_t; pub fn sendmsg(fd: ::c_int, - msg: *const msghdr, + msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; } cfg_if! { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 048c0b8880e0d..3f966cd60713f 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -1,6 +1,6 @@ //! Linux-specific definitions for linux-like values -use dox::mem; +use dox::{mem, Option}; pub type useconds_t = u32; pub type dev_t = u64; @@ -905,31 +905,31 @@ extern { flags: ::c_int, errfunc: Option ::c_int>, - pglob: *mut glob_t) -> ::c_int; - pub fn globfree(pglob: *mut glob_t); + pglob: *mut ::glob_t) -> ::c_int; + pub fn globfree(pglob: *mut ::glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - pub fn shm_unlink(name: *const c_char) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; - pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); - pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ::ssize_t; + flags: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; - pub fn bind(socket: ::c_int, address: *const sockaddr, - address_len: socklen_t) -> ::c_int; + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::socklen_t) -> ::c_int; pub fn writev(fd: ::c_int, iov: *const ::iovec, @@ -939,9 +939,9 @@ extern { iovcnt: ::c_int) -> ::ssize_t; pub fn sendmsg(fd: ::c_int, - msg: *const msghdr, + msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; } cfg_if! { diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 452b25f43298c..394098787352a 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -1,4 +1,4 @@ -use dox::mem; +use dox::{mem, Option}; pub type c_char = i8; pub type c_long = i64; @@ -1095,36 +1095,36 @@ extern { pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; - pub fn glob(pattern: *const c_char, + pub fn glob(pattern: *const ::c_char, flags: ::c_int, - errfunc: Option ::c_int>, - pglob: *mut glob_t) -> ::c_int; + pglob: *mut ::glob_t) -> ::c_int; - pub fn globfree(pglob: *mut glob_t); + pub fn globfree(pglob: *mut ::glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - pub fn shm_unlink(name: *const c_char) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; - pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); - pub fn telldir(dirp: *mut ::DIR) -> c_long; + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ::ssize_t; + flags: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; - pub fn bind(socket: ::c_int, address: *const sockaddr, - address_len: socklen_t) -> ::c_int; + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::socklen_t) -> ::c_int; pub fn writev(fd: ::c_int, iov: *const ::iovec, @@ -1134,7 +1134,7 @@ extern { iovcnt: ::c_int) -> ::ssize_t; pub fn sendmsg(fd: ::c_int, - msg: *const msghdr, + msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; } From 9a20f93222e33cdf63e6f95ee0220dc26a4330a5 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 27 Feb 2017 17:54:51 -0300 Subject: [PATCH 9/9] Fix style --- src/unix/bsd/mod.rs | 3 ++- src/unix/haiku/mod.rs | 3 ++- src/unix/notbsd/android/b32/mod.rs | 3 ++- src/unix/notbsd/linux/mod.rs | 3 ++- src/unix/solaris/mod.rs | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 7db901a5ff335..826bd9288bd53 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -426,7 +426,8 @@ extern { flags: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recvmsg$UNIX2003")] - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) + -> ::ssize_t; } cfg_if! { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index ee3996e1395bb..c4b446769bf61 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -801,7 +801,8 @@ extern { pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) + -> ::ssize_t; } cfg_if! { diff --git a/src/unix/notbsd/android/b32/mod.rs b/src/unix/notbsd/android/b32/mod.rs index fb192b5f0484e..9efcd61c726ec 100644 --- a/src/unix/notbsd/android/b32/mod.rs +++ b/src/unix/notbsd/android/b32/mod.rs @@ -177,7 +177,8 @@ extern { pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) + -> ::ssize_t; pub fn timegm64(tm: *const ::tm) -> ::time64_t; } diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 3f966cd60713f..248ea50b411fc 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -941,7 +941,8 @@ extern { pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) + -> ::ssize_t; } cfg_if! { diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 394098787352a..55ac0a276dbe9 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -1136,5 +1136,6 @@ extern { pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) + -> ::ssize_t; }