diff options
| author | Ronald Kinard <[email protected]> | 2017-07-10 10:03:38 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-07-10 10:03:38 -0500 |
| commit | 9ecf14ee0814a5fb7fe24b2222347b72c9c81189 (patch) | |
| tree | b13939b2c16939c4aa1f827f1aeb736efeb4e60a /ctr-std/src/sys | |
| parent | Merge pull request #30 from kentaromiura/compile_again (diff) | |
| parent | Update README (diff) | |
| download | ctru-rs-9ecf14ee0814a5fb7fe24b2222347b72c9c81189.tar.xz ctru-rs-9ecf14ee0814a5fb7fe24b2222347b72c9c81189.zip | |
Merge pull request #32 from FenrirWolf/libc-update
Remove `ctr-libc`, use upstream `libc` from crates.io
Diffstat (limited to 'ctr-std/src/sys')
| -rw-r--r-- | ctr-std/src/sys/unix/memchr.rs | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/ctr-std/src/sys/unix/memchr.rs b/ctr-std/src/sys/unix/memchr.rs index d7e9c2b..ae8e3d0 100644 --- a/ctr-std/src/sys/unix/memchr.rs +++ b/ctr-std/src/sys/unix/memchr.rs @@ -28,24 +28,11 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> { } pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> { - - #[cfg(target_os = "linux")] + // turns out that newlib doesn't have memrchr(), so we + // use the fallback version instead fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> { - use libc; - - // GNU's memrchr() will - unlike memchr() - error if haystack is empty. - if haystack.is_empty() {return None} - let p = unsafe { - libc::memrchr( - haystack.as_ptr() as *const libc::c_void, - needle as libc::c_int, - haystack.len()) - }; - if p.is_null() { - None - } else { - Some(p as usize - (haystack.as_ptr() as usize)) - } + ::sys_common::memchr::fallback::memrchr(needle, haystack) } + memrchr_specific(needle, haystack) } |