@@ -22,45 +22,106 @@ pub unsafe fn fn_0(mut v: Vec<libc::c_char>) -> Vec<libc::c_char> {
2222pub unsafe fn fn2_1 ( v : * const Vec < libc:: c_char > ) -> * const Vec < libc:: c_char > {
2323 return v;
2424}
25+ pub unsafe fn log_to_2 (
26+ mut out : * mut :: libc:: FILE ,
27+ mut fmt : * const libc:: c_char ,
28+ mut args_2 : * const libc:: c_char ,
29+ mut args_3 : i32 ,
30+ ) {
31+ ( unsafe {
32+ libc:: fprintf (
33+ out as * mut :: libc:: FILE ,
34+ fmt as * const libc:: c_char ,
35+ ( args_2) ,
36+ ( args_3) ,
37+ )
38+ } ) ;
39+ }
40+ pub unsafe fn log_to_3 ( mut out : * mut :: libc:: FILE , mut fmt : * const libc:: c_char , mut args : i32 ) {
41+ ( unsafe { libc:: fprintf ( out as * mut :: libc:: FILE , fmt as * const libc:: c_char , ( args) ) } ) ;
42+ }
43+ pub unsafe fn log_fmt_4 ( mut fmt : * const libc:: c_char , mut v : i32 ) {
44+ ( unsafe { libc:: printf ( fmt as * const libc:: c_char , ( v) ) } ) ;
45+ }
2546pub fn main ( ) {
2647 unsafe {
2748 __cpp2rust_init_globals ( ) ;
2849 std:: process:: exit ( main_0 ( ) as i32 ) ;
2950 }
3051}
3152unsafe fn main_0 ( ) -> i32 {
32- printf ( c"%s\n " . as_ptr ( ) as * const i8 , c"fprintf stdout" . as_ptr ( ) ) ;
33- printf ( c"%d %u %ld\n " . as_ptr ( ) as * const i8 , 1 , 2_u32 , 3_i64 ) ;
34- printf ( c"hello world" . as_ptr ( ) as * const i8 ) ;
53+ ( unsafe {
54+ libc:: fprintf (
55+ libcc2rs:: stdout_unsafe ( ) as * mut :: libc:: FILE ,
56+ c"%s\n " . as_ptr ( ) as * const libc:: c_char ,
57+ ( c"fprintf stdout" . as_ptr ( ) ) ,
58+ )
59+ } ) ;
60+ ( unsafe {
61+ libc:: fprintf (
62+ libcc2rs:: stdout_unsafe ( ) as * mut :: libc:: FILE ,
63+ c"%d %u %ld\n " . as_ptr ( ) as * const libc:: c_char ,
64+ ( 1 ) ,
65+ ( 2_u32 ) ,
66+ ( 3_i64 ) ,
67+ )
68+ } ) ;
69+ ( unsafe {
70+ libc:: fprintf (
71+ libcc2rs:: stdout_unsafe ( ) as * mut :: libc:: FILE ,
72+ c"hello world" . as_ptr ( ) as * const libc:: c_char ,
73+ )
74+ } ) ;
3575 let mut in_: * mut :: libc:: FILE = libcc2rs:: stdin_unsafe ( ) ;
3676 assert ! ( !( ( in_) . is_null( ) ) ) ;
37- printf ( c"%s\n " . as_ptr ( ) as * const i8 , c"printf" . as_ptr ( ) ) ;
38- printf ( c"hello world" . as_ptr ( ) as * const i8 ) ;
77+ ( unsafe {
78+ libc:: printf (
79+ c"%s\n " . as_ptr ( ) as * const libc:: c_char ,
80+ ( c"printf" . as_ptr ( ) ) ,
81+ )
82+ } ) ;
83+ ( unsafe { libc:: printf ( c"hello world" . as_ptr ( ) as * const libc:: c_char ) } ) ;
3984 let mut s: Vec < libc:: c_char > = {
4085 let s = c"a string" . as_ptr ( ) ;
4186 std:: slice:: from_raw_parts ( s, ( 0 ..) . take_while ( |& i| * s. add ( i) != 0 ) . count ( ) + 1 ) . to_vec ( )
4287 } ;
43- printf ( c"%s\n " . as_ptr ( ) as * const i8 , s. as_mut_ptr ( ) ) ;
44- printf (
45- c"%s\n " . as_ptr ( ) as * const i8 ,
46- ( unsafe {
47- fn_0 ( {
48- let s = c"foo" . as_ptr ( ) ;
49- std:: slice:: from_raw_parts ( s, ( 0 ..) . take_while ( |& i| * s. add ( i) != 0 ) . count ( ) + 1 )
50- . to_vec ( )
88+ ( unsafe { libc:: printf ( c"%s\n " . as_ptr ( ) as * const libc:: c_char , ( s. as_mut_ptr ( ) ) ) } ) ;
89+ ( unsafe {
90+ libc:: printf (
91+ c"%s\n " . as_ptr ( ) as * const libc:: c_char ,
92+ ( ( unsafe {
93+ fn_0 ( {
94+ let s = c"foo" . as_ptr ( ) ;
95+ std:: slice:: from_raw_parts ( s, ( 0 ..) . take_while ( |& i| * s. add ( i) != 0 ) . count ( ) + 1 )
96+ . to_vec ( )
97+ } )
5198 } )
52- } )
53- . as_ptr ( ) ,
54- ) ;
55- printf (
56- c"%s\n " . as_ptr ( ) as * const i8 ,
57- ( * ( unsafe { fn2_1 ( & s) } ) ) . as_ptr ( ) ,
58- ) ;
59- printf (
60- c"{} %ju %jd\n " . as_ptr ( ) as * const i8 ,
61- 5_u64 ,
62- ( -6_i32 as i64 ) ,
63- ) ;
99+ . as_ptr ( ) ) ,
100+ )
101+ } ) ;
102+ ( unsafe {
103+ libc:: printf (
104+ c"%s\n " . as_ptr ( ) as * const libc:: c_char ,
105+ ( ( * ( unsafe { fn2_1 ( & s) } ) ) . as_ptr ( ) ) ,
106+ )
107+ } ) ;
108+ ( unsafe {
109+ log_to_2 (
110+ libcc2rs:: stdout_unsafe ( ) ,
111+ c"%s %d\n " . as_ptr ( ) ,
112+ c"runtime" . as_ptr ( ) ,
113+ 4 ,
114+ )
115+ } ) ;
116+ ( unsafe { log_to_3 ( libcc2rs:: stderr_unsafe ( ) , c"%d\n " . as_ptr ( ) , 5 ) } ) ;
117+ ( unsafe { log_fmt_4 ( c"%d\n " . as_ptr ( ) , 6 ) } ) ;
118+ ( unsafe {
119+ libc:: printf (
120+ c"{} %ju %jd\n " . as_ptr ( ) as * const libc:: c_char ,
121+ ( 5_u64 ) ,
122+ ( -6_i32 as i64 ) ,
123+ )
124+ } ) ;
64125 return 0 ;
65126}
66127pub unsafe fn __cpp2rust_init_globals ( ) { }
0 commit comments