mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Clean up users of rust_dbg_call
This commit is contained in:
parent
c45dee5efd
commit
b91c1aafec
@ -27,10 +27,10 @@ rust_dbg_extern_identity_u8(char u) {
|
|||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void *(*dbg_callback)(void*);
|
typedef uint64_t (*dbg_callback)(uint64_t);
|
||||||
|
|
||||||
void *
|
uint64_t
|
||||||
rust_dbg_call(dbg_callback cb, void *data) {
|
rust_dbg_call(dbg_callback cb, uint64_t data) {
|
||||||
return cb(data);
|
return cb(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,28 +1,21 @@
|
|||||||
#![crate_name = "externcallback"]
|
#![crate_name = "externcallback"]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate libc;
|
#[link(name = "rust_test_helpers", kind = "static")]
|
||||||
|
extern "C" {
|
||||||
pub mod rustrt {
|
pub fn rust_dbg_call(
|
||||||
extern crate libc;
|
cb: extern "C" fn(u64) -> u64,
|
||||||
|
data: u64,
|
||||||
#[link(name = "rust_test_helpers", kind = "static")]
|
) -> u64;
|
||||||
extern "C" {
|
|
||||||
pub fn rust_dbg_call(
|
|
||||||
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
|
|
||||||
data: libc::uintptr_t,
|
|
||||||
) -> libc::uintptr_t;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
|
pub fn fact(n: u64) -> u64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("n = {}", n);
|
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 }
|
if data == 1 { data } else { fact(data - 1) * data }
|
||||||
}
|
}
|
||||||
|
28
tests/ui/abi/extern/extern-call-deep.rs
vendored
28
tests/ui/abi/extern/extern-call-deep.rs
vendored
@ -1,35 +1,27 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ ignore-emscripten blows the JS stack
|
//@ ignore-emscripten blows the JS stack
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
#[link(name = "rust_test_helpers", kind = "static")]
|
||||||
|
extern "C" {
|
||||||
extern crate libc;
|
pub fn rust_dbg_call(
|
||||||
|
cb: extern "C" fn(u64) -> u64,
|
||||||
mod rustrt {
|
data: u64,
|
||||||
extern crate libc;
|
) -> u64;
|
||||||
|
|
||||||
#[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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 }
|
if data == 1 { data } else { count(data - 1) + 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
fn count(n: u64) -> u64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("n = {}", n);
|
println!("n = {}", n);
|
||||||
rustrt::rust_dbg_call(cb, n)
|
rust_dbg_call(cb, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let result = count(1000);
|
let result = count(1000);
|
||||||
println!("result = {}", result);
|
println!("result = {:?}", result);
|
||||||
assert_eq!(result, 1000);
|
assert_eq!(result, 1000);
|
||||||
}
|
}
|
||||||
|
29
tests/ui/abi/extern/extern-call-deep2.rs
vendored
29
tests/ui/abi/extern/extern-call-deep2.rs
vendored
@ -1,31 +1,24 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
#![allow(unused_must_use)]
|
|
||||||
//@ needs-threads
|
//@ needs-threads
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate libc;
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
mod rustrt {
|
#[link(name = "rust_test_helpers", kind = "static")]
|
||||||
extern crate libc;
|
extern "C" {
|
||||||
|
pub fn rust_dbg_call(
|
||||||
#[link(name = "rust_test_helpers", kind = "static")]
|
cb: extern "C" fn(u64) -> u64,
|
||||||
extern "C" {
|
data: u64,
|
||||||
pub fn rust_dbg_call(
|
) -> u64;
|
||||||
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
|
|
||||||
data: libc::uintptr_t,
|
|
||||||
) -> libc::uintptr_t;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 }
|
if data == 1 { data } else { count(data - 1 ) + 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
fn count(n: u64) -> u64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("n = {}", n);
|
println!("n = {}", n);
|
||||||
rustrt::rust_dbg_call(cb, n)
|
rust_dbg_call(cb, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,5 +30,5 @@ pub fn main() {
|
|||||||
println!("result = {}", result);
|
println!("result = {}", result);
|
||||||
assert_eq!(result, 1000);
|
assert_eq!(result, 1000);
|
||||||
})
|
})
|
||||||
.join();
|
.join().unwrap();
|
||||||
}
|
}
|
||||||
|
26
tests/ui/abi/extern/extern-call-indirect.rs
vendored
26
tests/ui/abi/extern/extern-call-indirect.rs
vendored
@ -1,29 +1,21 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
#[link(name = "rust_test_helpers", kind = "static")]
|
||||||
|
extern "C" {
|
||||||
extern crate libc;
|
pub fn rust_dbg_call(
|
||||||
|
cb: extern "C" fn(u64) -> u64,
|
||||||
mod rustrt {
|
data: u64,
|
||||||
extern crate libc;
|
) -> u64;
|
||||||
|
|
||||||
#[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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
extern "C" fn cb(data: u64) -> u64 {
|
||||||
if data == 1 { data } else { fact(data - 1) * data }
|
if data == 1 { data } else { fact(data - 1) * data }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
|
fn fact(n: u64) -> u64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("n = {}", n);
|
println!("n = {}", n);
|
||||||
rustrt::rust_dbg_call(cb, n)
|
rust_dbg_call(cb, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
tests/ui/abi/extern/extern-call-scrub.rs
vendored
30
tests/ui/abi/extern/extern-call-scrub.rs
vendored
@ -1,35 +1,27 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
#![allow(unused_must_use)]
|
//@ needs-threads
|
||||||
// This time we're testing repeatedly going up and down both stacks to
|
// This time we're testing repeatedly going up and down both stacks to
|
||||||
// make sure the stack pointers are maintained properly in both
|
// make sure the stack pointers are maintained properly in both
|
||||||
// directions
|
// directions
|
||||||
|
|
||||||
//@ needs-threads
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate libc;
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
mod rustrt {
|
#[link(name = "rust_test_helpers", kind = "static")]
|
||||||
extern crate libc;
|
extern "C" {
|
||||||
|
pub fn rust_dbg_call(
|
||||||
#[link(name = "rust_test_helpers", kind = "static")]
|
cb: extern "C" fn(u64) -> u64,
|
||||||
extern "C" {
|
data: u64,
|
||||||
pub fn rust_dbg_call(
|
) -> u64;
|
||||||
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
|
|
||||||
data: libc::uintptr_t,
|
|
||||||
) -> libc::uintptr_t;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) + count(data - 1) }
|
if data == 1 { data } else { count(data - 1) + count(data - 1) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
fn count(n: u64) -> u64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("n = {}", n);
|
println!("n = {}", n);
|
||||||
rustrt::rust_dbg_call(cb, n)
|
rust_dbg_call(cb, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,5 +33,5 @@ pub fn main() {
|
|||||||
println!("result = {}", result);
|
println!("result = {}", result);
|
||||||
assert_eq!(result, 2048);
|
assert_eq!(result, 2048);
|
||||||
})
|
})
|
||||||
.join();
|
.join().unwrap();
|
||||||
}
|
}
|
||||||
|
9
tests/ui/abi/extern/extern-crosscrate.rs
vendored
9
tests/ui/abi/extern/extern-crosscrate.rs
vendored
@ -1,15 +1,12 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ aux-build:extern-crosscrate-source.rs
|
//@ aux-build:extern-crosscrate-source.rs
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate externcallback;
|
extern crate externcallback;
|
||||||
extern crate libc;
|
|
||||||
|
|
||||||
fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
|
fn fact(n: u64) -> u64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("n = {}", n);
|
println!("n = {:?}", n);
|
||||||
externcallback::rustrt::rust_dbg_call(externcallback::cb, n)
|
externcallback::rust_dbg_call(externcallback::cb, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
//@ run-pass
|
|
||||||
//@ needs-threads
|
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate libc;
|
|
||||||
|
|
||||||
use std::mem;
|
|
||||||
use std::thread;
|
|
||||||
|
|
||||||
#[link(name = "rust_test_helpers", kind = "static")]
|
|
||||||
extern "C" {
|
|
||||||
fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t), data: libc::uintptr_t) -> libc::uintptr_t;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
unsafe {
|
|
||||||
thread::spawn(move || {
|
|
||||||
let i: isize = 100;
|
|
||||||
rust_dbg_call(callback_isize, mem::transmute(&i));
|
|
||||||
})
|
|
||||||
.join()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
let i: i32 = 100;
|
|
||||||
rust_dbg_call(callback_i32, mem::transmute(&i));
|
|
||||||
})
|
|
||||||
.join()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
let i: i64 = 100;
|
|
||||||
rust_dbg_call(callback_i64, mem::transmute(&i));
|
|
||||||
})
|
|
||||||
.join()
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn callback_isize(data: libc::uintptr_t) {
|
|
||||||
unsafe {
|
|
||||||
let data = data as *const isize;
|
|
||||||
assert_eq!(*data, 100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn callback_i64(data: libc::uintptr_t) {
|
|
||||||
unsafe {
|
|
||||||
let data = data as *const i64;
|
|
||||||
assert_eq!(*data, 100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn callback_i32(data: libc::uintptr_t) {
|
|
||||||
unsafe {
|
|
||||||
let data = data as *const i32;
|
|
||||||
assert_eq!(*data, 100);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user