about summary refs log tree commit diff
path: root/library/std/src/sys/unix
AgeCommit message (Collapse)AuthorLines
2021-10-10Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisabors-1/+5
Add new tier-3 target: armv7-unknown-linux-uclibceabihf This change adds a new tier-3 target: armv7-unknown-linux-uclibceabihf This target is primarily used in embedded linux devices where system resources are slim and glibc is deemed too heavyweight. Cross compilation C toolchains are available [here](https://toolchains.bootlin.com/) or via [buildroot](https://buildroot.org). The change is based largely on a previous PR #79380 with a few minor modifications. The author of that PR was unable to push the PR forward, and graciously allowed me to take it over. Per the [target tier 3 policy](https://github.com/rust-lang/rfcs/blob/master/text/2803-target-tier-policy.md), I volunteer to be the "target maintainer". This is my first PR to Rust itself, so I apologize if I've missed things!
2021-10-09Rollup merge of #87528 - :stack_overflow_obsd, r=joshtriplettGuillaume Gomez-8/+9
stack overflow handler specific openbsd change.
2021-10-06Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-seManish Goregaokar-1/+1
Rename `std::thread::available_conccurrency` to `std::thread::available_parallelism` _Tracking issue: https://github.com/rust-lang/rust/issues/74479_ This PR renames `std::thread::available_conccurrency` to `std::thread::available_parallelism`. ## Rationale The API was initially named `std::thread::hardware_concurrency`, mirroring the [C++ API of the same name](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency). We eventually decided to omit any reference to the word "hardware" after [this comment](https://github.com/rust-lang/rust/pull/74480#issuecomment-662045841). And so we ended up with `available_concurrency` instead. --- For a talk I was preparing this week I was reading through ["Understanding and expressing scalable concurrency" (A. Turon, 2013)](http://aturon.github.io/academic/turon-thesis.pdf), and the following passage stood out to me (emphasis mine): > __Concurrency is a system-structuring mechanism.__ An interactive system that deals with disparate asynchronous events is naturally structured by division into concurrent threads with disparate responsibilities. Doing so creates a better fit between problem and solution, and can also decrease the average latency of the system by preventing long-running computations from obstructing quicker ones. > __Parallelism is a resource.__ A given machine provides a certain capacity for parallelism, i.e., a bound on the number of computations it can perform simultaneously. The goal is to maximize throughput by intelligently using this resource. For interactive systems, parallelism can decrease latency as well. _Chapter 2.1: Concurrency is not Parallelism. Page 30._ --- _"Concurrency is a system-structuring mechanism. Parallelism is a resource."_ — It feels like this accurately captures the way we should be thinking about these APIs. What this API returns is not "the amount of concurrency available to the program" which is a property of the program, and thus even with just a single thread is effectively unbounded. But instead it returns "the amount of _parallelism_ available to the program", which is a resource hard-constrained by the machine's capacity (and can be further restricted by e.g. operating systems). That's why I'd like to propose we rename this API from `available_concurrency` to `available_parallelism`. This still meets the criteria we previously established of not attempting to define what exactly we mean by "hardware", "threads", and other such words. Instead we only talk about "concurrency" as an abstract resource available to our program. r? `@joshtriplett`
2021-10-06add platform support details file for armv7-unknown-linux-uclibcJonah Petri-1/+1
2021-10-06Add new target armv7-unknown-linux-uclibceabihfYannick Koehler-2/+6
Co-authored-by: Jonah Petri <jonah@petri.us>
2021-10-05Rollup merge of #88828 - FabianWolff:issue-88585, r=dtolnayManish Goregaokar-3/+13
Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock Fixes #88585. POSIX [specifies](https://man7.org/linux/man-pages/man3/fork.3p.html) that after forking, > to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called. Rust's standard library does not currently adhere to this, as evidenced by #88585. The child process calls [`sys::signal()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/android.rs#L76), which on Android calls [`libc::dlsym()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/weak.rs#L101), which is [**not**](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, and in fact causes a deadlock in the example in #88585. I think the easiest solution here would be to just call `libc::sigaction()` instead, which [is](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, provides the functionality we need, and is apparently available on all Android versions because it is also used e.g. [here](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/stack_overflow.rs#L112-L114).
2021-10-04Rollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisaManish Goregaokar-6/+10
haiku thread affinity build fix
2021-10-04Rollup merge of #87631 - :solarish_upd_fs, r=joshtriplettManish Goregaokar-13/+17
os current_exe using same approach as linux to get always the full ab… …solute path
2021-10-03Rollup merge of #88305 - ijackson:exitstatus-debug, r=dtolnayManish Goregaokar-3/+21
Manual Debug for Unix ExitCode ExitStatus ExitStatusError These structs have misleading names. An ExitStatus[Error] is actually a Unix wait status; an ExitCode is actually an exit status. These misleading names appear in the `Debug` output. The `Display` impls on Unix have been improved, but the `Debug` impls are still misleading, as reported in #74832. Fix this by pretending that these internal structs are called `unix_exit_status` and `unix_wait_status` as applicable. (We can't actually rename the structs because of the way that the cross-platform machinery works: the names are cross-platform.) After this change, this program ``` #![feature(exit_status_error)] fn main(){ let x = std::process::Command::new("false").status().unwrap(); dbg!(x.exit_ok()); eprintln!("x={:?}",x); } ``` produces this output ``` [src/main.rs:4] x.exit_ok() = Err( ExitStatusError( unix_wait_status( 256, ), ), ) x=ExitStatus(unix_wait_status(256)) ``` Closes #74832
2021-10-03Rollup merge of #88286 - LeSeulArtichaut:unnecessary-unsafe-block-std, r=dtolnayManish Goregaokar-2/+1
Remove unnecessary unsafe block in `process_unix` Because it's nested under this unsafe fn! This block isn't detected as unnecessary because of a bug in the compiler: #88260.
2021-10-02haiku thread affinity build fixDavid Carlier-6/+10
2021-10-01Call `libc::sigaction()` only on AndroidFabian Wolff-3/+14
2021-09-30Rollup merge of #89306 - devnexen:haiku_ncpus, r=nagisaManish Goregaokar-1/+10
thread: implements available_concurrency on haiku
2021-09-29Auto merge of #89011 - bjorn3:restructure_rt, r=dtolnaybors-1/+1
Restructure std::rt These changes should reduce binary size slightly while at the same slightly improving performance of startup, thread spawning and `std::thread::current()`. I haven't verified if the compiler is able to optimize some of these cases already, but at least for some others the compiler is unable to do these optimizations as they slightly change behavior in cases where program startup would crash anyway by omitting a backtrace and panic location. I can remove 6f6bb16 if preferred.
2021-09-28Clean up unneeded explicit pointer castDavid Tolnay-1/+1
The reference automatically coerces to a pointer. Writing an explicit cast here is slightly misleading because that's most commonly used when a pointer needs to be converted from one pointer type to another, e.g. `*const c_void` to `*const sigaction` or vice versa.
2021-09-28Rename `std::thread::available_onccurrency` to ↵Yoshua Wuyts-1/+1
`std::thread::available_parallelism`
2021-09-27thread: implements available_concurrency on haikuDavid Carlier-1/+10
2021-09-16Replace a couple of asserts with rtassert! in rt codebjorn3-1/+1
This replaces a couple of panic locations with hard aborts. The panics can't be catched by the user anyway in these locations.
2021-09-14Add chown functions to std::os::unix::fs to change the owner and group of filesJosh Triplett-0/+17
This is a straightforward wrapper that uses the existing helpers for C string handling and errno handling. Having this available is convenient for UNIX utility programs written in Rust, and avoids having to call unsafe functions like `libc::chown` directly and handle errors manually, in a program that may otherwise be entirely safe code. In addition, these functions provide a more Rustic interface by accepting appropriate traits and using `None` rather than `-1`.
2021-09-10Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlockFabian Wolff-4/+3
2021-09-01Rollup merge of #88542 - tavianator:readdir_r-errno, r=jyn514Mara Bos-2/+3
Use the return value of readdir_r() instead of errno POSIX says: > If successful, the readdir_r() function shall return zero; otherwise, > an error number shall be returned to indicate the error. But we were previously using errno instead of the return value. This led to issue #86649.
2021-08-31Use the return value of readdir_r() instead of errnoTavian Barnes-2/+3
POSIX says: > If successful, the readdir_r() function shall return zero; otherwise, > an error number shall be returned to indicate the error. But we were previously using errno instead of the return value. This led to issue #86649.
2021-08-30clean up `c::linger` conversionibraheemdev-1/+1
2021-08-30add `TcpStream::set_linger` and `TcpStream::linger`ibraheemdev-0/+39
2021-08-27Handle stack_t.ss_sp type change for DragonFlyBSDRyan Zoeller-14/+0
stack_t.ss_sp is now c_void on DragonFlyBSD, so the specialization is no longer needed. Changed in https://github.com/rust-lang/libc/commit/02922ef7504906589d02c2e4d97d1172fa247cc3.
2021-08-24Manual Debug for Unix ExitCode ExitStatus ExitStatusErrorIan Jackson-3/+21
These structs have misleading names. An ExitStatus[Error] is actually a Unix wait status; an ExitCode is actually an exit status. The Display impls are fixed, but the Debug impls are still misleading, as reported in #74832. Fix this by pretending that these internal structs are called `unix_exit_status` and `unix_wait_status` as applicable. (We can't actually rename the structs because of the way that the cross-platform machinery works: the names are cross-platform.) Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-24Remove unnecessary unsafe block in `process_unix`Léo Lanteri Thauvin-2/+1
2021-08-19Fix an unused import warning.Dan Gohman-1/+1
2021-08-19Update PidFd for the new I/O safety APIs.Dan Gohman-5/+11
2021-08-19I/O safety.Dan Gohman-135/+295
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-08-10STD support for the ESP-IDF frameworkivmarkov-41/+334
2021-08-07Auto merge of #87810 - devnexen:haiku_os_simpl, r=Mark-Simulacrumbors-33/+8
current_exe haiku code path simplification all of these part of libc
2021-08-06current_exe haiku code path simplification all of these part of libcDavid Carlier-33/+8
2021-08-06Rollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahcYuki Okushi-2/+9
thread set_name haiku implementation.
2021-08-02os current_exe using same approach as linux to get always the full absolute pathDavid Carlier-13/+17
but in case of failure (e.g. prcfs not mounted) still using getexecname.
2021-08-02Rollup merge of #86509 - CDirkx:os_str, r=m-ou-seYuki Okushi-2/+266
Move `os_str_bytes` to `sys::unix` Followup to #84967, with `OsStrExt` and `OsStringExt` moved out of `sys_common`, there is no reason anymore for `os_str_bytes` to live in `sys_common` and not in sys. This pr moves it to the location `sys::unix::os_str` and reuses the code on other platforms via `#[path]` (as is common in `sys`) instead of importing.
2021-08-02Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-seYuki Okushi-5/+4
Change environment variable getters to error recoverably This PR changes the standard library environment variable getter functions to error recoverably (i.e. not panic) when given an invalid value. On some platforms, it is invalid for environment variable names to contain `'\0'` or `'='`, or for their values to contain `'\0'`. Currently, the standard library panics when manipulating environment variables with names or values that violate these invariants. However, this behavior doesn't make a lot of sense, at least in the case of getters. If the environment variable is missing, the standard library just returns an error value, rather than panicking. It doesn't make sense to treat the case where the variable is invalid any differently from that. See the [internals thread](https://internals.rust-lang.org/t/why-should-std-var-panic/14847) for discussion. Thus, this PR changes the functions to error recoverably in this case as well. If desired, I could change the functions that manipulate environment variables in other ways as well. I didn't do that here because it wasn't entirely clear what to change them to. Should they error silently or do something else? If someone tells me how to change them, I'm happy to implement the changes. This fixes #86082, an ICE that arises from the current behavior. It also adds a regression test to make sure the ICE does not occur again in the future. `@rustbot` label +T-libs r? `@joshtriplett`
2021-08-01Auto merge of #87622 - pietroalbini:bump-bootstrap, r=Mark-Simulacrumbors-5/+0
Bump bootstrap compiler to 1.55 Changing the cfgs for stdarch is missing, but my understanding is that we don't need to do it as part of this PR? r? `@Mark-Simulacrum`
2021-08-01Auto merge of #81825 - voidc:pidfd, r=joshtriplettbors-3/+174
Add Linux-specific pidfd process extensions (take 2) Continuation of #77168. I addressed the following concerns from the original PR: - make `CommandExt` and `ChildExt` sealed traits - wrap file descriptors in `PidFd` struct representing ownership over the fd - add `take_pidfd` to take the fd out of `Child` - close fd when dropped Tracking Issue: #82971
2021-08-01bump bootstrap compiler to 1.55Pietro Albini-5/+0
2021-07-29fs File get_path procfs usage for netbsd same as linux.David Carlier-2/+7
2021-07-28thread set_name haiku implementation.David Carlier-2/+9
2021-07-28stack overflow handler specific openbsd fix.David Carlier-8/+9
On this platform, when doing stack allocation, MAP_STACK is needed otherwise the mapping fails.
2021-07-27Rollup merge of #87446 - devnexen:macos_update, r=dtolnayYuki Okushi-5/+2
macos current_exe using directly libc instead.
2021-07-27Rollup merge of #87354 - Wind-River:2021_master, r=kennytmYuki Okushi-1/+3
Update VxWork's UNIX support 1. VxWorks does not provide glibc 2. VxWorks does provide `sigemptyset` and `sigaddset` Note: these changes are concurrent to [this PR](https://github.com/rust-lang/libc/pull/2295) in libc.
2021-07-25macos current_exe using directly libc instead.David CARLIER-5/+2
2021-07-24Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitorbors-4/+30
Implement setting thread name for Fuchsia
2021-07-21VxWorks does provide sigemptyset and sigaddsetNicholas Baron-1/+1
2021-07-21Disable glibc tests on vxworksNicholas Baron-0/+2
VxWorks does not provide glibc, but we still need to test rustc on VxWorks.
2021-07-21Add tracking issue and link to man-pageDominik Stolz-1/+1