summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-20 15:22:10 +0000
committerbors <bors@rust-lang.org>2021-08-20 15:22:10 +0000
commit4fbc1b47d1887fe786bef74dfaf60a4db318aa80 (patch)
tree58acee1c3839e07a96b53be06eefe8f0de615c1e
parent99f7e2f5a5905f1bc0d66dd6bcfcb3deba085a64 (diff)
parent0dc6e309e0a06033b64facab63ebafc615c43e56 (diff)
downloadrust-libc-4fbc1b47d1887fe786bef74dfaf60a4db318aa80.tar.gz
Auto merge of #2293 - devnexen:system_prop_api_android, r=JohnTitor
android system prop api update.
-rw-r--r--libc-test/build.rs3
-rw-r--r--libc-test/semver/android-aarch64.txt1
-rw-r--r--libc-test/semver/android.txt8
-rw-r--r--src/unix/linux_like/android/b64/mod.rs6
-rw-r--r--src/unix/linux_like/android/mod.rs31
5 files changed, 49 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index d8fc16c940..e491cb39d1 100644
--- 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 757a953c94..4e706c9db2 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 0f291179cf..94d7bd7882 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 0278c35782..0995c5412a 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 aae6719cc0..04801fd5ea 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; 32],
+ __serial: ::c_uint,
+ __value: [[::c_char; 4]; 23],
+ }
}
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 <link.h>
/// Only available in API Version 21+