Skip to content

Commit

Permalink
Auto merge of #2293 - devnexen:system_prop_api_android, r=JohnTitor
Browse files Browse the repository at this point in the history
android system prop api update.
  • Loading branch information
bors committed Aug 20, 2021
2 parents 99f7e2f + 0dc6e30 commit 4fbc1b4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
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

0 comments on commit 4fbc1b4

Please sign in to comment.