Don't do implicit memsets for struct timespec - always has only

a tv_sec and tv_nsec member field which always get set
This commit is contained in:
LibretroAdmin 2022-09-02 23:47:58 +02:00
parent 2463a63c78
commit 8f14143859
5 changed files with 15 additions and 15 deletions

View File

@ -410,7 +410,7 @@ static void exynos_perf_memcpy(struct exynos_perf *p, bool start)
clock_gettime(CLOCK_MONOTONIC, &p->tspec);
else
{
struct timespec new = { 0 };
struct timespec new;
clock_gettime(CLOCK_MONOTONIC, &new);
p->memcpy_time += (new.tv_sec - p->tspec.tv_sec) * 1000000;
@ -425,7 +425,7 @@ static void exynos_perf_g2d(struct exynos_perf *p, bool start)
clock_gettime(CLOCK_MONOTONIC, &p->tspec);
else
{
struct timespec new = { 0 };
struct timespec new;
clock_gettime(CLOCK_MONOTONIC, &new);
p->g2d_time += (new.tv_sec - p->tspec.tv_sec) * 1000000;

View File

@ -126,7 +126,7 @@
static int ra_clock_gettime(int clk_ik, struct timespec *t)
{
struct timeval now;
int rv = gettimeofday(&now, NULL);
int rv = gettimeofday(&now, NULL);
if (rv)
return rv;
t->tv_sec = now.tv_sec;
@ -184,7 +184,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
#elif !defined(__MACH__) && (defined(_XBOX360) || defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__) || defined(__PSL1GHT__) || defined(__PPC64__) || defined(__powerpc64__))
time_ticks = __mftb();
#elif (defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0) || defined(__QNX__) || defined(ANDROID)
struct timespec tv = {0};
struct timespec tv;
if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) == 0)
time_ticks = (retro_perf_tick_t)tv.tv_sec * 1000000000 +
(retro_perf_tick_t)tv.tv_nsec;
@ -251,7 +251,7 @@ retro_time_t cpu_features_get_time_usec(void)
#elif defined(_3DS)
return osGetTime() * 1000;
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__)
struct timespec tv = {0};
struct timespec tv;
if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) < 0)
return 0;
return tv.tv_sec * INT64_C(1000000) + (tv.tv_nsec + 500) / 1000;

View File

@ -102,7 +102,7 @@ static int nanosleepDOS(const struct timespec *rqtp, struct timespec *rmtp)
#else
#define retro_sleep(msec) \
{ \
struct timespec tv = {0}; \
struct timespec tv; \
tv.tv_sec = msec / 1000; \
tv.tv_nsec = (msec % 1000) * 1000000; \
nanosleep(&tv, NULL); \

View File

@ -265,26 +265,27 @@ static INLINE int pthread_cond_wait(pthread_cond_t *cond,
static INLINE int pthread_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex, const struct timespec *abstime)
{
struct timespec now = {0};
/* Missing clock_gettime*/
struct timespec now;
struct timeval tm;
int retval = 0;
do {
do
{
s64 timeout;
gettimeofday(&tm, NULL);
now.tv_sec = tm.tv_sec;
now.tv_sec = tm.tv_sec;
now.tv_nsec = tm.tv_usec * 1000;
s64 timeout = (abstime->tv_sec - now.tv_sec) * 1000000000 + (abstime->tv_nsec - now.tv_nsec);
if (timeout < 0)
if ((timeout = (abstime->tv_sec - now.tv_sec) * 1000000000 +
(abstime->tv_nsec - now.tv_nsec)) < 0)
{
retval = ETIMEDOUT;
break;
}
if (!CondVar_WaitTimeout((CondVar *)cond, (LightLock *)mutex, timeout)) {
if (!CondVar_WaitTimeout((CondVar *)cond, (LightLock *)mutex, timeout))
break;
}
} while (1);
return retval;

View File

@ -826,8 +826,7 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
#else
int ret;
int64_t seconds, remainder;
struct timespec now = {0};
struct timespec now;
#ifdef __MACH__
/* OSX doesn't have clock_gettime. */
clock_serv_t cclock;