Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/new/bionic_libc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
//!
//! <https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/include/>

pub(crate) mod pthread;
pub(crate) mod sys;
pub(crate) mod unistd;
31 changes: 31 additions & 0 deletions src/new/bionic_libc/pthread.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//! Header: `unistd.h`

pub use crate::new::common::linux_like::pthread::pthread_setname_np;
pub use crate::new::common::posix::pthread::{
pthread_atfork,
pthread_attr_getguardsize,
pthread_attr_getinheritsched,
pthread_attr_setguardsize,
pthread_attr_setinheritsched,
pthread_barrier_destroy,
pthread_barrier_init,
pthread_barrier_wait,
pthread_barrierattr_destroy,
pthread_barrierattr_getpshared,
pthread_barrierattr_init,
pthread_barrierattr_setpshared,
pthread_condattr_getpshared,
pthread_create,
pthread_getcpuclockid,
pthread_getschedparam,
pthread_kill,
pthread_mutex_timedlock,
pthread_mutexattr_getpshared,
pthread_setschedparam,
pthread_sigmask,
pthread_spin_destroy,
pthread_spin_init,
pthread_spin_lock,
pthread_spin_trylock,
pthread_spin_unlock,
};
2 changes: 1 addition & 1 deletion src/new/common/linux_like/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! API that primarily comes from Linux but is also used other platforms (e.g. Android).

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub(crate) mod pthread;
2 changes: 1 addition & 1 deletion src/new/common/linux_like/pthread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ extern "C" {
cpuset: *const crate::cpu_set_t,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int;
}
2 changes: 1 addition & 1 deletion src/new/common/posix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
//! These can be found at: <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/contents.html>.

// FIXME(pthread): eventually all platforms should use this module
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))]
pub(crate) mod pthread;
pub(crate) mod unistd;
52 changes: 26 additions & 26 deletions src/new/common/posix/pthread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
use crate::prelude::*;

