about summary refs log tree commit diff
path: root/library/std/src/sys/unix
AgeCommit message (Collapse)AuthorLines
2022-04-15Rollup merge of #96040 - m-ou-se:futex-u32, r=AmanieuDylan DPC-42/+40
Use u32 instead of i32 for futexes. This changes futexes from i32 to u32. The [Linux man page](https://man7.org/linux/man-pages/man2/futex.2.html) uses `uint32_t` for them, so I'm not sure why I used i32 for them. Maybe because I first used them for thread parkers, where I used -1, 0, and 1 as the states. (Wasm's `memory.atomic.wait32` does use `i32`, because wasm doesn't support `u32`.) It doesn't matter much, but using the unsigned type probably results in fewer surprises when shifting bits around or using comparison operators. r? ```@Amanieu```
2022-04-14library: Remove definitions and reexports of `strlen` from libstdVadim Petrochenkov-1/+0
2022-04-14Use u32 instead of i32 for futexes.Mara Bos-42/+40
2022-04-12Allow cvt_nz to be unused on some platforms.Mara Bos-0/+1
2022-04-12Add debug asserts to futex ReentrantMutex impl.Mara Bos-0/+2
2022-04-12Initialize thread local with const{}.Mara Bos-1/+1
2022-04-12Move current_thread_unique_ptr to the only module that uses it.Mara Bos-1/+9
2022-04-12Add futex-based ReentrantMutex on Linux.Mara Bos-6/+88
2022-04-11Use is_ or has_ prefix for pure `-> bool` functions.Mara Bos-23/+25
2022-04-11Use compare_exchange_weak in futex rwlock implementation.Mara Bos-4/+11
2022-04-11Add comments to futex rwlock implementation.Mara Bos-1/+12
2022-04-11Add doc comments to futex operations.Mara Bos-0/+10
2022-04-08Fix typo in futex rwlock.Mara Bos-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-04-08Add futex-based RwLock on Linux.Mara Bos-2/+295
2022-04-07Return status from futex_wake().Mara Bos-6/+4
2022-04-07Auto merge of #95688 - pfmooney:libc-update, r=Mark-Simulacrumbors-17/+1
Update libc to 0.2.121 With the updated libc, UNIX stack overflow handling in libstd can now use the common `si_addr` accessor function, rather than attempting to use a field from that name in `siginfo_t`. This simplifies the collection of the fault address, particularly on platforms where that data resides within a union in `siginfo_t`.
2022-04-07Rollup merge of #95626 - saethlin:pass-pointer-to-prctl, r=cuviperDylan DPC-1/+7
Don't cast thread name to an integer for prctl `libc::prctl` and the `prctl` definitions in glibc, musl, and the kernel headers are C variadic functions. Therefore, all the arguments (except for the first) are untyped. It is only the Linux man page which says that `prctl` takes 4 `unsigned long` arguments. I have no idea why it says this. In any case, the upshot is that we don't need to cast the pointer to an integer and confuse Miri. But in light of this... what are we doing with those three `0`s? We're passing 3 `i32`s to `prctl`, which doesn't fill me with confidence. The man page says `unsigned long` and all the constants in the linux kernel are macros for expressions of the form `1UL << N`. I'm mostly commenting on this because looks a whole lot like some UB that was found in SQLite a few years ago: <https://youtu.be/LbzbHWdLAI0?t=1925> that was related to accidentally passing a 32-bit value from a literal `0` instead of a pointer-sized value. This happens to work on x86 due to the size of pointers and happens to work on x86_64 due to the calling convention. But also, there is no good reason for an implementation to be looking at those arguments. Some other calls to `prctl` require that other arguments be zeroed, but not `PR_SET_NAME`... so why are we even passing them? I would prefer to end such questions by either passing 3 `libc::c_ulong`, or not passing those at all, but I'm not sure which is better.
2022-04-06Change trailing prctl arguments to c_ulongBen Kimock-1/+7
2022-04-06Rename RWLock to RwLock in std::sys.Mara Bos-12/+12
2022-04-05Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPCbors-0/+11
Rollup of 8 pull requests Successful merges: - #88025 (ScmCredentials netbsd implementation.) - #95473 (track individual proc-macro expansions in the self-profiler) - #95547 (caution against ptr-to-int transmutes) - #95585 (Explain why `&T` is cloned when `T` is not `Clone`) - #95591 (Use revisions to track NLL test output (part 1)) - #95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut) - #95673 (:arrow_up: rust-analyzer) - #95681 (resolve: Fix resolution of empty paths passed from rustdoc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-05Rollup merge of #88025 - devnexen:netbsd_scm_creds, r=AmanieuDylan DPC-0/+11
ScmCredentials netbsd implementation.
2022-04-05Auto merge of #95035 - m-ou-se:futex-locks-on-linux, r=Amanieubors-40/+250
Replace Linux Mutex and Condvar with futex based ones. Tracking issue: https://github.com/rust-lang/rust/issues/93740
2022-04-05Update libc to 0.2.121Patrick Mooney-17/+1
With the updated libc, UNIX stack overflow handling in libstd can now use the common `si_addr` accessor function, rather than attempting to use a field from that name in `siginfo_t`. This simplifies the collection of the fault address, particularly on platforms where that data resides within a union in `siginfo_t`.
2022-04-05Reword comment in futex condvar implementation.Mara Bos-1/+1
2022-04-05Mark unix::locks::futex::Mutex::new as #[inline].Mara Bos-0/+1
2022-04-04ScmCredentials netbsd implementation.David Carlier-0/+11
2022-04-03Don't cast thread name to an integer for prctlBen Kimock-1/+1
libc::prctl and the prctl definitions in glibc, musl, and the kernel headers are C variadic functions. Therefore, all the arguments (except for the first) are untyped. It is only the Linux man page which says that prctl takes 4 unsigned long arguments. I have no idea why it says this. In any case, the upshot is that we don't need to cast the pointer to an integer and confuse Miri.
2022-04-01Use MaybeUninit for clock_gettime's timespec.Mara Bos-3/+4
2022-04-01Don't spin on contended mutexes.Mara Bos-1/+3
2022-04-01Shuffle around #[inline] and #[cold] in mutex impl.Mara Bos-5/+7
2022-04-01Add comment about futex_wait timeout.Mara Bos-0/+2
2022-03-30Fix library/std compilation on openbsd.Dan Gohman-1/+1
Fix a minor typo from #95241 which prevented compilation on x86_64-unknown-openbsd.
2022-03-29mark FIXMES for all the places found that are probably offset_fromAria Beingessner-0/+2
2022-03-29revert changes that cast functions to raw pointers, portability hazardAria Beingessner-9/+8
2022-03-29Make some linux/unix APIs better conform to strict provenance.Alexis Beingessner-33/+36
This largely makes the stdlib conform to strict provenance on Ubuntu. Some hairier things have been left alone for now.
2022-03-28Fix build on i686-apple-darwin systemsMarcus Calhoun-Lopez-0/+3
On 32-bit systems, fdopendir is called `_fdopendir$INODE64$UNIX2003`. On 64-bit systems, fdopendir is called `_fdopendir$INODE64`.
2022-03-28Fix build on i686-apple-darwin systemsMarcus Calhoun-Lopez-5/+5
Replace `target_arch = "x86_64"` with `not(target_arch = "aarch64")` so that i686-apple-darwin systems dynamically choose implementation.
2022-03-24Explicitly use CLOCK_MONOTONIC in futex_wait.Mara Bos-3/+3
Instant might be changed to use CLOCK_BOOTTIME at some point.
2022-03-24Make Timespec available in sys::unix.Mara Bos-15/+13
2022-03-24Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT on Linux.Mara Bos-22/+38
2022-03-23Spin before blocking in Mutex::lock.Mara Bos-4/+38
2022-03-23Replace Linux Mutex and Condvar with futex based ones.Mara Bos-8/+149
2022-03-23Add futex_wake_all.Mara Bos-0/+12
2022-03-23Return timeout status in futex_wait.Mara Bos-4/+5
2022-03-23Auto merge of #95173 - m-ou-se:sys-locks-module, r=dtolnaybors-50/+60
Move std::sys::{mutex, condvar, rwlock} to std::sys::locks. This cleans up the the std::sys modules a bit by putting the locks in a single module called `locks` rather than spread over the three modules `mutex`, `condvar`, and `rwlock`. This makes it easier to organise lock implementations, which helps with https://github.com/rust-lang/rust/issues/93740.
2022-03-21Move pthread locks to own module.Mara Bos-50/+60
2022-03-20Rollup merge of #94749 - RalfJung:remove-dir-all-miri, r=cuviperMatthias Krüger-3/+3
remove_dir_all: use fallback implementation on Miri Fixes https://github.com/rust-lang/miri/issues/1966 The new implementation requires `openat`, `unlinkat`, and `fdopendir`. These cannot easily be shimmed in Miri since libstd does not expose APIs corresponding to them. So for now it is probably easiest to just use the fallback code in Miri. Nobody should run Miri as root anyway...
2022-03-19Rollup merge of #93858 - krallin:process-process_group, r=dtolnayDylan DPC-2/+80
Add a `process_group` method to UNIX `CommandExt` - Tracking issue: #93857 - RFC: https://github.com/rust-lang/rfcs/pull/3228 Add a `process_group` method to `std::os::unix::process::CommandExt` that allows setting the process group id (i.e. calling `setpgid`) in the child, thus enabling users to set process groups while leveraging the `posix_spawn` fast path.
2022-03-19Rollup merge of #92612 - atopia:update-lib-l4re, r=dtolnayDylan DPC-15/+49
Update stdlib for the l4re target This PR contains the work by ``@humenda`` and myself to update standard library support for the x86_64-unknown-l4re-uclibc tier 3 target, split out from humenda/rust as requested in #85967. The changes have been rebased on current master and updated in follow up commits by myself. The publishing of the changes is authorized and preferred by the original author. To preserve attribution, when standard library changes were introduced as part of other changes to the compiler, I have kept the changes concerning the standard library and altered the commit messages as indicated. Any incompatibilities have been remedied in follow up commits, so that the PR as a whole should result in a clean update of the target.
2022-03-17feat: Add use of bool::then in sys/unix/processwcampbell-3/+3
Remove else { None } in favor of using bool::then()