Commit Graph

125 Commits

Author SHA1 Message Date
JohnTitor e187543fdd Constify `CMSG_SPACE` for all the targets 2021-03-30 17:37:13 +09:00
Torbjørn Birch Moltu 0f40951415 Add NetBSD unpcbid, LOCAL_PEEREID and other LOCAL_ constants 2021-03-07 21:44:23 +01:00
Alexander Batischev 3e4d684dcd
Add bindings for iconv calls
FreeBSD-likes all implement iconv:
- DragonflyBSD: bbb35c81f7/include/iconv.h
- FreeBSD: a6dc68c0e0/include/iconv.h

NetBSD-likes:
- NetBSD: 81a39f6087/include/iconv.h
- OpenBSD doesn't implement it

macOS: apparently ships a conforming implementation as a separate
library:
https://stackoverflow.com/questions/57734434/libiconv-or-iconv-undefined-symbol-on-mac-osx/57734435#57734435

Linux:
- glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=iconv/iconv.h;h=fdddf53d99c3046ef9c280db01a425c2f499043e;hb=HEAD
- musl: https://git.musl-libc.org/cgit/musl/tree/include/iconv.h?id=455f96857f91d14e193219ca00969354a981c09c
2021-02-11 01:22:49 +03:00
Lzu Tao 6711eefc8c Add dl_iterate_phdr for netbsd 2020-10-27 18:03:33 +07:00
Max Blachman a6c451d17f add clock_nanosleep to freebsd 12 and netbsd 2020-10-15 10:11:43 -07:00
Robert Collins e9c6804523 Add missing NetBSD RLIMIT_ constants 2020-10-10 20:37:47 +02:00
Daniil Bondarev 773f5562ba Use safe_f! consistently across platforms
The pr #1870 introduced safe_f! macro, which made some functions like
WIFEXITED and WEXITSTATUS const and safe on linux_like platform only,
which causes inconsistency when trying to use those functions in crates
compiled across multiple platforms, as using unsafe on those functions
will generate unused_unsafe warning on linux platforms and lack of
unsafe block will fail compilation on non-linux platforms.

To avoid the inconsistency, this commit applies the same macro for all
the same functions on other platforms too.
2020-09-12 23:38:06 -07:00
Yuki Okushi 05c4574f3a
Declare `utmpx` on musl 2020-07-22 09:51:21 +09:00
Sébastien Marie bc0f2ae606 REG_ENOSYS is NetBSD specific 2020-04-14 11:35:06 +00:00
Daniel Fox Franke 0a2566d0be Add <sys/timex.h> declarations for BSDs 2020-03-01 14:01:14 -05:00
Vickenty Fesunov 1c012aec18 Add memmem
memmem is a non-standard extension, first added in GNU libc and later
ported to other systems. Support for it is non-uniform, thus it was only
added to platforms that seem to support it.
2020-02-19 10:32:33 +01:00
Vickenty Fesunov 9358be36d6 Remove unnecessary parenthesis
This triggers a warning on a recent nightly, which in turn breaks CI due to
`#![deny(warnings)]` in libc-test/build.rs
2020-02-12 10:09:22 +01:00
bors bba019bff5 Auto merge of #1610 - GrayJack:utmp_netbsd, r=gnzlbg
Implement utmp for NetBSD

Followed this: https://github.com/NetBSD/src/blob/trunk/include/utmp.h
2019-11-29 11:00:07 +00:00
bors ea0a54a661 Auto merge of #1608 - lzutao:netbsd-mut-pthread_setname_np, r=gnzlbg
use *const pointer for NetBSD's pthread_setname_np
2019-11-29 09:54:20 +00:00
GrayJack 42289eb64f Implement utmp for NetBSD 2019-11-28 20:47:50 -03:00
Lzu Tao f851312153 use *const pointer for NetBSD's pthread_setname_np 2019-11-28 10:37:32 +07:00
GrayJack 6fffc1685c Comment fields that are array with size above 32 in Debug impl utmpx lastlogx 2019-11-27 13:35:58 -03:00
GrayJack 033a775459 Fix the lastlogx PartialEq impl 2019-11-27 13:29:15 -03:00
GrayJack 5d3c5b9d40 Fix the PartialEq utmpx impl 2019-11-20 12:38:29 -03:00
GrayJack 40f9253fc9 Fix style error that `cargo fmt` didn't got 2019-11-19 06:10:36 -03:00
GrayJack 863e106543 Run rustfmt 2019-11-19 03:22:08 -03:00
Eric Shimizu Karbstein d08a3e8ae2
Merge branch 'master' into utmpx_netbsd 2019-11-19 01:06:43 -03:00
Sébastien Marie 487b454d9f add shm support for NetBSD and OpenBSD
initial work from @landryb for OpenBSD, various fixes and NetBSD support from me.

