From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/abi/extern/extern-call-deep.rs | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/ui/abi/extern/extern-call-deep.rs (limited to 'tests/ui/abi/extern/extern-call-deep.rs') diff --git a/tests/ui/abi/extern/extern-call-deep.rs b/tests/ui/abi/extern/extern-call-deep.rs new file mode 100644 index 000000000..db5f2ca65 --- /dev/null +++ b/tests/ui/abi/extern/extern-call-deep.rs @@ -0,0 +1,36 @@ +// run-pass +// ignore-wasm32-bare no libc to test ffi with +// 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; + } +} + +extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t { + if data == 1 { data } else { count(data - 1) + 1 } +} + +fn count(n: libc::uintptr_t) -> libc::uintptr_t { + unsafe { + println!("n = {}", n); + rustrt::rust_dbg_call(cb, n) + } +} + +pub fn main() { + let result = count(1000); + println!("result = {}", result); + assert_eq!(result, 1000); +} -- cgit v1.2.3