Commit Graph

30 Commits

Author SHA1 Message Date
hdhoang
7682abb703 Import portable_atomic::AtomicU64 when std does not provide it
Restores support for 32-bit powerpc and mips. Fixes #10415.

Signed-off-by: Hoang Duc Hieu <code@hdhoang.space>
2024-08-11 14:50:39 +02:00
Peter Ammon
90535d5b51
Allow clippy::ptr_arg and fix cases 2024-06-29 18:48:49 -07:00
Peter Ammon
73c46db609
Remove some (hopefully) unnecessary clippy and compiler directives 2024-06-23 17:13:14 -07:00
Peter Ammon
631516398e
Remove the notion of the "principal" environment stack
The "principal" environment stack was the one that was associated with the
"principal" parser and would dispatch changes like to TZ, etc.

This was always very suspicious, as a global; now we can remove it.
2024-06-23 16:49:11 -07:00
Peter Ammon
01d45ad755
Clarify a comment about safety in the environment impl
We use an unusual pattern of protecting data via a global lock, but it's safe.
2024-06-23 16:49:11 -07:00
Peter Ammon
0378cb750b
Be more explicit about when to dispatch variable changes
This controls e.g. when we react to TZ changes. Rather than having a special
blessed environment stack, simply store it as a property.
2024-06-23 16:49:11 -07:00
Peter Ammon
9ad875cdb7
Enforce that nobody can push/pop from the global environment stack
This is just a precaution.
2024-06-23 16:39:39 -07:00
Peter Ammon
376bdb16c7
Fix a misspeeled comment 2024-06-15 16:20:15 -07:00
Peter Ammon
5a45b189da
Make EnvStackSetResult use Rust naming conventions 2024-06-15 15:57:28 -07:00
Fabian Boehm
20830744a9 Apply some clippy lints
Nothing too surprising, mostly removing useless references and lambdas
2024-05-26 10:37:37 +02:00
Johannes Altmanninger
2fa98ec20c Fix deadlock when importing universal LC_* variable
The C++ version of this code simply copied the entire uvar table.
Today we take a reference. It's not clear which one is better.

Removal of locale variables like LC_ALL triggers variable change handlers
which call EnvStackImpl::get. This deadlocks because we still hold the lock
to protect the reference to all uvars.  Work around this.

Closes #10513
2024-05-21 23:11:06 +02:00
Mahmoud Al-Qudsi
3d648e6e04 Remove Arc from environment::globals() (take 2)
We don't forward this variable for storage in any structs, so there's no reason
to go through an Arc instead of returning the `&'static EnvStack` directly.

NB: This particular change was safe, and passes all tests on its own.
2024-05-16 21:17:15 -05:00
Mahmoud Al-Qudsi
45e249dd94 Revert removal of Arc from principal() and global()
This reverts commit c6d3bde0c6.
This reverts commit 4ce13f0adb.
2024-05-16 21:08:06 -05:00
Mahmoud Al-Qudsi
c6d3bde0c6 Remove Arc from environment::globals()
We don't forward this variable for storage in any structs, so there's no reason
to go through an Arc instead of returning the `&'static EnvStack` directly.
2024-05-16 20:50:23 -05:00
Mahmoud Al-Qudsi
4ce13f0adb Simplify lifetime of environment::principal()
It's clearer that using it with `Rc::from_raw()` is safe since we don't have to
go through an `Arc<T>`.
2024-05-16 20:46:28 -05:00
Mahmoud Al-Qudsi
ec1bf60941 Add note about possible safety issue with GLOBAL_NODE 2024-05-16 20:33:43 -05:00
Mahmoud Al-Qudsi
66618d64cb Convert some lazy_static to OnceCell/OnceLock
These have clearer sync/unsync semantics and now ship with rust itself.
They don't paper over any possible cross-thread issues, and we can specifically
choose which we want for the purpose.
2024-05-16 20:33:43 -05:00
Mahmoud Al-Qudsi
0f18480559 Simplify Parser and EnvStack singletons and clarify thread semantics
`Parser` is a single-threaded `!Send`, `!Sync` type and does not need to use
`Arc` for anything. We were using it because that's all we had for the parser's
`EnvStack`, but though that is *technically* protected internally by a mutex
(shared with global EnvStack), there's nothing to say that other parsers with a
narrower scope/lifetime on other threads will be necessarily using the same
backing mutex.

We can safely marshal the existing `Arc<EnvStack>` we get from
`environment::principal()` into an `Rc<EnvStack>` since the underlying reference
is always valid. To prove this point, we could have PRINCIPAL_STACK be a static
`EnvStack` and have `environment::principal()` use `Arc::from_raw()` to turn
that into an `Arc<EnvStack>`, but there's no need to factorize this process.
2024-05-16 20:33:39 -05:00
Mahmoud Al-Qudsi
5f8f799cf7 Replace C++ doc \return with "Return"
quick_replace '\\\\return(s)? ' 'Return$1 ' src/

Filtered to only lines beginning with //
2024-05-06 14:59:36 -05:00
Mahmoud Al-Qudsi
589639a87d Replace C++-style \p with Markdown backticks
quick_replace '\\\\p ([a-zA-Z0-9_]+)' '`$1`' src/

Filtered to only lines beginning with //
2024-05-06 14:59:23 -05:00
Anurag Singh
62a8b48fd1 Move generated completions to cache directory 2024-04-27 10:39:30 +02:00
Johannes Altmanninger
4f536d6a9b Update commandline state snapshot lazily
I think commit 8386088b3 (Update commandline state changes eagerly as well,
2024-04-11) broke the alt-s binding.

This is because we update the commandline state snapshot (which is consumed
by builtin commandline and others) only at key points.  This seems like a
dubious optimization.  With the new streamlined bind execution semantics,
this doesn't really work anymore; any shell command can run any number of
commands like "commandline -i foo" which should synchronize.

Do the simple thing of calculating the snapshot whenever needed.
2024-04-13 14:36:11 +02:00
Johannes Altmanninger
0f758f12b7 environment.rs: minor cleanup 2024-03-23 10:38:28 +01:00
The0x539
4c3e814a50 Address clippy lints 2024-03-09 13:49:25 +01:00
Johannes Altmanninger
8545b5debe Remove obsolete no_mangle directives 2024-02-15 01:22:37 +01:00
Fabian Boehm
76a80a0678 Remove unneeded second UVARS global
This was apparently never used
2024-02-01 17:35:44 +01:00
Fabian Boehm
0a92d03498 Remove L! from sprintf calls
Remove unnecessary L!
2024-01-13 08:52:54 +01:00
Fabian Boehm
fae780d666 clippy
There are a bunch more now that widestrs is gone
2024-01-13 08:52:54 +01:00
Fabian Boehm
09cd7c7ad9 Remove widestring-suffix uses
This removes both the `#[widestrs]` annotation as well as all `"foo"L`
suffixes, and does a `cargo fmt` run on the result
2024-01-13 08:52:54 +01:00
Johannes Altmanninger
3ae20bdba0 Move fish-rust to project root 2024-01-13 03:58:33 +01:00