Commit Graph

92 Commits

Author SHA1 Message Date
Yuki Okushi 3fae7e9ce7 Fix style 2021-04-06 10:10:29 +09:00
Niels Sascha Reedijk d4e4814f32 Haiku: change argument types for readv() and writev()
This crate's definition was recently updated to conform to the actual type
definition in the header files. However, this deviates from the standard,
and thus breaks building - amongst others - libstd. This reverts to the
original definition. Parallel to this, there is an effort to fix the
definition on Haiku. In the interim, the disparity between the definitions
should not cause any issues for users that pass valid vector sizes.
2021-03-12 11:10:52 +00:00
Niels Sascha Reedijk 0687d245f7 Haiku: change type of ioctl() argument to c_ulong and add missing 2021-03-12 11:10:51 +00:00
Niels Sascha Reedijk 59afbfe9f6 Haiku: use raw pointers instead of references in convenience functions
The Haiku API has some convenience macros to make it easier to call certain
functions. In the libc implementation, these are implemented as unsafe
functions. The previous choice was to take certain pointer parameters as
references, and do the conversion to raw pointers when the actual external
function was called.

However, this causes issues with the image_info struct, which needs to be
initialized in Rust, before a native API call is used to enter data. Since
part of this structure consists of function pointers, mem::zeroed() cannot be
used, since in Rust function pointers cannot be NULL. Thus one needs to use the
MaybeUnit<T> API to properly initialize it. This then makes it problematic to
use the convenience functions, as a MaybeUnit<image_info> cannot be converted
into an &image_info before it is marked as initialized with valid data. It can
be converted into a raw *mut image_info, so if the function accepts this as a
parameter it can be used.

For consistency, all convenience functions have been converted from using
references to using raw pointers.
2021-02-13 11:07:39 +00:00
Niels Sascha Reedijk 813d7d839b Haiku: fix various issues pointed out by the automated tests
No changes to other platforms.
2021-01-28 14:31:24 +00:00
Niels Sascha Reedijk c3f7febb83 Haiku: add definitions for the Haiku's native sytem API.
On the Haiku platform, the POSIX (and BSD) API coexists with the native API,
that has its origins on the BeOS platform. Unlike other UNIX-like platforms,
the native API is not an extension of the POSIX API, but instead exists sui
generis, and many of the POSIX concepts have their own native variety, with
relatively limited interoperability.

Nontheless, the native API coexists in the same library as the standard C and
POSIX functions, namely libroot.so, and therefore this crate is a good place
to add bindings to it.

This commit implements most of Haiku's support kit, the most important parts
of the kernel kit, and a part of the storage kit.
2021-01-28 14:13:41 +00:00
dylni d116ee592d Define CLD_ constants for more targets 2020-12-21 21:31:14 -05:00
dylni 29b4faed15 Make si_status method more compatible 2020-12-17 00:21:54 -05: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
Niels Sascha Reedijk 43ad09ee63 Haiku: add [get/set]priority()
These methods were added in Haiku R1 beta 2.
2020-08-22 21:57:11 +00:00
Josh Triplett 13d0cdb68f Expose si_pid, si_uid, and si_status from siginfo_t as functions
On Linux, siginfo_t cannot expose these fields directly due to
https://github.com/rust-lang/libc/issues/716 , so expose them as
functions, just like si_addr and si_value.

In order to get alignment correct on both 32-bit and 64-bit
architectures, define an sifields union that includes a pointer field,
to ensure that it has the same alignment as a pointer.
2020-08-10 01:24:22 -07:00
Marcin Konicki c17a4c1711
Add missing sysconf constants for Haiku
Hi,

