Skip to content

Commit 152ed37

Browse files
authored
Rollup merge of rust-lang#58949 - jethrogb:jb/sgx-thread-id, r=joshtriplett
SGX target: Expose thread id function in os module In order to call `std::os::fortanix_sgx::usercalls::send`, you need the thread id. This exposes it through another function in `std::os::fortanix_sgx`. I looked at how other platforms do this. On Windows and `cfg(unix)` you can get the OS handle from a `thread::JoinHandle`, but that's not sufficient, I need it for a `thread::Thread`. In the future, this functionality could be added to `thread::Thread` and this platform can follow suit. r? @joshtriplett
2 parents 9859b81 + 67eabc6 commit 152ed37

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/libstd/os/fortanix_sgx/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ pub mod mem {
4343
}
4444

4545
pub use crate::sys::ext::{io, arch, ffi};
46+
47+
/// Functions for querying thread-related information.
48+
pub mod thread {
49+
pub use crate::sys::abi::thread::current;
50+
}

src/libstd/sys/sgx/abi/thread.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use fortanix_sgx_abi::Tcs;
44
/// all currently running threads in the enclave, and it is guaranteed to be
55
/// constant for the lifetime of the thread. More specifically for SGX, there
66
/// is a one-to-one correspondence of the ID to the address of the TCS.
7+
#[unstable(feature = "sgx_platform", issue = "56975")]
78
pub fn current() -> Tcs {
89
extern "C" { fn get_tcs_addr() -> Tcs; }
910
unsafe { get_tcs_addr() }

0 commit comments

Comments
 (0)