forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#124096 - saethlin:rust-dbg-call, r=Nilstrieb Clean up users of rust_dbg_call `rust_dbg_call` is a C test helper that until this PR was declared in C with `void*` arguments and used in Rust _mostly_ with `libc::uintptr_t` arguments. Nearly every user just wants to pass integers around, so I've changed all users to `uint64_t` or `u64`. The single test that actually used the pointer-ness of the argument is a test for ensuring that Rust can make extern calls outside of tasks. Rust hasn't had tasks for quite a few years now, so I'm deleting that test under the same logic as the test deleted in rust-lang#124073
- Loading branch information
Showing
8 changed files
with
56 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
#![crate_name = "externcallback"] | ||
#![crate_type = "lib"] | ||
#![feature(rustc_private)] | ||
|
||
extern crate libc; | ||
|
||
pub mod rustrt { | ||
extern crate libc; | ||
|
||
#[link(name = "rust_test_helpers", kind = "static")] | ||
extern "C" { | ||
pub fn rust_dbg_call( | ||
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, | ||
data: libc::uintptr_t, | ||
) -> libc::uintptr_t; | ||
} | ||
#[link(name = "rust_test_helpers", kind = "static")] | ||
extern "C" { | ||
pub fn rust_dbg_call( | ||
cb: extern "C" fn(u64) -> u64, | ||
data: u64, | ||
) -> u64; | ||
} | ||
|
||
pub fn fact(n: libc::uintptr_t) -> libc::uintptr_t { | ||
pub fn fact(n: u64) -> u64 { | ||
unsafe { | ||
println!("n = {}", n); | ||
rustrt::rust_dbg_call(cb, n) | ||
rust_dbg_call(cb, n) | ||
} | ||
} | ||
|
||
pub extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t { | ||
pub extern "C" fn cb(data: u64) -> u64 { | ||
if data == 1 { data } else { fact(data - 1) * data } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,27 @@ | ||
//@ run-pass | ||
//@ ignore-emscripten blows the JS stack | ||
|
||
#![feature(rustc_private)] | ||
|
||
extern crate libc; | ||
|
||
mod rustrt { | ||
extern crate libc; | ||
|
||
#[link(name = "rust_test_helpers", kind = "static")] | ||
extern "C" { | ||
pub fn rust_dbg_call( | ||
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, | ||
data: libc::uintptr_t, | ||
) -> libc::uintptr_t; | ||
} | ||
#[link(name = "rust_test_helpers", kind = "static")] | ||
extern "C" { | ||
pub fn rust_dbg_call( | ||
cb: extern "C" fn(u64) -> u64, | ||
data: u64, | ||
) -> u64; | ||
} | ||
|
||
extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t { | ||
extern "C" fn cb(data: u64) -> u64 { | ||
if data == 1 { data } else { count(data - 1) + 1 } | ||
} | ||
|
||
fn count(n: libc::uintptr_t) -> libc::uintptr_t { | ||
fn count(n: u64) -> u64 { | ||
unsafe { | ||
println!("n = {}", n); | ||
rustrt::rust_dbg_call(cb, n) | ||
rust_dbg_call(cb, n) | ||
} | ||
} | ||
|
||
pub fn main() { | ||
let result = count(1000); | ||
println!("result = {}", result); | ||
println!("result = {:?}", result); | ||
assert_eq!(result, 1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.