File tree Expand file tree Collapse file tree 1 file changed +5
-22
lines changed Expand file tree Collapse file tree 1 file changed +5
-22
lines changed Original file line number Diff line number Diff line change 11// Test what happens we save incremental compilation state that makes
22// use of foreign items. This used to ICE (#34991).
3- //@ ignore-sgx no libc
4-
53//@ revisions: rpass1
64
7- #![ feature( rustc_private) ]
8-
9- extern crate libc;
10-
115use std:: ffi:: CString ;
126
137mod mlibc {
14- use libc:: { c_char, c_long, c_longlong} ;
15-
168 extern "C" {
17- pub fn atol ( x : * const c_char ) -> c_long ;
18- pub fn atoll ( x : * const c_char ) -> c_longlong ;
9+ // strlen is provided either by an external library or compiler-builtins as a fallback
10+ pub fn strlen ( x : * const std :: ffi :: c_char ) -> usize ;
1911 }
2012}
2113
22- fn atol ( s : String ) -> isize {
23- let c = CString :: new ( s) . unwrap ( ) ;
24- unsafe { mlibc:: atol ( c. as_ptr ( ) ) as isize }
25- }
26-
27- fn atoll ( s : String ) -> i64 {
14+ fn strlen ( s : String ) -> usize {
2815 let c = CString :: new ( s) . unwrap ( ) ;
29- unsafe { mlibc:: atoll ( c. as_ptr ( ) ) as i64 }
16+ unsafe { mlibc:: strlen ( c. as_ptr ( ) ) }
3017}
3118
3219pub fn main ( ) {
33- assert_eq ! ( atol( "1024" . to_string( ) ) * 10 , atol( "10240" . to_string( ) ) ) ;
34- assert_eq ! (
35- ( atoll( "11111111111111111" . to_string( ) ) * 10 ) ,
36- atoll( "111111111111111110" . to_string( ) )
37- ) ;
20+ assert_eq ! ( strlen( "1024" . to_string( ) ) , strlen( "2048" . to_string( ) ) ) ;
3821}
You can’t perform that action at this time.
0 commit comments