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:
Sam Lantinga
2024-08-22 10:30:45 -07:00
parent 658fc3db0f
commit 6501e90018
743 changed files with 11882 additions and 11882 deletions

View File

@@ -38,7 +38,7 @@ typedef struct SDL_cond_impl_t
pfnSDL_WaitConditionTimeoutNS WaitTimeoutNS;
} SDL_cond_impl_t;
/* Implementation will be chosen at runtime based on available Kernel features */
// Implementation will be chosen at runtime based on available Kernel features
static SDL_cond_impl_t SDL_cond_impl_active = { 0 };
/**
@@ -80,13 +80,13 @@ typedef struct SDL_cond_cv
static SDL_Condition *SDL_CreateCondition_cv(void)
{
/* Relies on CONDITION_VARIABLE_INIT == 0. */
// Relies on CONDITION_VARIABLE_INIT == 0.
return (SDL_Condition *)SDL_calloc(1, sizeof(SDL_cond_cv));
}
static void SDL_DestroyCondition_cv(SDL_Condition *cond)
{
/* There are no kernel allocated resources */
// There are no kernel allocated resources
SDL_free(cond);
}
@@ -140,7 +140,7 @@ static int SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mutex
return SDL_SetError("Passed mutex is not locked or locked recursively");
}
/* The mutex must be updated to the released state */
// The mutex must be updated to the released state
mutex->count = 0;
mutex->owner = 0;
@@ -154,7 +154,7 @@ static int SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mutex
ret = 0;
}
/* The mutex is owned by us again, regardless of status of the wait */
// The mutex is owned by us again, regardless of status of the wait
SDL_assert(mutex->count == 0 && mutex->owner == 0);
mutex->count = 1;
mutex->owner = GetCurrentThreadId();
@@ -187,7 +187,7 @@ static const SDL_cond_impl_t SDL_cond_impl_cv = {
#ifndef SDL_PLATFORM_WINRT
/* Generic Condition Variable implementation using SDL_Mutex and SDL_Semaphore */
// Generic Condition Variable implementation using SDL_Mutex and SDL_Semaphore
static const SDL_cond_impl_t SDL_cond_impl_generic = {
&SDL_CreateCondition_generic,
&SDL_DestroyCondition_generic,
@@ -203,7 +203,7 @@ SDL_Condition *SDL_CreateCondition(void)
const SDL_cond_impl_t *impl = NULL;
if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) {
/* The mutex implementation isn't decided yet, trigger it */
// The mutex implementation isn't decided yet, trigger it
SDL_Mutex *mutex = SDL_CreateMutex();
if (!mutex) {
return NULL;
@@ -214,10 +214,10 @@ SDL_Condition *SDL_CreateCondition(void)
}
#ifdef SDL_PLATFORM_WINRT
/* Link statically on this platform */
// Link statically on this platform
impl = &SDL_cond_impl_cv;
#else
/* Default to generic implementation, works with all mutex implementations */
// Default to generic implementation, works with all mutex implementations
impl = &SDL_cond_impl_generic;
{
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
@@ -227,7 +227,7 @@ SDL_Condition *SDL_CreateCondition(void)
pSleepConditionVariableSRW = (pfnSleepConditionVariableSRW)GetProcAddress(kernel32, "SleepConditionVariableSRW");
pSleepConditionVariableCS = (pfnSleepConditionVariableCS)GetProcAddress(kernel32, "SleepConditionVariableCS");
if (pWakeConditionVariable && pWakeAllConditionVariable && pSleepConditionVariableSRW && pSleepConditionVariableCS) {
/* Use the Windows provided API */
// Use the Windows provided API
impl = &SDL_cond_impl_cv;
}
}

View File

@@ -32,7 +32,7 @@
#include "SDL_sysmutex_c.h"
/* Implementation will be chosen at runtime based on available Kernel features */
// Implementation will be chosen at runtime based on available Kernel features
SDL_mutex_impl_t SDL_mutex_impl_active = { 0 };
/**
@@ -40,7 +40,7 @@ SDL_mutex_impl_t SDL_mutex_impl_active = { 0 };
*/
#ifdef SDL_PLATFORM_WINRT
/* Functions are guaranteed to be available */
// Functions are guaranteed to be available
#define pInitializeSRWLock InitializeSRWLock
#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive
#define pAcquireSRWLockExclusive AcquireSRWLockExclusive
@@ -67,7 +67,7 @@ static SDL_Mutex *SDL_CreateMutex_srw(void)
static void SDL_DestroyMutex_srw(SDL_Mutex *mutex)
{
/* There are no kernel allocated resources */
// There are no kernel allocated resources
SDL_free(mutex);
}

View File

@@ -42,7 +42,7 @@ typedef struct SDL_mutex_impl_t
pfnSDL_LockMutex Lock;
pfnSDL_TryLockMutex TryLock;
pfnSDL_UnlockMutex Unlock;
/* Needed by SDL_Condition: */
// Needed by SDL_Condition:
SDL_MutexType Type;
} SDL_mutex_impl_t;
@@ -62,7 +62,7 @@ typedef struct _SRWLOCK
typedef struct SDL_mutex_srw
{
SRWLOCK srw;
/* SRW Locks are not recursive, that has to be handled by SDL: */
// SRW Locks are not recursive, that has to be handled by SDL:
DWORD count;
DWORD owner;
} SDL_mutex_srw;

View File

@@ -24,7 +24,7 @@
* Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer.
*/
/* This header makes sure SRWLOCK is actually declared, even on ancient WinSDKs. */
// This header makes sure SRWLOCK is actually declared, even on ancient WinSDKs.
#include "SDL_sysmutex_c.h"
typedef VOID(WINAPI *pfnInitializeSRWLock)(PSRWLOCK);
@@ -36,7 +36,7 @@ typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK);
typedef BOOLEAN(WINAPI *pfnTryAcquireSRWLockExclusive)(PSRWLOCK);
#ifdef SDL_PLATFORM_WINRT
/* Functions are guaranteed to be available */
// Functions are guaranteed to be available
#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive
#define pInitializeSRWLock InitializeSRWLock
#define pReleaseSRWLockShared ReleaseSRWLockShared
@@ -74,10 +74,10 @@ typedef struct SDL_rwlock_impl_t
pfnSDL_UnlockRWLock Unlock;
} SDL_rwlock_impl_t;
/* Implementation will be chosen at runtime based on available Kernel features */
// Implementation will be chosen at runtime based on available Kernel features
static SDL_rwlock_impl_t SDL_rwlock_impl_active = { 0 };
/* rwlock implementation using Win7+ slim read/write locks (SRWLOCK) */
// rwlock implementation using Win7+ slim read/write locks (SRWLOCK)
typedef struct SDL_rwlock_srw
{
@@ -98,7 +98,7 @@ static void SDL_DestroyRWLock_srw(SDL_RWLock *_rwlock)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
if (rwlock) {
/* There are no kernel allocated resources */
// There are no kernel allocated resources
SDL_free(rwlock);
}
}
@@ -167,7 +167,7 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_srw = {
#include "../generic/SDL_sysrwlock_c.h"
/* Generic rwlock implementation using SDL_Mutex, SDL_Condition, and SDL_AtomicInt */
// Generic rwlock implementation using SDL_Mutex, SDL_Condition, and SDL_AtomicInt
static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = {
&SDL_CreateRWLock_generic,
&SDL_DestroyRWLock_generic,
@@ -185,10 +185,10 @@ SDL_RWLock *SDL_CreateRWLock(void)
const SDL_rwlock_impl_t *impl;
#ifdef SDL_PLATFORM_WINRT
/* Link statically on this platform */
// Link statically on this platform
impl = &SDL_rwlock_impl_srw;
#else
/* Default to generic implementation, works with all mutex implementations */
// Default to generic implementation, works with all mutex implementations
impl = &SDL_rwlock_impl_generic;
{
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
@@ -204,7 +204,7 @@ SDL_RWLock *SDL_CreateRWLock(void)
LOOKUP_SRW_SYM(TryAcquireSRWLockExclusive);
#undef LOOKUP_SRW_SYM
if (okay) {
impl = &SDL_rwlock_impl_srw; /* Use the Windows provided API instead of generic fallback */
impl = &SDL_rwlock_impl_srw; // Use the Windows provided API instead of generic fallback
}
}
}

View File

@@ -50,19 +50,19 @@ typedef struct SDL_semaphore_impl_t
pfnSDL_SignalSemaphore Post;
} SDL_sem_impl_t;
/* Implementation will be chosen at runtime based on available Kernel features */
// Implementation will be chosen at runtime based on available Kernel features
static SDL_sem_impl_t SDL_sem_impl_active = { 0 };
/**
* Atomic + WaitOnAddress implementation
*/
/* APIs not available on WinPhone 8.1 */
/* https://www.microsoft.com/en-us/download/details.aspx?id=47328 */
// APIs not available on WinPhone 8.1
// https://www.microsoft.com/en-us/download/details.aspx?id=47328
#if !SDL_WINAPI_FAMILY_PHONE
#ifdef SDL_PLATFORM_WINRT
/* Functions are guaranteed to be available */
// Functions are guaranteed to be available
#define pWaitOnAddress WaitOnAddress
#define pWakeByAddressSingle WakeByAddressSingle
#else
@@ -143,7 +143,7 @@ static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_Semaphore *_sem, Sint64 timeoutNS
for (;;) {
count = sem->count;
/* If no semaphore is available we need to wait */
// If no semaphore is available we need to wait
while (count == 0) {
now = SDL_GetTicksNS();
if (deadline > now) {
@@ -160,8 +160,8 @@ static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_Semaphore *_sem, Sint64 timeoutNS
count = sem->count;
}
/* Actually the semaphore is only consumed if this succeeds */
/* If it doesn't we need to do everything again */
// Actually the semaphore is only consumed if this succeeds
// If it doesn't we need to do everything again
if (InterlockedCompareExchange(&sem->count, count - 1, count) == count) {
return 0;
}
@@ -201,7 +201,7 @@ static const SDL_sem_impl_t SDL_sem_impl_atom = {
&SDL_GetSemaphoreValue_atom,
&SDL_SignalSemaphore_atom,
};
#endif /* !SDL_WINAPI_FAMILY_PHONE */
#endif // !SDL_WINAPI_FAMILY_PHONE
/**
* Fallback Semaphore implementation using Kernel Semaphores
@@ -213,15 +213,15 @@ typedef struct SDL_semaphore_kern
LONG count;
} SDL_sem_kern;
/* Create a semaphore */
// Create a semaphore
static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value)
{
SDL_sem_kern *sem;
/* Allocate sem memory */
// Allocate sem memory
sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem));
if (sem) {
/* Create the semaphore, with max value 32K */
// Create the semaphore, with max value 32K
// !!! FIXME: CreateSemaphoreEx is available in Vista and later, so if XP support is dropped, we can lose this #ifdef.
#ifdef SDL_PLATFORM_WINRT
sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS);
@@ -238,7 +238,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value)
return (SDL_Semaphore *)sem;
}
/* Free the semaphore */
// Free the semaphore
static void SDL_DestroySemaphore_kern(SDL_Semaphore *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
@@ -281,7 +281,7 @@ static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_Semaphore *_sem, Sint64 timeoutNS
return retval;
}
/* Returns the current count of the semaphore */
// Returns the current count of the semaphore
static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
@@ -305,7 +305,7 @@ static int SDL_SignalSemaphore_kern(SDL_Semaphore *_sem)
*/
InterlockedIncrement(&sem->count);
if (ReleaseSemaphore(sem->id, 1, NULL) == FALSE) {
InterlockedDecrement(&sem->count); /* restore */
InterlockedDecrement(&sem->count); // restore
return SDL_SetError("ReleaseSemaphore() failed");
}
return 0;
@@ -326,13 +326,13 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = {
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
if (!SDL_sem_impl_active.Create) {
/* Default to fallback implementation */
// Default to fallback implementation
const SDL_sem_impl_t *impl = &SDL_sem_impl_kern;
#if !SDL_WINAPI_FAMILY_PHONE
if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, SDL_FALSE)) {
#ifdef SDL_PLATFORM_WINRT
/* Link statically on this platform */
// Link statically on this platform
impl = &SDL_sem_impl_atom;
#else
/* We already statically link to features from this Api
@@ -343,7 +343,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
*/
HMODULE synch120 = GetModuleHandle(TEXT("api-ms-win-core-synch-l1-2-0.dll"));
if (synch120) {
/* Try to load required functions provided by Win 8 or newer */
// Try to load required functions provided by Win 8 or newer
pWaitOnAddress = (pfnWaitOnAddress)GetProcAddress(synch120, "WaitOnAddress");
pWakeByAddressSingle = (pfnWakeByAddressSingle)GetProcAddress(synch120, "WakeByAddressSingle");
@@ -355,7 +355,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
}
#endif
/* Copy instead of using pointer to save one level of indirection */
// Copy instead of using pointer to save one level of indirection
SDL_copyp(&SDL_sem_impl_active, impl);
}
return SDL_sem_impl_active.Create(initial_value);
@@ -381,4 +381,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem)
return SDL_sem_impl_active.Post(sem);
}
#endif /* SDL_THREAD_WINDOWS */
#endif // SDL_THREAD_WINDOWS

