aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/sys
diff options
context:
space:
mode:
authorFenrir <[email protected]>2017-07-07 11:39:39 -0600
committerFenrir <[email protected]>2017-07-07 12:38:43 -0600
commiteec80b496b8de2ee332b4ae04fbe00c7c93525b3 (patch)
treef809316596ccf906c46c420c72fadbc568db871f /ctr-std/src/sys
parentMerge pull request #30 from kentaromiura/compile_again (diff)
downloadctru-rs-eec80b496b8de2ee332b4ae04fbe00c7c93525b3.tar.xz
ctru-rs-eec80b496b8de2ee332b4ae04fbe00c7c93525b3.zip
Use libc from crates.io
The libc crate has newlib bindings now, so we don't have to maintain them in-tree anymore
Diffstat (limited to 'ctr-std/src/sys')
-rw-r--r--ctr-std/src/sys/unix/memchr.rs21
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)
}