-
Notifications
You must be signed in to change notification settings - Fork 48
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
Public safe fn native_cpuid::cpuid_count() technically unsafe #41
Comments
Hehe no worries, in fact thanks for being pedantic! This is one more dark corner of x86 :) but basically sgx environments and some ancient 32bit machines don't support cpuid. I'm somewhat inclined to go with a just an assert/panic here rather than marking the function unsafe for ergonomics. |
Break compilation on SGX and 32-bit x86 without SSE (fixes #41)
Reviewing unsafe code in this crate, here's one more issue (but much less important, more pedantic - sorry about that).
All intrinsics in
std::arch
are unsafe, if only because the instruction may not be available on the current CPU. Even CPUID does not exist in all x86 and x86_64 instruction sets, so exposing the unsafe function as a safe function is technically unsound.A possible solution may be to do something equivalent to
assert!(has_cpuid())
(the implementation is very interesting), or to just make the functionunsafe
.A third approach would be an API to do the check only once:
The text was updated successfully, but these errors were encountered: