Skip to content

Commit 132fe5b

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 e3c4971 commit 132fe5b

6 files changed

Lines changed: 62 additions & 31 deletions

File tree

libc-test/build.rs

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

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

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

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

libc-test/semver/android.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,14 @@ RT_TABLE_MAIN
23642364
RT_TABLE_UNSPEC
23652365
RUSAGE_CHILDREN
23662366
RUSAGE_SELF
2367+
RWF_APPEND
2368+
RWF_ATOMIC
2369+
RWF_DONTCACHE
2370+
RWF_DSYNC
2371+
RWF_HIPRI
2372+
RWF_NOAPPEND
2373+
RWF_NOWAIT
2374+
RWF_SYNC
23672375
R_OK
23682376
SA_NOCLDSTOP
23692377
SA_NOCLDWAIT
@@ -3765,6 +3773,7 @@ prctl
37653773
pread
37663774
pread64
37673775
preadv
3776+
preadv2
37683777
preadv64
37693778
printf
37703779
prlimit
@@ -3868,6 +3877,7 @@ puts
38683877
pwrite
38693878
pwrite64
38703879
pwritev
3880+
pwritev2
38713881
pwritev64
38723882
qsort
38733883
raise

src/unix/linux_like/android/mod.rs

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

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

37633787
cfg_if! {

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,22 +1017,6 @@ extern "C" {
10171017
dirfd: c_int,
10181018
path: *const c_char,
10191019
) -> c_int;
1020-
#[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")]
1021-
pub fn preadv2(
1022-
fd: c_int,
1023-
iov: *const crate::iovec,
1024-
iovcnt: c_int,
1025-
offset: off_t,
1026-
flags: c_int,
1027-
) -> ssize_t;
1028-
#[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")]
1029-
pub fn pwritev2(
1030-
fd: c_int,
1031-
iov: *const crate::iovec,
1032-
iovcnt: c_int,
1033-
offset: off_t,
1034-
flags: c_int,
1035-
) -> ssize_t;
10361020
pub fn preadv64v2(
10371021
fd: c_int,
10381022
iov: *const crate::iovec,

src/unix/linux_like/linux/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,6 +4070,24 @@ extern "C" {
40704070
flags: c_int,
40714071
) -> c_int;
40724072
pub fn open_by_handle_at(mount_fd: c_int, handle: *mut file_handle, flags: c_int) -> c_int;
4073+
#[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")]
4074+
#[cfg(not(target_env = "uclibc"))]
4075+
pub fn preadv2(
4076+
fd: c_int,
4077+
iov: *const crate::iovec,
4078+
iovcnt: c_int,
4079+
offset: off_t,
4080+
flags: c_int,
4081+
) -> ssize_t;
4082+
#[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")]
4083+
#[cfg(not(target_env = "uclibc"))]
4084+
pub fn pwritev2(
4085+
fd: c_int,
4086+
iov: *const crate::iovec,
4087+
iovcnt: c_int,
4088+
offset: off_t,
4089+
flags: c_int,
4090+
) -> ssize_t;
40734091
}
40744092

40754093
// LFS64 extensions

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

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

0 commit comments

Comments
 (0)