View File

@@ -22,7 +22,7 @@
#ifdef SDL_THREAD_WINDOWS
/* Win32 thread management routines for SDL */
// Win32 thread management routines for SDL
#include "../SDL_thread_c.h"
#include "../SDL_systhread.h"
@@ -66,10 +66,10 @@ int SDL_SYS_CreateThread(SDL_Thread *thread,
const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
/* Save the function which we will have to call to clear the RTL of calling app! */
// Save the function which we will have to call to clear the RTL of calling app!
thread->endfunc = vpfnEndThread;
/* thread->stacksize == 0 means "system default", same as win32 expects */
// thread->stacksize == 0 means "system default", same as win32 expects
if (pfnBeginThread) {
unsigned threadid = 0;
thread->handle = (SYS_ThreadHandle)((size_t)pfnBeginThread(NULL, (unsigned int)thread->stacksize,
@@ -90,10 +90,10 @@ int SDL_SYS_CreateThread(SDL_Thread *thread,
#pragma pack(push, 8)
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; /* must be 0x1000 */
LPCSTR szName; /* pointer to name (in user addr space) */
DWORD dwThreadID; /* thread ID (-1=caller thread) */
DWORD dwFlags; /* reserved for future use, must be zero */
DWORD dwType; // must be 0x1000
LPCSTR szName; // pointer to name (in user addr space)
DWORD dwThreadID; // thread ID (-1=caller thread)
DWORD dwFlags; // reserved for future use, must be zero
} THREADNAME_INFO;
#pragma pack(pop)
@@ -109,7 +109,7 @@ void SDL_SYS_SetupThread(const char *name)
{
if (name) {
PVOID exceptionHandlerHandle;
#ifndef SDL_PLATFORM_WINRT /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */
#ifndef SDL_PLATFORM_WINRT // !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment.
static pfnSetThreadDescription pSetThreadDescription = NULL;
static HMODULE kernel32 = NULL;
@@ -142,14 +142,14 @@ void SDL_SYS_SetupThread(const char *name)
exceptionHandlerHandle = AddVectoredExceptionHandler(1, EmptyVectoredExceptionHandler);
if (exceptionHandlerHandle) {
THREADNAME_INFO inf;
/* This magic tells the debugger to name a thread if it's listening. */
// This magic tells the debugger to name a thread if it's listening.
SDL_zero(inf);
inf.dwType = 0x1000;
inf.szName = name;
inf.dwThreadID = (DWORD)-1;
inf.dwFlags = 0;
/* The debugger catches this, renames the thread, continues on. */
// The debugger catches this, renames the thread, continues on.
RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG), (const ULONG_PTR *)&inf);
RemoveVectoredExceptionHandler(exceptionHandlerHandle);
}
@@ -191,4 +191,4 @@ void SDL_SYS_DetachThread(SDL_Thread *thread)
CloseHandle(thread->handle);
}
#endif /* SDL_THREAD_WINDOWS */
#endif // SDL_THREAD_WINDOWS

View File

@@ -27,4 +27,4 @@
typedef HANDLE SYS_ThreadHandle;
#endif /* SDL_systhread_c_h_ */
#endif // SDL_systhread_c_h_

View File

@@ -90,4 +90,4 @@ void SDL_SYS_QuitTLSData(void)
}
}
#endif /* SDL_THREAD_WINDOWS */
#endif // SDL_THREAD_WINDOWS