File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-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 @@ -8,6 +8,7 @@ type c_int = i16;
8
8
#[ cfg( not( target_pointer_width = "16" ) ) ]
9
9
type c_int = i32 ;
10
10
11
+ use core:: ffi:: c_char;
11
12
use core:: intrinsics:: { atomic_load_unordered, atomic_store_unordered, exact_div} ;
12
13
use core:: mem;
13
14
use core:: ops:: { BitOr , Shl } ;
@@ -68,6 +69,18 @@ intrinsics! {
68
69
pub unsafe extern "C" fn bcmp( s1: * const u8 , s2: * const u8 , n: usize ) -> i32 {
69
70
memcmp( s1, s2, n)
70
71
}
72
+
73
+ #[ mem_builtin]
74
+ #[ cfg_attr( not( all( target_os = "windows" , target_env = "gnu" ) ) , linkage = "weak" ) ]
75
+ pub unsafe extern "C" fn strlen( s: * const c_char) -> usize {
76
+ let mut n = 0 ;
77
+ let mut s = s;
78
+ while * s != 0 {
79
+ n += 1 ;
80
+ s = s. offset( 1 ) ;
81
+ }
82
+ n
83
+ }
71
84
}
72
85
73
86
// `bytes` must be a multiple of `mem::size_of::<T>()`
You can’t perform that action at this time.
0 commit comments