diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-06 10:31:02 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-06 10:31:02 +0000 |
commit | dfd71f419d02f1f139ab614a88393aaab53654e5 (patch) | |
tree | a224dc2a6c42dfb70c7b85a2ee45f22e2bf1386e /os/various | |
parent | 1f472e1845179b3b6d56314be45dadd2af98707e (diff) | |
download | ChibiOS-dfd71f419d02f1f139ab614a88393aaab53654e5.tar.gz ChibiOS-dfd71f419d02f1f139ab614a88393aaab53654e5.tar.bz2 ChibiOS-dfd71f419d02f1f139ab614a88393aaab53654e5.zip |
Fixed bug #696.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8825 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/various')
-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) {
|