Don't use LFS64 symbols on musl

Simplify #[cfg] blocks

fmt

don't try to use the more appropriate direntry on musl
This commit is contained in:
git-bruh 2023-09-19 19:47:50 +05:30 committed by git-bruh
parent 2cad938a81
commit 7a504cc68a
3 changed files with 42 additions and 14 deletions

View File

@ -329,7 +329,14 @@ pub trait MetadataExt {
impl MetadataExt for Metadata { impl MetadataExt for Metadata {
#[allow(deprecated)] #[allow(deprecated)]
fn as_raw_stat(&self) -> &raw::stat { fn as_raw_stat(&self) -> &raw::stat {
unsafe { &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat) } #[cfg(target_env = "musl")]
unsafe {
&*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat)
}
#[cfg(not(target_env = "musl"))]
unsafe {
&*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat)
}
} }
fn st_dev(&self) -> u64 { fn st_dev(&self) -> u64 {
self.as_inner().as_inner().st_dev as u64 self.as_inner().as_inner().st_dev as u64

View File

@ -126,9 +126,17 @@ pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> {
} }
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> { pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))] #[cfg(not(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
)))]
use libc::pread as pread64; use libc::pread as pread64;
#[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))] #[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
))]
use libc::pread64; use libc::pread64;
unsafe { unsafe {
@ -285,9 +293,17 @@ pub fn is_write_vectored(&self) -> bool {
} }
pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> { pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))] #[cfg(not(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
)))]
use libc::pwrite as pwrite64; use libc::pwrite as pwrite64;
#[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))] #[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
))]
use libc::pwrite64; use libc::pwrite64;
unsafe { unsafe {

View File

@ -40,13 +40,17 @@
))] ))]
use libc::c_char; use libc::c_char;
#[cfg(any( #[cfg(any(
target_os = "linux", all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten", target_os = "emscripten",
target_os = "android", target_os = "android",
target_os = "hurd", target_os = "hurd"
))] ))]
use libc::dirfd; use libc::dirfd;
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd"))] #[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten",
target_os = "hurd"
))]
use libc::fstatat64; use libc::fstatat64;
#[cfg(any( #[cfg(any(
target_os = "android", target_os = "android",
@ -57,9 +61,10 @@
target_os = "aix", target_os = "aix",
target_os = "nto", target_os = "nto",
target_os = "vita", target_os = "vita",
all(target_os = "linux", target_env = "musl"),
))] ))]
use libc::readdir as readdir64; use libc::readdir as readdir64;
#[cfg(any(target_os = "linux", target_os = "hurd"))] #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
use libc::readdir64; use libc::readdir64;
#[cfg(any(target_os = "emscripten", target_os = "l4re"))] #[cfg(any(target_os = "emscripten", target_os = "l4re"))]
use libc::readdir64_r; use libc::readdir64_r;
@ -84,7 +89,7 @@
lstat as lstat64, off64_t, open as open64, stat as stat64, lstat as lstat64, off64_t, open as open64, stat as stat64,
}; };
#[cfg(not(any( #[cfg(not(any(
target_os = "linux", all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten", target_os = "emscripten",
target_os = "l4re", target_os = "l4re",
target_os = "android", target_os = "android",
@ -95,7 +100,7 @@
lstat as lstat64, off_t as off64_t, open as open64, stat as stat64, lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
}; };
#[cfg(any( #[cfg(any(
target_os = "linux", all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten", target_os = "emscripten",
target_os = "l4re", target_os = "l4re",
target_os = "hurd" target_os = "hurd"
@ -853,10 +858,10 @@ pub fn file_name(&self) -> OsString {
#[cfg(all( #[cfg(all(
any( any(
target_os = "linux", all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten", target_os = "emscripten",
target_os = "android", target_os = "android",
target_os = "hurd", target_os = "hurd"
), ),
not(miri) not(miri)
))] ))]
@ -882,7 +887,7 @@ pub fn metadata(&self) -> io::Result<FileAttr> {
#[cfg(any( #[cfg(any(
not(any( not(any(
target_os = "linux", all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten", target_os = "emscripten",
target_os = "android", target_os = "android",
target_os = "hurd", target_os = "hurd",