Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android system prop api update. #2293

Merged
merged 1 commit into from Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions libc-test/build.rs
Expand Up @@ -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,
}
Expand Down Expand Up @@ -1647,6 +1649,7 @@ fn test_android(target: &str) {
// test the XSI version below.
"strerror_r" => true,
"reallocarray" => true,
"__system_property_wait" => true,

_ => false,
}
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/android-aarch64.txt
Expand Up @@ -10,3 +10,4 @@ HWCAP2_SVESM4
SYS_arch_specific_syscall
SYS_syscalls
SYS_fcntl
__system_property_wait
8 changes: 8 additions & 0 deletions libc-test/semver/android.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2939,6 +2946,7 @@ prlimit
prlimit64
process_vm_readv
process_vm_writev
prop_info
protoent
pselect
pthread_atfork
Expand Down
6 changes: 6 additions & 0 deletions src/unix/linux_like/android/b64/mod.rs
Expand Up @@ -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! {
Expand Down
31 changes: 31 additions & 0 deletions src/unix/linux_like/android/mod.rs
Expand Up @@ -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! {
Expand Down Expand Up @@ -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()
}
}
}
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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+
Expand Down