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

@@ -33,7 +33,7 @@ struct SDL_Condition
pthread_cond_t cond;
};
/* Create a condition variable */
// Create a condition variable
SDL_Condition *SDL_CreateCondition(void)
{
SDL_Condition *cond;
@@ -49,7 +49,7 @@ SDL_Condition *SDL_CreateCondition(void)
return cond;
}
/* Destroy a condition variable */
// Destroy a condition variable
void SDL_DestroyCondition(SDL_Condition *cond)
{
if (cond) {
@@ -58,7 +58,7 @@ void SDL_DestroyCondition(SDL_Condition *cond)
}
}
/* Restart one of the threads that are waiting on the condition variable */
// Restart one of the threads that are waiting on the condition variable
int SDL_SignalCondition(SDL_Condition *cond)
{
int retval;
@@ -74,7 +74,7 @@ int SDL_SignalCondition(SDL_Condition *cond)
return retval;
}
/* Restart all threads that are waiting on the condition variable */
// Restart all threads that are waiting on the condition variable
int SDL_BroadcastCondition(SDL_Condition *cond)
{
int retval;
@@ -130,7 +130,7 @@ tryagain:
switch (retval) {
case EINTR:
goto tryagain;
/* break; -Wunreachable-code-break */
// break; -Wunreachable-code-break
case ETIMEDOUT:
retval = SDL_MUTEX_TIMEDOUT;
break;

View File

@@ -37,4 +37,4 @@ struct SDL_Mutex
#endif
};
#endif /* SDL_mutex_c_h_ */
#endif // SDL_mutex_c_h_

View File

@@ -33,7 +33,7 @@ SDL_RWLock *SDL_CreateRWLock(void)
{
SDL_RWLock *rwlock;
/* Allocate the structure */
// Allocate the structure
rwlock = (SDL_RWLock *)SDL_calloc(1, sizeof(*rwlock));
if (rwlock) {
if (pthread_rwlock_init(&rwlock->id, NULL) != 0) {

View File

@@ -26,10 +26,10 @@
#include <sys/time.h>
#include <time.h>
/* Wrapper around POSIX 1003.1b semaphores */
// Wrapper around POSIX 1003.1b semaphores
#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)
/* macOS doesn't support sem_getvalue() as of version 10.4 */
// macOS doesn't support sem_getvalue() as of version 10.4
#include "../generic/SDL_syssem.c"
#else
@@ -38,7 +38,7 @@ struct SDL_Semaphore
sem_t sem;
};
/* Create a semaphore, initialized with value */
// Create a semaphore, initialized with value
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_Semaphore *sem = (SDL_Semaphore *)SDL_malloc(sizeof(SDL_Semaphore));
@@ -76,7 +76,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
return SDL_InvalidParamError("sem");
}
/* Try the easy cases first */
// Try the easy cases first
if (timeoutNS == 0) {
retval = SDL_MUTEX_TIMEDOUT;
if (sem_trywait(&sem->sem) == 0) {
@@ -103,24 +103,24 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
#ifdef HAVE_CLOCK_GETTIME
clock_gettime(CLOCK_REALTIME, &ts_timeout);
/* Add our timeout to current time */
// Add our timeout to current time
ts_timeout.tv_sec += (timeoutNS / SDL_NS_PER_SECOND);
ts_timeout.tv_nsec += (timeoutNS % SDL_NS_PER_SECOND);
#else
gettimeofday(&now, NULL);
/* Add our timeout to current time */
// Add our timeout to current time
ts_timeout.tv_sec = now.tv_sec + (timeoutNS / SDL_NS_PER_SECOND);
ts_timeout.tv_nsec = SDL_US_TO_NS(now.tv_usec) + (timeoutNS % SDL_NS_PER_SECOND);
#endif
/* Wrap the second if needed */
// Wrap the second if needed
while (ts_timeout.tv_nsec >= 1000000000) {
ts_timeout.tv_sec += 1;
ts_timeout.tv_nsec -= 1000000000;
}
/* Wait. */
// Wait.
do {
retval = sem_timedwait(&sem->sem, &ts_timeout);
} while (retval < 0 && errno == EINTR);
@@ -141,7 +141,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
}
SDL_DelayNS(100);
}
#endif /* HAVE_SEM_TIMEDWAIT */
#endif // HAVE_SEM_TIMEDWAIT
return retval;
}
@@ -177,4 +177,4 @@ int SDL_SignalSemaphore(SDL_Semaphore *sem)
return retval;
}
#endif /* SDL_PLATFORM_MACOS */
#endif // SDL_PLATFORM_MACOS

View File

