This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +56
-157
lines changed Expand file tree Collapse file tree 8 files changed +56
-157
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ rust_dbg_extern_identity_u8(char u) {
2727 return u ;
2828}
2929
30- typedef void * (* dbg_callback )(void * );
30+ typedef uint64_t (* dbg_callback )(uint64_t );
3131
32- void *
33- rust_dbg_call (dbg_callback cb , void * data ) {
32+ uint64_t
33+ rust_dbg_call (dbg_callback cb , uint64_t data ) {
3434 return cb (data );
3535}
3636
Original file line number Diff line number Diff line change 11#![ crate_name = "externcallback" ]
22#![ crate_type = "lib" ]
3- #![ feature( rustc_private) ]
43
5- extern crate libc;
6-
7- pub mod rustrt {
8- extern crate libc;
9-
10- #[ link( name = "rust_test_helpers" , kind = "static" ) ]
11- extern "C" {
12- pub fn rust_dbg_call (
13- cb : extern "C" fn ( libc:: uintptr_t ) -> libc:: uintptr_t ,
14- data : libc:: uintptr_t ,
15- ) -> libc:: uintptr_t ;
16- }
4+ #[ link( name = "rust_test_helpers" , kind = "static" ) ]
5+ extern "C" {
6+ pub fn rust_dbg_call (
7+ cb : extern "C" fn ( u64 ) -> u64 ,
8+ data : u64 ,
9+ ) -> u64 ;
1710}
1811
19- pub fn fact ( n : libc :: uintptr_t ) -> libc :: uintptr_t {
12+ pub fn fact ( n : u64 ) -> u64 {
2013 unsafe {
2114 println ! ( "n = {}" , n) ;
22- rustrt :: rust_dbg_call ( cb, n)
15+ rust_dbg_call ( cb, n)
2316 }
2417}
2518
26- pub extern "C" fn cb ( data : libc :: uintptr_t ) -> libc :: uintptr_t {
19+ pub extern "C" fn cb ( data : u64 ) -> u64 {
2720 if data == 1 { data } else { fact ( data - 1 ) * data }
2821}
Original file line number Diff line number Diff line change 11//@ run-pass
22//@ ignore-emscripten blows the JS stack
33
4- #![ feature( rustc_private) ]
5-
6- extern crate libc;
7-
8- mod rustrt {
9- extern crate libc;
10-
11- #[ link( name = "rust_test_helpers" , kind = "static" ) ]
12- extern "C" {
13- pub fn rust_dbg_call (
14- cb : extern "C" fn ( libc:: uintptr_t ) -> libc:: uintptr_t ,
15- data : libc:: uintptr_t ,
16- ) -> libc:: uintptr_t ;
17- }
4+ #[ link( name = "rust_test_helpers" , kind = "static" ) ]
5+ extern "C" {
6+ pub fn rust_dbg_call (
7+ cb : extern "C" fn ( u64 ) -> u64 ,
8+ data : u64 ,
9+ ) -> u64 ;
1810}
1911
20- extern "C" fn cb ( data : libc :: uintptr_t ) -> libc :: uintptr_t {
12+ extern "C" fn cb ( data : u64 ) -> u64 {
2113 if data == 1 { data } else { count ( data - 1 ) + 1 }
2214}
2315
24- fn count ( n : libc :: uintptr_t ) -> libc :: uintptr_t {
16+ fn count ( n : u64 ) -> u64 {
2517 unsafe {
2618 println ! ( "n = {}" , n) ;
27- rustrt :: rust_dbg_call ( cb, n)
19+ rust_dbg_call ( cb, n)
2820 }
2921}
3022
3123pub fn main ( ) {
3224 let result = count ( 1000 ) ;
33- println ! ( "result = {}" , result) ;
25+ println ! ( "result = {:? }" , result) ;
3426 assert_eq ! ( result, 1000 ) ;
3527}
Original file line number Diff line number Diff line change 11//@ run-pass
2- #![ allow( unused_must_use) ]
32//@ needs-threads
4- #![ feature( rustc_private) ]
53
6- extern crate libc;
74use std:: thread;
85
9- mod rustrt {
10- extern crate libc;
11-
12- #[ link( name = "rust_test_helpers" , kind = "static" ) ]
13- extern "C" {
14- pub fn rust_dbg_call (
15- cb : extern "C" fn ( libc:: uintptr_t ) -> libc:: uintptr_t ,
16- data : libc:: uintptr_t ,
17- ) -> libc:: uintptr_t ;
18- }
6+ #[ link( name = "rust_test_helpers" , kind = "static" ) ]
7+ extern "C" {
8+ pub fn rust_dbg_call (
9+ cb : extern "C" fn ( u64 ) -> u64 ,
10+ data : u64 ,
11+ ) -> u64 ;
1912}
2013
21- extern "C" fn cb ( data : libc :: uintptr_t ) -> libc :: uintptr_t {
22- if data == 1 { data } else { count ( data - 1 ) + 1 }
14+ extern "C" fn cb ( data : u64 ) -> u64 {
15+ if data == 1 { data } else { count ( data - 1 ) + 1 }
2316}
2417
25- fn count ( n : libc :: uintptr_t ) -> libc :: uintptr_t {
18+ fn count ( n : u64 ) -> u64 {
2619 unsafe {
2720 println ! ( "n = {}" , n) ;
28- rustrt :: rust_dbg_call ( cb, n)
21+ rust_dbg_call ( cb, n)
2922 }
3023}
3124
@@ -37,5 +30,5 @@ pub fn main() {
3730 println ! ( "result = {}" , result) ;
3831 assert_eq ! ( result, 1000 ) ;
3932 } )
40- . join ( ) ;
33+ . join ( ) . unwrap ( ) ;
4134}
Original file line number Diff line number Diff line change 11//@ run-pass
22
3- #![ feature( rustc_private) ]
4-
5- extern crate libc;
6-
7- mod rustrt {
8- extern crate libc;
9-
10- #[ link( name = "rust_test_helpers" , kind = "static" ) ]
11- extern "C" {
12- pub fn rust_dbg_call (
13- cb : extern "C" fn ( libc:: uintptr_t ) -> libc:: uintptr_t ,
14- data : libc:: uintptr_t ,
15- ) -> libc:: uintptr_t ;
16- }
3+ #[ link( name = "rust_test_helpers" , kind = "static" ) ]
4+ extern "C" {
5+ pub fn rust_dbg_call (
6+ cb : extern "C" fn ( u64 ) -> u64 ,
7+ data : u64 ,
8+ ) -> u64 ;
179}
1810
19- extern "C" fn cb ( data : libc :: uintptr_t ) -> libc :: uintptr_t {
11+ extern "C" fn cb ( data : u64 ) -> u64 {
2012 if data == 1 { data } else { fact ( data - 1 ) * data }
2113}
2214
23- fn fact ( n : libc :: uintptr_t ) -> libc :: uintptr_t {
15+ fn fact ( n : u64 ) -> u64 {
2416 unsafe {
2517 println ! ( "n = {}" , n) ;
26- rustrt :: rust_dbg_call ( cb, n)
18+ rust_dbg_call ( cb, n)
2719 }
2820}
2921
Original file line number Diff line number Diff line change 11//@ run-pass
2- #! [ allow ( unused_must_use ) ]
2+ //@ needs-threads
33// This time we're testing repeatedly going up and down both stacks to
44// make sure the stack pointers are maintained properly in both
55// directions
66
7- //@ needs-threads
8- #![ feature( rustc_private) ]
9-
10- extern crate libc;
117use std:: thread;
128
13- mod rustrt {
14- extern crate libc;
15-
16- #[ link( name = "rust_test_helpers" , kind = "static" ) ]
17- extern "C" {
18- pub fn rust_dbg_call (
19- cb : extern "C" fn ( libc:: uintptr_t ) -> libc:: uintptr_t ,
20- data : libc:: uintptr_t ,
21- ) -> libc:: uintptr_t ;
22- }
9+ #[ link( name = "rust_test_helpers" , kind = "static" ) ]
10+ extern "C" {
11+ pub fn rust_dbg_call (
12+ cb : extern "C" fn ( u64 ) -> u64 ,
13+ data : u64 ,
14+ ) -> u64 ;
2315}
2416
25- extern "C" fn cb ( data : libc :: uintptr_t ) -> libc :: uintptr_t {
17+ extern "C" fn cb ( data : u64 ) -> u64 {
2618 if data == 1 { data } else { count ( data - 1 ) + count ( data - 1 ) }
2719}
2820
29- fn count ( n : libc :: uintptr_t ) -> libc :: uintptr_t {
21+ fn count ( n : u64 ) -> u64 {
3022 unsafe {
3123 println ! ( "n = {}" , n) ;
32- rustrt :: rust_dbg_call ( cb, n)
24+ rust_dbg_call ( cb, n)
3325 }
3426}
3527
@@ -41,5 +33,5 @@ pub fn main() {
4133 println ! ( "result = {}" , result) ;
4234 assert_eq ! ( result, 2048 ) ;
4335 } )
44- . join ( ) ;
36+ . join ( ) . unwrap ( ) ;
4537}
Original file line number Diff line number Diff line change 11//@ run-pass
22//@ aux-build:extern-crosscrate-source.rs
33
4- #![ feature( rustc_private) ]
5-
64extern crate externcallback;
7- extern crate libc;
85
9- fn fact ( n : libc :: uintptr_t ) -> libc :: uintptr_t {
6+ fn fact ( n : u64 ) -> u64 {
107 unsafe {
11- println ! ( "n = {}" , n) ;
12- externcallback:: rustrt :: rust_dbg_call ( externcallback:: cb, n)
8+ println ! ( "n = {:? }" , n) ;
9+ externcallback:: rust_dbg_call ( externcallback:: cb, n)
1310 }
1411}
1512
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments