From d0c4849d0bdb023ec014999ec4dd1db3320a8eb4 Mon Sep 17 00:00:00 2001 From: David Demelier Date: Thu, 23 Feb 2023 20:33:51 +0100 Subject: [PATCH] Rename SDL_atomic_t to SDL_AtomicInt --- build-scripts/SDL_migration.cocci | 4 ++++ docs/README-migration.md | 6 ++++- include/SDL3/SDL_atomic.h | 18 +++++++------- include/SDL3/SDL_oldnames.h | 3 +++ src/atomic/SDL_atomic.c | 8 +++---- src/audio/SDL_sysaudio.h | 6 ++--- src/audio/alsa/SDL_alsa_audio.c | 2 +- src/audio/coreaudio/SDL_coreaudio.h | 2 +- src/audio/wasapi/SDL_wasapi.h | 4 ++-- src/audio/wasapi/SDL_wasapi_winrt.cpp | 4 ++-- src/core/android/SDL_android.c | 4 ++-- src/core/windows/SDL_immdevice.c | 6 ++--- src/core/windows/SDL_immdevice.h | 4 ++-- src/dynapi/SDL_dynapi_procs.h | 8 +++---- src/events/SDL_events.c | 4 ++-- src/haptic/windows/SDL_windowshaptic_c.h | 2 +- src/joystick/SDL_joystick.c | 2 +- src/joystick/hidapi/SDL_hidapi_rumble.c | 4 ++-- src/joystick/hidapi/SDL_hidapijoystick_c.h | 2 +- src/joystick/windows/SDL_rawinputjoystick.c | 2 +- .../windows/SDL_windows_gaming_input.c | 2 +- src/sensor/SDL_sensor.c | 2 +- src/stdlib/SDL_malloc.c | 2 +- src/thread/SDL_thread.c | 2 +- src/thread/SDL_thread_c.h | 2 +- src/timer/SDL_timer.c | 6 ++--- src/video/SDL_video.c | 2 +- src/video/cocoa/SDL_cocoaopengl.h | 6 ++--- src/video/wayland/SDL_waylandwindow.h | 2 +- test/testatomic.c | 24 +++++++++---------- test/testlock.c | 2 +- test/testmultiaudio.c | 2 +- test/torturethread.c | 2 +- 33 files changed, 81 insertions(+), 70 deletions(-) diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index cfbdf9bd6..2fa9e20b5 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -2529,3 +2529,7 @@ constant c1, c2; @@ - SDL_CreateShapedWindow(e1, c1, c2, e2, e3, e4) + SDL_CreateShapedWindow(e1, e2, e3, e4) +typedef SDL_atomic_t, SDL_AtomicInt; +@@ +- SDL_atomic_t ++ SDL_AtomicInt diff --git a/docs/README-migration.md b/docs/README-migration.md index b6f51e996..24bf248cb 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -46,6 +46,11 @@ begin_code.h and close_code.h in the public headers have been renamed to SDL_beg The vi format comments have been removed from source code. Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style. +## SDL_atomic.h + +The following structures have been renamed: +- SDL_atomic_t => SDL_AtomicInt + ## SDL_audio.h SDL_AudioInit() and SDL_AudioQuit() have been removed. Instead you can call SDL_InitSubSytem() and SDL_QuitSubSytem() with SDL_INIT_AUDIO, which will properly refcount the subsystems. You can choose a specific audio driver using SDL_AUDIO_DRIVER hint. @@ -1115,4 +1120,3 @@ SDL_Vulkan_GetInstanceExtensions() no longer takes a window parameter. SDL_Vulkan_GetVkGetInstanceProcAddr() now returns `SDL_FunctionPointer` instead of `void *`, and should be cast to PFN_vkGetInstanceProcAddr. SDL_Vulkan_GetDrawableSize() has been removed. SDL_GetWindowSizeInPixels() can be used in its place. - diff --git a/include/SDL3/SDL_atomic.h b/include/SDL3/SDL_atomic.h index 746bdc957..8c99ece2d 100644 --- a/include/SDL3/SDL_atomic.h +++ b/include/SDL3/SDL_atomic.h @@ -266,7 +266,7 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); * \brief A type representing an atomic integer value. It is a struct * so people don't accidentally use numeric operations on it. */ -typedef struct { int value; } SDL_atomic_t; +typedef struct { int value; } SDL_AtomicInt; /** * Set an atomic variable to a new value if it is currently an old value. @@ -274,7 +274,7 @@ typedef struct { int value; } SDL_atomic_t; * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * - * \param a a pointer to an SDL_atomic_t variable to be modified + * \param a a pointer to an SDL_AtomicInt variable to be modified * \param oldval the old value * \param newval the new value * \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. @@ -285,7 +285,7 @@ typedef struct { int value; } SDL_atomic_t; * \sa SDL_AtomicGet * \sa SDL_AtomicSet */ -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_AtomicInt *a, int oldval, int newval); /** * Set an atomic variable to a value. @@ -295,7 +295,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * - * \param a a pointer to an SDL_atomic_t variable to be modified + * \param a a pointer to an SDL_AtomicInt variable to be modified * \param v the desired value * \returns the previous value of the atomic variable. * @@ -303,7 +303,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int * * \sa SDL_AtomicGet */ -extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); +extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_AtomicInt *a, int v); /** * Get the value of an atomic variable. @@ -311,14 +311,14 @@ extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * - * \param a a pointer to an SDL_atomic_t variable + * \param a a pointer to an SDL_AtomicInt variable * \returns the current value of an atomic variable. * * \since This function is available since SDL 3.0.0. * * \sa SDL_AtomicSet */ -extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); +extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_AtomicInt *a); /** * Add to an atomic variable. @@ -328,7 +328,7 @@ extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * - * \param a a pointer to an SDL_atomic_t variable to be modified + * \param a a pointer to an SDL_AtomicInt variable to be modified * \param v the desired value to add * \returns the previous value of the atomic variable. * @@ -337,7 +337,7 @@ extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); * \sa SDL_AtomicDecRef * \sa SDL_AtomicIncRef */ -extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); +extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_AtomicInt *a, int v); /** * \brief Increment an atomic variable used as a reference count. diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index 5676ddce8..38037e621 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -39,6 +39,9 @@ */ #ifdef SDL_ENABLE_OLD_NAMES +/* ##SDL_atomic.h */ +#define SDL_atomic_t SDL_AtomicInt + /* ##SDL_audio.h */ #define SDL_AudioStreamAvailable SDL_GetAudioStreamAvailable #define SDL_AudioStreamClear SDL_ClearAudioStream diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index 78e249ca3..0c8d91d0f 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -123,7 +123,7 @@ static SDL_INLINE void leaveLock(void *a) #endif SDL_bool -SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval) +SDL_AtomicCAS(SDL_AtomicInt *a, int oldval, int newval) { #ifdef HAVE_MSC_ATOMICS SDL_COMPILE_TIME_ASSERT(atomic_cas, sizeof(long) == sizeof(a->value)); @@ -183,7 +183,7 @@ SDL_AtomicCASPtr(void **a, void *oldval, void *newval) #endif } -int SDL_AtomicSet(SDL_atomic_t *a, int v) +int SDL_AtomicSet(SDL_AtomicInt *a, int v) { #ifdef HAVE_MSC_ATOMICS SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value)); @@ -223,7 +223,7 @@ SDL_AtomicSetPtr(void **a, void *v) #endif } -int SDL_AtomicAdd(SDL_atomic_t *a, int v) +int SDL_AtomicAdd(SDL_AtomicInt *a, int v) { #ifdef HAVE_MSC_ATOMICS SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value)); @@ -246,7 +246,7 @@ int SDL_AtomicAdd(SDL_atomic_t *a, int v) #endif } -int SDL_AtomicGet(SDL_atomic_t *a) +int SDL_AtomicGet(SDL_AtomicInt *a) { #ifdef HAVE_ATOMIC_LOAD_N return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST); diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 7d16ad38b..29e1d00c8 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -138,9 +138,9 @@ struct SDL_AudioDevice SDL_AudioStream *stream; /* Current state flags */ - SDL_atomic_t shutdown; /* true if we are signaling the play thread to end. */ - SDL_atomic_t enabled; /* true if device is functioning and connected. */ - SDL_atomic_t paused; + SDL_AtomicInt shutdown; /* true if we are signaling the play thread to end. */ + SDL_AtomicInt enabled; /* true if device is functioning and connected. */ + SDL_AtomicInt paused; SDL_bool iscapture; /* Scratch buffer used in the bridge between SDL and the user callback. */ diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index e25538cd4..6ff9f41cd 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -894,7 +894,7 @@ static void ALSA_HotplugIteration(void) } #if SDL_ALSA_HOTPLUG_THREAD -static SDL_atomic_t ALSA_hotplug_shutdown; +static SDL_AtomicInt ALSA_hotplug_shutdown; static SDL_Thread *ALSA_hotplug_thread; static int SDLCALL ALSA_HotplugThread(void *arg) diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h index 309d63010..bce6a429d 100644 --- a/src/audio/coreaudio/SDL_coreaudio.h +++ b/src/audio/coreaudio/SDL_coreaudio.h @@ -64,7 +64,7 @@ struct SDL_PrivateAudioData char *thread_error; #if MACOSX_COREAUDIO AudioDeviceID deviceID; - SDL_atomic_t device_change_flag; + SDL_AtomicInt device_change_flag; #else SDL_bool interrupted; CFTypeRef interruption_listener; diff --git a/src/audio/wasapi/SDL_wasapi.h b/src/audio/wasapi/SDL_wasapi.h index 1ef97c156..ae50e8448 100644 --- a/src/audio/wasapi/SDL_wasapi.h +++ b/src/audio/wasapi/SDL_wasapi.h @@ -38,7 +38,7 @@ extern "C" { struct SDL_PrivateAudioData { - SDL_atomic_t refcount; + SDL_AtomicInt refcount; WCHAR *devid; WAVEFORMATEX *waveformat; IAudioClient *client; @@ -52,7 +52,7 @@ struct SDL_PrivateAudioData int default_device_generation; SDL_bool device_lost; void *activation_handler; - SDL_atomic_t just_activated; + SDL_AtomicInt just_activated; }; /* win32 and winrt implementations call into these. */ diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp index eea018727..556bcd34c 100644 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -56,8 +56,8 @@ static Platform::String ^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4 static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid); static void WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid); extern "C" { -SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; -SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; +SDL_AtomicInt SDL_IMMDevice_DefaultPlaybackGeneration; +SDL_AtomicInt SDL_IMMDevice_DefaultCaptureGeneration; } /* This is a list of device id strings we have inflight, so we have consistent pointers to the same device. */ diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 2508f4331..ceab5054a 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -366,7 +366,7 @@ static SDL_bool bHasNewData; static SDL_bool bHasEnvironmentVariables; -static SDL_atomic_t bPermissionRequestPending; +static SDL_AtomicInt bPermissionRequestPending; static SDL_bool bPermissionRequestResult; /* Android AssetManager */ @@ -1359,7 +1359,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( Functions called by SDL into Java *******************************************************************************/ -static SDL_atomic_t s_active; +static SDL_AtomicInt s_active; struct LocalReferenceHolder { JNIEnv *m_env; diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index 683f99ce6..df0a5d0f9 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -52,8 +52,8 @@ static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x /* *INDENT-ON* */ /* clang-format on */ /* these increment as default devices change. Opened default devices pick up changes in their threads. */ -SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; -SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; +SDL_AtomicInt SDL_IMMDevice_DefaultPlaybackGeneration; +SDL_AtomicInt SDL_IMMDevice_DefaultCaptureGeneration; static void GetMMDeviceInfo(IMMDevice *device, char **utf8dev, WAVEFORMATEXTENSIBLE *fmt, GUID *guid) { @@ -180,7 +180,7 @@ static void SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAV typedef struct SDLMMNotificationClient { const IMMNotificationClientVtbl *lpVtbl; - SDL_atomic_t refcount; + SDL_AtomicInt refcount; SDL_bool useguid; } SDLMMNotificationClient; diff --git a/src/core/windows/SDL_immdevice.h b/src/core/windows/SDL_immdevice.h index cfab4a520..c97402fda 100644 --- a/src/core/windows/SDL_immdevice.h +++ b/src/core/windows/SDL_immdevice.h @@ -35,7 +35,7 @@ int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int isca SDL_AudioFormat WaveFormatToSDLFormat(WAVEFORMATEX *waveformat); /* these increment as default devices change. Opened default devices pick up changes in their threads. */ -extern SDL_atomic_t SDL_IMMDevice_DefaultPlaybackGeneration; -extern SDL_atomic_t SDL_IMMDevice_DefaultCaptureGeneration; +extern SDL_AtomicInt SDL_IMMDevice_DefaultPlaybackGeneration; +extern SDL_AtomicInt SDL_IMMDevice_DefaultCaptureGeneration; #endif /* SDL_IMMDEVICE_H */ diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 94d61004d..8b95da73f 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -122,13 +122,13 @@ SDL_DYNAPI_PROC(int,SDL_AddGamepadMappingsFromRW,(SDL_RWops *a, int b),(a,b),ret SDL_DYNAPI_PROC(int,SDL_AddHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimer,(Uint32 a, SDL_TimerCallback b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_RWops*,SDL_CreateRW,(void),(),return) -SDL_DYNAPI_PROC(int,SDL_AtomicAdd,(SDL_atomic_t *a, int b),(a,b),return) -SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCAS,(SDL_atomic_t *a, int b, int c),(a,b,c),return) +SDL_DYNAPI_PROC(int,SDL_AtomicAdd,(SDL_AtomicInt *a, int b),(a,b),return) +SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCAS,(SDL_AtomicInt *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCASPtr,(void **a, void *b, void *c),(a,b,c),return) -SDL_DYNAPI_PROC(int,SDL_AtomicGet,(SDL_atomic_t *a),(a),return) +SDL_DYNAPI_PROC(int,SDL_AtomicGet,(SDL_AtomicInt *a),(a),return) SDL_DYNAPI_PROC(void*,SDL_AtomicGetPtr,(void **a),(a),return) SDL_DYNAPI_PROC(void,SDL_AtomicLock,(SDL_SpinLock *a),(a),) -SDL_DYNAPI_PROC(int,SDL_AtomicSet,(SDL_atomic_t *a, int b),(a,b),return) +SDL_DYNAPI_PROC(int,SDL_AtomicSet,(SDL_AtomicInt *a, int b),(a,b),return) SDL_DYNAPI_PROC(void*,SDL_AtomicSetPtr,(void **a, void *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicTryLock,(SDL_SpinLock *a),(a),return) SDL_DYNAPI_PROC(void,SDL_AtomicUnlock,(SDL_SpinLock *a),(a),) diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 772173e8e..47dc13985 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -60,7 +60,7 @@ static SDL_EventWatcher *SDL_event_watchers = NULL; static int SDL_event_watchers_count = 0; static SDL_bool SDL_event_watchers_dispatching = SDL_FALSE; static SDL_bool SDL_event_watchers_removed = SDL_FALSE; -static SDL_atomic_t SDL_sentinel_pending; +static SDL_AtomicInt SDL_sentinel_pending; typedef struct { @@ -89,7 +89,7 @@ static struct { SDL_mutex *lock; SDL_bool active; - SDL_atomic_t count; + SDL_AtomicInt count; int max_events_seen; SDL_EventEntry *head; SDL_EventEntry *tail; diff --git a/src/haptic/windows/SDL_windowshaptic_c.h b/src/haptic/windows/SDL_windowshaptic_c.h index 6be64a7dc..0d93479cf 100644 --- a/src/haptic/windows/SDL_windowshaptic_c.h +++ b/src/haptic/windows/SDL_windowshaptic_c.h @@ -47,7 +47,7 @@ struct haptic_hwdata SDL_Thread *thread; SDL_mutex *mutex; Uint64 stopTicks; - SDL_atomic_t stopThread; + SDL_AtomicInt stopThread; }; /* diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 49ff93432..88dca2ebf 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -113,7 +113,7 @@ static int SDL_joysticks_locked; static SDL_bool SDL_joysticks_initialized; static SDL_bool SDL_joysticks_quitting = SDL_FALSE; static SDL_Joystick *SDL_joysticks SDL_GUARDED_BY(SDL_joystick_lock) = NULL; -static SDL_atomic_t SDL_last_joystick_instance_id SDL_GUARDED_BY(SDL_joystick_lock); +static SDL_AtomicInt SDL_last_joystick_instance_id SDL_GUARDED_BY(SDL_joystick_lock); static int SDL_joystick_player_count SDL_GUARDED_BY(SDL_joystick_lock) = 0; static SDL_JoystickID *SDL_joystick_players SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE; diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index adc22d27c..fc01a029a 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -41,8 +41,8 @@ typedef struct SDL_HIDAPI_RumbleRequest typedef struct SDL_HIDAPI_RumbleContext { - SDL_atomic_t initialized; - SDL_atomic_t running; + SDL_AtomicInt initialized; + SDL_AtomicInt running; SDL_Thread *thread; SDL_sem *request_sem; SDL_HIDAPI_RumbleRequest *requests_head; diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h index e5c59c58a..913e8a61a 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -71,7 +71,7 @@ typedef struct SDL_HIDAPI_Device void *context; SDL_mutex *dev_lock; SDL_hid_device *dev; - SDL_atomic_t rumble_pending; + SDL_AtomicInt rumble_pending; int num_joysticks; SDL_JoystickID *joysticks; diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 8a988f322..08333c223 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -95,7 +95,7 @@ static void RAWINPUT_JoystickClose(SDL_Joystick *joystick); typedef struct SDL_RAWINPUT_Device { - SDL_atomic_t refcount; + SDL_AtomicInt refcount; char *name; char *path; Uint16 vendor_id; diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index f5abd9540..92a463c5b 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -208,7 +208,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) typedef struct RawGameControllerDelegate { __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController iface; - SDL_atomic_t refcount; + SDL_AtomicInt refcount; } RawGameControllerDelegate; static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, REFIID riid, void **ppvObject) diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index 31391b40e..68e33523d 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -50,7 +50,7 @@ static SDL_SensorDriver *SDL_sensor_drivers[] = { }; static SDL_mutex *SDL_sensor_lock = NULL; /* This needs to support recursive locks */ static SDL_Sensor *SDL_sensors SDL_GUARDED_BY(SDL_sensor_lock) = NULL; -static SDL_atomic_t SDL_last_sensor_instance_id SDL_GUARDED_BY(SDL_sensor_lock); +static SDL_AtomicInt SDL_last_sensor_instance_id SDL_GUARDED_BY(SDL_sensor_lock); void SDL_LockSensors(void) SDL_ACQUIRE(SDL_sensor_lock) { diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index eec78fdbf..8fcdb5a51 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -5203,7 +5203,7 @@ static struct SDL_calloc_func calloc_func; SDL_realloc_func realloc_func; SDL_free_func free_func; - SDL_atomic_t num_allocations; + SDL_AtomicInt num_allocations; } s_mem = { real_malloc, real_calloc, real_realloc, real_free, { 0 } }; diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 7dbc1bcb0..0fa11f024 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -29,7 +29,7 @@ SDL_TLSID SDL_TLSCreate(void) { - static SDL_atomic_t SDL_tls_id; + static SDL_AtomicInt SDL_tls_id; return SDL_AtomicIncRef(&SDL_tls_id) + 1; } diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 03b4aec23..601e1a5b4 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -62,7 +62,7 @@ struct SDL_Thread SDL_threadID threadid; SYS_ThreadHandle handle; int status; - SDL_atomic_t state; /* SDL_THREAD_STATE_* */ + SDL_AtomicInt state; /* SDL_THREAD_STATE_* */ SDL_error errbuf; char *name; size_t stacksize; /* 0 for default, >0 for user-specified stack size. */ diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 3729fff67..6b7c8d5cf 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -34,7 +34,7 @@ typedef struct SDL_Timer void *param; Uint64 interval; Uint64 scheduled; - SDL_atomic_t canceled; + SDL_AtomicInt canceled; struct SDL_Timer *next; } SDL_Timer; @@ -50,7 +50,7 @@ typedef struct { /* Data used by the main thread */ SDL_Thread *thread; - SDL_atomic_t nextID; + SDL_AtomicInt nextID; SDL_TimerMap *timermap; SDL_mutex *timermap_lock; @@ -62,7 +62,7 @@ typedef struct SDL_sem *sem; SDL_Timer *pending; SDL_Timer *freelist; - SDL_atomic_t active; + SDL_AtomicInt active; /* List of timers - this is only touched by the timer thread */ SDL_Timer *timers; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index ccb51f11d..9f36c5644 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -310,7 +310,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U } static SDL_VideoDevice *_this = NULL; -static SDL_atomic_t SDL_messagebox_count; +static SDL_AtomicInt SDL_messagebox_count; static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects) { diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h index 20c5eadd5..3aba3d584 100644 --- a/src/video/cocoa/SDL_cocoaopengl.h +++ b/src/video/cocoa/SDL_cocoaopengl.h @@ -41,7 +41,7 @@ struct SDL_GLDriverData @interface SDLOpenGLContext : NSOpenGLContext { - SDL_atomic_t dirty; + SDL_AtomicInt dirty; SDL_Window *window; CVDisplayLinkRef displayLink; @public @@ -49,9 +49,9 @@ struct SDL_GLDriverData @public SDL_cond *swapIntervalCond; @public - SDL_atomic_t swapIntervalSetting; + SDL_AtomicInt swapIntervalSetting; @public - SDL_atomic_t swapIntervalsPassed; + SDL_AtomicInt swapIntervalsPassed; } - (id)initWithFormat:(NSOpenGLPixelFormat *)format diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index 9a7cc1321..4b420f88f 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -94,7 +94,7 @@ struct SDL_WindowData /* floating dimensions for restoring from maximized and fullscreen */ int floating_width, floating_height; - SDL_atomic_t swap_interval_ready; + SDL_AtomicInt swap_interval_ready; #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH struct qt_extended_surface *extended_surface; diff --git a/test/testatomic.c b/test/testatomic.c index da41d02f0..776c7dd16 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -36,7 +36,7 @@ static void RunBasicTest(void) int value; SDL_SpinLock lock = 0; - SDL_atomic_t v; + SDL_AtomicInt v; SDL_bool tfret = SDL_FALSE; SDL_Log("\nspin lock---------------------------------------\n\n"); @@ -106,9 +106,9 @@ enum }; SDL_COMPILE_TIME_ASSERT(size, CountTo_GreaterThanZero); /* check for rollover */ -static SDL_atomic_t good = { 42 }; +static SDL_AtomicInt good = { 42 }; static atomicValue bad = 42; -static SDL_atomic_t threadsRunning; +static SDL_AtomicInt threadsRunning; static SDL_sem *threadDone; static int SDLCALL adder(void *junk) @@ -255,7 +255,7 @@ static void RunEpicTest(void) typedef struct { - SDL_atomic_t sequence; + SDL_AtomicInt sequence; SDL_Event event; } SDL_EventQueueEntry; @@ -265,23 +265,23 @@ typedef struct char cache_pad1[SDL_CACHELINE_SIZE - ((sizeof(SDL_EventQueueEntry) * MAX_ENTRIES) % SDL_CACHELINE_SIZE)]; - SDL_atomic_t enqueue_pos; + SDL_AtomicInt enqueue_pos; - char cache_pad2[SDL_CACHELINE_SIZE - sizeof(SDL_atomic_t)]; + char cache_pad2[SDL_CACHELINE_SIZE - sizeof(SDL_AtomicInt)]; - SDL_atomic_t dequeue_pos; + SDL_AtomicInt dequeue_pos; - char cache_pad3[SDL_CACHELINE_SIZE - sizeof(SDL_atomic_t)]; + char cache_pad3[SDL_CACHELINE_SIZE - sizeof(SDL_AtomicInt)]; #ifdef TEST_SPINLOCK_FIFO SDL_SpinLock lock; - SDL_atomic_t rwcount; - SDL_atomic_t watcher; + SDL_AtomicInt rwcount; + SDL_AtomicInt watcher; - char cache_pad4[SDL_CACHELINE_SIZE - sizeof(SDL_SpinLock) - 2 * sizeof(SDL_atomic_t)]; + char cache_pad4[SDL_CACHELINE_SIZE - sizeof(SDL_SpinLock) - 2 * sizeof(SDL_AtomicInt)]; #endif - SDL_atomic_t active; + SDL_AtomicInt active; /* Only needed for the mutex test */ SDL_mutex *mutex; diff --git a/test/testlock.c b/test/testlock.c index a14d7f64a..fcb790e8a 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -23,7 +23,7 @@ static SDL_mutex *mutex = NULL; static SDL_threadID mainthread; static SDL_Thread *threads[6]; -static SDL_atomic_t doterminate; +static SDL_AtomicInt doterminate; /** * SDL_Quit() shouldn't be used with atexit() directly because diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index a80c6e724..c418852e2 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -28,7 +28,7 @@ typedef struct { SDL_AudioDeviceID dev; int soundpos; - SDL_atomic_t done; + SDL_AtomicInt done; } callback_data; static callback_data cbd[64]; diff --git a/test/torturethread.c b/test/torturethread.c index 7dd441180..22a86816c 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -20,7 +20,7 @@ #define NUMTHREADS 10 -static SDL_atomic_t time_for_threads_to_die[NUMTHREADS]; +static SDL_AtomicInt time_for_threads_to_die[NUMTHREADS]; /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void