SDL: Fix 64-bit timeval/timespec delta calculations

From 62629c2b5dd0ededa907910a2eef436eeb71a9b6 Mon Sep 17 00:00:00 2001
From: Brick <[EMAIL REDACTED]>
Date: Tue, 2 Nov 2021 22:17:41 +0000
Subject: [PATCH] Fix 64-bit timeval/timespec delta calculations

---
 src/timer/psp/SDL_systimer.c  | 2 +-
 src/timer/unix/SDL_systimer.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/timer/psp/SDL_systimer.c b/src/timer/psp/SDL_systimer.c
index 15d29e494b..cc841383ef 100644
--- a/src/timer/psp/SDL_systimer.c
+++ b/src/timer/psp/SDL_systimer.c
@@ -61,7 +61,7 @@ SDL_GetTicks64(void)
     }
 
     gettimeofday(&now, NULL);
-    return (((Uint64)(now.tv_sec-start.tv_sec)) * 1000) + (((Uint64) (now.tv_usec-start.tv_usec)) / 1000);
+    return (Uint64) (((Sint64) (now.tv_sec - start.tv_sec) * 1000) + ((now.tv_usec - start.tv_usec) / 1000));
 }
 
 Uint64
diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c
index 3bae176b12..30b0931d9f 100644
--- a/src/timer/unix/SDL_systimer.c
+++ b/src/timer/unix/SDL_systimer.c
@@ -117,7 +117,7 @@ SDL_GetTicks64(void)
 #if HAVE_CLOCK_GETTIME
         struct timespec now;
         clock_gettime(SDL_MONOTONIC_CLOCK, &now);
-        return (((Uint64) (now.tv_sec - start_ts.tv_sec)) * 1000) + (((Uint64) (now.tv_nsec - start_ts.tv_nsec)) / 1000000);
+        return (Uint64) (((Sint64) (now.tv_sec - start_ts.tv_sec) * 1000) + ((now.tv_nsec - start_ts.tv_nsec) / 1000000));
 #elif defined(__APPLE__)
         const uint64_t now = mach_absolute_time();
         return (Uint64) ((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
@@ -128,7 +128,7 @@ SDL_GetTicks64(void)
     }
 
     gettimeofday(&now, NULL);
-    return (((Uint64) (now.tv_sec - start_tv.tv_sec)) * 1000) + (((Uint64) (now.tv_usec - start_tv.tv_usec)) / 1000);
+    return (Uint64) (((Sint64) (now.tv_sec - start_tv.tv_sec) * 1000) + ((now.tv_usec - start_tv.tv_usec) / 1000));
 }
 
 Uint64