Commit Graph

776 Commits

Author SHA1 Message Date
bors
8a53df9f36 Auto merge of #312 - nbaksalyar:master, r=alexcrichton
Fix semaphores on Solaris/Illumos

This adds `sem_t` structure introduced in https://github.com/rust-lang/libc/pull/309 and fixes compilation on Solaris.
2016-06-10 00:51:48 -07:00
Nikita Baksalyar
a1c6ad7706
Fix compilation on Solaris/Illumos 2016-06-10 05:54:16 +05:00
Axel Viala
26ee782523 Add Directory file descriptor relative syscall.
I only added "*at" syscall relative to Posix2008 specification.

At the moment OSX and Android are partially supporting this API.

This include:
* `openat`
* `faccessat`
* `fchmodat`
* `fchownat`
* `fstatat`
* `linkat`
* `mkdirat`
* `mknodat` [0]
* `readlinkat`
* `renameat`
* `symlinkat`
* `unlinkat`
* `mkfifoat` [0][1]

[1] Not available on Android at the moment:
* `mkfifo`

[1] Not available on OSX at the moment:
* `mkfifoat`
* `mknodat`

And exclude operating system specific API:
* `renameat2`: Linux specific
* `execveat`: Linux specific since 3.19
* `futimesat`: GNU extension
* `name_to_handle_at`: GNU extension
* `scandirat`: GNU extension
* `fanotify_mark`: belong to fanotify API.
2016-06-10 02:33:32 +02:00
bors
9ae6227b42 Auto merge of #310 - nrc:WIF, r=alexcrichton
Add more constants from sys/wait.h

And fix WIFEXITED on Linux, which seemed to be wrong.
2016-06-09 07:13:31 -07:00
Nick Cameron
8c15a36466 Add more constants from sys/wait.h
And fix WIFEXITED on Linux, which seemed to be wrong.
2016-06-08 15:24:21 +02:00
bors
d1f4c2dd37 Auto merge of #309 - sfackler:sem, r=alexcrichton
Add semaphore APIs
2016-06-06 01:21:29 -07:00
Steven Fackler
41699f7406 Add semaphore APIs 2016-06-05 17:26:11 +01:00
bors
eb637d2773 Auto merge of #299 - lemonrock:sched_getcpu, r=alexcrichton
Adding sched_getcpu() for Android and Linux

None
2016-06-01 23:22:37 -07:00
Raphael Cohn
ae664ff911 Removing sched_getcpu for musl as no current releases support it 2016-06-01 10:24:34 +01:00
Raphael Cohn
b06c1f8345 Merge remote-tracking branch 'upstream/master' into sched_getcpu 2016-06-01 10:02:55 +01:00
bors
45d85899e9 Auto merge of #301 - Amanieu:musl_ioctl, r=alexcrichton
Fix ioctl types for non-x86 musl

This fixes up #289 by changing the type for other platforms as well.
2016-05-31 09:38:52 -07:00
Amanieu d'Antras
aa4a2c6ec2 Fix ioctl types for non-x86 musl 2016-05-30 08:05:44 +01:00
Raphael Cohn
a69b6c09d0 Merge remote-tracking branch 'upstream/master' into sched_getcpu 2016-05-28 10:55:50 +01:00
bors
bb4dabbc73 Auto merge of #300 - rrichardson:master, r=alexcrichton
added const SOCK_SEQPACKET,  and SOCK_RDM where applicable

... which is used for UNIX Seqpacket sockets as well as SCTP IP.

I have verified in source on  a couple Linux flavours as well as freebsd and darwin source that SOCK_SEQPACKET has value 5.
Solaris is the odd one with a value of 6.  I also added RDM for solaris (value 5)
2016-05-27 13:07:17 -07:00
Rick Richardson
df0a9bafda added const SOCK_SEQPACKET, which is used for unix seqpacket sockets as well as SCTP IP 2016-05-27 00:02:29 -04:00
bors
a200a04d44 Auto merge of #294 - lemonrock:getpriority, r=alexcrichton
Added nice, setpriority and getpriority along with constants and type…

