Why is cpuid unsafe?

While looking at the cpuid functionality in core::arch, I was wondering why __cpuid_count is marked unsafe. There is no danger for memory unsafety or other issues.

Does anyone know the reasoning here?

It's probably using a C library underneath.

A colleague has pointed me to this page which explains the reasoning. It's basically all marked unsafe, because it's not portable and care must be taken.

It isn't, it's implemented using inline assembly. You can tell by clicking on the [src] next to its documentation.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.