Skip to content

Commit

Permalink
android add handful lock free stdio calls
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Jul 5, 2023
1 parent 30a7a9f commit 67ff092
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libc-test/build.rs
Expand Up @@ -1863,6 +1863,10 @@ fn test_android(target: &str) {
// Added in API level 28, but some tests use level 24.
"syncfs" => true,

// Added in API level 28, but some tests use level 24.
"fread_unlocked" | "fwrite_unlocked" | "fgets_unlocked" => true,


_ => false,
}
});
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/android.txt
Expand Up @@ -3087,6 +3087,7 @@ ff_trigger
fgetc
fgetpos
fgets
fgets_unlocked
fgetxattr
fileno
flistxattr
Expand All @@ -3102,6 +3103,7 @@ fprintf
fputc
fputs
fread
fread_unlocked
free
freeaddrinfo
freeifaddrs
Expand Down Expand Up @@ -3130,6 +3132,7 @@ ftruncate
ftruncate64
futimens
fwrite
fwrite_unlocked
gai_strerror
genlmsghdr
getaddrinfo
Expand Down
14 changes: 14 additions & 0 deletions src/unix/linux_like/android/mod.rs
Expand Up @@ -3678,6 +3678,20 @@ extern "C" {
needle: *const ::c_void,
needlelen: ::size_t,
) -> *mut ::c_void;
pub fn fread_unlocked(
buf: *mut ::c_void,
size: ::size_t,
nobj: ::size_t,
stream: *mut ::FILE,
) -> ::size_t;
pub fn fwrite_unlocked(
buf: *const ::c_void,
size: ::size_t,
nobj: ::size_t,
stream: *mut ::FILE,
) -> ::size_t;
pub fn fflush_unlocked(stream: *mut ::FILE) -> ::c_int;
pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char;
}

cfg_if! {
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/linux/mod.rs
Expand Up @@ -4764,7 +4764,7 @@ extern "C" {
newfd: ::c_int,
) -> ::c_int;
pub fn fread_unlocked(
ptr: *mut ::c_void,
buf: *mut ::c_void,
size: ::size_t,
nobj: ::size_t,
stream: *mut ::FILE,
Expand Down

0 comments on commit 67ff092

Please sign in to comment.