… definitions
2016-05-25 11:07:21 -07:00
Raphael Cohn
dc98bd0fd4 Merged master 2016-05-25 18:18:26 +01:00
bors
505575f8b6 Auto merge of #288 - lemonrock:sysinfo, r=alexcrichton
Adding sysinfo() and sysinfo struct for Linux and Android.

Sadly, the sysinfo struct varies slightly between Musl and Glibc / Bionic.

This means that users need to be careful when using the uptime, and should
always cast it to a signed value. Why uptime can be signed is beyond me...
2016-05-25 08:55:51 -07:00
Raphael Cohn
f5df6b9142 Adding sched_getcpu() for Android and Linux 2016-05-25 11:37:01 +01:00
Raphael Cohn
4d37980fc3 Merge branch 'master' into sysinfo 2016-05-25 10:58:31 +01:00
Raphael Cohn
cbc88ca0d5 Adjustments for latest merge 2016-05-25 09:13:46 +01:00
bors
1f870b8073 Auto merge of #297 - Amanieu:mutex_types, r=alexcrichton
Add pthread mutex type constants

These are needed to create a pthread mutex that doesn't use lock elision on glibc.
2016-05-22 11:07:24 -07:00
bors
e0202b84e7 Auto merge of #298 - peterhj:peterhj-pthread-affinity, r=alexcrichton
linux: Support getting and setting the cpu affinity for the current pthread.

This implements `pthread_getaffinity_np` and `pthread_setaffinity_np` for linux.
2016-05-22 10:10:54 -07:00
Peter Jin
0b3635fda8 linux: Support getting and setting the cpu affinity for the current
pthread.
2016-05-21 20:50:20 -07:00
Raphael Cohn
bf5b72be85 Changing android to not use id_t 2016-05-21 09:49:31 +01:00
Amanieu d'Antras
b2b9f29eec Add pthread mutex type constants 2016-05-21 06:40:14 +01:00
Severen Redwood
fa53abb748 Add the TIOCGWINSZ and TIOCSWINSZ constants 2016-05-20 12:23:19 +01:00
Raphael Cohn
ad2d42601c Merge branch 'master' into sysinfo 2016-05-20 11:18:01 +01:00
Raphael Cohn
e6150ae2b9 Adding sysinfo() and sysinfo struct for Linux and Android.
Sadly, the sysinfo struct varies slightly between Musl and Glibc / Bionic.

This means that users need to be careful when using the uptime, and should
always cast it to a signed value. Why uptime can be signed is beyond me...
2016-05-20 11:17:22 +01:00
Raphael Cohn
a2d2b0cbe6 Redefining id_t because it is differently sized and has a different meaning across BSD platforms 2016-05-20 10:59:03 +01:00
Raphael Cohn
2de25f81a4 glibc defines __priority_which_t two different ways 2016-05-20 10:35:40 +01:00
Raphael Cohn
fabef1d78a Added nice, setpriority and getpriority along with constants and type definitions 2016-05-20 09:29:07 +01:00
bors
e88693700e Auto merge of #293 - SShrike:freebsd-ioctl-constants, r=alexcrichton
Add the TIOCGWINSZ and TIOCSWINSZ constants

I've added the `TIOCGWINSZ` and `TIOCSWINSZ` constants/ioctl control codes. I wasn't quite sure where to put them, so hopefully they're in the right place.

As of now it's set to compile on 'FreeBSD-like' platforms, so it will compile on both FreeBSD *and* DragonflyBSD. I've only tested it on FreeBSD though, but it should also work on DragonflyBSD AFAIK.

Fixes #292.
2016-05-19 15:02:11 -07:00
Severen Redwood
ae72fc7e43
Add the TIOCGWINSZ and TIOCSWINSZ constants 2016-05-19 22:45:38 +12:00
bors
fb5008c0aa Auto merge of #289 - fnichol:fix-musl-ioctl-constants, r=alexcrichton
Fix ioctl constants for musl target envs.

Heya!

I ran across this issue today while trying to build a portable static binary using the `x86_64-unknown-linux-musl` target. Took a bit of digging to make sure I understood what was going on, and while I may still be off the mark, I believe this is a fix to my issue.

Thanks!!

----

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-18 09:16:06 -07:00
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