Store user pointers as address-only types instead of platform pointers#1053
Merged
Conversation
This PR changes how the Linux shim represents user pointers, so that `Platform` is no longer viral across types that merely hold a pointer value. Previously, litebox_shim_linux and litebox_common_linux stored user pointers using the platform's associated pointer types (`Platform::RawConstPointer`/`RawMutPointer`). Because those types are parameterized by the platform, every struct, enum, and signature that carried a user pointer had to carry a `Platform` (or `RawPointerProvider`) parameter -- even when it never dereferenced anything. This is the main obstacle to eventually dropping litebox_platform_multiplex from the shim in favor of explicit `Platform` generic bounds. This PR introduces address-only `UserPtr<T>`/`UserPtrMut<T>` (transparent `usize` wrappers) in litebox_common_linux and uses them everywhere a user pointer is stored. The platform only re-enters at the handful of sites that actually access memory: the access methods take the platform as an explicit witness (e.g. `ptr.read_at_offset::<Platform>(..)`), converting back to the real platform pointer via `to_platform_ptr`. As a result, `Platform` shows up only where memory is genuinely read or written, which is both clearer and the setup needed to make the shim generic over the platform. Behavior is unchanged; this is purely a representation refactor.
jaybosamiya-ms
left a comment
Member
There was a problem hiding this comment.
Thanks John! Overall looks good to me, just a few minor nits to fix up before merging
Member
|
Also, since semver-checks CI bot does not fire on branches from forks, here's its output as of bac25fe (basically expected tweaks): click to unfold |
jaybosamiya-ms
approved these changes
Jul 21, 2026
jaybosamiya-ms
left a comment
Member
There was a problem hiding this comment.
Pushed fixes for the minor nits; lgtm
jaybosamiya-ms
enabled auto-merge
July 21, 2026 00:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes how the Linux shim represents user pointers, so that
Platformis no longer viral across types that merely hold a pointer value.Previously, litebox_shim_linux and litebox_common_linux stored user pointers using the platform's associated pointer types (
Platform::RawConstPointer/RawMutPointer). Because those types are parameterized by the platform, every struct, enum, and signature that carried a user pointer had to carry aPlatform(orRawPointerProvider) parameter -- even when it never dereferenced anything. This is the main obstacle to eventually dropping litebox_platform_multiplex from the shim in favor of explicitPlatformgeneric bounds.This PR introduces address-only
UserPtr<T>/UserPtrMut<T>(transparentusizewrappers) in litebox_common_linux and uses them everywhere a user pointer is stored. The platform only re-enters at the handful of sites that actually access memory: the access methods take the platform as an explicit witness (e.g.ptr.read_at_offset::<Platform>(..)), converting back to the real platform pointer viato_platform_ptr. As a result,Platformshows up only where memory is genuinely read or written, which is both clearer and the setup needed to make the shim generic over the platform.Behavior is unchanged; this is purely a representation refactor.