Could you add some missing Haiku constants (i'm guessing they were added after Haiku port was last updated)?

These are defined in `unistd.h`: 194a45c6b4/headers/posix/unistd.h (L134-L137)
2020-07-03 22:09:46 +02:00
Yuki Okushi f9f56830f8
Re-define `__priority_which`s as c_uint in linux-gnu 2020-05-21 21:57:46 +09:00
Niels Sascha Reedijk 080a57f805 Haiku: fix name of AF_UNSPEC 2020-05-02 09:17:44 +00:00
Niels Sascha Reedijk ccda4ada09 Haiku: add futimens and utimensat, remove futimes and cleanup.
* Function futimes is not available in Haiku.
 * Functions futimens and utimensat are.
 * Cleanup some leftover cfg_attr attributes.
2020-03-28 08:35:29 +00:00
Yuki Okushi 483bb8171f Replace TODO with FIXME to make grep easy 2020-02-29 13:36:27 +09: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
Niels Sascha Reedijk abddbd3d24 Haiku: Fix constants for S_IFIFO and S_IFCHR 2019-10-04 11:42:57 +01:00
gnzlbg 939a2e5a3a Formatting 2019-09-12 15:12:33 +02:00
Luke Petre 2b158cefc2 Adding UTIME_NOW and UTIME_OMIT to OSes which support utimensat 2019-08-17 06:37:25 +01:00
Joe Richey b7a27b5c7c libc::c_int -> ::c_int 2019-07-10 18:04:48 -07:00
Joe Richey aa3578fa85 Add __errno_location on Redox, DragonFlyBSD, Haiku 2019-07-10 18:04:48 -07: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
Nikolay Korotkiy 60254f1151
haiku: add missing ioctl identifiers to control the TTY 2019-06-20 19:37:20 +03: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
gnzlbg a74b588ad2 Deprecate AF_MAX and PF_MAX 2019-05-29 12:24:47 +02:00
gnzlbg 8f403e5ac2 Update MUSL Linux kernel headers and re-enable Linux tests 2019-05-27 22:23:02 +02:00
gnzlbg d52732581a Test strerror_r on Android and Linux 2019-05-23 16:29:28 +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
Charles Lew 1cf0294e2d Fix getgrgid_r to accept gid_t. 2019-04-29 22:12:41 +08:00
bors 66f00d2ebb Auto merge of #1271 - Susurrus:more_debug_impls, r=gnzlbg
Implement more extra_traits

Finishing the implementation of rust-lang/rust#57715 now that all platforms are tested in CI. I plan to expand this CI to all platforms that need this treatment (solarish, empscripten, freebsd, and netbsd), but thought I'd get the part I've already started running in CI since I can't test this changes locally.
2019-02-24 13:19:56 +00:00
Bryant Mairs 7597520dae Add extra traits for haiku datatypes 2019-02-22 20:15:38 -08:00
gnzlbg f5cbdbc2b9 Clean libc-test for apple targets
This cleans up the build.rs of `libc-test` for apple targets.

I wanted to update the docker containers of some targets so that we can start
testing newer currently-skipped APIs properly, but it is impossible to figure
out which headers and APIs are skipped for each target.

This PR separates the testing of apple targets into its own self-contained
function. This allows seeing exactly which headers are included, and which items
are skipped. A lot of work will be required to separate the testing of all major
platforms and make the script reasonable.

During the clean up, I discovered that, at least for apple targets, deprecated
but not removed APIs are not tested. I re-enabled testing for those, and fixed
`daemon`, which was not properly linking its symbol. I also added the
`#[deprecated]` attribute to the `#[deprecated]` APIs of the apple targets. The
attribute is available since Rust 1.9.0 and the min. Rust version we support is
Rust 1.13.0.

Many other APIs are also currently not tested "because they are weird" which I
interpret as "the test failed for an unknown reason", as a consequence:

* the signatures of execv, execve, and execvp are incorrect (see
  https://github.com/rust-lang/libc/issues/1272)

* the `sig_t` type is called `sighandler_t` in libc for some reason:
  https://github.com/rust-lang/libc/issues/1273

This probably explains why some other things, like the
`sa_handler`/`sa_sigaction` fields of `sigaction` were skipped. The field is
actually a union, which can be either a `sig_t` for the `sa_handler` field, or
some other type for the `sa_sigaction` field, but because the distinction was
not made, the field was not checked.

The latest ctest version can check volatile pointers, so a couple of skipped
tests are now tested using this feature.
2019-02-22 19:18:02 +01:00
gnzlbg 2130d45fb1 Fix Haiku build 2019-02-20 11:21:38 +01:00
gnzlbg 7ac0fe53eb Cleanup dox mess 2019-02-13 14:48:50 +01: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
Bryant Mairs f3684584c9 Check for Copy impls for all types 2019-02-02 16:32:00 -08:00
Bryant Mairs fa9cb78b4a Check for Debug impls for all types
This was not compile-tested on all platforms, but instead all `pub enum`
types had a `Debug` impl derived for them.
2019-02-02 16:32:00 -08:00
Alan Somers 36baf9323d Fix uname on FreeBSD
On FreeBSD, uname is an inline function.  The uname that is present in
libc.so is for FreeBSD 1.0 compatibility.  It expects a buffer of a
different size.

Fixes #1190
Reported-by: Alex Zepeda
2019-01-03 08:53:50 -07:00
gnzlbg 5c1a6b8a6d splice the common libc functions and ctypes throughout the library 2018-11-21 20:58:02 +01:00
Samuel Holland 1b130d4c34 Add F_RDLCK/F_WRLCK/F_UNLCK to several platforms
These are used by the flock wrapper in rustc_data_structures. The
constants were already present in x86_64-linux-gnu and BSD (since
4928bd9869).
2018-11-01 03:40:59 +00:00
bors 0d0a5f7510 Auto merge of #1024 - nielx:master, r=alexcrichton
Haiku: Add more IP_* and IPV6_* constants.

These are used in the socket2 library.
2018-06-28 03:31:12 +00:00
Niels Sascha Reedijk 572f142459 Haiku: Add more IP_* and IPV6_* constants.
These are used in the socket2 library.
2018-06-20 06:47:38 +00:00
Scott Lamb 322ba046d8 add fdopendir on macOS
Fixes #1017

I moved it up to src/unix/mod.rs, as it's specified in POSIX.1-2008 and
appears to be implemented on every Unix-like system.

The symbol names on macOS appear similar to those for opendir; I found
them via the commands below. I tested the x86_64 version;
fdopendir$INODE64 worked as expected.

$ nm -arch x86_64 /usr/lib/system/libsystem_c.dylib | grep fdopendir
000000000007ea6d T _fdopendir
000000000002ba97 T _fdopendir$INODE64
$ nm -arch i386 /usr/lib/system/libsystem_c.dylib | grep fdopendir
00082d1e T _fdopendir
0002b528 T _fdopendir$INODE64$UNIX2003
00082d1e T _fdopendir$UNIX2003
2018-06-07 21:49:10 -07:00
Calvin Hill 353d64549d haiku: Add RLIMIT_STACK and fix RTLD_* definitions 2018-04-20 12:35:01 +01:00
Josh Driver b3fca2443c Add missing EAI_* flags for multiple platforms 2017-12-12 22:13:03 +10:30
Alexander von Gluck IV f7d16bce0c haiku: Add missing lutimes
* BeOS traditionally didn't have lutimes, however to make Haiku
  more compatible and easier to port for, we added an implementation
  of it.
2017-11-25 10:15:08 -06:00
luozijun 9108f5b51d Add network interface flag constants for all platforms
Add network interface flag constants for all platforms.
2017-11-09 16:54:03 +08:00
Jessica Hamilton 3c91010af0 haiku: add missing definitions found from building nix. 2017-09-26 04:02:03 +00:00
Jessica Hamilton ee8a490e06 haiku: add openpty/forkpty, and link to libbsd. 2017-09-26 01:01:22 +00:00