Run ios tests
This WIP PR runs the tests on the iOS simulator. I've tested it locally using macOS Sierra and XCode 8.2.1. I get this output:
RUNNING ALL TESTS
PASSED 6756 tests
The python script probably needs to be customized for the specific failure output from this test runner (update: newest commit should have this).
Added defines from ttycom.h for dragonfly and freebsd.
I wasn't sure about the convention but looking at other files it seems that whatever is over 0x80000000 is c_ulong so I went with that.
Add waitid and related constants and types.
[`waitid`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitid.html) is a variation on `waitpid` with a marginally more convenient way of reporting the status, and a couple of handy
additional features, such as the ability to peek at an exit status without consuming it. It's in POSIX.1-2008 and should be available on all supported Unixes.
Along with it come the type `idtype_t` and the constants `WEXITED`, `WSTOPPED`, `WCONTINUED`, and `WNOWAIT`. The constants were already defined for unix/notbsd platforms.
The patch is currently incomplete: I'm pushing it to get CI to test platforms I don't have. Todo list is
* [x] Add a definition of `siginfo_t` to all platforms that don't have it.
* [x] Verify that the new constants are consistent for all \*BSD platforms.
* [x] Verify that `idtype_t` is consistent across the board.
* [x] Add `link_name` annotations for `waitid` if/as necessary.
Add MSG_PEEK socket flag
#### MSG_PEEK
This PR exposes a cross-platform `MSG_PEEK` flag that a user may pass into the `flags` parameter for `recv()`, `recvfrom()`, or `recvmsg()` calls.
```
MSG_PEEK
This flag causes the receive operation to return data from the
beginning of the receive queue without removing that data from the
queue. Thus, a subsequent receive call will return the same data.
```
In short, users may call `recv()` to "peek" at new data (or a message) without consuming it. Recall that in the normal case, calls to `recv()` consume the data from the socket's receive queue, making it unavailable to future calls.
#### Motivation
This change enables `libc` users, such as the rust standard library, to potentially add peeking functionality to TCP and UDP implementations, like `TcpStream` and `UdpSocket`, without being concerned about the highly platform-dependent nature of the flags.
(In this case, the flag's value `0x2` is very consistent, but that is not the case for many of the `MSG_*` flags. It makes sense to keep these differences confined to `libc`)
#### Reference
[bsd/apple: socket.h](https://opensource.apple.com/source/xnu/xnu-2050.7.9/bsd/sys/socket.h)
[bsd/freebsdlike/freebsd: socket.h](https://github.com/freebsd/freebsd/blob/master/sys/sys/socket.h#L418)
[bsd/freebsdlike/dragonfly: socket.h](1f249c981c/sys/sys/socket.h (L367))
[bsd/netbsdlike: socket.h](af5d253140/sys/sys/socket.h (L517))
[unix/haiku: socket.h](b65adbdfbc/headers/posix/sys/socket.h (L114))
[unix/notbsd/linux: socket.h](5924bbecd0/include/linux/socket.h (L264))
[unix/notbsd/android: socket.h](73a5a3baaa/ndk/platforms/android-20/include/sys/socket.h (229))
It turns out that *only* FreeBSD and NetBSD proper have waitid, and that
Solaris' additional W* constants are totally different from everyone
else's, which tips me over from 'find some way to shoehorn this into
the top-level unix/mod.rs' to 'put it in the submodules, live with the
code duplication'.
Remove kind='static' from Redox linkage
Our cross compiler links binaries statically, and the rustc target has dynamic linking disabled - adding kind = "static" is not necessary.
* OpenBSD doesn't have idtype_t or the P_* constants either
* FreeBSD has different values for the P_* constants
* Android gives idtype_t a different signedness
* Disable waitid on NetBSD as it causes a link failure - I think this
may be a problem with the test environment
Add getpeereid function
This is a wrapper around getsockopt() for getting the uid/gid of a remote Unix domain socket peer. It was added in FreeBSD 4.6 and present in all modern BSDs I checked (including Mac OS X).
This is a wrapper around getsockopt() for getting the uid/gid of a
remote Unix domain socket peer. It was added in FreeBSD 4.6 and present
in all modern BSDs I checked (including Mac OS X).
* idtype_t no longer an enum.
* Darwin/x86-32 needs the $UNIX2003 thing.
* Darwin, FreeBSD, and NetBSD all have different values for the new constants.
* OpenBSD doesn't have this feature at all. (Hopefully we can get away
with defining idtype_t anyway.)
waitid() is a variation on waitpid() with a marginally more
convenient way of reporting the status, and a couple of handy
additional features, such as the ability to peek at an exit
status without consuming it. It's in POSIX.1-2008 and should
be available on all supported Unixes.
Along with it come the type 'idtype_t' and the constants
WEXITED, WSTOPPED, WCONTINUED, and WNOWAIT. Theconstants
were alre dy defined for unix/notbsd platforms.
Patch incomplete: several targets are going to have to add
definitions of siginfo_t, but I'm not sure which ones yet.
Link libc and libm in Redox [critical]
This is critical to being able to set up a proper cross compilation setup for Redox. Due to the way libc is vendored, I have to have this change merged in and have liblibc updated in the Rust repository as well before I can have a working buildbot for Redox.
Add Solaris constants for fcntl-style advisory locking
Solaris doesn't implement flock(), so any Rust implementation of flock()
will need to implement it using fcntl(), using the F_RDLCK, F_WRLCK, and
F_UNLCK constants.
Solaris doesn't implement flock(), so any Rust implementation of flock()
will need to implement it using fcntl(), using the F_RDLCK, F_WRLCK, and
F_UNLCK constants.
Support Neg and Not in no_core mode.
Needed by rust-lang/rust#38776 which requires the traits to be implemented even for integer types.
This is already the case with binary operator traits, which always require the trait and its impls.
sparc64-linux support
This needs to be "cleaned" up to use modules instead of a bunch of `cfg`s ...
Sadly, sparc64 constants are very different from other architectures so cleaning this will result in a bunch of duplication, I think.
While working on this, I was wondering why the constants are not written like this:
``` rust
// linux/mod.rs
const COMMON: ::c_int = 3;
cfg_if! {
if #[cfg(target_arch = "sparc64")] {
const FOO: ::c_int = 1;
} else if #[cfg(any(target_arch = "mips64", target_arch = "x86_64"))] {
const FOO: ::c_int = 2;
} else {
// unsupported/unknown architecture
}
}
```
I think this might result in less duplicated code. @alexcrichton Has something like that ^ been attempted before?