Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the use of std::sync::Once with no_std-compatible code #745

Closed
briansmith opened this issue Dec 27, 2018 · 3 comments
Closed

Replace the use of std::sync::Once with no_std-compatible code #745

briansmith opened this issue Dec 27, 2018 · 3 comments

Comments

@briansmith
Copy link
Owner

See #744. One of the two pain ports in porting ring to a no_std platform is our use of std::sync::Once, which (obviously) requires libstd. There is only one use of std::sync::Once. Our single use of std::sync::Once is very simple: We look up the CPU capabilities (e.g. using CPUID) and store the results.

I think it is safe to assume that looking up the CPU capabilities is idempotent, so we could probably even let threads race with each other to cache the CPU capabilities, letting them stomp on each other's caching (in a controlled way).

/cc @jethrogb

@briansmith
Copy link
Owner Author

Another solution would be to use parking_lot in no_std mode.

@briansmith
Copy link
Owner Author

Fixed in 0.14 by using spin::Once.

@briansmith
Copy link
Owner Author

Fixed in 0.14 by using spin::Once.

This caused #931: CPU feature detection may be racy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant