Skip to content

Commit acd8db5

Browse files
committed
Auto merge of #1432 - josephlr:errno, r=gnzlbg
Add __errno_location on Redox, DragonFlyBSD, Haiku Currently [`libstd`](https://github.com/rust-lang/rust/blob/909f5a049415a815b23502a5498de9a99bbf276b/src/libstd/sys/unix/os.rs#L29-L49) and the [`getrandom` crate](https://github.com/rust-random/getrandom/pull/54/files#diff-027a56068e2bf3d31dc4273ee6e07034R12) have to use external declarations in order to implement `errno_location` across all UNIX platforms. This change adds bindings for the remaining UNIX platforms, allowing everyone to just use normal `libc` bindings. This also removes the need for a seperate [`errno-dragonfly`](https://crates.io/crates/errno-dragonfly) crate. Links to the relevant header files: - Redox: [`relibc`'s `bits/errno.h`](https://github.com/redox-os/relibc/blob/master/include/bits/errno.h) uses `__errno_location` - Haiku: [`posix/errno.h`](https://github.com/luciang/haiku/blob/master/headers/posix/errno.h) uses `_errnop` - DragonFlyBSD: [`sys/errno.h`](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/errno.h) uses `__error` just like FreeBSD (which makes sense) - Note that the `__error` function is inlined. I don't think this causes a problem.
2 parents 1375b11 + 4fc38ca commit acd8db5

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

src/unix/bsd/freebsdlike/freebsd/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,6 @@ f! {
11321132
}
11331133

11341134
extern {
1135-
pub fn __error() -> *mut ::c_int;
1136-
11371135
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
11381136
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
11391137
pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;

src/unix/bsd/freebsdlike/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,8 @@ f! {
10861086
}
10871087

10881088
extern {
1089+
pub fn __error() -> *mut ::c_int;
1090+
10891091
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
10901092
pub fn sem_init(sem: *mut sem_t,
10911093
pshared: ::c_int,

src/unix/haiku/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,7 @@ extern {
12671267
pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
12681268
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
12691269
buflen: ::size_t) -> ::c_int;
1270+
pub fn _errnop() -> *mut libc::c_int;
12701271

12711272
pub fn abs(i: ::c_int) -> ::c_int;
12721273
pub fn atof(s: *const ::c_char) -> ::c_double;

src/unix/redox/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ extern {
539539

540540
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
541541
buflen: ::size_t) -> ::c_int;
542+
pub fn __errno_location() -> *mut libc::c_int;
542543

543544
// malloc.h
544545
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;

0 commit comments

Comments
 (0)