mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-27 09:44:15 +00:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../thread/SDL_systhread.h"
|
||||
|
||||
/* #define DEBUG_TIMERS */
|
||||
// #define DEBUG_TIMERS
|
||||
|
||||
#if !defined(SDL_PLATFORM_EMSCRIPTEN) || !defined(SDL_THREADS_DISABLED)
|
||||
|
||||
@@ -46,25 +46,25 @@ typedef struct SDL_TimerMap
|
||||
struct SDL_TimerMap *next;
|
||||
} SDL_TimerMap;
|
||||
|
||||
/* The timers are kept in a sorted list */
|
||||
// The timers are kept in a sorted list
|
||||
typedef struct
|
||||
{
|
||||
/* Data used by the main thread */
|
||||
// Data used by the main thread
|
||||
SDL_Thread *thread;
|
||||
SDL_TimerMap *timermap;
|
||||
SDL_Mutex *timermap_lock;
|
||||
|
||||
/* Padding to separate cache lines between threads */
|
||||
// Padding to separate cache lines between threads
|
||||
char cache_pad[SDL_CACHELINE_SIZE];
|
||||
|
||||
/* Data used to communicate with the timer thread */
|
||||
// Data used to communicate with the timer thread
|
||||
SDL_SpinLock lock;
|
||||
SDL_Semaphore *sem;
|
||||
SDL_Timer *pending;
|
||||
SDL_Timer *freelist;
|
||||
SDL_AtomicInt active;
|
||||
|
||||
/* List of timers - this is only touched by the timer thread */
|
||||
// List of timers - this is only touched by the timer thread
|
||||
SDL_Timer *timers;
|
||||
} SDL_TimerData;
|
||||
|
||||
@@ -87,7 +87,7 @@ static void SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
|
||||
}
|
||||
}
|
||||
|
||||
/* Insert the timer here! */
|
||||
// Insert the timer here!
|
||||
if (prev) {
|
||||
prev->next = timer;
|
||||
} else {
|
||||
@@ -111,14 +111,14 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
||||
* 3. Wait until next dispatch time or new timer arrives
|
||||
*/
|
||||
for (;;) {
|
||||
/* Pending and freelist maintenance */
|
||||
// Pending and freelist maintenance
|
||||
SDL_LockSpinlock(&data->lock);
|
||||
{
|
||||
/* Get any timers ready to be queued */
|
||||
// Get any timers ready to be queued
|
||||
pending = data->pending;
|
||||
data->pending = NULL;
|
||||
|
||||
/* Make any unused timer structures available */
|
||||
// Make any unused timer structures available
|
||||
if (freelist_head) {
|
||||
freelist_tail->next = data->freelist;
|
||||
data->freelist = freelist_head;
|
||||
@@ -126,7 +126,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
||||
}
|
||||
SDL_UnlockSpinlock(&data->lock);
|
||||
|
||||
/* Sort the pending timers into our list */
|
||||
// Sort the pending timers into our list
|
||||
while (pending) {
|
||||
current = pending;
|
||||
pending = pending->next;
|
||||
@@ -135,27 +135,27 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
||||
freelist_head = NULL;
|
||||
freelist_tail = NULL;
|
||||
|
||||
/* Check to see if we're still running, after maintenance */
|
||||
// Check to see if we're still running, after maintenance
|
||||
if (!SDL_AtomicGet(&data->active)) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Initial delay if there are no timers */
|
||||
// Initial delay if there are no timers
|
||||
delay = (Uint64)-1;
|
||||
|
||||
tick = SDL_GetTicksNS();
|
||||
|
||||
/* Process all the pending timers for this tick */
|
||||
// Process all the pending timers for this tick
|
||||
while (data->timers) {
|
||||
current = data->timers;
|
||||
|
||||
if (tick < current->scheduled) {
|
||||
/* Scheduled for the future, wait a bit */
|
||||
// Scheduled for the future, wait a bit
|
||||
delay = (current->scheduled - tick);
|
||||
break;
|
||||
}
|
||||
|
||||
/* We're going to do something with this timer */
|
||||
// We're going to do something with this timer
|
||||
data->timers = current->next;
|
||||
|
||||
if (SDL_AtomicGet(¤t->canceled)) {
|
||||
@@ -169,7 +169,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
||||
}
|
||||
|
||||
if (interval > 0) {
|
||||
/* Reschedule this timer */
|
||||
// Reschedule this timer
|
||||
current->interval = interval;
|
||||
current->scheduled = tick + interval;
|
||||
SDL_AddTimerInternal(data, current);
|
||||
@@ -186,7 +186,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
||||
}
|
||||
}
|
||||
|
||||
/* Adjust the delay based on processing time */
|
||||
// Adjust the delay based on processing time
|
||||
now = SDL_GetTicksNS();
|
||||
interval = (now - tick);
|
||||
if (interval > delay) {
|
||||
@@ -224,7 +224,7 @@ int SDL_InitTimers(void)
|
||||
|
||||
SDL_AtomicSet(&data->active, 1);
|
||||
|
||||
/* Timer threads use a callback into the app, so we can't set a limited stack size here. */
|
||||
// Timer threads use a callback into the app, so we can't set a limited stack size here.
|
||||
data->thread = SDL_CreateThread(SDL_TimerThread, name, data);
|
||||
if (!data->thread) {
|
||||
SDL_QuitTimers();
|
||||
@@ -240,8 +240,8 @@ void SDL_QuitTimers(void)
|
||||
SDL_Timer *timer;
|
||||
SDL_TimerMap *entry;
|
||||
|
||||
if (SDL_AtomicCompareAndSwap(&data->active, 1, 0)) { /* active? Move to inactive. */
|
||||
/* Shutdown the timer thread */
|
||||
if (SDL_AtomicCompareAndSwap(&data->active, 1, 0)) { // active? Move to inactive.
|
||||
// Shutdown the timer thread
|
||||
if (data->thread) {
|
||||
SDL_SignalSemaphore(data->sem);
|
||||
SDL_WaitThread(data->thread, NULL);
|
||||
@@ -251,7 +251,7 @@ void SDL_QuitTimers(void)
|
||||
SDL_DestroySemaphore(data->sem);
|
||||
data->sem = NULL;
|
||||
|
||||
/* Clean up the timer entries */
|
||||
// Clean up the timer entries
|
||||
while (data->timers) {
|
||||
timer = data->timers;
|
||||
data->timers = timer->next;
|
||||
@@ -327,13 +327,13 @@ static SDL_TimerID SDL_CreateTimer(Uint64 interval, SDL_TimerCallback callback_m
|
||||
data->timermap = entry;
|
||||
SDL_UnlockMutex(data->timermap_lock);
|
||||
|
||||
/* Add the timer to the pending list for the timer thread */
|
||||
// Add the timer to the pending list for the timer thread
|
||||
SDL_LockSpinlock(&data->lock);
|
||||
timer->next = data->pending;
|
||||
data->pending = timer;
|
||||
SDL_UnlockSpinlock(&data->lock);
|
||||
|
||||
/* Wake up the timer thread if necessary */
|
||||
// Wake up the timer thread if necessary
|
||||
SDL_SignalSemaphore(data->sem);
|
||||
|
||||
return entry->timerID;
|
||||
@@ -359,7 +359,7 @@ int SDL_RemoveTimer(SDL_TimerID id)
|
||||
return SDL_InvalidParamError("id");
|
||||
}
|
||||
|
||||
/* Find the timer */
|
||||
// Find the timer
|
||||
SDL_LockMutex(data->timermap_lock);
|
||||
prev = NULL;
|
||||
for (entry = data->timermap; entry; prev = entry, entry = entry->next) {
|
||||
@@ -492,7 +492,7 @@ int SDL_RemoveTimer(SDL_TimerID id)
|
||||
return SDL_InvalidParamError("id");
|
||||
}
|
||||
|
||||
/* Find the timer */
|
||||
// Find the timer
|
||||
prev = NULL;
|
||||
for (entry = data->timermap; entry; prev = entry, entry = entry->next) {
|
||||
if (entry->timerID == id) {
|
||||
@@ -514,7 +514,7 @@ int SDL_RemoveTimer(SDL_TimerID id)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !defined(SDL_PLATFORM_EMSCRIPTEN) || !SDL_THREADS_DISABLED */
|
||||
#endif // !defined(SDL_PLATFORM_EMSCRIPTEN) || !SDL_THREADS_DISABLED
|
||||
|
||||
static Uint64 tick_start;
|
||||
static Uint32 tick_numerator_ns;
|
||||
@@ -544,14 +544,14 @@ static void SDL_SetSystemTimerResolutionMS(int period)
|
||||
timeBeginPeriod((UINT)timer_period);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_TIME_BEGIN_PERIOD */
|
||||
#endif // HAVE_TIME_BEGIN_PERIOD
|
||||
}
|
||||
|
||||
static void SDLCALL SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
int period;
|
||||
|
||||
/* Unless the hint says otherwise, let's have good sleep precision */
|
||||
// Unless the hint says otherwise, let's have good sleep precision
|
||||
if (hint && *hint) {
|
||||
period = SDL_atoi(hint);
|
||||
} else {
|
||||
@@ -606,7 +606,7 @@ void SDL_QuitTicks(void)
|
||||
SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION,
|
||||
SDL_TimerResolutionChanged, NULL);
|
||||
|
||||
SDL_SetSystemTimerResolutionMS(0); /* always release our timer resolution request. */
|
||||
SDL_SetSystemTimerResolutionMS(0); // always release our timer resolution request.
|
||||
|
||||
tick_start = 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Useful functions and variables from SDL_timer.c */
|
||||
// Useful functions and variables from SDL_timer.c
|
||||
|
||||
#define ROUND_RESOLUTION(X) \
|
||||
(((X + TIMER_RESOLUTION - 1) / TIMER_RESOLUTION) * TIMER_RESOLUTION)
|
||||
@@ -36,4 +36,4 @@ extern void SDL_QuitTimers(void);
|
||||
|
||||
extern void SDL_SYS_DelayNS(Uint64 ns);
|
||||
|
||||
#endif /* SDL_timer_c_h_ */
|
||||
#endif // SDL_timer_c_h_
|
||||
|
||||
@@ -40,4 +40,4 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
snooze((bigtime_t)SDL_NS_TO_US(ns));
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_HAIKU */
|
||||
#endif // SDL_TIMER_HAIKU
|
||||
|
||||
@@ -40,4 +40,4 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
svcSleepThread(ns);
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_N3DS */
|
||||
#endif // SDL_TIMER_N3DS
|
||||
|
||||
@@ -34,7 +34,7 @@ extern "C" {
|
||||
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
/* FIXME: Need to account for 32-bit wrapping */
|
||||
// FIXME: Need to account for 32-bit wrapping
|
||||
return (Uint64)User::TickCount();
|
||||
}
|
||||
|
||||
@@ -56,4 +56,4 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_TIMER_NGAGE */
|
||||
#endif // SDL_TIMER_NGAGE
|
||||
|
||||
@@ -47,4 +47,4 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
nanosleep(&tv, NULL);
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_PS2 */
|
||||
#endif // SDL_TIMER_PS2
|
||||
|
||||
@@ -51,4 +51,4 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
sceKernelDelayThreadCB((SceUInt)SDL_NS_TO_US(ns));
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_PSP */
|
||||
#endif // SDL_TIMER_PSP
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
|
||||
/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */
|
||||
// Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
#ifdef CLOCK_MONOTONIC_RAW
|
||||
#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW
|
||||
@@ -60,7 +60,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The first ticks value of the application */
|
||||
// The first ticks value of the application
|
||||
#if !defined(HAVE_CLOCK_GETTIME) && defined(SDL_PLATFORM_APPLE)
|
||||
mach_timebase_info_data_t mach_base_info;
|
||||
#endif
|
||||
@@ -148,13 +148,13 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) {
|
||||
/* pseudo-synchronous pause, used directly or through e.g. SDL_WaitEvent */
|
||||
// pseudo-synchronous pause, used directly or through e.g. SDL_WaitEvent
|
||||
emscripten_sleep(ns / SDL_NS_PER_MS);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set the timeout interval */
|
||||
// Set the timeout interval
|
||||
#ifdef HAVE_NANOSLEEP
|
||||
remaining.tv_sec = (time_t)(ns / SDL_NS_PER_SECOND);
|
||||
remaining.tv_nsec = (long)(ns % SDL_NS_PER_SECOND);
|
||||
@@ -169,7 +169,7 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
tv.tv_nsec = remaining.tv_nsec;
|
||||
was_error = nanosleep(&tv, &remaining);
|
||||
#else
|
||||
/* Calculate the time interval left (in case of interrupt) */
|
||||
// Calculate the time interval left (in case of interrupt)
|
||||
now = SDL_GetTicksNS();
|
||||
elapsed = (now - then);
|
||||
then = now;
|
||||
@@ -181,8 +181,8 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
tv.tv_usec = SDL_NS_TO_US(ns % SDL_NS_PER_SECOND);
|
||||
|
||||
was_error = select(0, NULL, NULL, NULL, &tv);
|
||||
#endif /* HAVE_NANOSLEEP */
|
||||
#endif // HAVE_NANOSLEEP
|
||||
} while (was_error && (errno == EINTR));
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_UNIX */
|
||||
#endif // SDL_TIMER_UNIX
|
||||
|
||||
@@ -48,4 +48,4 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
sceKernelDelayThreadCB((SceUInt)SDL_NS_TO_US(ns));
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_VITA */
|
||||
#endif // SDL_TIMER_VITA
|
||||
|
||||
@@ -45,13 +45,13 @@ HANDLE SDL_GetWaitableTimer(void)
|
||||
}
|
||||
return timer;
|
||||
}
|
||||
#endif /* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION */
|
||||
#endif // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||
|
||||
Uint64 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. */
|
||||
SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later.
|
||||
return (Uint64)counter.QuadPart;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ Uint64 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. */
|
||||
SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later.
|
||||
return (Uint64)frequency.QuadPart;
|
||||
}
|
||||
|
||||
@@ -109,4 +109,4 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_WINDOWS */
|
||||
#endif // SDL_TIMER_WINDOWS
|
||||
|
||||
Reference in New Issue
Block a user