(GX/Gekko) Implement scond_wait_timeout - now.tv_sec / now.tv_nsec were
previously uninitialized when being touched
This commit is contained in:
parent
f96ff71416
commit
8590dd6425
|
@ -47,6 +47,7 @@
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#endif
|
#endif
|
||||||
#elif defined(GEKKO)
|
#elif defined(GEKKO)
|
||||||
|
#include <ogc/lwp_watchdog.h>
|
||||||
#include "gx_pthread.h"
|
#include "gx_pthread.h"
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
#include "ctr_pthread.h"
|
#include "ctr_pthread.h"
|
||||||
|
@ -824,14 +825,12 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
|
||||||
* accidentally get 2ms. */
|
* accidentally get 2ms. */
|
||||||
return _scond_wait_win32(cond, lock, timeout_us / 1000);
|
return _scond_wait_win32(cond, lock, timeout_us / 1000);
|
||||||
#else
|
#else
|
||||||
int ret;
|
|
||||||
int64_t seconds, remainder;
|
int64_t seconds, remainder;
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
#ifdef __MACH__
|
#ifdef __MACH__
|
||||||
/* OSX doesn't have clock_gettime. */
|
/* OSX doesn't have clock_gettime. */
|
||||||
clock_serv_t cclock;
|
clock_serv_t cclock;
|
||||||
mach_timespec_t mts;
|
mach_timespec_t mts;
|
||||||
|
|
||||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||||
clock_get_time(cclock, &mts);
|
clock_get_time(cclock, &mts);
|
||||||
mach_port_deallocate(mach_task_self(), cclock);
|
mach_port_deallocate(mach_task_self(), cclock);
|
||||||
|
@ -840,7 +839,6 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
|
||||||
#elif !defined(__PSL1GHT__) && defined(__PS3__)
|
#elif !defined(__PSL1GHT__) && defined(__PS3__)
|
||||||
sys_time_sec_t s;
|
sys_time_sec_t s;
|
||||||
sys_time_nsec_t n;
|
sys_time_nsec_t n;
|
||||||
|
|
||||||
sys_time_get_current_time(&s, &n);
|
sys_time_get_current_time(&s, &n);
|
||||||
now.tv_sec = s;
|
now.tv_sec = s;
|
||||||
now.tv_nsec = n;
|
now.tv_nsec = n;
|
||||||
|
@ -850,14 +848,18 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
|
||||||
now.tv_nsec = tickms * 1000;
|
now.tv_nsec = tickms * 1000;
|
||||||
#elif !defined(DINGUX_BETA) && (defined(__mips__) || defined(VITA) || defined(_3DS))
|
#elif !defined(DINGUX_BETA) && (defined(__mips__) || defined(VITA) || defined(_3DS))
|
||||||
struct timeval tm;
|
struct timeval tm;
|
||||||
|
|
||||||
gettimeofday(&tm, NULL);
|
gettimeofday(&tm, NULL);
|
||||||
now.tv_sec = tm.tv_sec;
|
now.tv_sec = tm.tv_sec;
|
||||||
now.tv_nsec = tm.tv_usec * 1000;
|
now.tv_nsec = tm.tv_usec * 1000;
|
||||||
#elif defined(RETRO_WIN32_USE_PTHREADS)
|
#elif defined(RETRO_WIN32_USE_PTHREADS)
|
||||||
_ftime64_s(&now);
|
_ftime64_s(&now);
|
||||||
#elif !defined(GEKKO)
|
#elif defined(GEKKO)
|
||||||
/* timeout on libogc is duration, not end time. */
|
/* Avoid gettimeofday due to it being reported to be broken */
|
||||||
|
struct timeval tm;
|
||||||
|
const uint64_t tickms = gettime() / TB_TIMER_CLOCK;
|
||||||
|
now.tv_sec = tickms / 1000;
|
||||||
|
now.tv_nsec = tickms * 1000;
|
||||||
|
#else
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -873,8 +875,7 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
|
||||||
now.tv_sec += 1;
|
now.tv_sec += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pthread_cond_timedwait(&cond->cond, &lock->lock, &now);
|
return (pthread_cond_timedwait(&cond->cond, &lock->lock, &now) == 0);
|
||||||
return (ret == 0);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue