Skip to content

Commit 49416c1

Browse files
committed
unix: add preadv2 and pwritev2 to android and linux.
Add preadv2 and pwrite2 to linux and Android, to allow using the new flags introduced in #4452. Add flags to Android too Move definitions from musl and gnu to linux/mod.rs instead of each separate system alone. Skip test on Android due to the definitions being introduced in API 33
1 parent 38c6231 commit 49416c1

5 files changed

Lines changed: 50 additions & 31 deletions

File tree

libc-test/build.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,13 @@ fn test_android(target: &str) {
21712171
"SOF_TIMESTAMPING_OPT_RX_FILTER" => true,
21722172

21732173
// FIXME(android): Requires >= 6.9 kernel headers.
2174-
"AT_HWCAP3" | "AT_HWCAP4" => true,
2174+
"AT_HWCAP3" | "AT_HWCAP4" | "RWF_NOAPPEND" => true,
2175+
2176+
// FIXME(android): Requires >= 6.11 kernel headers.
2177+
"RWF_ATOMIC" => true,
2178+
2179+
// FIXME(android): Requires >= 6.14 kernel headers.
2180+
"RWF_DONTCACHE" => true,
21752181

21762182
_ => false,
21772183
}
@@ -2205,6 +2211,9 @@ fn test_android(target: &str) {
22052211
// Added in API level 30, but tests use level 28.
22062212
"memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" => true,
22072213

2214+
// Added in API level 33, but tests use level 28.
2215+
"preadv2" | "pwritev2" => true,
2216+
22082217
// Added in glibc 2.25.
22092218
"getentropy" => true,
22102219

src/unix/linux_like/android/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,6 +3286,16 @@ pub const AT_MINSIGSTKSZ: c_ulong = 51;
32863286
pub const SI_DETHREAD: c_int = -7;
32873287
pub const TRAP_PERF: c_int = 6;
32883288

3289+
// Flags for preadv2/pwritev2
3290+
pub const RWF_HIPRI: c_int = 0x00000001;
3291+
pub const RWF_DSYNC: c_int = 0x00000002;
3292+
pub const RWF_SYNC: c_int = 0x00000004;
3293+
pub const RWF_NOWAIT: c_int = 0x00000008;
3294+
pub const RWF_APPEND: c_int = 0x00000010;
3295+
pub const RWF_NOAPPEND: c_int = 0x00000020;
3296+
pub const RWF_ATOMIC: c_int = 0x00000040;
3297+
pub const RWF_DONTCACHE: c_int = 0x00000080;
3298+
32893299
// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
32903300
// following are only available on newer Linux versions than the versions
32913301
// currently used in CI in some configurations, so we define them here.
@@ -3757,6 +3767,20 @@ extern "C" {
37573767
newpath: *const c_char,
37583768
flags: c_uint,
37593769
) -> c_int;
3770+
pub fn preadv2(
3771+
fd: c_int,
3772+
iov: *const crate::iovec,
3773+
iovcnt: c_int,
3774+
offset: off_t,
3775+
flags: c_int,
3776+
) -> ssize_t;
3777+
pub fn pwritev2(
3778+
fd: c_int,
3779+
iov: *const crate::iovec,
3780+
iovcnt: c_int,
3781+
offset: off_t,
3782+
flags: c_int,
3783+
) -> ssize_t;
37603784
}
37613785

37623786
cfg_if! {

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,22 +1029,6 @@ extern "C" {
10291029
dirfd: c_int,
10301030
path: *const c_char,
10311031
) -> c_int;
1032-
#[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")]
1033-
pub fn preadv2(
1034-
fd: c_int,
1035-
iov: *const crate::iovec,
1036-
iovcnt: c_int,
1037-
offset: off_t,
1038-
flags: c_int,
1039-
) -> ssize_t;
1040-
#[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")]
1041-
pub fn pwritev2(
1042-
fd: c_int,
1043-
iov: *const crate::iovec,
1044-
iovcnt: c_int,
1045-
offset: off_t,
1046-
flags: c_int,
1047-
) -> ssize_t;
10481032
pub fn preadv64v2(
10491033
fd: c_int,
10501034
iov: *const crate::iovec,

src/unix/linux_like/linux/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4370,6 +4370,22 @@ extern "C" {
43704370
flags: c_int,
43714371
) -> c_int;
43724372
pub fn open_by_handle_at(mount_fd: c_int, handle: *mut file_handle, flags: c_int) -> c_int;
4373+
#[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")]
4374+
pub fn preadv2(
4375+
fd: c_int,
4376+
iov: *const crate::iovec,
4377+
iovcnt: c_int,
4378+
offset: off_t,
4379+
flags: c_int,
4380+
) -> ssize_t;
4381+
#[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")]
4382+
pub fn pwritev2(
4383+
fd: c_int,
4384+
iov: *const crate::iovec,
4385+
iovcnt: c_int,
4386+
offset: off_t,
4387+
flags: c_int,
4388+
) -> ssize_t;
43734389
}
43744390

43754391
// LFS64 extensions

src/unix/linux_like/linux/musl/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -780,20 +780,6 @@ extern "C" {
780780
dirfd: c_int,
781781
path: *const c_char,
782782
) -> c_int;
783-
pub fn preadv2(
784-
fd: c_int,
785-
iov: *const crate::iovec,
786-
iovcnt: c_int,
787-
offset: off_t,
788-
flags: c_int,
789-
) -> ssize_t;
790-
pub fn pwritev2(
791-
fd: c_int,
792-
iov: *const crate::iovec,
793-
iovcnt: c_int,
794-
offset: off_t,
795-
flags: c_int,
796-
) -> ssize_t;
797783
pub fn getauxval(type_: c_ulong) -> c_ulong;
798784
pub fn renameat2(
799785
olddirfd: c_int,

0 commit comments

Comments
 (0)