Commit Graph

941 Commits

Author SHA1 Message Date
bors
b19b5465a1 Auto merge of #291 - alexcrichton:readd-hw-ncpu, r=alexcrichton
Add back HW_NCPU

Removed by accident in #285
2016-05-16 10:25:04 -07:00
Alex Crichton
841a4df413 Add back HW_NCPU
Removed by accident in #285
2016-05-16 10:24:20 -07:00
Fletcher Nichol
78d9be216e Fix ioctl constants for musl target envs.
According to musl's source, the `ioctl` [function
signature][musl-ioctl-h] takes an `int` as the request argument (i.e. an
`i32`) which is reflected in this crate's [ioctl
binding][musl-ioctl-rs]. It looks like when the ioctl constants were
added that [glibc's default][glibc-ioctl-h] of a `c_ulong` type was used
for the musl values as well, rather than a `c_int` type. This change
updates these constants to a `c_int` so that they match the expected
function call type.

Here is a minimal reproduction of the issue. Given this Rust program:

```rust
extern crate libc;

use libc::{ioctl, winsize, STDOUT_FILENO, TIOCGWINSZ};

fn main() {
    let mut wsize = winsize {
        ws_row: 0,
        ws_col: 0,
        ws_xpixel: 0,
        ws_ypixel: 0,
    };
    unsafe {
        ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut wsize);
    }
    println!("Sizes: {{ rows: {}, cols: {}, xpixel: {}, ypixel: {} }}",
             wsize.ws_row,
             wsize.ws_col,
             wsize.ws_xpixel,
             wsize.ws_ypixel);
}
```

When run against the `x86_64-unknwon-linux-gnu` and
`x86_64-unknown-linux-musl` targets, we see the difference in behavior:

```
> cargo clean

> cargo run --target=x86_64-unknown-linux-gnu
   Compiling libc v0.2.11
   Compiling libc-musl-ioctl v0.1.0 (file:///src/libc-musl-ioctl)
     Running `target/x86_64-unknown-linux-gnu/debug/libc-musl-ioctl`
Sizes: { rows: 28, cols: 211, xpixel: 0, ypixel: 0 }

> cargo clean

> cargo run --target=x86_64-unknown-linux-musl
   Compiling libc v0.2.11
   Compiling libc-musl-ioctl v0.1.0 (file:///src/libc-musl-ioctl)
src/main.rs:13:30: 13:40 error: mismatched types:
 expected `i32`,
    found `u64` [E0308]
src/main.rs:13         ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut wsize);
                                            ^~~~~~~~~~
src/main.rs:13:30: 13:40 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
Could not compile `libc-musl-ioctl`.

To learn more, run the command again with --verbose.
```

Working against this fix:

```
> cargo clean

> cargo run --target=x86_64-unknown-linux-gnu
    Updating git repository `https://github.com/fnichol/rust-lang-libc.git`
   Compiling libc v0.2.11 (https://github.com/fnichol/rust-lang-libc.git?branch=fix-musl-ioctl-constants#3285f387)
   Compiling libc-musl-ioctl v0.1.0 (file:///src/libc-musl-ioctl)
     Running `target/x86_64-unknown-linux-gnu/debug/libc-musl-ioctl`
Sizes: { rows: 28, cols: 211, xpixel: 0, ypixel: 0 }

> cargo clean

> cargo run --target=x86_64-unknown-linux-musl
   Compiling libc v0.2.11 (https://github.com/fnichol/rust-lang-libc.git?branch=fix-musl-ioctl-constants#3285f387)
   Compiling libc-musl-ioctl v0.1.0 (file:///src/libc-musl-ioctl)
     Running `target/x86_64-unknown-linux-musl/debug/libc-musl-ioctl`
Sizes: { rows: 28, cols: 211, xpixel: 0, ypixel: 0 }
```

[musl-ioctl-rs]:
https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl/libc/fn.ioctl.html

[musl-ioctl-h]:
https://git.musl-libc.org/cgit/musl/tree/include/sys/ioctl.h

[glibc-ioctl-h]:
http://bazaar.launchpad.net/~vcs-imports/glibc/master/view/head:/include/sys/ioctl.h
2016-05-15 15:04:13 -06:00
bors
4a397ab06b Auto merge of #287 - alexcrichton:no-util-on-musl, r=alexcrichton
Don't link util on musl, consolidate #[link]
2016-05-14 17:31:55 -07:00
bors
72519bf427 Auto merge of #285 - lemonrock:sysctl, r=alexcrichton
Added extensive constants to make use of the BSD's sysctl function.

sysctl usage does differ significantly across the BSDs, and, whilst
some constants overlap, many do not. It is easier to maintain them
in separate modules, rather than trying to tease out common definitions.
2016-05-13 20:47:31 -07:00
Raphael Cohn
786d505616 Merge branch 'master' into sysctl 2016-05-13 11:26:06 +01:00
Raphael Cohn
a6d48051d3 Added extensive constants to make use of the BSD's sysctl function.
sysctl usage does differ significantly across the BSDs, and, whilst
some constants overlap, many do not. It is easier to maintain them
in separate modules, rather than trying to tease out common definitions.
2016-05-13 11:25:56 +01:00
Alex Crichton
33fef1063f Don't link util on musl, consolidate #[link] 2016-05-12 23:12:13 -07:00
bors
81e3af27ea Auto merge of #283 - jvns:add_process_vm_readv, r=alexcrichton
Add notbsd process_vm_readv and process_vm_writev system calls
2016-05-12 15:17:37 -07:00
Julia Evans
c9496fe712 Add process_vm_readv and process_vm_writev system calls 2016-05-12 16:44:05 -04:00
bors
6598e2cbfd Auto merge of #284 - lemonrock:getloadavg, r=alexcrichton
Added getloadavg for Linux, the BSDs and Solaris.

Sadly Android's bionic lacks this functionality.
2016-05-11 15:16:56 -07:00
Raphael Cohn
72f1fb68d8 Added getloadavg for Linux, the BSDs and Solaris.
Sadly Android's bionic lacks this functionality.
2016-05-11 18:06:14 +01:00
bors
19fd504725 Auto merge of #281 - lemonrock:getprogname, r=alexcrichton
Getprogname

Added `getprogname()` and `setprogname()` for all BSDs and Solaris (including Mac OS X).

Added `program_invocation_short_name` global, for Linux (glibc and Musl) which is effectively the same thing, and is what compatibility libraries like `libbsd` use to implement `getprogname()`.

Added `__progname` global for Android, which, whilst not quite the same as `getprogname` or `program_invocation_short_name`, is better than using argv[0], as it (a) avoids a common bug with no arguments (b) avoids a common bug with a NULL string in argv[0] and (c) incorporates Android's chosen name for an unknown process.
2016-05-10 11:50:23 -07:00
Raphael Cohn
893d4d846a Adding getprogname and setprogname for all BSDs and Solaris.
Adding program_invocation_short_name for Linux (Musl and glibc).

Adding __progname for Android. This is a little different, but
is a safer alternative to using argv[0], which may not exist, and
includes Android's default application name (currently '<unknown>').

Adding these functions and externs means it is possible for all
but Windows applications to safely discover their
name, rather than rely on argv[0] parsing, /proc/self/exe, etc.
2016-05-10 19:11:44 +01:00
bors
2cd2cff10c Auto merge of #280 - fiveop:refine_mcontext, r=alexcrichton
Refine defininition of mcontext_t on linux glibc x86-64 and x86.
2016-05-08 14:22:10 -07:00
bors
53e14e2f64 Auto merge of #282 - Nercury:correctly-sized-structs-and-types-for-android-aarch64, r=alexcrichton
Add correctly sized structs and types for Android aarch64.

So far both android x86_64 and aarch64 configurations used incorrect types from 32-bit architecture.

This PR updates only the aarch64, because it is more common. The x86_64 may be also incorrect, but is out of scope of this PR.
2016-05-08 10:45:36 -07:00
Nerijus Arlauskas
dad0dd2a50 Add correctly sized structs and types for Android aarch64. 2016-05-08 18:26:12 +03:00
Philipp Matthias Schaefer
7c0c28f55f Refine definition of mcontext_t on x86. 2016-05-07 19:13:13 +02:00
Philipp Matthias Schaefer
ac7f0fac2f Refine defininition of mcontext_t on x86-x64. 2016-05-07 16:17:09 +02:00
bors
a04a52a066 Auto merge of #279 - kamalmarhubi:pipe_buf, r=alexcrichton
unix: Add PIPE_BUF for bsd and notbsd

This is the maximum size of guaranteed-atomic writes to a pipe.
2016-05-06 09:04:15 -07:00
Kamal Marhubi
ce0dc73608 unix: Add PIPE_BUF for bsd and notbsd
This is the maximum size of guaranteed-atomic writes to a pipe.
2016-05-05 18:56:28 -04:00
bors
4fc03fe957 Auto merge of #278 - lemonrock:syslog, r=alexcrichton
Adding syslog functions, constants and structs

This commit adds the functions:-
- syslog
- openlog
- closelog
- setlogmask

It adds LOG_* constants.

It adds the `CODE` struct used by the `#define` definitions `prioritynames` and `facilitynames`.

It does not add:-
- the function `vsyslog`; this is an extension to POSIX and uses va_list macros;
- the `#define`s `prioritynames` and `facilitynames`, as usage is not common
- rust functions mirroring the macros:-
  - LOG_PRI
  - LOG_MAKEPRI
  - LOG_MASK
  - LOG_UPTO
  - LOG_FAC
* `CODE` is included in case a third-party unsafe C function returns or takes it.
2016-05-05 14:47:43 -07:00
Raphael Cohn
828766fd23 Added LOG_CRON back for Solaris 2016-05-05 18:30:49 +01:00
Raphael Cohn
25df1e4c37 Added support for LOG_NTP, LOG_SECURITY and LOG_CONSOLE to FreeBSD.
Did this by moving these definitions up from DragonFlyBSD.
2016-05-05 18:04:12 +01:00
Raphael Cohn
f5b64dd0dd Merge branch 'syslog' of https://github.com/lemonrock/libc into syslog 2016-05-05 17:46:44 +01:00
Raphael Cohn
1c6c0ca735 Moved LOG_NFEATURES from notbsd to Linux
This is because Android bionic doesn't support `LOG_NFEATURES`.
2016-05-05 17:45:29 +01:00
Raphael Cohn
3045cb2eae Merge branch 'master' into syslog 2016-05-05 15:42:36 +01:00
Raphael Cohn
7fc0969900 Substantial changes to better support Solaris and BSD variants.
Removed CODE, as its definition and name varies too wildy and I
have no current code using it to test permutations with.

Moved LOG_NFACILITIES down, as Mac OS X defines this value
differently.

Added Mac OS X specific LOG_* facilities.

Added FreeBSD / DragonFly BSD specific LOG_* facilities.

Moved LOG_PERROR down, as all platforms bar Solaris define this.

Moved LOG_CRON down, as Solaris defines this with a different value.

Moved LOG_AUTHPRIV and LOG_FTP down, as all platforms bar Solaris
define these.

Looks like Solaris is suffering from the bit rot of commercial Unix...
2016-05-05 15:41:21 +01:00
bors
ac752505bd Auto merge of #277 - lemonrock:strnlen, r=alexcrichton
Added strnlen function to all platforms.

strnlen is used to find the length of a C string that may be
lacking a terminal NUL character. Whilst it is possible to
implement the equivalent functionality in rust code, it is
cleaner, simpler and removes the need for duplication of tricky
functionality to get right. It also makes it easier to port
C code snippets to rust. In my case, it's needed for dealing with
the result of `gethostname`.

Note that strnlen is not part of POSIX or C99, but is present on all major platforms.
2016-05-04 17:45:44 -07:00
bors
39f03eaa6d Auto merge of #276 - lemonrock:SC_HOSTNAME_MAX_OpenBsd, r=alexcrichton
Definition of _SC_HOST_NAME_MAX for OpenBSD and FreeBSD
2016-05-04 13:16:03 -07:00
Raphael Cohn
29b1ceab3e Added strnlen function to all platforms.
strnlen is used to find the length of a C string that may be
lacking a terminal NUL character. Whilst it is possible to
implement the equivalent functionality in rust code, it is
cleaner, simpler and removes the need for duplication of tricky
functionality to get right. It also makes it easier to port
C code snippets to rust.

Note that strnlen is not part of POSIX or C99.
2016-05-04 18:24:28 +01:00
bors
fc9a7deede Auto merge of #275 - lemonrock:SC_HOSTNAME_MAX, r=alexcrichton
Added _SC_HOST_NAME_MAX for FreeBSD, DragonFly, BitRig and Linux (glibc and musl)

I'd have liked to also add NetBSD and OpenBSD, but I can't find where _SC_HOST_NAME_MAX is defined.
2016-05-04 09:52:30 -07:00
Raphael Cohn
7e0dbc3270 Adding syslog functions, constants and structs
This commit adds the functions:-
- syslog
- openlog
- closelog
- setlogmask

It adds LOG_* constants.

It adds the CODE struct used by the #define definitions prioritynames and facilitynames.

It does not add:-
- the function vsyslog; this is an extension to POSIX and uses va_list macros;
- the #defines prioritynames and facilitynames, as usage is not common
- rust functions mirroring the macros:-
  - LOG_PRI
  - LOG_MAKEPRI
  - LOG_MASK
  - LOG_UPTO
  - LOG_FAC
* CODE is included in case a third-party unsafe C function returns or takes it.
2016-05-04 11:47:02 +01:00
Raphael Cohn
cdb99e3584 Definition of _SC_HOST_NAME_MAX for OpenBSD and FreeBSD 2016-05-04 11:20:23 +01:00
Raphael Cohn
f365111fcc Added _SC_HOST_NAME_MAX for FreeBSD, BitRig and Linux (glibc and musl) 2016-05-04 10:35:08 +01:00
bors
8adb9c54b3 Auto merge of #274 - alexcrichton:bump, r=alexcrichton
Bump to 0.2.11

Closes #273
2016-05-03 09:39:48 -07:00
Alex Crichton
959c6ab21b Bump to 0.2.11 2016-05-03 09:39:11 -07:00
bors
e2af623698 Auto merge of #272 - kamalmarhubi:apple-rlimit-rss, r=alexcrichton
apple: Add RLIMIT_RSS as alias of RLIMIT_AS

This is defined in <sys/resource.h> as

    #define	RLIMIT_RSS	RLIMIT_AS	/* source compatibility alias */

See http://opensource.apple.com//source/xnu/xnu-1456.1.26/bsd/sys/resource.h
2016-04-30 11:40:18 -07:00
Kamal Marhubi
6b980b1074 apple: Add RLIMIT_RSS as alias of RLIMIT_AS
This is defined in <sys/resource.h> as

    #define	RLIMIT_RSS	RLIMIT_AS	/* source compatibility alias */

See http://opensource.apple.com//source/xnu/xnu-1456.1.26/bsd/sys/resource.h
2016-04-30 10:43:10 -04:00
bors
6ad1be729a Auto merge of #271 - mbarnett:add_WSIGNALED_etc_for_osx, r=alexcrichton
OS X: add various process status tests defined by wait.h

Adds the various process test macros specified in the wait(2) manpage on OS X. ```WCOREDUMP``` is implemented BSD-wide as it seems to be the only macro whose definition is constant across the BSDs.
2016-04-29 15:41:05 -07:00
Matt Barnett
06abf3a28b fix naming of _WSTATUS macro from wait.h 2016-04-29 10:05:48 -06:00
bors
81efe51afc Auto merge of #268 - kamalmarhubi:prlimit, r=alexcrichton
linux: Add prlimit(2) and prlimit64(2)

As with `getrlimit` and `setrlimit`, the glibc wrappers have a non-`int`
for the `resource` argument, eg:

    extern int prlimit (__pid_t __pid, enum __rlimit_resource __resource,
                        const struct rlimit *__new_limit,
                        struct rlimit *__old_limit) __THROW;
2016-04-29 08:53:36 -07:00
Kamal Marhubi
9569599507 linux: Add prlimit(2) and prlimit64(2)
As with `getrlimit` and `setrlimit`, the glibc wrappers have a non-`int`
for the `resource` argument, eg:

    extern int prlimit (__pid_t __pid, enum __rlimit_resource __resource,
                        const struct rlimit *__new_limit,
                        struct rlimit *__old_limit) __THROW;
2016-04-29 09:49:19 -04:00
bors
4cc1df9350 Auto merge of #269 - kamalmarhubi:linux-android-dups, r=alexcrichton
notbsd: Deduplicate definitions

A bunch of definitions were duplicated across, eg, android and linux.
This commit pulls these up to higher levels where they can be shared.
2016-04-28 15:50:39 -07:00
Matt Barnett
71e9d6c720 OS X: add various process status tests defined by wait.h 2016-04-28 15:11:23 -06:00
bors
ac59d35b10 Auto merge of #265 - fiveop:missing_signals, r=alexcrichton
Add SIGEMT (for apple) and SIGINFO (for bsd).
2016-04-28 10:17:30 -07:00
bors
8025a3ee5e Auto merge of #259 - nodakai:patch-1, r=alexcrichton
Explain about the automated tests on Travis

in order to advise contributors to locally test their patches.
2016-04-28 08:51:43 -07:00
Kamal Marhubi
b9750b650d notbsd: Deduplicate definitions
A bunch of definitions were duplicated across, eg, android and linux.
This commit pulls these up to higher levels where they can be shared.
2016-04-27 22:25:48 -04:00
Kai Noda
cba130bc01
Explain about the automated tests on Travis
in order to advise contributors to locally test their patches.

Also update ctest to include a fix on rerun-if-changed so that human
developers doing trial & error can properly test their latest code.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2016-04-27 08:35:18 +08:00
Philipp Matthias Schaefer
a0725ad9fa Add SIGEMT (for apple) and SIGINFO (for bsd). 2016-04-26 08:01:32 +02:00