Skip to content

Commit 56bf14e

Browse files
bors[bot]GuillaumeGomezcuviper
committed
640: Reexport current_thread_index function r=cuviper a=GuillaumeGomez Fixes rayon-rs#639. Co-authored-by: Guillaume Gomez <[email protected]> Co-authored-by: Josh Stone <[email protected]>
2 parents 5611490 + d2a0054 commit 56bf14e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

rayon-core/tests/stack_overflow_crash.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ fn force_stack_overflow(depth: u32) {
1515
}
1616
}
1717

18+
#[cfg(unix)]
19+
fn overflow_code() -> Option<i32> {
20+
None
21+
}
22+
23+
#[cfg(windows)]
24+
fn overflow_code() -> Option<i32> {
25+
use std::os::windows::process::ExitStatusExt;
26+
use std::process::ExitStatus;
27+
28+
ExitStatus::from_raw(0xc00000fd /*STATUS_STACK_OVERFLOW*/).code()
29+
}
30+
1831
fn main() {
1932
if env::args().len() == 1 {
2033
// first check that the recursivecall actually causes a stack overflow, and does not get optimized away
@@ -24,11 +37,8 @@ fn main() {
2437
.status()
2538
.unwrap();
2639

27-
#[cfg(windows)]
28-
assert_eq!(status.code(), Some(0xc00000fd /*STATUS_STACK_OVERFLOW*/));
29-
30-
#[cfg(unix)]
31-
assert_eq!(status.code(), None);
40+
#[cfg(any(unix, windows))]
41+
assert_eq!(status.code(), overflow_code());
3242

3343
#[cfg(target_os = "linux")]
3444
assert!(

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ mod par_either;
109109

110110
mod compile_fail;
111111

112-
pub use rayon_core::current_num_threads;
112+
pub use rayon_core::{current_num_threads, current_thread_index};
113113
pub use rayon_core::FnContext;
114114
pub use rayon_core::ThreadPool;
115115
pub use rayon_core::ThreadPoolBuildError;

0 commit comments

Comments
 (0)