Fixes #1585
2019-11-07 13:10:04 +01:00
GrayJack e8106bd4de Implement utmpx.h itens 2019-10-31 05:04:04 -03:00
Garrett Squire a94417f033 add pthread_attr_get_np for NetBSD 2019-10-15 15:20:35 -07:00
Murarth 36a92d5278 Add `pthread_main_np` to FreeBSD-like and `_lwp_self` to NetBSD 2019-09-27 16:44:38 -07:00
Philipp Gesang 165161bec3
fix argument names in the mq_* family of functions
It's *msg_prio* in both manpages and posix.
2019-09-18 23:29:34 +02:00
gnzlbg 939a2e5a3a Formatting 2019-09-12 15:12:33 +02:00
Alan Somers ac1e12409e Deprecate RLIM_NLIMITS
This constant is not stable across OS versions, so it cannot be used in
any backwards- or forwards- compatible way.  It's typically used to size
arrays in the kernel and in debugging utilities that are closely tied to
the OS version.  Since libc is ignorant about OS versions, we shouldn't
even be defining it.
2019-09-02 10:21:57 -06:00
bors 38750521a6 Auto merge of #1474 - lpetre:add_utime_constants, r=gnzlbg
Adding UTIME_NOW and UTIME_OMIT to OSes which support utimensat

I've managed to verify a handful of these:

- [FreeBSD](1d6e424741/tools/build/stat.h (L35))
- [NetBSD](64b8a48e12/sys/sys/stat.h (L235))
 - [Apple](https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/stat.h.auto.html)

I'm less confident in these:
 - [Haiku](abb59d7351/headers/posix/sys/stat.h (L105))
   - I could be wrong on this one: https://github.com/haiku/haiku/search?q=UTIME_NOW&unscoped_q=UTIME_NOW
 - [WASI](24792713d7/libc-top-half/musl/include/sys/stat.h (L71))
  - I could be wrong on this one: https://github.com/CraneStation/wasi-libc/search?q=UTIME_NOW&unscoped_q=UTIME_NOW
 - [Solarish](4e0c5eff9a/usr/src/uts/common/sys/stat.h (L478))
2019-08-20 09:45:52 +00:00
Sébastien Marie 3b7be3c193 adapt ioctl() BPF for OpenBSD 2019-08-18 10:19:49 +02:00
Luke Petre 2b158cefc2 Adding UTIME_NOW and UTIME_OMIT to OSes which support utimensat 2019-08-17 06:37:25 +01:00
Douman 0c2e7831ce Expose signal value of siginfo_t
Exposes value for most unix like platforms
2019-07-09 15:15:17 +02:00
Bryant Mairs 215f095601 Remove AF_MAX, PF_MAX, NET_MAXID constants
These constants have already been deprecated for a few releases with
a deprecation notice, so they can finally be removed.

Closes rust-lang/libc#665
2019-07-05 07:39:00 -07:00
bors e0ff1e68b9 Auto merge of #1387 - tormol:fionclex, r=gnzlbg
Add FIONCLEX and other FIO* constants for Linux, DragonFly and OpenBSD

