diff --git a/libc-test/build.rs b/libc-test/build.rs index 9cb4e41e503db..0837ac48fde7b 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1598,6 +1598,8 @@ fn test_android(target: &str) { "termios2" => true, // uc_sigmask and uc_sigmask64 of ucontext_t are an anonymous union "ucontext_t" => true, + // 'private' type + "prop_info" => true, _ => false, } @@ -1647,6 +1649,7 @@ fn test_android(target: &str) { // test the XSI version below. "strerror_r" => true, "reallocarray" => true, + "__system_property_wait" => true, _ => false, } diff --git a/libc-test/semver/android-aarch64.txt b/libc-test/semver/android-aarch64.txt index 757a953c94f57..4e706c9db21e1 100644 --- a/libc-test/semver/android-aarch64.txt +++ b/libc-test/semver/android-aarch64.txt @@ -10,3 +10,4 @@ HWCAP2_SVESM4 SYS_arch_specific_syscall SYS_syscalls SYS_fcntl +__system_property_wait diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 0f291179cfcae..94d7bd7882622 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -1621,6 +1621,8 @@ PRIO_PGRP PRIO_PROCESS PRIO_USER PROC_SUPER_MAGIC +PROP_NAME_MAX +PROP_VALUE_MAX PROT_EXEC PROT_GROWSDOWN PROT_GROWSUP @@ -2562,6 +2564,11 @@ __kernel_pid_t __sched_cpualloc __sched_cpucount __sched_cpufree +__system_property_find +__system_property_find_nth +__system_property_foreach +__system_property_get +__system_property_set _exit abort accept @@ -2939,6 +2946,7 @@ prlimit prlimit64 process_vm_readv process_vm_writev +prop_info protoent pselect pthread_atfork diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 0278c35782d9f..0995c5412ae5f 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -331,6 +331,12 @@ f! { extern "C" { pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; + pub fn __system_property_wait( + pi: *const ::prop_info, + __old_serial: u32, + __new_serial_ptr: *mut u32, + __relative_timeout: *const ::timespec, + ) -> bool; } cfg_if! { diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index aae6719cc0a4d..a06f3b3f78fd6 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -422,6 +422,12 @@ s_no_extra_traits! { pub ivlen: u32, pub iv: [::c_uchar; 0], } + + pub struct prop_info { + __name: [::c_char; 32usize], + __serial: ::c_uint, + __value: [::c_char; 92usize], + } } cfg_if! { @@ -740,6 +746,24 @@ cfg_if! { self.as_slice().hash(state); } } + + impl PartialEq for prop_info { + fn eq(&self, other: &prop_info) -> bool { + self.__name == other.__name && + self.__serial == other.__serial && + self.__value == other.__value + } + } + impl Eq for prop_info {} + impl ::fmt::Debug for prop_info { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("prop_info") + .field("__name", &self.__name) + .field("__serial", &self.__serial) + .field("__value", &self.__value) + .finish() + } + } } } @@ -2412,6 +2436,7 @@ pub const PF_VSOCK: ::c_int = AF_VSOCK; // sys/system_properties.h pub const PROP_VALUE_MAX: ::c_int = 92; +pub const PROP_NAME_MAX: ::c_int = 32; f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, @@ -2864,6 +2889,12 @@ extern "C" { pub fn __system_property_set(__name: *const ::c_char, __value: *const ::c_char) -> ::c_int; pub fn __system_property_get(__name: *const ::c_char, __value: *mut ::c_char) -> ::c_int; + pub fn __system_property_find(__name: *const ::c_char) -> *const prop_info; + pub fn __system_property_find_nth(__n: ::c_uint) -> *const prop_info; + pub fn __system_property_foreach( + __callback: unsafe extern "C" fn(__pi: *const prop_info, __cookie: *mut ::c_void), + __cookie: *mut ::c_void, + ) -> ::c_int; // #include /// Only available in API Version 21+