diff options
Diffstat (limited to 'os/various/lwip_bindings/arch/sys_arch.c')
-rw-r--r-- | os/various/lwip_bindings/arch/sys_arch.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/os/various/lwip_bindings/arch/sys_arch.c b/os/various/lwip_bindings/arch/sys_arch.c index 6107de252..950213ef1 100644 --- a/os/various/lwip_bindings/arch/sys_arch.c +++ b/os/various/lwip_bindings/arch/sys_arch.c @@ -99,18 +99,18 @@ void sys_sem_signal_S(sys_sem_t *sem) { } u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) { - systime_t tmo; - u32_t time; + systime_t tmo, start, remaining; osalSysLock(); tmo = timeout > 0 ? MS2ST((systime_t)timeout) : TIME_INFINITE; - time = (u32_t)ST2MS(osalOsGetSystemTimeX());
- if (chSemWaitTimeoutS(*sem, tmo) != MSG_OK)
- time = SYS_ARCH_TIMEOUT;
- else
- time = (u32_t)ST2MS(osalOsGetSystemTimeX()) - time;
+ start = osalOsGetSystemTimeX();
+ if (chSemWaitTimeoutS(*sem, tmo) != MSG_OK) {
+ osalSysUnlock();
+ return SYS_ARCH_TIMEOUT;
+ }
+ remaining = osalOsGetSystemTimeX() - start;
osalSysUnlock();
- return time;
+ return (u32_t)ST2MS(remaining);
}
int sys_sem_valid(sys_sem_t *sem) {
@@ -171,18 +171,18 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) { } u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) { - u32_t time; - systime_t tmo; + systime_t tmo, start, remaining;
osalSysLock(); tmo = timeout > 0 ? MS2ST((systime_t)timeout) : TIME_INFINITE; - time = (u32_t)osalOsGetSystemTimeX();
- if (chMBFetchS(*mbox, (msg_t *)msg, tmo) != MSG_OK)
- time = SYS_ARCH_TIMEOUT;
- else
- time = (u32_t)ST2MS(osalOsGetSystemTimeX()) - time;
+ start = osalOsGetSystemTimeX();
+ if (chMBFetchS(*mbox, (msg_t *)msg, tmo) != MSG_OK) {
+ osalSysUnlock();
+ return SYS_ARCH_TIMEOUT;
+ }
+ remaining = osalOsGetSystemTimeX() - start;
osalSysUnlock();
- return time;
+ return (u32_t)ST2MS(remaining);
}
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) {
|