Skip to content

Commit

Permalink
Simplify global state management in adapter (#13)
Browse files Browse the repository at this point in the history
* Simplify global state management in adapter

I was looking recently to implement args-related syscalls but that would
require yet-more globals and yet-more state to be managed. Instead of
adding a slew of new globals for this which are all manually kept in
sync I opted to instead redesign how global state is managed in the
adapter.

The previous multiple `global`s are all removed in favor of just one, as
sort of a "tls slot" of sorts. This one remaining slot points to a
one-time-allocated `State` object which internally stores information
like buffer metadata, fd information, etc. Along the way I've also
simplified syscalls with new methods and `?`-using closures.

* Turn off incremental for dev builds

Helps with CGU splitting and ensuring that appropriate code is produced
even without `--release`.

* Review comments

* Add accessors with specific errors
* Update handling of `*_global_ptr`

* Update internal mutability around path buffer

Use an `UnsafeCell` layering to indicate that mutation may happen
through `&T`.
  • Loading branch information
alexcrichton authored Dec 1, 2022
1 parent c9d42fe commit 2d25a84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test-programs/macros/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {

let mut components = Vec::new();

println!("cargo:rerun-if-changed=../../");
println!("cargo:rerun-if-changed=../../src");
let mut cmd = Command::new("cargo");
cmd.arg("build")
.arg("--release")
Expand Down

0 comments on commit 2d25a84

Please sign in to comment.