Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 58e0fba

Browse files
committed
Auto merge of rust-lang#3945 - RalfJung:pthread_attr_t, r=RalfJung
avoid pthread_attr_t in tests We don't support `pthread_attr_init` so the code here is actually technically wrong (passing attributes to `pthread_create` that were not initialized properly). It's also unnecessary, we can just pass a null pointer for the attributes to indicate "default attributes please".
2 parents 3b418b1 + 885ec88 commit 58e0fba

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
1212
fn main() {
1313
unsafe {
1414
let mut native: libc::pthread_t = mem::zeroed();
15-
let attr: libc::pthread_attr_t = mem::zeroed();
16-
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
17-
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
15+
assert_eq!(
16+
libc::pthread_create(&mut native, ptr::null(), thread_start, ptr::null_mut()),
17+
0
18+
);
1819
}
1920
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ extern "C" fn thread_start() -> *mut libc::c_void {
1212
fn main() {
1313
unsafe {
1414
let mut native: libc::pthread_t = mem::zeroed();
15-
let attr: libc::pthread_attr_t = mem::zeroed();
16-
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
1715
let thread_start: extern "C" fn() -> *mut libc::c_void = thread_start;
1816
let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void =
1917
mem::transmute(thread_start);
20-
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
18+
assert_eq!(
19+
libc::pthread_create(&mut native, ptr::null(), thread_start, ptr::null_mut()),
20+
0
21+
);
2122
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
2223
}
2324
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ extern "C" fn thread_start(_null: *mut libc::c_void, _x: i32) -> *mut libc::c_vo
1212
fn main() {
1313
unsafe {
1414
let mut native: libc::pthread_t = mem::zeroed();
15-
let attr: libc::pthread_attr_t = mem::zeroed();
16-
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
1715
let thread_start: extern "C" fn(*mut libc::c_void, i32) -> *mut libc::c_void = thread_start;
1816
let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void =
1917
mem::transmute(thread_start);
20-
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
18+
assert_eq!(
19+
libc::pthread_create(&mut native, ptr::null(), thread_start, ptr::null_mut()),
20+
0
21+
);
2122
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
2223
}
2324
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
1111
fn main() {
1212
unsafe {
1313
let mut native: libc::pthread_t = mem::zeroed();
14-
let attr: libc::pthread_attr_t = mem::zeroed();
15-
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
16-
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
14+
assert_eq!(
15+
libc::pthread_create(&mut native, ptr::null(), thread_start, ptr::null_mut()),
16+
0
17+
);
1718
assert_eq!(libc::pthread_detach(native), 0);
1819
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread
1920
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
1111
fn main() {
1212
unsafe {
1313
let mut native: libc::pthread_t = mem::zeroed();
14-
let attr: libc::pthread_attr_t = mem::zeroed();
15-
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
16-
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
14+
assert_eq!(
15+
libc::pthread_create(&mut native, ptr::null(), thread_start, ptr::null_mut()),
16+
0
17+
);
1718
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
1819
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread
1920
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
1414
fn main() {
1515
unsafe {
1616
let mut native: libc::pthread_t = mem::zeroed();
17-
let attr: libc::pthread_attr_t = mem::zeroed();
18-
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
19-
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
17+
assert_eq!(
18+
libc::pthread_create(&mut native, ptr::null(), thread_start, ptr::null_mut()),
19+
0
20+
);
2021
let mut native_copy: libc::pthread_t = mem::zeroed();
2122
ptr::copy_nonoverlapping(&native, &mut native_copy, 1);
2223
let handle = thread::spawn(move || {

0 commit comments

Comments
 (0)