Access to platform registers

On Windows, the fs (x86), gs (x64) or x18 (aarch64) register is used to address the Thread Information Block (TIB). With the MSVC C++ compiler these can be accessed via intrinsics such as __readgsdword which will read a u32 for the given offset from the gs base.

On other platforms these registers can also be used for platform-specific purposes (I think glibc uses fs for TLS).

Currently there is no stable way to access these registers. Could some way to access platform registers be added to core::arch? I realize that if/when asm! is stabilized there would be another way to access these registers but then again this could be said about most things in arch.

1 Like

The intel intrinsics guide lists the _writefsbase_u32, _writefsbase_u64, _writegsbase_u32 and _writegsbase_u64 functions:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.