Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594
This commit is contained in:
@@ -46,7 +46,8 @@ typedef struct _SDL_TimerMap
|
||||
} SDL_TimerMap;
|
||||
|
||||
/* The timers are kept in a sorted list */
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
/* Data used by the main thread */
|
||||
SDL_Thread *thread;
|
||||
SDL_atomic_t nextID;
|
||||
@@ -75,14 +76,13 @@ static SDL_TimerData SDL_timer_data;
|
||||
* Timers are removed by simply setting a canceled flag
|
||||
*/
|
||||
|
||||
static void
|
||||
SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
|
||||
static void SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
|
||||
{
|
||||
SDL_Timer *prev, *curr;
|
||||
|
||||
prev = NULL;
|
||||
for (curr = data->timers; curr; prev = curr, curr = curr->next) {
|
||||
if ((Sint32)(timer->scheduled-curr->scheduled) < 0) {
|
||||
if ((Sint32)(timer->scheduled - curr->scheduled) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -96,8 +96,7 @@ SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
|
||||
timer->next = curr;
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
SDL_TimerThread(void *_data)
|
||||
static int SDLCALL SDL_TimerThread(void *_data)
|
||||
{
|
||||
SDL_TimerData *data = (SDL_TimerData *)_data;
|
||||
SDL_Timer *pending;
|
||||
@@ -111,7 +110,7 @@ SDL_TimerThread(void *_data)
|
||||
* 2. Handle any timers that should dispatch this cycle
|
||||
* 3. Wait until next dispatch time or new timer arrives
|
||||
*/
|
||||
for ( ; ; ) {
|
||||
for (;;) {
|
||||
/* Pending and freelist maintenance */
|
||||
SDL_AtomicLock(&data->lock);
|
||||
{
|
||||
@@ -150,7 +149,7 @@ SDL_TimerThread(void *_data)
|
||||
while (data->timers) {
|
||||
current = data->timers;
|
||||
|
||||
if ((Sint32)(tick-current->scheduled) < 0) {
|
||||
if ((Sint32)(tick - current->scheduled) < 0) {
|
||||
/* Scheduled for the future, wait a bit */
|
||||
delay = (current->scheduled - tick);
|
||||
break;
|
||||
@@ -202,8 +201,7 @@ SDL_TimerThread(void *_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_TimerInit(void)
|
||||
int SDL_TimerInit(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
|
||||
@@ -234,14 +232,13 @@ SDL_TimerInit(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TimerQuit(void)
|
||||
void SDL_TimerQuit(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_Timer *timer;
|
||||
SDL_TimerMap *entry;
|
||||
|
||||
if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */
|
||||
if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */
|
||||
/* Shutdown the timer thread */
|
||||
if (data->thread) {
|
||||
SDL_SemPost(data->sem);
|
||||
@@ -384,17 +381,17 @@ typedef struct _SDL_TimerMap
|
||||
struct _SDL_TimerMap *next;
|
||||
} SDL_TimerMap;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int nextID;
|
||||
SDL_TimerMap *timermap;
|
||||
} SDL_TimerData;
|
||||
|
||||
static SDL_TimerData SDL_timer_data;
|
||||
|
||||
static void
|
||||
SDL_Emscripten_TimerHelper(void *userdata)
|
||||
static void SDL_Emscripten_TimerHelper(void *userdata)
|
||||
{
|
||||
SDL_TimerMap *entry = (SDL_TimerMap*)userdata;
|
||||
SDL_TimerMap *entry = (SDL_TimerMap *)userdata;
|
||||
entry->interval = entry->callback(entry->interval, entry->param);
|
||||
if (entry->interval > 0) {
|
||||
entry->timeoutID = emscripten_set_timeout(&SDL_Emscripten_TimerHelper,
|
||||
@@ -403,14 +400,12 @@ SDL_Emscripten_TimerHelper(void *userdata)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_TimerInit(void)
|
||||
int SDL_TimerInit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TimerQuit(void)
|
||||
void SDL_TimerQuit(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_TimerMap *entry;
|
||||
@@ -485,7 +480,7 @@ SDL_RemoveTimer(SDL_TimerID id)
|
||||
Uint32
|
||||
SDL_GetTicks(void)
|
||||
{
|
||||
return (Uint32) (SDL_GetTicks64() & 0xFFFFFFFF);
|
||||
return (Uint32)(SDL_GetTicks64() & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/* Useful functions and variables from SDL_timer.c */
|
||||
|
||||
#define ROUND_RESOLUTION(X) \
|
||||
(((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
|
||||
(((X + TIMER_RESOLUTION - 1) / TIMER_RESOLUTION) * TIMER_RESOLUTION)
|
||||
|
||||
extern void SDL_TicksInit(void);
|
||||
extern void SDL_TicksQuit(void);
|
||||
|
||||
@@ -22,11 +22,9 @@
|
||||
|
||||
#if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED)
|
||||
|
||||
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
@@ -34,8 +32,7 @@ SDL_TicksInit(void)
|
||||
ticks_started = SDL_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
@@ -63,8 +60,7 @@ SDL_GetPerformanceFrequency(void)
|
||||
return 1000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
@@ -24,12 +24,10 @@
|
||||
|
||||
#include <kernel/OS.h>
|
||||
|
||||
|
||||
static bigtime_t start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
@@ -40,8 +38,7 @@ SDL_TicksInit(void)
|
||||
start = system_time();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
@@ -53,7 +50,7 @@ SDL_GetTicks64(void)
|
||||
SDL_TicksInit();
|
||||
}
|
||||
|
||||
return (Uint64) ((system_time() - start) / 1000);
|
||||
return (Uint64)((system_time() - start) / 1000);
|
||||
}
|
||||
|
||||
Uint64
|
||||
@@ -68,8 +65,7 @@ SDL_GetPerformanceFrequency(void)
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
snooze(ms * 1000);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ static u64 start_tick;
|
||||
|
||||
#define NSEC_PER_MSEC 1000000ULL
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
@@ -40,8 +39,7 @@ SDL_TicksInit(void)
|
||||
start_tick = svcGetSystemTick();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
@@ -70,8 +68,7 @@ SDL_GetPerformanceFrequency(void)
|
||||
return SYSCLOCK_ARM11;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
svcSleepThread(ms * NSEC_PER_MSEC);
|
||||
}
|
||||
|
||||
@@ -25,34 +25,31 @@
|
||||
#include <e32std.h>
|
||||
#include <e32hal.h>
|
||||
|
||||
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
static TUint start = 0;
|
||||
static TInt tickPeriodMilliSeconds;
|
||||
static TUint start = 0;
|
||||
static TInt tickPeriodMilliSeconds;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
}
|
||||
ticks_started = SDL_TRUE;
|
||||
start = User::TickCount();
|
||||
start = User::TickCount();
|
||||
|
||||
TTimeIntervalMicroSeconds32 period;
|
||||
TInt tmp = UserHal::TickPeriod(period);
|
||||
TInt tmp = UserHal::TickPeriod(period);
|
||||
|
||||
(void)tmp; /* Suppress redundant warning. */
|
||||
|
||||
tickPeriodMilliSeconds = period.Int() / 1000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
@@ -60,7 +57,7 @@ SDL_TicksQuit(void)
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
{
|
||||
if (! ticks_started) {
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
}
|
||||
|
||||
@@ -82,8 +79,7 @@ SDL_GetPerformanceFrequency(void)
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
User::After(TTimeIntervalMicroSeconds32(ms * 1000));
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
static uint64_t start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
@@ -42,8 +41,7 @@ SDL_TicksInit(void)
|
||||
start = GetTimerSystemTime();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
@@ -75,9 +73,9 @@ SDL_GetPerformanceFrequency(void)
|
||||
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
struct timespec tv = {0};
|
||||
tv.tv_sec = ms / 1000;
|
||||
tv.tv_nsec = (ms % 1000) * 1000000;
|
||||
struct timespec tv = { 0 };
|
||||
tv.tv_sec = ms / 1000;
|
||||
tv.tv_nsec = (ms % 1000) * 1000000;
|
||||
nanosleep(&tv, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
static struct timeval start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
@@ -42,8 +41,7 @@ SDL_TicksInit(void)
|
||||
gettimeofday(&start, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,7 @@ static SDL_bool has_monotonic_time = SDL_FALSE;
|
||||
static struct timeval start_tv;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
@@ -95,8 +94,7 @@ SDL_TicksInit(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
@@ -176,13 +174,12 @@ SDL_GetPerformanceFrequency(void)
|
||||
freq /= mach_base_info.numer;
|
||||
return freq;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
int was_error;
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
static uint64_t start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
@@ -42,8 +41,7 @@ SDL_TicksInit(void)
|
||||
start = sceKernelGetProcessTimeWide();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
@@ -58,7 +56,7 @@ SDL_GetTicks64(void)
|
||||
}
|
||||
|
||||
now = sceKernelGetProcessTimeWide();
|
||||
return (Uint64) ((now - start) / 1000);
|
||||
return (Uint64)((now - start) / 1000);
|
||||
}
|
||||
|
||||
Uint64
|
||||
|
||||
@@ -25,19 +25,16 @@
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
|
||||
|
||||
|
||||
/* The first (low-resolution) ticks value of the application */
|
||||
static DWORD start = 0;
|
||||
static BOOL ticks_started = FALSE;
|
||||
static BOOL ticks_started = FALSE;
|
||||
|
||||
/* The first high-resolution ticks value of the application */
|
||||
static LARGE_INTEGER start_ticks;
|
||||
/* The number of ticks per second of the high-resolution performance counter */
|
||||
static LARGE_INTEGER ticks_per_second;
|
||||
|
||||
static void
|
||||
SDL_SetSystemTimerResolution(const UINT uPeriod)
|
||||
static void SDL_SetSystemTimerResolution(const UINT uPeriod)
|
||||
{
|
||||
#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
static UINT timer_period = 0;
|
||||
@@ -56,8 +53,7 @@ SDL_SetSystemTimerResolution(const UINT uPeriod)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SDLCALL
|
||||
SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
static void SDLCALL SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
UINT uPeriod;
|
||||
|
||||
@@ -72,8 +68,7 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
BOOL rc;
|
||||
|
||||
@@ -92,17 +87,16 @@ SDL_TicksInit(void)
|
||||
so we'll rely on it here.
|
||||
*/
|
||||
rc = QueryPerformanceFrequency(&ticks_per_second);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
QueryPerformanceCounter(&start_ticks);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION,
|
||||
SDL_TimerResolutionChanged, NULL);
|
||||
|
||||
SDL_SetSystemTimerResolution(0); /* always release our timer resolution request. */
|
||||
SDL_SetSystemTimerResolution(0); /* always release our timer resolution request. */
|
||||
|
||||
start = 0;
|
||||
ticks_started = SDL_FALSE;
|
||||
@@ -119,8 +113,8 @@ SDL_GetTicks64(void)
|
||||
}
|
||||
|
||||
rc = QueryPerformanceCounter(&now);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64) (((now.QuadPart - start_ticks.QuadPart) * 1000) / ticks_per_second.QuadPart);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64)(((now.QuadPart - start_ticks.QuadPart) * 1000) / ticks_per_second.QuadPart);
|
||||
}
|
||||
|
||||
Uint64
|
||||
@@ -128,8 +122,8 @@ SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
LARGE_INTEGER counter;
|
||||
const BOOL rc = QueryPerformanceCounter(&counter);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64) counter.QuadPart;
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64)counter.QuadPart;
|
||||
}
|
||||
|
||||
Uint64
|
||||
@@ -137,28 +131,27 @@ SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
LARGE_INTEGER frequency;
|
||||
const BOOL rc = QueryPerformanceFrequency(&frequency);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64) frequency.QuadPart;
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64)frequency.QuadPart;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
/* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag was added in Windows 10 version 1803.
|
||||
*
|
||||
* Sleep() is not publicly available to apps in early versions of WinRT.
|
||||
*
|
||||
* Visual C++ 2013 Update 4 re-introduced Sleep() for Windows 8.1 and
|
||||
* Windows Phone 8.1.
|
||||
*
|
||||
* Use the compiler version to determine availability.
|
||||
*
|
||||
* NOTE #1: _MSC_FULL_VER == 180030723 for Visual C++ 2013 Update 3.
|
||||
* NOTE #2: Visual C++ 2013, when compiling for Windows 8.0 and
|
||||
* Windows Phone 8.0, uses the Visual C++ 2012 compiler to build
|
||||
* apps and libraries.
|
||||
*/
|
||||
#ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||
*
|
||||
* Sleep() is not publicly available to apps in early versions of WinRT.
|
||||
*
|
||||
* Visual C++ 2013 Update 4 re-introduced Sleep() for Windows 8.1 and
|
||||
* Windows Phone 8.1.
|
||||
*
|
||||
* Use the compiler version to determine availability.
|
||||
*
|
||||
* NOTE #1: _MSC_FULL_VER == 180030723 for Visual C++ 2013 Update 3.
|
||||
* NOTE #2: Visual C++ 2013, when compiling for Windows 8.0 and
|
||||
* Windows Phone 8.0, uses the Visual C++ 2012 compiler to build
|
||||
* apps and libraries.
|
||||
*/
|
||||
#ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||
HANDLE timer = CreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
|
||||
if (timer) {
|
||||
LARGE_INTEGER due_time;
|
||||
|
||||
Reference in New Issue
Block a user