Skip to content

Commit 4fbc1b4

Browse files
committed
Auto merge of #2293 - devnexen:system_prop_api_android, r=JohnTitor
android system prop api update.
2 parents 99f7e2f + 0dc6e30 commit 4fbc1b4

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,8 @@ fn test_android(target: &str) {
15981598
"termios2" => true,
15991599
// uc_sigmask and uc_sigmask64 of ucontext_t are an anonymous union
16001600
"ucontext_t" => true,
1601+
// 'private' type
1602+
"prop_info" => true,
16011603

16021604
_ => false,
16031605
}
@@ -1647,6 +1649,7 @@ fn test_android(target: &str) {
16471649
// test the XSI version below.
16481650
"strerror_r" => true,
16491651
"reallocarray" => true,
1652+
"__system_property_wait" => true,
16501653

16511654
_ => false,
16521655
}

libc-test/semver/android-aarch64.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ HWCAP2_SVESM4
1010
SYS_arch_specific_syscall
1111
SYS_syscalls
1212
SYS_fcntl
13+
__system_property_wait

libc-test/semver/android.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,8 @@ PRIO_PGRP
16211621
PRIO_PROCESS
16221622
PRIO_USER
16231623
PROC_SUPER_MAGIC
1624+
PROP_NAME_MAX
1625+
PROP_VALUE_MAX
16241626
PROT_EXEC
16251627
PROT_GROWSDOWN
16261628
PROT_GROWSUP
@@ -2562,6 +2564,11 @@ __kernel_pid_t
25622564
__sched_cpualloc
25632565
__sched_cpucount
25642566
__sched_cpufree
2567+
__system_property_find
2568+
__system_property_find_nth
2569+
__system_property_foreach
2570+
__system_property_get
2571+
__system_property_set
25652572
_exit
25662573
abort
25672574
accept
@@ -2939,6 +2946,7 @@ prlimit
29392946
prlimit64
29402947
process_vm_readv
29412948
process_vm_writev
2949+
prop_info
29422950
protoent
29432951
pselect
29442952
pthread_atfork

src/unix/linux_like/android/b64/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@ f! {
331331

332332
extern "C" {
333333
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
334+
pub fn __system_property_wait(
335+
pi: *const ::prop_info,
336+
__old_serial: u32,
337+
__new_serial_ptr: *mut u32,
338+
__relative_timeout: *const ::timespec,
339+
) -> bool;
334340
}
335341

336342
cfg_if! {

src/unix/linux_like/android/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ s_no_extra_traits! {
422422
pub ivlen: u32,
423423
pub iv: [::c_uchar; 0],
424424
}
425+
426+
pub struct prop_info {
427+
__name: [::c_char; 32],
428+
__serial: ::c_uint,
429+
__value: [[::c_char; 4]; 23],
430+
}
425431
}
426432

427433
cfg_if! {
@@ -740,6 +746,24 @@ cfg_if! {
740746
self.as_slice().hash(state);
741747
}
742748
}
749+
750+
impl PartialEq for prop_info {
751+
fn eq(&self, other: &prop_info) -> bool {
752+
self.__name == other.__name &&
753+
self.__serial == other.__serial &&
754+
self.__value == other.__value
755+
}
756+
}
757+
impl Eq for prop_info {}
758+
impl ::fmt::Debug for prop_info {
759+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
760+
f.debug_struct("prop_info")
761+
.field("__name", &self.__name)
762+
.field("__serial", &self.__serial)
763+
.field("__value", &self.__value)
764+
.finish()
765+
}
766+
}
743767
}
744768
}
745769

@@ -2412,6 +2436,7 @@ pub const PF_VSOCK: ::c_int = AF_VSOCK;
24122436

24132437
// sys/system_properties.h
24142438
pub const PROP_VALUE_MAX: ::c_int = 92;
2439+
pub const PROP_NAME_MAX: ::c_int = 32;
24152440

24162441
f! {
24172442
pub fn CMSG_NXTHDR(mhdr: *const msghdr,
@@ -2864,6 +2889,12 @@ extern "C" {
28642889

28652890
pub fn __system_property_set(__name: *const ::c_char, __value: *const ::c_char) -> ::c_int;
28662891
pub fn __system_property_get(__name: *const ::c_char, __value: *mut ::c_char) -> ::c_int;
2892+
pub fn __system_property_find(__name: *const ::c_char) -> *const prop_info;
2893+
pub fn __system_property_find_nth(__n: ::c_uint) -> *const prop_info;
2894+
pub fn __system_property_foreach(
2895+
__callback: unsafe extern "C" fn(__pi: *const prop_info, __cookie: *mut ::c_void),
2896+
__cookie: *mut ::c_void,
2897+
) -> ::c_int;
28672898

28682899
// #include <link.h>
28692900
/// Only available in API Version 21+

0 commit comments

Comments
 (0)