File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 4
4
#![ cfg_attr( not( feature = "no-asm" ) , feature( global_asm) ) ]
5
5
#![ feature( cfg_target_has_atomic) ]
6
6
#![ feature( compiler_builtins) ]
7
+ #![ feature( core_ffi_c) ]
7
8
#![ feature( core_intrinsics) ]
8
9
#![ feature( lang_items) ]
9
10
#![ feature( linkage) ]
Original file line number Diff line number Diff line change @@ -68,6 +68,18 @@ intrinsics! {
68
68
pub unsafe extern "C" fn bcmp( s1: * const u8 , s2: * const u8 , n: usize ) -> i32 {
69
69
memcmp( s1, s2, n)
70
70
}
71
+
72
+ #[ mem_builtin]
73
+ #[ cfg_attr( not( all( target_os = "windows" , target_env = "gnu" ) ) , linkage = "weak" ) ]
74
+ pub unsafe extern "C" fn strlen( s: * const core:: ffi:: c_char) -> usize {
75
+ let mut n = 0 ;
76
+ let mut s = s;
77
+ while * s != 0 {
78
+ n += 1 ;
79
+ s = s. offset( 1 ) ;
80
+ }
81
+ n
82
+ }
71
83
}
72
84
73
85
// `bytes` must be a multiple of `mem::size_of::<T>()`
You can’t perform that action at this time.
0 commit comments