diff --git a/src/syscalls/semaphore.rs b/src/syscalls/semaphore.rs index c11db47667..f6d9544f95 100644 --- a/src/syscalls/semaphore.rs +++ b/src/syscalls/semaphore.rs @@ -5,9 +5,6 @@ use crate::synch::semaphore::Semaphore; use crate::syscalls::{sys_clock_gettime, CLOCK_REALTIME}; use crate::time::timespec; -#[allow(non_camel_case_types)] -pub type sem_t = *const Semaphore; - /// Create a new, unnamed semaphore. /// /// This function can be used to get the raw memory location of a semaphore. @@ -16,7 +13,7 @@ pub type sem_t = *const Semaphore; /// Returns `0` on success, `-EINVAL` if `sem` is null. #[hermit_macro::system] #[no_mangle] -pub unsafe extern "C" fn sys_sem_init(sem: *mut sem_t, pshared: i32, value: u32) -> i32 { +pub unsafe extern "C" fn sys_sem_init(sem: *mut *mut Semaphore, pshared: i32, value: u32) -> i32 { if sem.is_null() || pshared != 0 { return -EINVAL; } @@ -36,7 +33,7 @@ pub unsafe extern "C" fn sys_sem_init(sem: *mut sem_t, pshared: i32, value: u32) /// Returns `0` on success, `-EINVAL` if `sem` is null. #[hermit_macro::system] #[no_mangle] -pub unsafe extern "C" fn sys_sem_destroy(sem: *mut sem_t) -> i32 { +pub unsafe extern "C" fn sys_sem_destroy(sem: *mut Semaphore) -> i32 { if sem.is_null() { return -EINVAL; } @@ -58,13 +55,13 @@ pub unsafe extern "C" fn sys_sem_destroy(sem: *mut sem_t) -> i32 { /// Returns `0` on success, or `-EINVAL` if `sem` is null. #[hermit_macro::system] #[no_mangle] -pub unsafe extern "C" fn sys_sem_post(sem: *mut sem_t) -> i32 { +pub unsafe extern "C" fn sys_sem_post(sem: *mut Semaphore) -> i32 { if sem.is_null() { return -EINVAL; } // Get a reference to the given semaphore and release it. - let semaphore = unsafe { &**sem }; + let semaphore = unsafe { &*sem }; semaphore.release(); 0 } @@ -77,13 +74,13 @@ pub unsafe extern "C" fn sys_sem_post(sem: *mut sem_t) -> i32 { /// Returns `0` on lock acquire, `-EINVAL` if `sem` is null, or `-ECANCELED` if the decrement fails. #[hermit_macro::system] #[no_mangle] -pub unsafe extern "C" fn sys_sem_trywait(sem: *mut sem_t) -> i32 { +pub unsafe extern "C" fn sys_sem_trywait(sem: *mut Semaphore) -> i32 { if sem.is_null() { return -EINVAL; } // Get a reference to the given semaphore and acquire it in a non-blocking fashion. - let semaphore = unsafe { &**sem }; + let semaphore = unsafe { &*sem }; if semaphore.try_acquire() { 0 } else { @@ -91,7 +88,7 @@ pub unsafe extern "C" fn sys_sem_trywait(sem: *mut sem_t) -> i32 { } } -unsafe fn sem_timedwait(sem: *mut sem_t, ms: u32) -> i32 { +unsafe fn sem_timedwait(sem: *mut Semaphore, ms: u32) -> i32 { if sem.is_null() { return -EINVAL; } @@ -99,7 +96,7 @@ unsafe fn sem_timedwait(sem: *mut sem_t, ms: u32) -> i32 { let delay = if ms > 0 { Some(u64::from(ms)) } else { None }; // Get a reference to the given semaphore and wait until we have acquired it or the wakeup time has elapsed. - let semaphore = unsafe { &**sem }; + let semaphore = unsafe { &*sem }; if semaphore.acquire(delay) { 0 } else { @@ -114,7 +111,7 @@ unsafe fn sem_timedwait(sem: *mut sem_t, ms: u32) -> i32 { /// Returns `0` on lock acquire, `-EINVAL` if sem is null, or `-ETIME` on timeout. #[hermit_macro::system] #[no_mangle] -pub unsafe extern "C" fn sys_sem_timedwait(sem: *mut sem_t, ts: *const timespec) -> i32 { +pub unsafe extern "C" fn sys_sem_timedwait(sem: *mut Semaphore, ts: *const timespec) -> i32 { if ts.is_null() { unsafe { sem_timedwait(sem, 0) } } else {