Skip to content

Commit

Permalink
Auto merge of #2758 - fkm3:master, r=JohnTitor
Browse files Browse the repository at this point in the history
Add misc constants and functions for android

These are the main diffs present in the downstream android opensource
project repo.
  • Loading branch information
bors committed Dec 21, 2022
2 parents 318dccc + 572e11b commit 45b431a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,9 @@ fn test_android(target: &str) {
// Added in glibc 2.25.
"getentropy" => true,

// Added in API level 28, but some tests use level 24.
"getrandom" => true,

_ => false,
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/android/b32/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ pub const SYS_pwritev2: ::c_long = 393;
pub const SYS_pkey_mprotect: ::c_long = 394;
pub const SYS_pkey_alloc: ::c_long = 395;
pub const SYS_pkey_free: ::c_long = 396;
pub const SYS_io_uring_setup: ::c_long = 425;
pub const SYS_io_uring_enter: ::c_long = 426;
pub const SYS_io_uring_register: ::c_long = 427;

// offsets in mcontext_t.gregs from sys/ucontext.h
pub const REG_R0: ::c_int = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/android/b32/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ pub const SYS_pwritev2: ::c_long = 379;
pub const SYS_pkey_mprotect: ::c_long = 380;
pub const SYS_pkey_alloc: ::c_long = 381;
pub const SYS_pkey_free: ::c_long = 382;
pub const SYS_io_uring_setup: ::c_long = 425;
pub const SYS_io_uring_enter: ::c_long = 426;
pub const SYS_io_uring_register: ::c_long = 427;

// offsets in user_regs_structs, from sys/reg.h
pub const EBX: ::c_int = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/android/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ pub const SYS_pwritev2: ::c_long = 287;
pub const SYS_pkey_mprotect: ::c_long = 288;
pub const SYS_pkey_alloc: ::c_long = 289;
pub const SYS_pkey_free: ::c_long = 290;
pub const SYS_io_uring_setup: ::c_long = 425;
pub const SYS_io_uring_enter: ::c_long = 426;
pub const SYS_io_uring_register: ::c_long = 427;
pub const SYS_syscalls: ::c_long = 436;

cfg_if! {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/android/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ pub const SYS_pwritev2: ::c_long = 328;
pub const SYS_pkey_mprotect: ::c_long = 329;
pub const SYS_pkey_alloc: ::c_long = 330;
pub const SYS_pkey_free: ::c_long = 331;
pub const SYS_io_uring_setup: ::c_long = 425;
pub const SYS_io_uring_enter: ::c_long = 426;
pub const SYS_io_uring_register: ::c_long = 427;

// offsets in user_regs_structs, from sys/reg.h
pub const R15: ::c_int = 0;
Expand Down
21 changes: 21 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2421,9 +2421,20 @@ pub const SND_CNT: usize = SND_MAX as usize + 1;
pub const UINPUT_VERSION: ::c_uint = 5;
pub const UINPUT_MAX_NAME_SIZE: usize = 80;

// bionic/libc/kernel/uapi/linux/if_tun.h
pub const IFF_TUN: ::c_int = 0x0001;
pub const IFF_TAP: ::c_int = 0x0002;
pub const IFF_NAPI: ::c_int = 0x0010;
pub const IFF_NAPI_FRAGS: ::c_int = 0x0020;
pub const IFF_NO_PI: ::c_int = 0x1000;
pub const IFF_ONE_QUEUE: ::c_int = 0x2000;
pub const IFF_VNET_HDR: ::c_int = 0x4000;
pub const IFF_TUN_EXCL: ::c_int = 0x8000;
pub const IFF_MULTI_QUEUE: ::c_int = 0x0100;
pub const IFF_ATTACH_QUEUE: ::c_int = 0x0200;
pub const IFF_DETACH_QUEUE: ::c_int = 0x0400;
pub const IFF_PERSIST: ::c_int = 0x0800;
pub const IFF_NOFILTER: ::c_int = 0x1000;

// start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h
// from https://android.googlesource.com/
Expand Down Expand Up @@ -2739,6 +2750,12 @@ pub const PF_VSOCK: ::c_int = AF_VSOCK;

pub const SOMAXCONN: ::c_int = 128;

// sys/prctl.h
pub const PR_SET_PDEATHSIG: ::c_int = 1;
pub const PR_GET_PDEATHSIG: ::c_int = 2;
pub const PR_GET_SECUREBITS: ::c_int = 27;
pub const PR_SET_SECUREBITS: ::c_int = 28;

// sys/system_properties.h
pub const PROP_VALUE_MAX: ::c_int = 92;
pub const PROP_NAME_MAX: ::c_int = 32;
Expand Down Expand Up @@ -3446,6 +3463,10 @@ extern "C" {

pub fn gettid() -> ::pid_t;

pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;

pub fn pthread_setname_np(thread: ::pthread_t, name: *const ::c_char) -> ::c_int;

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;
Expand Down

0 comments on commit 45b431a

Please sign in to comment.