diff options
| author | panicbit <[email protected]> | 2017-07-10 17:20:32 +0200 |
|---|---|---|
| committer | panicbit <[email protected]> | 2017-07-10 17:20:32 +0200 |
| commit | d53dc9ae57466fe98d7a805721026562aa19e690 (patch) | |
| tree | a37e33d1b53406aadd277eaed97eec514c92d244 /ctr-std/src/sys | |
| parent | Merge pull request #1 from FenrirWolf/collections-update (diff) | |
| parent | Merge pull request #32 from FenrirWolf/libc-update (diff) | |
| download | ctru-rs-d53dc9ae57466fe98d7a805721026562aa19e690.tar.xz ctru-rs-d53dc9ae57466fe98d7a805721026562aa19e690.zip | |
Merge branch 'master' into nightly_update
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) } |