@@ -36,7 +36,7 @@
#include <unistd.h>
#include "../../core/linux/SDL_dbus.h"
#endif /* SDL_PLATFORM_LINUX */
#endif // SDL_PLATFORM_LINUX
#if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN)
#include <dlfcn.h>
@@ -55,7 +55,7 @@
#include <kernel/OS.h>
#endif
/* List of signals to mask in the subthreads */
// List of signals to mask in the subthreads
static const int sig_list[] = {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
SIGVTALRM, SIGPROF, 0
@@ -83,7 +83,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread,
{
pthread_attr_t type;
/* do this here before any threads exist, so there's no race condition. */
// do this here before any threads exist, so there's no race condition.
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN)
if (!checked_setname) {
void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np");
@@ -96,18 +96,18 @@ int SDL_SYS_CreateThread(SDL_Thread *thread,
}
#endif
/* Set the thread attributes */
// Set the thread attributes
if (pthread_attr_init(&type) != 0) {
return SDL_SetError("Couldn't initialize pthread attributes");
}
pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
/* Set caller-requested stack size. Otherwise: use the system default. */
// Set caller-requested stack size. Otherwise: use the system default.
if (thread->stacksize) {
pthread_attr_setstacksize(&type, thread->stacksize);
}
/* Create the thread and go! */
// Create the thread and go!
if (pthread_create(&thread->handle, &type, RunThread, thread) != 0) {
return SDL_SetError("Not enough resources to create thread");
}
@@ -128,7 +128,7 @@ void SDL_SYS_SetupThread(const char *name)
ppthread_setname_np(name);
#elif defined(SDL_PLATFORM_LINUX)
if (ppthread_setname_np(pthread_self(), name) == ERANGE) {
char namebuf[16]; /* Limited to 16 char */
char namebuf[16]; // Limited to 16 char
SDL_strlcpy(namebuf, name, sizeof(namebuf));
ppthread_setname_np(pthread_self(), namebuf);
}
@@ -139,7 +139,7 @@ void SDL_SYS_SetupThread(const char *name)
pthread_setname_np(pthread_self(), "%s", name);
#else
if (pthread_setname_np(pthread_self(), name) == ERANGE) {
char namebuf[16]; /* Limited to 16 char */
char namebuf[16]; // Limited to 16 char
SDL_strlcpy(namebuf, name, sizeof(namebuf));
pthread_setname_np(pthread_self(), namebuf);
}
@@ -147,14 +147,14 @@ void SDL_SYS_SetupThread(const char *name)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(pthread_self(), name);
#elif defined(SDL_PLATFORM_HAIKU)
/* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */
// The docs say the thread name can't be longer than B_OS_NAME_LENGTH.
char namebuf[B_OS_NAME_LENGTH];
SDL_strlcpy(namebuf, name, sizeof(namebuf));
rename_thread(find_thread(NULL), namebuf);
#endif
}
/* Mask asynchronous signals for this thread */
// Mask asynchronous signals for this thread
sigemptyset(&mask);
for (i = 0; sig_list[i]; ++i) {
sigaddset(&mask, sig_list[i]);
@@ -162,7 +162,7 @@ void SDL_SYS_SetupThread(const char *name)
pthread_sigmask(SIG_BLOCK, &mask, 0);
#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
/* Allow ourselves to be asynchronously cancelled */
// Allow ourselves to be asynchronously cancelled
{
int oldstate;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
@@ -178,7 +178,7 @@ SDL_ThreadID SDL_GetCurrentThreadID(void)
int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
#ifdef SDL_PLATFORM_RISCOS
/* FIXME: Setting thread priority does not seem to be supported */
// FIXME: Setting thread priority does not seem to be supported
return 0;
#else
struct sched_param sched;
@@ -203,7 +203,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
case SDL_THREAD_PRIORITY_HIGH:
case SDL_THREAD_PRIORITY_TIME_CRITICAL:
#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)
/* Apple requires SCHED_RR for high priority threads */
// Apple requires SCHED_RR for high priority threads
pri_policy = SCHED_RR;
break;
#else
@@ -221,7 +221,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
if (policyhint) {
if (SDL_strcmp(policyhint, "current") == 0) {
/* Leave current thread scheduler policy unchanged */
// Leave current thread scheduler policy unchanged
} else if (SDL_strcmp(policyhint, "other") == 0) {
policy = SCHED_OTHER;
} else if (SDL_strcmp(policyhint, "rr") == 0) {
@@ -251,14 +251,14 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)
if (min_priority == 15 && max_priority == 47) {
/* Apple has a specific set of thread priorities */
// Apple has a specific set of thread priorities
if (priority == SDL_THREAD_PRIORITY_HIGH) {
sched.sched_priority = 45;
} else {
sched.sched_priority = 37;
}
} else
#endif /* SDL_PLATFORM_MACOS || SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS */
#endif // SDL_PLATFORM_MACOS || SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS
{
sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
if (priority == SDL_THREAD_PRIORITY_HIGH) {
@@ -270,8 +270,8 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
return SDL_SetError("pthread_setschedparam() failed");
}
return 0;
#endif /* linux */
#endif /* #if SDL_PLATFORM_RISCOS */
#endif // linux
#endif // #if SDL_PLATFORM_RISCOS
}
void SDL_SYS_WaitThread(SDL_Thread *thread)