use crate::{ctypes, utils::e};
use arceos_posix_api as api;
use core::ffi::{c_int, c_void};
#[no_mangle]
pub unsafe extern "C" fn pthread_self() -> ctypes::pthread_t {
api::sys_pthread_self()
}
#[no_mangle]
pub unsafe extern "C" fn pthread_create(
res: *mut ctypes::pthread_t,
attr: *const ctypes::pthread_attr_t,
start_routine: extern "C" fn(arg: *mut c_void) -> *mut c_void,
arg: *mut c_void,
) -> c_int {
e(api::sys_pthread_create(res, attr, start_routine, arg))
}
#[no_mangle]
pub unsafe extern "C" fn pthread_exit(retval: *mut c_void) -> ! {
api::sys_pthread_exit(retval)
}
#[no_mangle]
pub unsafe extern "C" fn pthread_join(
thread: ctypes::pthread_t,
retval: *mut *mut c_void,
) -> c_int {
e(api::sys_pthread_join(thread, retval))
}
#[no_mangle]
pub unsafe extern "C" fn pthread_mutex_init(
mutex: *mut ctypes::pthread_mutex_t,
attr: *const ctypes::pthread_mutexattr_t,
) -> c_int {
e(api::sys_pthread_mutex_init(mutex, attr))
}
#[no_mangle]
pub unsafe extern "C" fn pthread_mutex_lock(mutex: *mut ctypes::pthread_mutex_t) -> c_int {
e(api::sys_pthread_mutex_lock(mutex))
}
#[no_mangle]
pub unsafe extern "C" fn pthread_mutex_unlock(mutex: *mut ctypes::pthread_mutex_t) -> c_int {
e(api::sys_pthread_mutex_unlock(mutex))
}