-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Print thread ID in panic message #115746
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
base: master
Are you sure you want to change the base?
Print thread ID in panic message #115746
Changes from 3 commits
8829bd5
df8ae53
0cd5add
1a92b00
dbfa586
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,14 @@ impl Thread { | |
} | ||
} | ||
|
||
pub(crate) fn current_os_id() -> Option<u64> { | ||
// SAFETY: FFI call with no preconditions. | ||
let id: u32 = unsafe { c::GetThreadId(c::GetCurrentThread()) }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going to change this to |
||
|
||
// A return value of 0 indicates failed lookup. | ||
if id == 0 { None } else { Some(id.into()) } | ||
} | ||
|
||
pub fn available_parallelism() -> io::Result<NonZero<usize>> { | ||
let res = unsafe { | ||
let mut sysinfo: c::SYSTEM_INFO = crate::mem::zeroed(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore the Miri shims and the relevant test, I think that can go through the Miri tree rust-lang/miri#4397. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, can we modify the macro in another PR to accept "safe extern" functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, but there should still be an
unsafe
somewhere to promise that the FFI signature is correct.We don't even really need "safe extern" though, because it's wrapped anyway -- e.g. we could just declare this safe if we wanted:
rust/library/std/src/sys/pal/unix/weak.rs
Lines 176 to 186 in 48aee7e