extern "C" {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_atfork(
prepare: Option<unsafe extern "C" fn()>,
parent: Option<unsafe extern "C" fn()>,
child: Option<unsafe extern "C" fn()>,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_attr_getguardsize(
attr: *const crate::pthread_attr_t,
guardsize: *mut size_t,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_attr_getinheritsched(
attr: *const crate::pthread_attr_t,
inheritsched: *mut c_int,
Expand All @@ -36,10 +36,10 @@ extern "C" {
policy: *mut c_int,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_attr_setinheritsched(
attr: *mut crate::pthread_attr_t,
inheritsched: c_int,
Expand All @@ -54,32 +54,32 @@ extern "C" {
#[cfg(target_os = "linux")]
pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_barrier_destroy(barrier: *mut crate::pthread_barrier_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_barrier_init(
barrier: *mut crate::pthread_barrier_t,
attr: *const crate::pthread_barrierattr_t,
count: c_uint,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_barrier_wait(barrier: *mut crate::pthread_barrier_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_barrierattr_getpshared(
attr: *const crate::pthread_barrierattr_t,
shared: *mut c_int,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_barrierattr_setpshared(
attr: *mut crate::pthread_barrierattr_t,
shared: c_int,
Expand All @@ -88,24 +88,24 @@ extern "C" {
#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
pub fn pthread_cancel(thread: crate::pthread_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_condattr_getpshared(
attr: *const crate::pthread_condattr_t,
pshared: *mut c_int,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))]
pub fn pthread_create(
native: *mut crate::pthread_t,
attr: *const crate::pthread_attr_t,
f: extern "C" fn(*mut c_void) -> *mut c_void,
value: *mut c_void,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_getschedparam(
native: crate::pthread_t,
policy: *mut c_int,
Expand All @@ -114,13 +114,13 @@ extern "C" {

// FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required
// in pthread.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int;

#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")]
pub fn pthread_mutex_timedlock(
lock: *mut crate::pthread_mutex_t,
Expand All @@ -133,7 +133,7 @@ extern "C" {
protocol: *mut c_int,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_mutexattr_getpshared(
attr: *const crate::pthread_mutexattr_t,
pshared: *mut c_int,
Expand All @@ -160,7 +160,7 @@ extern "C" {
#[cfg(target_os = "linux")]
pub fn pthread_once(control: *mut crate::pthread_once_t, routine: extern "C" fn()) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_setschedparam(
native: crate::pthread_t,
policy: c_int,
Expand All @@ -172,25 +172,25 @@ extern "C" {

// FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required
// in pthread.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_sigmask(
how: c_int,
set: *const crate::sigset_t,
oldset: *mut crate::sigset_t,
) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int;
}
1 change: 1 addition & 0 deletions src/new/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
//!
//! * Headers: <https://github.com/emscripten-core/emscripten/tree/main/system/lib/libc>

pub(crate) mod pthread;
pub(crate) mod unistd;
3 changes: 3 additions & 0 deletions src/new/emscripten/pthread.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Header: `pthread.h`

pub use crate::new::common::posix::pthread::pthread_create;
2 changes: 1 addition & 1 deletion src/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ cfg_if! {
cfg_if! {
if #[cfg(target_family = "unix")] {
// FIXME(pthread): eventually all platforms should use this module
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))]
pub use pthread::*;
pub use unistd::*;
}
Expand Down
73 changes: 2 additions & 71 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3508,11 +3508,6 @@ extern "C" {
timeout: c_int,
) -> c_int;
pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int;
pub fn pthread_getschedparam(
native: crate::pthread_t,
policy: *mut c_int,
param: *mut crate::sched_param,
) -> c_int;
pub fn unshare(flags: c_int) -> c_int;
pub fn umount(target: *const c_char) -> c_int;
pub fn sched_get_priority_max(policy: c_int) -> c_int;
Expand Down Expand Up @@ -3553,32 +3548,7 @@ extern "C" {
timeout: *const crate::timespec,
sigmask: *const sigset_t,
) -> c_int;
pub fn pthread_mutex_timedlock(
lock: *mut pthread_mutex_t,
abstime: *const crate::timespec,
) -> c_int;
pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int;
pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int;
pub fn pthread_barrierattr_getpshared(
attr: *const crate::pthread_barrierattr_t,
shared: *mut c_int,
) -> c_int;
pub fn pthread_barrierattr_setpshared(
attr: *mut crate::pthread_barrierattr_t,
shared: c_int,
) -> c_int;
pub fn pthread_barrier_init(
barrier: *mut pthread_barrier_t,
attr: *const crate::pthread_barrierattr_t,
count: c_uint,
) -> c_int;
pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int;
pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int;
pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int;
pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int;
pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int;
pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int;
pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int;

pub fn clone(
cb: extern "C" fn(*mut c_void) -> c_int,
child_stack: *mut c_void,
Expand All @@ -3593,29 +3563,11 @@ extern "C" {
rqtp: *const crate::timespec,
rmtp: *mut crate::timespec,
) -> c_int;
pub fn pthread_attr_getguardsize(
attr: *const crate::pthread_attr_t,
guardsize: *mut size_t,
) -> c_int;
pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;
pub fn pthread_attr_getinheritsched(
attr: *const crate::pthread_attr_t,
flag: *mut c_int,
) -> c_int;
pub fn pthread_attr_setinheritsched(attr: *mut crate::pthread_attr_t, flag: c_int) -> c_int;

pub fn sethostname(name: *const c_char, len: size_t) -> c_int;
pub fn sched_get_priority_min(policy: c_int) -> c_int;
pub fn pthread_condattr_getpshared(
attr: *const pthread_condattr_t,
pshared: *mut c_int,
) -> c_int;
pub fn sysinfo(info: *mut crate::sysinfo) -> c_int;
pub fn umount2(target: *const c_char, flags: c_int) -> c_int;
pub fn pthread_setschedparam(
native: crate::pthread_t,
policy: c_int,
param: *const crate::sched_param,
) -> c_int;
pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int;
pub fn sched_setscheduler(
pid: crate::pid_t,
Expand Down Expand Up @@ -3643,10 +3595,8 @@ extern "C" {
buflen: size_t,
result: *mut *mut crate::group,
) -> c_int;
pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int;
pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t;
pub fn getgrnam(name: *const c_char) -> *mut crate::group;
pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int;
pub fn sem_unlink(name: *const c_char) -> c_int;
pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int;
pub fn getpwnam_r(
Expand All @@ -3669,11 +3619,6 @@ extern "C" {
timeout: *const crate::timespec,
) -> c_int;
pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int;
pub fn pthread_atfork(
prepare: Option<unsafe extern "C" fn()>,
parent: Option<unsafe extern "C" fn()>,
child: Option<unsafe extern "C" fn()>,
) -> c_int;
pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group;
pub fn getgrouplist(
user: *const c_char,
Expand All @@ -3682,18 +3627,8 @@ extern "C" {
ngroups: *mut c_int,
) -> c_int;
pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int;
pub fn pthread_mutexattr_getpshared(
attr: *const pthread_mutexattr_t,
pshared: *mut c_int,
) -> c_int;
pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE;
pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int;
pub fn pthread_create(
native: *mut crate::pthread_t,
attr: *const crate::pthread_attr_t,
f: extern "C" fn(*mut c_void) -> *mut c_void,
value: *mut c_void,
) -> c_int;
pub fn __errno() -> *mut c_int;
pub fn inotify_rm_watch(fd: c_int, wd: u32) -> c_int;
pub fn inotify_init() -> c_int;
Expand Down Expand Up @@ -3729,8 +3664,6 @@ extern "C" {
pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;
pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int;

pub fn pthread_setname_np(thread: crate::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 All @@ -3755,8 +3688,6 @@ extern "C" {

pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void;

pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int;

pub fn dirname(path: *const c_char) -> *mut c_char;
pub fn basename(path: *const c_char) -> *mut c_char;
pub fn getopt_long(
Expand Down
Loading