From 973c8b3273820f9421d85292911809f319d19964 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 10 Oct 2023 12:38:22 -0700 Subject: [PATCH] Added SDL properties API Fixes https://github.com/libsdl-org/SDL/issues/7799 --- VisualC-GDK/SDL/SDL.vcxproj | 6 +- VisualC-GDK/SDL/SDL.vcxproj.filters | 5 + VisualC-WinRT/SDL-UWP.vcxproj | 3 + VisualC-WinRT/SDL-UWP.vcxproj.filters | 26 +- VisualC/SDL/SDL.vcxproj | 9 +- VisualC/SDL/SDL.vcxproj.filters | 5 + .../testautomation/testautomation.vcxproj | 1 + Xcode/SDL/SDL.xcodeproj/project.pbxproj | 29 +- include/SDL3/SDL.h | 1 + include/SDL3/SDL_properties.h | 133 +++++++++ src/SDL.c | 3 + src/SDL_hashtable.c | 40 ++- src/SDL_hashtable.h | 11 +- src/SDL_properties.c | 278 ++++++++++++++++++ src/SDL_properties_c.h | 23 ++ src/dynapi/SDL_dynapi.sym | 6 + src/dynapi/SDL_dynapi_overrides.h | 6 + src/dynapi/SDL_dynapi_procs.h | 6 + test/testautomation.c | 1 + test/testautomation_properties.c | 190 ++++++++++++ test/testautomation_suites.h | 1 + 21 files changed, 746 insertions(+), 37 deletions(-) create mode 100644 include/SDL3/SDL_properties.h create mode 100644 src/SDL_properties.c create mode 100644 src/SDL_properties_c.h create mode 100644 test/testautomation_properties.c diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj index d222f42cd..7df28485f 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj +++ b/VisualC-GDK/SDL/SDL.vcxproj @@ -473,6 +473,7 @@ + @@ -541,9 +542,6 @@ - - - @@ -714,8 +712,10 @@ + + diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters index 683d6b4f3..19b7eb904 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj.filters +++ b/VisualC-GDK/SDL/SDL.vcxproj.filters @@ -306,6 +306,9 @@ API Headers + + API Headers + API Headers @@ -823,6 +826,7 @@ + render\direct3d12 @@ -849,6 +853,7 @@ + audio diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj index 863b0e3e3..c911765b9 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj +++ b/VisualC-WinRT/SDL-UWP.vcxproj @@ -71,6 +71,7 @@ + @@ -156,6 +157,7 @@ + @@ -398,6 +400,7 @@ + diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters index a1c99a51e..7b90f411f 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj.filters +++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters @@ -324,7 +324,9 @@ Source Files - + + Source Files + Source Files @@ -334,6 +336,9 @@ Source Files + + Source Files + Source Files @@ -640,13 +645,24 @@ Source Files - + + Source Files + Source Files + + Source Files + Source Files + + Source Files + + + Source Files + Source Files @@ -797,12 +813,6 @@ Source Files - - Source Files - - - Source Files - Source Files diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj index 31263605c..f4d4dc002 100644 --- a/VisualC/SDL/SDL.vcxproj +++ b/VisualC/SDL/SDL.vcxproj @@ -283,6 +283,7 @@ + @@ -400,6 +401,7 @@ + @@ -467,9 +469,6 @@ - - - @@ -590,10 +589,12 @@ - + + + diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters index df44db6b2..f72de3a0a 100644 --- a/VisualC/SDL/SDL.vcxproj.filters +++ b/VisualC/SDL/SDL.vcxproj.filters @@ -300,6 +300,9 @@ API Headers + + API Headers + API Headers @@ -814,6 +817,7 @@ + render\direct3d12 @@ -828,6 +832,7 @@ + audio diff --git a/VisualC/tests/testautomation/testautomation.vcxproj b/VisualC/tests/testautomation/testautomation.vcxproj index 2cae2109f..fd1f86c9b 100644 --- a/VisualC/tests/testautomation/testautomation.vcxproj +++ b/VisualC/tests/testautomation/testautomation.vcxproj @@ -211,6 +211,7 @@ + diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 2ed36dcb0..cc082179e 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 000040E76FDC6AE48CBF0000 /* SDL_hashtable.c in Sources */ = {isa = PBXBuildFile; fileRef = 000078E1881E857EBB6C0000 /* SDL_hashtable.c */; }; 007317A40858DECD00B2BC32 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0073179D0858DECD00B2BC32 /* Cocoa.framework */; platformFilters = (macos, ); }; 007317A60858DECD00B2BC32 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0073179F0858DECD00B2BC32 /* IOKit.framework */; platformFilters = (ios, maccatalyst, macos, ); }; 00CFA89D106B4BA100758660 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CFA89C106B4BA100758660 /* ForceFeedback.framework */; platformFilters = (macos, ); }; @@ -405,6 +406,8 @@ F3B38CDB296E2E52005DA6D3 /* SDL_oldnames.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B38CCD296E2E52005DA6D3 /* SDL_oldnames.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3B38CDF296E2E52005DA6D3 /* SDL_intrin.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B38CCE296E2E52005DA6D3 /* SDL_intrin.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3D60A8328C16A1900788A3A /* SDL_hidapi_wii.c in Sources */ = {isa = PBXBuildFile; fileRef = F3D60A8228C16A1800788A3A /* SDL_hidapi_wii.c */; }; + F3E5A6EB2AD5E0E600293D83 /* SDL_properties.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E5A6EA2AD5E0E600293D83 /* SDL_properties.c */; }; + F3E5A6ED2AD5E10800293D83 /* SDL_properties.h in Headers */ = {isa = PBXBuildFile; fileRef = F3E5A6EC2AD5E10800293D83 /* SDL_properties.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F07D5A269640160074468B /* SDL_hidapi_luna.c in Sources */ = {isa = PBXBuildFile; fileRef = F3F07D59269640160074468B /* SDL_hidapi_luna.c */; }; F3F7D8ED2933074E00816151 /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8AA2933074900816151 /* SDL_audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F7D8F12933074E00816151 /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8AB2933074900816151 /* SDL_platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -469,8 +472,6 @@ F3F7D9E12933074E00816151 /* SDL_begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8E72933074E00816151 /* SDL_begin_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F7D9E52933074E00816151 /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8E82933074E00816151 /* SDL_system.h */; settings = {ATTRIBUTES = (Public, ); }; }; FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; platformFilters = (ios, maccatalyst, macos, tvos, watchos, ); }; - 000040E76FDC6AE48CBF0000 /* SDL_hashtable.c in Sources */ = {isa = PBXBuildFile; fileRef = 000078E1881E857EBB6C0000 /* SDL_hashtable.c */; }; - 0000CE8F0EF0E7EF781D0000 /* SDL_hashtable.h in Headers */ = {isa = PBXBuildFile; fileRef = 0000B6ADCD88CAD6610F0000 /* SDL_hashtable.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -497,6 +498,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 000078E1881E857EBB6C0000 /* SDL_hashtable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hashtable.c; sourceTree = ""; }; + 0000B6ADCD88CAD6610F0000 /* SDL_hashtable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_hashtable.h; sourceTree = ""; }; 0073179D0858DECD00B2BC32 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 0073179F0858DECD00B2BC32 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; 007317C10858E15000B2BC32 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; @@ -897,6 +900,8 @@ F3B38CCD296E2E52005DA6D3 /* SDL_oldnames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_oldnames.h; path = SDL3/SDL_oldnames.h; sourceTree = ""; }; F3B38CCE296E2E52005DA6D3 /* SDL_intrin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_intrin.h; path = SDL3/SDL_intrin.h; sourceTree = ""; }; F3D60A8228C16A1800788A3A /* SDL_hidapi_wii.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_wii.c; sourceTree = ""; }; + F3E5A6EA2AD5E0E600293D83 /* SDL_properties.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_properties.c; sourceTree = ""; }; + F3E5A6EC2AD5E10800293D83 /* SDL_properties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_properties.h; path = SDL3/SDL_properties.h; sourceTree = ""; }; F3F07D59269640160074468B /* SDL_hidapi_luna.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_luna.c; sourceTree = ""; }; F3F7D8AA2933074900816151 /* SDL_audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_audio.h; path = SDL3/SDL_audio.h; sourceTree = ""; }; F3F7D8AB2933074900816151 /* SDL_platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_platform.h; path = SDL3/SDL_platform.h; sourceTree = ""; }; @@ -964,8 +969,6 @@ F59C710600D5CB5801000001 /* SDL.info */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SDL.info; sourceTree = ""; }; F5A2EF3900C6A39A01000001 /* BUGS.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = BUGS.txt; path = ../../BUGS.txt; sourceTree = SOURCE_ROOT; }; FA73671C19A540EF004122E4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; - 000078E1881E857EBB6C0000 /* SDL_hashtable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_hashtable.c; path = SDL_hashtable.c; sourceTree = ""; }; - 0000B6ADCD88CAD6610F0000 /* SDL_hashtable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_hashtable.h; path = SDL_hashtable.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -994,7 +997,6 @@ 0153844A006D81B07F000001 /* Public Headers */ = { isa = PBXGroup; children = ( - F3F7D8CF2933074C00816151 /* SDL.h */, F3F7D8E02933074D00816151 /* SDL_assert.h */, F3F7D8B92933074A00816151 /* SDL_atomic.h */, F3F7D8AA2933074900816151 /* SDL_audio.h */, @@ -1023,26 +1025,27 @@ F3F7D8D92933074C00816151 /* SDL_loadso.h */, F3F7D8C42933074B00816151 /* SDL_locale.h */, F3F7D8B72933074A00816151 /* SDL_log.h */, - F3F7D8B02933074900816151 /* SDL_main.h */, F3B38CCA296E2E52005DA6D3 /* SDL_main_impl.h */, + F3F7D8B02933074900816151 /* SDL_main.h */, F3F7D8B62933074A00816151 /* SDL_messagebox.h */, F3F7D8D22933074C00816151 /* SDL_metal.h */, F3F7D8D52933074C00816151 /* SDL_misc.h */, F3F7D8DA2933074D00816151 /* SDL_mouse.h */, F3F7D8E62933074E00816151 /* SDL_mutex.h */, F3B38CCD296E2E52005DA6D3 /* SDL_oldnames.h */, - F3F7D8E12933074D00816151 /* SDL_opengl.h */, F3F7D8C02933074A00816151 /* SDL_opengl_glext.h */, + F3F7D8E12933074D00816151 /* SDL_opengl.h */, F3F7D8C62933074B00816151 /* SDL_opengles.h */, - F3F7D8C72933074B00816151 /* SDL_opengles2.h */, F3F7D8AE2933074900816151 /* SDL_opengles2_gl2.h */, F3F7D8BD2933074A00816151 /* SDL_opengles2_gl2ext.h */, F3F7D8C92933074B00816151 /* SDL_opengles2_gl2platform.h */, F3F7D8B12933074900816151 /* SDL_opengles2_khrplatform.h */, + F3F7D8C72933074B00816151 /* SDL_opengles2.h */, F3F7D8B52933074A00816151 /* SDL_pixels.h */, - F3F7D8AB2933074900816151 /* SDL_platform.h */, F3B38CCB296E2E52005DA6D3 /* SDL_platform_defines.h */, + F3F7D8AB2933074900816151 /* SDL_platform.h */, F3F7D8DB2933074D00816151 /* SDL_power.h */, + F3E5A6EC2AD5E10800293D83 /* SDL_properties.h */, F3F7D8DF2933074D00816151 /* SDL_quit.h */, F3F7D8E22933074D00816151 /* SDL_rect.h */, F3F7D8DE2933074D00816151 /* SDL_render.h */, @@ -1061,6 +1064,7 @@ F3F7D8E42933074D00816151 /* SDL_version.h */, F3F7D8C52933074B00816151 /* SDL_video.h */, F3F7D8D42933074C00816151 /* SDL_vulkan.h */, + F3F7D8CF2933074C00816151 /* SDL.h */, ); name = "Public Headers"; path = ../../include; @@ -1123,6 +1127,8 @@ A7D8A57523E2513D00DCD162 /* SDL_error_c.h */, A7D8A8BF23E2513F00DCD162 /* SDL_error.c */, F382071C284F362F004DD584 /* SDL_guid.c */, + 000078E1881E857EBB6C0000 /* SDL_hashtable.c */, + 0000B6ADCD88CAD6610F0000 /* SDL_hashtable.h */, A7D8A8D123E2514000DCD162 /* SDL_hints_c.h */, A7D8A5AB23E2513D00DCD162 /* SDL_hints.c */, A7D8A58323E2513D00DCD162 /* SDL_internal.h */, @@ -1130,11 +1136,10 @@ A1BB8B6227F6CF330057CFA8 /* SDL_list.h */, F386F6E42884663E001840AA /* SDL_log_c.h */, A7D8A5DD23E2513D00DCD162 /* SDL_log.c */, + F3E5A6EA2AD5E0E600293D83 /* SDL_properties.c */, F386F6E52884663E001840AA /* SDL_utils_c.h */, F386F6E62884663E001840AA /* SDL_utils.c */, A7D8A57123E2513D00DCD162 /* SDL.c */, - 000078E1881E857EBB6C0000 /* SDL_hashtable.c */, - 0000B6ADCD88CAD6610F0000 /* SDL_hashtable.h */, ); name = "Library Source"; path = ../../src; @@ -2156,6 +2161,7 @@ F3B38CDB296E2E52005DA6D3 /* SDL_oldnames.h in Headers */, F3F7D9C92933074E00816151 /* SDL_opengl.h in Headers */, F3F7D9452933074E00816151 /* SDL_opengl_glext.h in Headers */, + F3E5A6ED2AD5E10800293D83 /* SDL_properties.h in Headers */, F3F7D95D2933074E00816151 /* SDL_opengles.h in Headers */, F3F7D9612933074E00816151 /* SDL_opengles2.h in Headers */, F3F7D8FD2933074E00816151 /* SDL_opengles2_gl2.h in Headers */, @@ -2502,6 +2508,7 @@ A7D8BBD723E2574800DCD162 /* SDL_uikitevents.m in Sources */, A7D8B5F323E2514300DCD162 /* SDL_syspower.c in Sources */, A7D8B95023E2514400DCD162 /* SDL_iconv.c in Sources */, + F3E5A6EB2AD5E0E600293D83 /* SDL_properties.c in Sources */, A7D8BA9D23E2514400DCD162 /* s_fabs.c in Sources */, F395C1B12569C6A000942BFF /* SDL_mfijoystick.m in Sources */, A7D8B99223E2514400DCD162 /* SDL_shaders_metal.metal in Sources */, diff --git a/include/SDL3/SDL.h b/include/SDL3/SDL.h index cb51cd7ac..498f0520c 100644 --- a/include/SDL3/SDL.h +++ b/include/SDL3/SDL.h @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/include/SDL3/SDL_properties.h b/include/SDL3/SDL_properties.h new file mode 100644 index 000000000..13a881c0b --- /dev/null +++ b/include/SDL3/SDL_properties.h @@ -0,0 +1,133 @@ +/* + Simple DiretMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_properties.h + * + * \brief Header file for SDL properties. + */ + +#ifndef SDL_properties_h_ +#define SDL_properties_h_ + +#include +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * SDL properties ID + */ +typedef Uint32 SDL_PropertiesID; + +/** + * Create a set of properties + * + * \returns an ID for a new set of properties, or 0 on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_DestroyProperties + */ +extern DECLSPEC SDL_PropertiesID SDLCALL SDL_CreateProperties(void); + +/** + * Lock a set of properties + * + * Obtain a multi-threaded lock for these properties. Other threads will wait while trying to lock these properties until they are unlocked. Properties must be unlocked before they are destroyed. + * + * The lock is automatically taken when setting individual properties, this function is only needed when you want to set several properties atomically or want to guarantee that properties being queried aren't freed in another thread. + * + * \param props the properties to lock + * + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_UnlockProperties + */ +extern DECLSPEC int SDLCALL SDL_LockProperties(SDL_PropertiesID props); + +/** + * Unlock a set of properties + * + * \param props the properties to unlock + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_LockProperties + */ +extern DECLSPEC void SDLCALL SDL_UnlockProperties(SDL_PropertiesID props); + +/** + * Set a property on a set of properties + * + * \param props the properties to modify + * \param name the name of the property to modify + * \param value the new value of the property, or NULL to delete the property + * \param cleanup the function to call when this property is deleted, or NULL if no cleanup is necessary + * \param userdata a pointer that is passed to the cleanup function + * + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_GetProperty + */ +extern DECLSPEC int SDLCALL SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value, void (SDLCALL *cleanup)(void *userdata, void *value), void *userdata); + +/** + * Get a property on a set of properties + * + * \param props the properties to query + * \param name the name of the property to query + * + * \returns the value of the property, or NULL if it is not set. + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_SetProperty + */ +extern DECLSPEC void *SDLCALL SDL_GetProperty(SDL_PropertiesID props, const char *name); + +/** + * Destroy a set of properties + * + * All properties are deleted and their cleanup functions will be called, if any. The set of properties must be unlocked when it is destroyed. + * + * \param props the properties to destroy + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_CreateProperties + */ +extern DECLSPEC void SDLCALL SDL_DestroyProperties(SDL_PropertiesID props); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include + +#endif /* SDL_properties_h_ */ diff --git a/src/SDL.c b/src/SDL.c index f099b0482..31bd02ea4 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -38,6 +38,7 @@ #include "SDL_assert_c.h" #include "SDL_log_c.h" +#include "SDL_properties_c.h" #include "audio/SDL_audio_c.h" #include "video/SDL_video_c.h" #include "events/SDL_events_c.h" @@ -167,6 +168,7 @@ int SDL_InitSubSystem(Uint32 flags) } SDL_InitLog(); + SDL_InitProperties(); /* Clear the error message */ SDL_ClearError(); @@ -499,6 +501,7 @@ void SDL_Quit(void) SDL_DBus_Quit(); #endif + SDL_QuitProperties(); SDL_QuitLog(); /* Now that every subsystem has been quit, we reset the subsystem refcount diff --git a/src/SDL_hashtable.c b/src/SDL_hashtable.c index e4b301c54..a5fc0f09e 100644 --- a/src/SDL_hashtable.c +++ b/src/SDL_hashtable.c @@ -18,7 +18,6 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - #include "SDL_internal.h" #include "SDL_hashtable.h" @@ -209,6 +208,21 @@ SDL_bool SDL_IterateHashTableKeys(const SDL_HashTable *table, const void **_key, return SDL_TRUE; } +SDL_bool SDL_HashTableEmpty(SDL_HashTable *table) +{ + if (table != NULL) { + Uint32 i; + + for (i = 0; i < table->table_len; i++) { + SDL_HashItem *item = table->table[i]; + if (item != NULL) { + return SDL_FALSE; + } + } + } + return SDL_TRUE; +} + void SDL_DestroyHashTable(SDL_HashTable *table) { if (table != NULL) { @@ -240,10 +254,10 @@ static SDL_INLINE Uint32 hash_string_djbxor(const char *str, size_t len) return hash; } -Uint32 SDL_HashString(const void *sym, void *data) +Uint32 SDL_HashString(const void *key, void *data) { - const char *str = (const char*) sym; - return hash_string_djbxor(str, SDL_strlen((const char *) str)); + const char *str = (const char *)key; + return hash_string_djbxor(str, SDL_strlen(str)); } SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *data) @@ -253,7 +267,21 @@ SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *data) } else if (!a || !b) { return SDL_FALSE; /* one pointer is NULL (and first test shows they aren't the same pointer), must not match. */ } - return (SDL_strcmp((const char *) a, (const char *) b) == 0) ? SDL_TRUE : SDL_FALSE; /* Check against actual string contents. */ + return (SDL_strcmp((const char *)a, (const char *)b) == 0) ? SDL_TRUE : SDL_FALSE; /* Check against actual string contents. */ } -/* vi: set ts=4 sw=4 expandtab: */ +/* We assume we can fit the ID in the key directly */ +SDL_COMPILE_TIME_ASSERT(SDL_HashID_KeySize, sizeof(Uint32) <= sizeof(const void *)); + +Uint32 SDL_HashID(const void *key, void *unused) +{ + return (Uint32)(uintptr_t)key; +} + +SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused) +{ + if (a == b) { + return SDL_TRUE; + } + return SDL_FALSE; +} diff --git a/src/SDL_hashtable.h b/src/SDL_hashtable.h index cb03b0c1f..eb8d7ba3c 100644 --- a/src/SDL_hashtable.h +++ b/src/SDL_hashtable.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 1997-2023 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -40,14 +40,15 @@ void SDL_DestroyHashTable(SDL_HashTable *table); SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value); SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key); SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value); +SDL_bool SDL_HashTableEmpty(SDL_HashTable *table); SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void *key, const void **_value, void **iter); SDL_bool SDL_IterateHashTableKeys(const SDL_HashTable *table, const void **_key, void **iter); -Uint32 SDL_HashString(const void *sym, void *unused); +Uint32 SDL_HashString(const void *key, void *unused); SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *unused); +Uint32 SDL_HashID(const void *key, void *unused); +SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused); + #endif /* SDL_hashtable_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ - diff --git a/src/SDL_properties.c b/src/SDL_properties.c new file mode 100644 index 000000000..a83067501 --- /dev/null +++ b/src/SDL_properties.c @@ -0,0 +1,278 @@ +/* + Simple DiretMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" +#include "SDL_hashtable.h" +#include "SDL_properties_c.h" + + +typedef struct +{ + void *value; + void (SDLCALL *cleanup)(void *userdata, void *value); + void *userdata; +} SDL_Property; + +typedef struct +{ + SDL_HashTable *props; + SDL_Mutex *lock; +} SDL_Properties; + +static SDL_HashTable *SDL_properties; +static SDL_RWLock *SDL_properties_lock; +static SDL_PropertiesID SDL_last_properties_id; + + +static void SDL_FreeProperty(const void *key, const void *value, void *data) +{ + SDL_Property *property = (SDL_Property *)value; + if (property->cleanup) { + property->cleanup(property->userdata, property->value); + } + SDL_free((void *)key); + SDL_free((void *)value); +} + +static void SDL_FreeProperties(const void *key, const void *value, void *data) +{ + SDL_Properties *properties = (SDL_Properties *)value; + if (properties) { + if (properties->props) { + SDL_DestroyHashTable(properties->props); + properties->props = NULL; + } + if (properties->lock) { + SDL_DestroyMutex(properties->lock); + properties->lock = NULL; + } + SDL_free(properties); + } +} + +int SDL_InitProperties(void) +{ + if (!SDL_properties_lock) { + SDL_properties_lock = SDL_CreateRWLock(); + if (!SDL_properties_lock) { + return -1; + } + } + if (!SDL_properties) { + SDL_properties = SDL_CreateHashTable(NULL, 16, SDL_HashID, SDL_KeyMatchID, SDL_FreeProperties, SDL_FALSE); + if (!SDL_properties) { + return -1; + } + } + return 0; +} + +void SDL_QuitProperties(void) +{ + if (SDL_properties) { + SDL_DestroyHashTable(SDL_properties); + SDL_properties = NULL; + } + if (SDL_properties_lock) { + SDL_DestroyRWLock(SDL_properties_lock); + SDL_properties_lock = NULL; + } +} + +SDL_PropertiesID SDL_CreateProperties(void) +{ + SDL_PropertiesID props; + SDL_Properties *properties = NULL; + SDL_bool inserted = SDL_FALSE; + + if (!SDL_properties && SDL_InitProperties() < 0) { + return 0; + } + + properties = SDL_malloc(sizeof(*properties)); + if (!properties) { + goto error; + } + properties->props = SDL_CreateHashTable(NULL, 4, SDL_HashString, SDL_KeyMatchString, SDL_FreeProperty, SDL_FALSE); + if (!properties->props) { + goto error; + } + properties->lock = SDL_CreateMutex(); + if (!properties->lock) { + goto error; + } + + if (SDL_InitProperties() < 0) { + goto error; + } + + if (SDL_LockRWLockForWriting(SDL_properties_lock) == 0) { + props = ++SDL_last_properties_id; + if (SDL_InsertIntoHashTable(SDL_properties, (const void *)(uintptr_t)props, properties)) { + inserted = SDL_TRUE; + } + SDL_UnlockRWLock(SDL_properties_lock); + } + + if (inserted) { + /* All done! */ + return props; + } + +error: + SDL_FreeProperties(NULL, properties, NULL); + return 0; +} + +int SDL_LockProperties(SDL_PropertiesID props) +{ + SDL_Properties *properties = NULL; + + if (!props) { + return SDL_InvalidParamError("props"); + } + if (SDL_LockRWLockForReading(SDL_properties_lock) == 0) { + SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties); + SDL_UnlockRWLock(SDL_properties_lock); + } + if (!properties) { + SDL_InvalidParamError("props"); + return -1; + } + return SDL_LockMutex(properties->lock); +} + +void SDL_UnlockProperties(SDL_PropertiesID props) +{ + SDL_Properties *properties = NULL; + + if (!props) { + return; + } + if (SDL_LockRWLockForReading(SDL_properties_lock) == 0) { + SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties); + SDL_UnlockRWLock(SDL_properties_lock); + } + if (!properties) { + return; + } + SDL_UnlockMutex(properties->lock); +} + +int SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value, void (SDLCALL *cleanup)(void *userdata, void *value), void *userdata) +{ + SDL_Properties *properties = NULL; + SDL_Property *property = NULL; + int result = 0; + + if (!props) { + return SDL_InvalidParamError("props"); + } + if (!name || !*name) { + return SDL_InvalidParamError("name"); + } + + if (SDL_LockRWLockForReading(SDL_properties_lock) == 0) { + SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties); + SDL_UnlockRWLock(SDL_properties_lock); + } + if (!properties) { + return SDL_InvalidParamError("props"); + } + + if (value) { + property = (SDL_Property *)SDL_malloc(sizeof(*property)); + if (!property) { + return SDL_OutOfMemory(); + } + + property->value = value; + property->cleanup = cleanup; + property->userdata = userdata; + } + + SDL_LockMutex(properties->lock); + { + SDL_RemoveFromHashTable(properties->props, name); + if (property) { + char *key = SDL_strdup(name); + if (!SDL_InsertIntoHashTable(properties->props, key, property)) { + SDL_FreeProperty(key, property, NULL); + result = -1; + } + } + } + SDL_UnlockMutex(properties->lock); + + return result; +} + +void *SDL_GetProperty(SDL_PropertiesID props, const char *name) +{ + SDL_Properties *properties = NULL; + void *value = NULL; + + if (!props) { + SDL_InvalidParamError("props"); + return NULL; + } + if (!name || !*name) { + SDL_InvalidParamError("name"); + return NULL; + } + + if (SDL_LockRWLockForReading(SDL_properties_lock) == 0) { + SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties); + SDL_UnlockRWLock(SDL_properties_lock); + } + if (!properties) { + SDL_InvalidParamError("props"); + return NULL; + } + + /* Note that taking the lock here only guarantees that we won't read the + * hashtable while it's being modified. The value itself can easily be + * freed from another thread after it is returned here. + */ + SDL_LockMutex(properties->lock); + { + SDL_Property *property = NULL; + if (SDL_FindInHashTable(properties->props, name, (const void **)&property)) { + value = property->value; + } else { + SDL_SetError("Couldn't find property named %s", name); + } + } + SDL_UnlockMutex(properties->lock); + + return value; +} + +void SDL_DestroyProperties(SDL_PropertiesID props) +{ + if (!props) { + return; + } + + if (SDL_LockRWLockForWriting(SDL_properties_lock) == 0) { + SDL_RemoveFromHashTable(SDL_properties, (const void *)(uintptr_t)props); + SDL_UnlockRWLock(SDL_properties_lock); + } +} diff --git a/src/SDL_properties_c.h b/src/SDL_properties_c.h new file mode 100644 index 000000000..10b4df4ae --- /dev/null +++ b/src/SDL_properties_c.h @@ -0,0 +1,23 @@ +/* + Simple DiretMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +extern int SDL_InitProperties(void); +extern void SDL_QuitProperties(void); diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 89bf3aff6..c73472068 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -908,6 +908,12 @@ SDL3_0.0.0 { SDL_SetAudioPostmixCallback; SDL_GetAudioStreamQueued; SDL_GetTextureDXGIResource; + SDL_CreateProperties; + SDL_LockProperties; + SDL_UnlockProperties; + SDL_SetProperty; + SDL_GetProperty; + SDL_DestroyProperties; # extra symbols go here (don't modify this line) local: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index e7b16789b..8148554c5 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -933,3 +933,9 @@ #define SDL_SetAudioPostmixCallback SDL_SetAudioPostmixCallback_REAL #define SDL_GetAudioStreamQueued SDL_GetAudioStreamQueued_REAL #define SDL_GetTextureDXGIResource SDL_GetTextureDXGIResource_REAL +#define SDL_CreateProperties SDL_CreateProperties_REAL +#define SDL_LockProperties SDL_LockProperties_REAL +#define SDL_UnlockProperties SDL_UnlockProperties_REAL +#define SDL_SetProperty SDL_SetProperty_REAL +#define SDL_GetProperty SDL_GetProperty_REAL +#define SDL_DestroyProperties SDL_DestroyProperties_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 6bb5f63da..985b13eb5 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -979,3 +979,9 @@ SDL_DYNAPI_PROC(int,SDL_SetAudioStreamFrequencyRatio,(SDL_AudioStream *a, float SDL_DYNAPI_PROC(int,SDL_SetAudioPostmixCallback,(SDL_AudioDeviceID a, SDL_AudioPostmixCallback b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GetAudioStreamQueued,(SDL_AudioStream *a),(a),return) SDL_DYNAPI_PROC(IDXGIResource*,SDL_GetTextureDXGIResource,(SDL_Texture *a),(a),return) +SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_CreateProperties,(void),(),return) +SDL_DYNAPI_PROC(int,SDL_LockProperties,(SDL_PropertiesID a),(a),return) +SDL_DYNAPI_PROC(void,SDL_UnlockProperties,(SDL_PropertiesID a),(a),) +SDL_DYNAPI_PROC(int,SDL_SetProperty,(SDL_PropertiesID a, const char *b, void *c, void (SDLCALL *d)(void *userdata, void *value), void *e),(a,b,c,d,e),return) +SDL_DYNAPI_PROC(void*,SDL_GetProperty,(SDL_PropertiesID a, const char *b),(a,b),return) +SDL_DYNAPI_PROC(void,SDL_DestroyProperties,(SDL_PropertiesID a),(a),) diff --git a/test/testautomation.c b/test/testautomation.c index 2e483daf9..8e5f002fe 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -35,6 +35,7 @@ static SDLTest_TestSuiteReference *testSuites[] = { &mouseTestSuite, &pixelsTestSuite, &platformTestSuite, + &propertiesTestSuite, &rectTestSuite, &renderTestSuite, &rwopsTestSuite, diff --git a/test/testautomation_properties.c b/test/testautomation_properties.c new file mode 100644 index 000000000..a02edff67 --- /dev/null +++ b/test/testautomation_properties.c @@ -0,0 +1,190 @@ +/** + * Properties test suite + */ + +#include +#include +#include "testautomation_suites.h" + +/* Test case functions */ + +/** + * \brief Test basic functionality + */ +static int properties_testBasic(void *arg) +{ + SDL_PropertiesID props; + char key[2], expected_value[2]; + void *value; + int i, result; + + props = SDL_CreateProperties(); + SDLTest_AssertPass("Call to SDL_CreateProperties()"); + SDLTest_AssertCheck(props != 0, + "Verify props were created, got: %" SDL_PRIu32 "", props); + + for (i = 0; i < 10; ++i) { + SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i); + SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i); + result = SDL_SetProperty(props, key, expected_value, NULL, NULL); + SDLTest_AssertPass("Call to SDL_SetProperty()"); + SDLTest_AssertCheck(result == 0, + "Verify property value was set, got: %d", result); + value = SDL_GetProperty(props, key); + SDLTest_AssertPass("Call to SDL_GetProperty()"); + SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, expected_value) == 0, + "Verify property value was set, got %s, expected %s", value ? (const char *)value : "NULL", expected_value); + } + + for (i = 0; i < 10; ++i) { + SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i); + result = SDL_SetProperty(props, key, NULL, NULL, NULL); + SDLTest_AssertPass("Call to SDL_SetProperty(NULL)"); + SDLTest_AssertCheck(result == 0, + "Verify property value was set, got: %d", result); + value = SDL_GetProperty(props, key); + SDLTest_AssertPass("Call to SDL_GetProperty()"); + SDLTest_AssertCheck(value == NULL, + "Verify property value was set, got %s, expected NULL", (const char *)value); + } + + SDL_DestroyProperties(props); + + return TEST_COMPLETED; +} + +/** + * \brief Test cleanup functionality + */ +static void SDLCALL cleanup(void *userdata, void *value) +{ + int *count = (int *)userdata; + ++(*count); +} +static int properties_testCleanup(void *arg) +{ + SDL_PropertiesID props; + char key[2], expected_value[2]; + int i, count; + + props = SDL_CreateProperties(); + + SDLTest_AssertPass("Call to SDL_SetProperty(cleanup)"); + count = 0; + SDL_SetProperty(props, "a", "0", cleanup, &count); + SDL_SetProperty(props, "a", NULL, cleanup, &count); + SDLTest_AssertCheck(count == 1, + "Verify cleanup for deleting property, got %d, expected 1", count); + + SDLTest_AssertPass("Call to SDL_DestroyProperties()"); + count = 0; + for (i = 0; i < 10; ++i) { + SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i); + SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i); + SDL_SetProperty(props, key, expected_value, cleanup, &count); + } + SDL_DestroyProperties(props); + SDLTest_AssertCheck(count == 10, + "Verify cleanup for destroying properties, got %d, expected 10", count); + + return TEST_COMPLETED; +} + +/** + * \brief Test locking functionality + */ +struct properties_thread_data +{ + SDL_bool done; + SDL_PropertiesID props; +}; +static int properties_thread(void *arg) +{ + struct properties_thread_data *data = (struct properties_thread_data *)arg; + + while (!data->done) { + SDL_LockProperties(data->props); + SDL_SetProperty(data->props, "a", "thread_loop", NULL, NULL); + SDL_UnlockProperties(data->props); + } + SDL_LockProperties(data->props); + SDL_SetProperty(data->props, "a", "thread_done", NULL, NULL); + SDL_UnlockProperties(data->props); + return 0; +} +static int properties_testLocking(void *arg) +{ + struct properties_thread_data data; + SDL_Thread *thread; + void *value; + + SDLTest_AssertPass("Testing property locking"); + data.done = SDL_FALSE; + data.props = SDL_CreateProperties(); + SDLTest_AssertPass("Setting property to 'init'"); + SDL_SetProperty(data.props, "a", "init", NULL, NULL); + thread = SDL_CreateThread(properties_thread, "properties_thread", &data); + if (thread) { + SDLTest_AssertPass("Waiting for property to change to 'thread_loop'"); + for ( ; ; ) + { + SDL_Delay(10); + SDL_LockProperties(data.props); + value = SDL_GetProperty(data.props, "a"); + SDL_UnlockProperties(data.props); + + if (!value || SDL_strcmp((const char *)value, "thread_loop") == 0) { + break; + } + } + SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "thread_loop") == 0, + "After thread loop, property is %s, expected 'thread_loop'", value ? (const char *)value : "NULL"); + + SDLTest_AssertPass("Setting property to 'main'"); + SDL_LockProperties(data.props); + SDL_SetProperty(data.props, "a", "main", NULL, NULL); + SDL_Delay(100); + value = SDL_GetProperty(data.props, "a"); + SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "main") == 0, + "After 100ms sleep, property is %s, expected 'main'", value ? (const char *)value : "NULL"); + SDL_UnlockProperties(data.props); + + data.done = SDL_TRUE; + SDL_WaitThread(thread, NULL); + + value = SDL_GetProperty(data.props, "a"); + SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "thread_done") == 0, + "After thread complete, property is %s, expected 'thread_done'", value ? (const char *)value : "NULL"); + } + SDL_DestroyProperties(data.props); + + return TEST_COMPLETED; +} + +/* ================= Test References ================== */ + +/* Properties test cases */ +static const SDLTest_TestCaseReference propertiesTest1 = { + (SDLTest_TestCaseFp)properties_testBasic, "properties_testBasic", "Test basic property functionality", TEST_ENABLED +}; + +static const SDLTest_TestCaseReference propertiesTest2 = { + (SDLTest_TestCaseFp)properties_testCleanup, "properties_testCleanup", "Test property cleanup functionality", TEST_ENABLED +}; + +static const SDLTest_TestCaseReference propertiesTest3 = { + (SDLTest_TestCaseFp)properties_testLocking, "properties_testLocking", "Test property locking functionality", TEST_ENABLED +}; + +/* Sequence of Properties test cases */ +static const SDLTest_TestCaseReference *propertiesTests[] = { + &propertiesTest1, &propertiesTest2, &propertiesTest3, NULL +}; + +/* Properties test suite (global) */ +SDLTest_TestSuiteReference propertiesTestSuite = { + "Properties", + NULL, + propertiesTests, + NULL +}; diff --git a/test/testautomation_suites.h b/test/testautomation_suites.h index 3fa83ea5d..e1a29e0b7 100644 --- a/test/testautomation_suites.h +++ b/test/testautomation_suites.h @@ -22,6 +22,7 @@ extern SDLTest_TestSuiteReference mathTestSuite; extern SDLTest_TestSuiteReference mouseTestSuite; extern SDLTest_TestSuiteReference pixelsTestSuite; extern SDLTest_TestSuiteReference platformTestSuite; +extern SDLTest_TestSuiteReference propertiesTestSuite; extern SDLTest_TestSuiteReference rectTestSuite; extern SDLTest_TestSuiteReference renderTestSuite; extern SDLTest_TestSuiteReference rwopsTestSuite;