1use crate::{ctypes, utils::e};
2use arceos_posix_api as api;
3use core::ffi::{c_int, c_void};
4
5#[unsafe(no_mangle)]
7pub unsafe extern "C" fn pthread_self() -> ctypes::pthread_t {
8 api::sys_pthread_self()
9}
10
11#[unsafe(no_mangle)]
16pub unsafe extern "C" fn pthread_create(
17 res: *mut ctypes::pthread_t,
18 attr: *const ctypes::pthread_attr_t,
19 start_routine: extern "C" fn(arg: *mut c_void) -> *mut c_void,
20 arg: *mut c_void,
21) -> c_int {
22 e(api::sys_pthread_create(res, attr, start_routine, arg))
23}
24
25#[unsafe(no_mangle)]
27pub unsafe extern "C" fn pthread_exit(retval: *mut c_void) -> ! {
28 api::sys_pthread_exit(retval)
29}
30
31#[unsafe(no_mangle)]
33pub unsafe extern "C" fn pthread_join(
34 thread: ctypes::pthread_t,
35 retval: *mut *mut c_void,
36) -> c_int {
37 e(api::sys_pthread_join(thread, retval))
38}
39
40#[unsafe(no_mangle)]
42pub unsafe extern "C" fn pthread_mutex_init(
43 mutex: *mut ctypes::pthread_mutex_t,
44 attr: *const ctypes::pthread_mutexattr_t,
45) -> c_int {
46 e(api::sys_pthread_mutex_init(mutex, attr))
47}
48
49#[unsafe(no_mangle)]
51pub unsafe extern "C" fn pthread_mutex_lock(mutex: *mut ctypes::pthread_mutex_t) -> c_int {
52 e(api::sys_pthread_mutex_lock(mutex))
53}
54
55#[unsafe(no_mangle)]
57pub unsafe extern "C" fn pthread_mutex_unlock(mutex: *mut ctypes::pthread_mutex_t) -> c_int {
58 e(api::sys_pthread_mutex_unlock(mutex))
59}