[OpenBSD header](https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/filio.h?annotate=1.5) | [DragonFly header](http://gitweb.dragonflybsd.org/dragonfly.git/blame/refs/heads/master:/sys/sys/filio.h) | [Linux search](https://github.com/torvalds/linux/search?q=FIONCLEX+FIOQSIZE&unscoped_q=FIONCLEX+FIOQSIZE&type=Code)
For Linux I've used [godbolt compiler explorer](https://godbolt.org/z/h-C7qM) to get final values where possible.

Wile this crate has FIOCLEX for Fuchsia, Emscripten and Redox, I've not added FIONCLEX for them because those targets appear to support neither.
I started adding FIOASYNC, FIOSETOWN and FIOGETOWN for all the Linux architectures, but gave up when I realized FIOASYNC is kind of deprecated and the other two useless without more symbols. If anybody is interested I have a [branch with how far I got](https://github.com/tormol/rust-libc/tree/sigio).
2019-06-11 18:05:33 +00:00
Bryant Mairs 7c265919ec Switch to manual trait impls for sigevent
sigevent structs on most platforms have padding or unused fields. Rather
than display those in the Debug impl by deriving it, manually implement
all extra_traits instead ignoring those fields.
2019-06-09 19:28:32 -07:00
Torbjørn Birch Moltu a319b62fbd Generalize some FIO* constants to all BSDs
* Change the type of FIONCLEX on apple platforms from c_uint to c_ulong
* Add FIONCLEX, FIONREAD, FIOASYNC, FIOSETOWN and FIOGETOWN
  for DragonFly and OpenBSD
2019-06-07 20:00:55 +02:00
bors 0e702c1b4e Auto merge of #1379 - gnzlbg:deprecate_fixed_width_ints, r=gnzlbg
Deprecate fixed width integer type aliases

cc @emilio - I think it makes sense to ensure that the latest released version of bindgen works properly with this change. That is, that even when asked to use C types from, e.g., `libc::`, it does not use aliases for the fixed-width integer C types (e.g. `libc::int64_t`) but uses Rust primitive types instead (e.g. `u64`).

Closes #1304 .
2019-05-29 18:13:57 +00:00
gnzlbg a0865265d4 Replace uses of fixed-width integer aliases with Rust types 2019-05-29 13:17:17 +02:00
gnzlbg a74b588ad2 Deprecate AF_MAX and PF_MAX 2019-05-29 12:24:47 +02:00
gnzlbg 759c837611 [breaking change] incorrect API of gettimeofday
The second argument of `gettimeofday` was a `*mut c_void` on all targets,
but that type is incorrect in the following targets, where it should be
a `*mut timezone` instead:

On these other targets it appears that the signature of gettimeofday was incorrect (it takes a time-zone pointer instead of a void pointer):

linux+gnu: http://man7.org/linux/man-pages/man2/gettimeofday.2.html
freebsd: https://www.freebsd.org/cgi/man.cgi?query=gettimeofday&apropos=0&sektion=2&manpath=FreeBSD+11.2-stable&arch=default&format=html
openbsd: https://man.openbsd.org/gettimeofday.2
android: https://github.com/ricardoquesada/android-ndk/blob/master/usr/include/sys/time.h
dragonfly: https://www.dragonflybsd.org/cgi/web-man?command=gettimeofday&section=2

This commit corrects the type on these targets, which is a breaking change. Due
to how this API is commonly used (e.g. passing `ptr::null_mut` to the second
argument), breakage should be minimal. Users wanting to support both versions
can just write `ptr as *mut _` instead.

Closes #1338.
2019-05-22 10:39:06 +02:00
Sébastien Marie 887ac11ed0 vm_size_t does not exist on OpenBSD 2019-03-03 06:50:23 +01:00
Bryant Mairs b39a762579 Add extra traits for NetBSD 2019-02-23 15:03:52 -08:00
gnzlbg 5f9be7eebe Remove the CMSG_ APIs from bitrig 2019-02-20 11:22:43 +01:00
bors 315e600acd Auto merge of #1231 - dholroyd:mmsg-support, r=gnzlbg
Broader sendmmsg() / recvmmsg() support

As a prerequisite for getting `sendmmsg()` / `recvmmsg()` into nix ( https://github.com/nix-rust/nix/pull/1017 ), support for non-linux platforms needs to be added in libc.

The initial commits in this PR will just be to test out target support via CI.
2019-02-18 17:22:08 +00:00
gnzlbg 7ac0fe53eb Cleanup dox mess 2019-02-13 14:48:50 +01:00
David Holroyd 250aa2496a openbsd doesn't have mmsghdr either! 2019-02-08 23:18:02 +00:00
David Holroyd 80f1b51ac0 openbsd lacks sendmmsg()/recvmmsg() 2019-02-08 19:14:06 +00:00
gnzlbg a17a91cdbf Fix build on all platforms
This PR fixes the build on all platforms and all Rust version down to the
minimum Rust version supported by libc: Rust 1.13.0.

The `build.rs` is extended with logic to detect the newer Rust features used by
`libc` since Rust 1.13.0:

* Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
  `cfg(libc_unions)` and not available on older Rust versions.

* Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
  Rust versions, all uses of `repr(align)` are split into `align.rs` and
  `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
  level. These modules sometimes contain macros that are expanded at the top
  level to avoid privacy issues (`pub(crate)` is not available in older Rust
  versions). Closes #1242 .

* Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
  constants on older Rust versions.

Also, `repr(packed)` structs cannot automatically `derive()` some traits like
`Debug`. These have been moved into `s_no_extra_traits!` and the lint of missing
`Debug` implementations on public items is silenced for these. We can manually
implement the `extra_traits` for these in a follow up PR. This is tracked
in #1243. Also, `extra_traits` does not enable `align` manually anymore.

Since `f64::to_bits` is not available in older Rust versions, its usage
has been replaced with a `transmute` to an `u64` which is what that method
does under the hood.

Closes #1232 .
2019-02-07 13:44:32 +01:00
bors 6b8ef413a3 Auto merge of #1211 - asomers:netbsd_aio, r=gnzlbg
Fix linking aio_read(3) and friends on NetBSD

The aio functions require librt on NetBSD.
2019-01-15 17:44:10 +00:00