Skip to content

Commit 724aedc

Browse files
committed
[WIP] fix on android/aarch64 and guard the structs
the statx struct is in a separate file because the style check doesn't allow multiple s! macros in one file, and #[cfg()] doesn't work in s!. Plain u64 (or uint64_t in C) can't be used for the statx fields because bionic defines them as __u64, and provides incompatible definitions of uint64_t and __u64.
1 parent d56ca22 commit 724aedc

File tree

3 files changed

+48
-44
lines changed

3 files changed

+48
-44
lines changed

src/unix/linux_like/android/b64/aarch64/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub type c_char = u8;
22
pub type wchar_t = u32;
3-
pub type __u64 = ::c_ulonglong;
4-
pub type __s64 = ::c_longlong;
3+
pub type __u64 = ::c_ulong;
4+
pub type __s64 = ::c_long;
55

66
s! {
77
pub struct stat {

src/unix/linux_like/linux_statx.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
s! {
2+
pub struct statx {
3+
pub stx_mask: ::__u32,
4+
pub stx_blksize: ::__u32,
5+
pub stx_attributes: ::__u64,
6+
pub stx_nlink: ::__u32,
7+
pub stx_uid: ::__u32,
8+
pub stx_gid: ::__u32,
9+
pub stx_mode: ::__u16,
10+
__statx_pad1: [::__u16; 1],
11+
pub stx_ino: ::__u64,
12+
pub stx_size: ::__u64,
13+
pub stx_blocks: ::__u64,
14+
pub stx_attributes_mask: ::__u64,
15+
pub stx_atime: statx_timestamp,
16+
pub stx_btime: statx_timestamp,
17+
pub stx_ctime: statx_timestamp,
18+
pub stx_mtime: statx_timestamp,
19+
pub stx_rdev_major: ::__u32,
20+
pub stx_rdev_minor: ::__u32,
21+
pub stx_dev_major: ::__u32,
22+
pub stx_dev_minor: ::__u32,
23+
pub stx_mnt_id: ::__u64,
24+
pub stx_dio_mem_align: ::__u32,
25+
pub stx_dio_offset_align: ::__u32,
26+
__statx_pad3: [::__u64; 12],
27+
}
28+
29+
pub struct statx_timestamp {
30+
pub tv_sec: ::__s64,
31+
pub tv_nsec: ::__u32,
32+
__statx_timestamp_pad1: [::__s32; 1],
33+
}
34+
}
35+
36+
extern "C" {
37+
pub fn statx(
38+
dirfd: ::c_int,
39+
pathname: *const ::c_char,
40+
flags: ::c_int,
41+
mask: ::c_uint,
42+
statxbuf: *mut statx,
43+
) -> ::c_int;
44+
}

src/unix/linux_like/mod.rs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -204,39 +204,6 @@ s! {
204204
pub msg_hdr: ::msghdr,
205205
pub msg_len: ::c_uint,
206206
}
207-
208-
pub struct statx {
209-
pub stx_mask: u32,
210-
pub stx_blksize: u32,
211-
pub stx_attributes: u64,
212-
pub stx_nlink: u32,
213-
pub stx_uid: u32,
214-
pub stx_gid: u32,
215-
pub stx_mode: u16,
216-
__statx_pad1: [u16; 1],
217-
pub stx_ino: u64,
218-
pub stx_size: u64,
219-
pub stx_blocks: u64,
220-
pub stx_attributes_mask: u64,
221-
pub stx_atime: statx_timestamp,
222-
pub stx_btime: statx_timestamp,
223-
pub stx_ctime: statx_timestamp,
224-
pub stx_mtime: statx_timestamp,
225-
pub stx_rdev_major: u32,
226-
pub stx_rdev_minor: u32,
227-
pub stx_dev_major: u32,
228-
pub stx_dev_minor: u32,
229-
pub stx_mnt_id: u64,
230-
pub stx_dio_mem_align: u32,
231-
pub stx_dio_offset_align: u32,
232-
__statx_pad3: [u64; 12],
233-
}
234-
235-
pub struct statx_timestamp {
236-
pub tv_sec: i64,
237-
pub tv_nsec: u32,
238-
__statx_timestamp_pad1: [i32; 1],
239-
}
240207
}
241208

242209
s_no_extra_traits! {
@@ -1922,15 +1889,8 @@ cfg_if! {
19221889
// The statx syscall, available on some libcs.
19231890
cfg_if! {
19241891
if #[cfg(any(target_env = "gnu", target_os = "android"))] {
1925-
extern "C" {
1926-
pub fn statx(
1927-
dirfd: ::c_int,
1928-
pathname: *const c_char,
1929-
flags: ::c_int,
1930-
mask: ::c_uint,
1931-
statxbuf: *mut statx,
1932-
) -> ::c_int;
1933-
}
1892+
mod linux_statx;
1893+
pub use self::linux_statx::*;
19341894
}
19351895
}
19361896

0 commit comments

Comments
 (0)