File tree 1 file changed +5
-22
lines changed
1 file changed +5
-22
lines changed Original file line number Diff line number Diff line change 1
1
// Test what happens we save incremental compilation state that makes
2
2
// use of foreign items. This used to ICE (#34991).
3
- //@ ignore-sgx no libc
4
-
5
3
//@ revisions: rpass1
6
4
7
- #![ feature( rustc_private) ]
8
-
9
- extern crate libc;
10
-
11
5
use std:: ffi:: CString ;
12
6
13
7
mod mlibc {
14
- use libc:: { c_char, c_long, c_longlong} ;
15
-
16
8
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 ;
19
11
}
20
12
}
21
13
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 {
28
15
let c = CString :: new ( s) . unwrap ( ) ;
29
- unsafe { mlibc:: atoll ( c. as_ptr ( ) ) as i64 }
16
+ unsafe { mlibc:: strlen ( c. as_ptr ( ) ) }
30
17
}
31
18
32
19
pub 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( ) ) ) ;
38
21
}
You can’t perform that action at this time.
0 commit comments